├── .gitignore ├── jimage-rs ├── tests │ └── test_data │ │ ├── lib │ │ ├── 3bytes-file.jimage │ │ ├── non-valid-magic.jimage │ │ ├── compressed_big-endian.jimage │ │ ├── compressed_little-endian.jimage │ │ ├── non-compressed_big-endian.jimage │ │ └── non-compressed_little-endian.jimage │ │ ├── mods │ │ └── java.base │ │ │ ├── without_parent.txt │ │ │ ├── java │ │ │ └── lang │ │ │ │ ├── without_ext │ │ │ │ └── Object.class │ │ │ └── module-info.class │ │ ├── src │ │ └── java.base │ │ │ ├── module-info.java │ │ │ └── java │ │ │ └── lang │ │ │ └── Object.java │ │ └── README.md ├── CHANGELOG.md ├── Cargo.toml ├── src │ ├── raw_jimage.rs │ ├── lib.rs │ ├── resource_header.rs │ └── error.rs └── LICENSE ├── src ├── vm │ ├── commons │ │ ├── mod.rs │ │ └── auto_dash_map │ │ │ ├── mod.rs │ │ │ └── auto_dash_map.rs │ ├── properties │ │ └── mod.rs │ ├── heap │ │ └── mod.rs │ ├── system_native │ │ ├── properties_provider │ │ │ └── mod.rs │ │ ├── zip │ │ │ ├── common.rs │ │ │ ├── mod.rs │ │ │ └── crc32.rs │ │ ├── object_offset │ │ │ ├── mod.rs │ │ │ └── offset_utils.rs │ │ ├── platform_specific_files │ │ │ ├── mod.rs │ │ │ ├── win32_error_mode.rs │ │ │ ├── wide_cstring.rs │ │ │ └── unix_file_system.rs │ │ ├── platform_native_dispatcher │ │ │ ├── mod.rs │ │ │ ├── unix_helpers.rs │ │ │ └── windows_helpers.rs │ │ ├── method_handle_natives │ │ │ ├── mod.rs │ │ │ ├── offsets.rs │ │ │ ├── method_type.rs │ │ │ └── types.rs │ │ ├── native_libraries.rs │ │ ├── file_descriptor.rs │ │ ├── strict_math.rs │ │ ├── native_seed_generator.rs │ │ ├── platform_file │ │ │ └── mod.rs │ │ ├── time_zone.rs │ │ ├── reflect_array.rs │ │ ├── io_util.rs │ │ ├── thread.rs │ │ ├── native_image_buffer.rs │ │ ├── mod.rs │ │ ├── object.rs │ │ ├── system_props_raw.rs │ │ └── reflecton.rs │ ├── exception │ │ ├── mod.rs │ │ └── throwing_result.rs │ ├── stack │ │ ├── mod.rs │ │ └── stack.rs │ ├── method_area │ │ ├── mod.rs │ │ ├── module_helper.rs │ │ ├── class_modifiers.rs │ │ └── primitives_helper.rs │ ├── execution_engine │ │ ├── mod.rs │ │ ├── common.rs │ │ ├── invoker.rs │ │ └── string_pool_helper.rs │ └── validation │ │ └── mod.rs ├── cli │ ├── mod.rs │ └── help.rs └── main.rs ├── utils ├── jimage_generators │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── github │ │ │ └── hextriclosan │ │ │ └── rustyjvm │ │ │ └── jimage │ │ │ ├── JImageBuilder.java │ │ │ └── ByteOrderConverter.java │ ├── .gitignore │ └── build.gradle └── classfile_generators │ ├── settings.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── src │ └── main │ │ └── java │ │ └── com │ │ └── github │ │ └── hextriclosan │ │ └── rustyjvm │ │ ├── Constants.java │ │ └── OperandStackOverflowGenerator.java │ ├── build.gradle │ ├── .gitignore │ └── README.md ├── rustfmt.toml ├── jclassfile ├── tests │ └── test_data │ │ ├── Info.class │ │ ├── Rcrd.class │ │ ├── Circle.class │ │ ├── Mutf8.class │ │ ├── Shape.class │ │ ├── Trivial.class │ │ ├── Rcrd.java │ │ ├── Trivial$1LocalCls.class │ │ ├── Trivial$InnerCls.class │ │ ├── FunctionalInterface.class │ │ ├── RuntimeInvisibleAnnotation.class │ │ ├── RuntimeVisibleTypeAnnotations.class │ │ ├── RuntimeInvisibleAnnotationUsage.class │ │ ├── RuntimeVisibleParameterAnnotations.class │ │ ├── RuntimeVisibleTypeAnnotations.java │ │ ├── Shape.java │ │ ├── RuntimeVisibleParameterAnnotations.java │ │ ├── Info.java │ │ ├── FunctionalInterface.java │ │ ├── Mutf8.java │ │ ├── RuntimeInvisibleAnnotationUsage.java │ │ └── Trivial.java ├── src │ ├── lib.rs │ ├── error.rs │ └── bin │ │ └── main.rs ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE └── Cargo.lock ├── rusty-jar ├── CHANGELOG.md ├── src │ ├── lib.rs │ └── error.rs ├── tests │ ├── test_data │ │ └── hello │ │ │ ├── target │ │ │ └── hello-1.0.jar │ │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── Hello.java │ │ │ └── pom.xml │ └── integration_tests.rs ├── Cargo.toml ├── README.md └── LICENSE ├── tests └── test_data │ ├── CompactSourceFilesArgsExample.java │ ├── NoMainMethod.java │ ├── generated │ └── samples │ │ ├── opcodes │ │ ├── nop │ │ │ └── NopGeneratedExample.class │ │ ├── pop2 │ │ │ └── Pop2GeneratedExample.class │ │ ├── swap │ │ │ └── SwapGeneratedExample.class │ │ ├── dup_x2 │ │ │ └── DupX2GeneratedExample.class │ │ ├── dup2_x1 │ │ │ └── Dup2_X1GeneratedExample.class │ │ └── dup2_x2 │ │ │ └── Dup2_X2GeneratedExample.class │ │ └── invalidprograms │ │ └── operandstackoverflow │ │ └── OperandStackOverflowExample.class │ ├── SystemLoad.java │ ├── CompactSourceFilesExample.java │ ├── SystemOutExample.java │ ├── ProgramArgsExample.java │ ├── SystemLoadWithoutCoreClasses.java │ ├── MapLibraryNameExample.java │ ├── EmptyStringInCPool.java │ ├── SubInts.java │ ├── SubFloats.java │ ├── RandomExample.java │ ├── SubDoubles.java │ ├── ExitWithCodeDemo.java │ ├── TrivialStringsCPool.java │ ├── AdderNegativeLong.java │ ├── AssertionExample.java │ ├── SubLongs.java │ ├── NativeCallSystemCurrentTimeMillis.java │ ├── ParentStaticMethodCalledViaChild.java │ ├── StaticMethodReturnsInterface.java │ ├── NormalOutputWithErrorOutput.java │ ├── AdderLong.java │ ├── StaticInitializationWithinOneClass.java │ ├── AdderInt.java │ ├── DeleteOnExitDemo.java │ ├── LocaleMonthsExample.java │ ├── FibonacciRecursive.java │ ├── TrivialConcurrentHashMap.java │ ├── TrivialStrings.java │ ├── StaticInitializationByConstructorExample.java │ ├── StaticInitializationChain.java │ ├── UnhandledExceptionExample.java │ ├── InitParentStaticBlockBeforeChild.java │ ├── UseGrandParentMethodViaSuperExample.java │ ├── RethrowExample.java │ ├── FileInputStreamExample.java │ ├── OnlyTheClassThatDeclaresStaticFieldIsInitialized.java │ ├── DefaultMethodViaParentExample.java │ ├── StringConcatInline.java │ ├── TrivialInterface.java │ ├── TrivialCast.java │ ├── LongToDoubleAndBack.java │ ├── FibonacciIterative.java │ ├── StaticInitializationCircular.java │ ├── SwitchExample.java │ ├── ArrayCastExample.java │ ├── VarArgsExample.java │ ├── InheritedImplementationInterface.java │ ├── EnumsExample.java │ ├── ChildFieldInParentBlockAccessedByChild.java │ ├── ClassIsInterfaceExample.java │ ├── ChildFieldInParentBlockAccessedByParent.java │ ├── BufferedOutputStreamChunkingExample.java │ ├── InitializedChildFieldInParentBlockAccessedByChild.java │ ├── ObjectMethods.java │ ├── InitializedChildFieldInParentBlockAccessedByParent.java │ ├── StaticFieldAccessFromParentExample.java │ ├── ConstantCallSiteExample.java │ ├── ClassGetNameExample.java │ ├── AbstractClassStaticInitExample.java │ ├── InterfaceInitializationDoesNotInitializeSuperinterfaces.java │ ├── OneInterfaceExtendsAnother.java │ ├── ReflectionGetCallerClassExample.java │ ├── AbstractClassWithoutInterfaceImplementation.java │ ├── FileOutputStreamExample.java │ ├── GetInterfacesExample.java │ ├── GetDefaultFileSystem.java │ ├── UnsafePutReferenceVolatileExample.java │ ├── ConstantPoolExample.java │ ├── ArrayClass.java │ ├── RecordExample.java │ ├── ClassForNameExample.java │ ├── IsEnumExample.java │ ├── Array3D.java │ ├── StringConcatFactoryExample.java │ ├── AbstractClass.java │ ├── TrivialReflection.java │ ├── StaticFieldsUserInts.java │ ├── StaticInitializationArray.java │ ├── ArrayToStringExample.java │ ├── MutableCallSiteExample.java │ ├── FileDispatcherExample.java │ ├── LazyInitializationExample.java │ ├── TrivialHashMap.java │ ├── TrivialTreeMap.java │ ├── InstanceFieldsUserLong.java │ ├── ClassGetNestHostExample.java │ ├── SystemGetPropertyExample.java │ ├── InstanceFieldsUserInts.java │ ├── PropertiesTrivial.java │ ├── InheritanceStaticField.java │ ├── StaticInitializationAdvanced.java │ ├── UnsafeGetLongUnalignedExample.java │ ├── FileOutputStreamThrowExample.java │ ├── DoubleOperations.java │ ├── ArrayDefaultValues.java │ ├── StringConcatHelperExample.java │ ├── XmlStringToFileExample.java │ ├── GetDeclaringClassExample.java │ ├── FileInputStreamThrowExample.java │ ├── ReflectionAreNestMatesExample.java │ ├── InterfaceDefaultMethodDirectCall.java │ ├── InheritanceInstanceField.java │ ├── HashCodeExample.java │ ├── FloatOperations.java │ └── TrivialUtilArrays.java ├── Cross.toml ├── .gitattributes ├── renovate.json ├── jdescriptor ├── Cargo.toml └── LICENSE ├── LICENSE ├── docs ├── bigendian.md └── build_integration_tests_data.md ├── CHANGELOG.md └── .github └── docker └── s390x └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .idea 3 | -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/lib/3bytes-file.jimage: -------------------------------------------------------------------------------- 1 | abc -------------------------------------------------------------------------------- /src/vm/commons/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod auto_dash_map; 2 | -------------------------------------------------------------------------------- /src/vm/properties/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod system_properties; 2 | -------------------------------------------------------------------------------- /src/cli/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod argument_parser; 2 | pub(crate) mod help; 3 | -------------------------------------------------------------------------------- /src/vm/heap/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod heap; 2 | pub(crate) mod java_instance; 3 | -------------------------------------------------------------------------------- /src/vm/system_native/properties_provider/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod properties; 2 | -------------------------------------------------------------------------------- /utils/jimage_generators/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jimage-generators' -------------------------------------------------------------------------------- /src/vm/system_native/zip/common.rs: -------------------------------------------------------------------------------- 1 | pub const DEFAULT_WINDOW_BITS: i32 = 15; 2 | -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/mods/java.base/without_parent.txt: -------------------------------------------------------------------------------- 1 | I'm file without a parent -------------------------------------------------------------------------------- /utils/classfile_generators/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'classfile-generators' 2 | -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/mods/java.base/java/lang/without_ext: -------------------------------------------------------------------------------- 1 | I'm file without an extension -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/src/java.base/module-info.java: -------------------------------------------------------------------------------- 1 | module java.base { 2 | exports java.lang; 3 | } 4 | -------------------------------------------------------------------------------- /src/vm/exception/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod common; 2 | pub(crate) mod helpers; 3 | pub(crate) mod throwing_result; 4 | -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/src/java.base/java/lang/Object.java: -------------------------------------------------------------------------------- 1 | package java.lang; 2 | 3 | public class Object { 4 | } 5 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 99 2 | group_imports = "One" 3 | imports_granularity = "Module" 4 | reorder_imports = true 5 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Info.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Info.class -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Rcrd.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Rcrd.class -------------------------------------------------------------------------------- /src/vm/system_native/zip/mod.rs: -------------------------------------------------------------------------------- 1 | mod common; 2 | pub(crate) mod crc32; 3 | pub(crate) mod deflater; 4 | pub(crate) mod inflater; 5 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Circle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Circle.class -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Mutf8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Mutf8.class -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Shape.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Shape.class -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Trivial.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Trivial.class -------------------------------------------------------------------------------- /rusty-jar/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.0.1 2 | ## What's Added 3 | Added support for 4 | * Basic functionality: read files from a JAR archive. 5 | -------------------------------------------------------------------------------- /src/vm/stack/mod.rs: -------------------------------------------------------------------------------- 1 | mod stack; 2 | pub(crate) mod stack_frame; 3 | pub(crate) mod stack_frames_util; 4 | pub(crate) mod stack_value; 5 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Rcrd.java: -------------------------------------------------------------------------------- 1 | // build command: 2 | // javac -g -parameters Rcrd.java 3 | 4 | public record Rcrd(int recordArg) { 5 | } 6 | -------------------------------------------------------------------------------- /src/vm/commons/auto_dash_map/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod auto_dash_map; 2 | pub(crate) mod auto_dash_map_i32; 3 | pub(crate) mod auto_dash_map_i64; 4 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Trivial$1LocalCls.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Trivial$1LocalCls.class -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Trivial$InnerCls.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/Trivial$InnerCls.class -------------------------------------------------------------------------------- /jclassfile/tests/test_data/FunctionalInterface.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/FunctionalInterface.class -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/lib/non-valid-magic.jimage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jimage-rs/tests/test_data/lib/non-valid-magic.jimage -------------------------------------------------------------------------------- /rusty-jar/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! A Rust library for handling JAR (Java ARchive) files. 2 | pub mod error; 3 | pub mod jarfile; 4 | pub use crate::jarfile::JarFile; 5 | -------------------------------------------------------------------------------- /rusty-jar/tests/test_data/hello/target/hello-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/rusty-jar/tests/test_data/hello/target/hello-1.0.jar -------------------------------------------------------------------------------- /utils/jimage_generators/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/utils/jimage_generators/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /jclassfile/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod attributes; 2 | pub mod class_file; 3 | pub mod constant_pool; 4 | pub mod error; 5 | mod extractors; 6 | pub mod fields; 7 | pub mod methods; 8 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/RuntimeInvisibleAnnotation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/RuntimeInvisibleAnnotation.class -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/lib/compressed_big-endian.jimage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jimage-rs/tests/test_data/lib/compressed_big-endian.jimage -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/mods/java.base/module-info.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jimage-rs/tests/test_data/mods/java.base/module-info.class -------------------------------------------------------------------------------- /utils/classfile_generators/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/utils/classfile_generators/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /jclassfile/tests/test_data/RuntimeVisibleTypeAnnotations.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/RuntimeVisibleTypeAnnotations.class -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/lib/compressed_little-endian.jimage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jimage-rs/tests/test_data/lib/compressed_little-endian.jimage -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/lib/non-compressed_big-endian.jimage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jimage-rs/tests/test_data/lib/non-compressed_big-endian.jimage -------------------------------------------------------------------------------- /tests/test_data/CompactSourceFilesArgsExample.java: -------------------------------------------------------------------------------- 1 | void main(String[] args) { 2 | for (var name : args) { 3 | IO.println(name + ": " + name.length()); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /jclassfile/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.3.0 2 | 3 | ## What's Changed 4 | * Support for RuntimeVisibleParameterAnnotations attribute. 5 | * Support for RuntimeVisibleTypeAnnotations attribute. 6 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/RuntimeInvisibleAnnotationUsage.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/RuntimeInvisibleAnnotationUsage.class -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/lib/non-compressed_little-endian.jimage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jimage-rs/tests/test_data/lib/non-compressed_little-endian.jimage -------------------------------------------------------------------------------- /jimage-rs/tests/test_data/mods/java.base/java/lang/Object.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jimage-rs/tests/test_data/mods/java.base/java/lang/Object.class -------------------------------------------------------------------------------- /jclassfile/tests/test_data/RuntimeVisibleParameterAnnotations.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/jclassfile/tests/test_data/RuntimeVisibleParameterAnnotations.class -------------------------------------------------------------------------------- /tests/test_data/NoMainMethod.java: -------------------------------------------------------------------------------- 1 | package samples.nomainmethod; 2 | 3 | public class NoMainMethod { 4 | public int add(int v1, int v2) { 5 | return v1 + v2; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/test_data/generated/samples/opcodes/nop/NopGeneratedExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/tests/test_data/generated/samples/opcodes/nop/NopGeneratedExample.class -------------------------------------------------------------------------------- /tests/test_data/generated/samples/opcodes/pop2/Pop2GeneratedExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/tests/test_data/generated/samples/opcodes/pop2/Pop2GeneratedExample.class -------------------------------------------------------------------------------- /tests/test_data/generated/samples/opcodes/swap/SwapGeneratedExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/tests/test_data/generated/samples/opcodes/swap/SwapGeneratedExample.class -------------------------------------------------------------------------------- /src/vm/system_native/object_offset/mod.rs: -------------------------------------------------------------------------------- 1 | /// Helper function dealing with object offsets here 2 | /// Should be moved to Klass when proper offsets will be implemented there 3 | pub(crate) mod offset_utils; 4 | -------------------------------------------------------------------------------- /tests/test_data/generated/samples/opcodes/dup_x2/DupX2GeneratedExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/tests/test_data/generated/samples/opcodes/dup_x2/DupX2GeneratedExample.class -------------------------------------------------------------------------------- /tests/test_data/generated/samples/opcodes/dup2_x1/Dup2_X1GeneratedExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/tests/test_data/generated/samples/opcodes/dup2_x1/Dup2_X1GeneratedExample.class -------------------------------------------------------------------------------- /tests/test_data/generated/samples/opcodes/dup2_x2/Dup2_X2GeneratedExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/tests/test_data/generated/samples/opcodes/dup2_x2/Dup2_X2GeneratedExample.class -------------------------------------------------------------------------------- /rusty-jar/tests/test_data/hello/src/main/java/com/example/Hello.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | public class Hello { 4 | public static void main(String[] args) { 5 | System.out.println("Hello"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/RuntimeVisibleTypeAnnotations.java: -------------------------------------------------------------------------------- 1 | // build command: 2 | // javac -g -parameters RuntimeVisibleTypeAnnotations.java 3 | 4 | interface RuntimeVisibleTypeAnnotations { 5 | @Info String someMethod(); 6 | } 7 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Shape.java: -------------------------------------------------------------------------------- 1 | // build command: 2 | // javac -g -parameters Shape.java 3 | 4 | public sealed interface Shape permits Circle { 5 | 6 | } 7 | 8 | final class Circle implements Shape { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/test_data/SystemLoad.java: -------------------------------------------------------------------------------- 1 | package samples.system.load; 2 | 3 | public class SystemLoad { 4 | public static void main(String[] args) { 5 | int result = 4321; 6 | System.out.println(result); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/vm/system_native/platform_specific_files/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(unix)] 2 | pub mod unix_file_system; 3 | #[cfg(windows)] 4 | pub mod wide_cstring; 5 | #[cfg(windows)] 6 | pub mod win32_error_mode; 7 | #[cfg(windows)] 8 | pub mod winnt_file_system; 9 | -------------------------------------------------------------------------------- /tests/test_data/CompactSourceFilesExample.java: -------------------------------------------------------------------------------- 1 | void main() { 2 | var authors = List.of("James", "Bill", "Guy", "Alex", "Dan", "Gavin"); 3 | for (var name : authors) { 4 | IO.println(name + ": " + name.length()); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/test_data/SystemOutExample.java: -------------------------------------------------------------------------------- 1 | package samples.system.outexample; 2 | 3 | public class SystemOutExample { 4 | public static void main(String[] args) { 5 | int result = 42; 6 | System.out.println(result); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Cross.toml: -------------------------------------------------------------------------------- 1 | [target.s390x-unknown-linux-gnu] 2 | # Tell `cross` to use the custom Docker image 3 | image = "ghcr.io/hextriclosan/cross-s390x-java:latest" 4 | # Tell `cross` to run this command inside the container's shell 5 | pre-run = "export JAVA_HOME=/opt/java" 6 | -------------------------------------------------------------------------------- /tests/test_data/generated/samples/invalidprograms/operandstackoverflow/OperandStackOverflowExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hextriclosan/rusty-jvm/HEAD/tests/test_data/generated/samples/invalidprograms/operandstackoverflow/OperandStackOverflowExample.class -------------------------------------------------------------------------------- /utils/classfile_generators/src/main/java/com/github/hextriclosan/rustyjvm/Constants.java: -------------------------------------------------------------------------------- 1 | package com.github.hextriclosan.rustyjvm; 2 | 3 | final public class Constants { 4 | public static final String OUTPUT_PATH = "../../tests/test_data/generated"; 5 | } 6 | -------------------------------------------------------------------------------- /src/vm/system_native/platform_native_dispatcher/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(windows)] 2 | pub mod windows_helpers; 3 | #[cfg(windows)] 4 | pub mod windows_native_dispatcher; 5 | 6 | #[cfg(unix)] 7 | mod unix_helpers; 8 | #[cfg(unix)] 9 | pub mod unix_native_dispatcher; 10 | -------------------------------------------------------------------------------- /tests/test_data/ProgramArgsExample.java: -------------------------------------------------------------------------------- 1 | package samples.system.programargs; 2 | 3 | import java.util.Arrays; 4 | 5 | public class ProgramArgsExample { 6 | public static void main(String[] args) { 7 | System.out.println(Arrays.toString(args)); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/vm/system_native/method_handle_natives/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod invocation; 2 | mod member_name; 3 | mod method_type; 4 | mod native_accessor; 5 | mod offsets; 6 | mod resolution; 7 | mod resolved_method_name; 8 | pub(crate) mod types; 9 | mod var_handle; 10 | pub(crate) mod wrappers; 11 | -------------------------------------------------------------------------------- /tests/test_data/SystemLoadWithoutCoreClasses.java: -------------------------------------------------------------------------------- 1 | package samples.system.loadwithoutcoreclasses; 2 | 3 | public class SystemLoadWithoutCoreClasses { 4 | public static void main(String[] args) { 5 | int a = 1; 6 | int b = 2; 7 | int c = a + b; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/test_data/MapLibraryNameExample.java: -------------------------------------------------------------------------------- 1 | package samples.system.maplibraryname; 2 | 3 | public class MapLibraryNameExample { 4 | public static void main(String[] args) { 5 | String libraryName = System.mapLibraryName("name"); 6 | System.out.println(libraryName); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/RuntimeVisibleParameterAnnotations.java: -------------------------------------------------------------------------------- 1 | // build command: 2 | // javac -g -parameters RuntimeVisibleParameterAnnotations.java 3 | 4 | public class RuntimeVisibleParameterAnnotations { 5 | public void someMethod(@Deprecated final String msg, @Deprecated int count) { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/test_data/EmptyStringInCPool.java: -------------------------------------------------------------------------------- 1 | package samples.javacore.strings.trivial; 2 | 3 | public class EmptyStringInCPool { 4 | public static void main(String[] args) { 5 | int result = "".length(); 6 | System.out.println(result == 0 ? "Empty string has length 0" : "ERROR"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/test_data/SubInts.java: -------------------------------------------------------------------------------- 1 | package samples.arithmetics.sub.ints; 2 | 3 | public class SubInts { 4 | public static void main(String[] args) { 5 | int first = 1; 6 | int second = 1000; 7 | int result = first - second; 8 | System.out.println(result); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /utils/classfile_generators/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Feb 26 11:35:11 EET 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /utils/jimage_generators/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Jun 15 22:46:57 EEST 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /tests/test_data/SubFloats.java: -------------------------------------------------------------------------------- 1 | package samples.arithmetics.sub.floats; 2 | 3 | public class SubFloats { 4 | public static void main(String[] args) { 5 | float first = 1.1f; 6 | int second = 1000; 7 | float result = first - second; 8 | System.out.println(result); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Info.java: -------------------------------------------------------------------------------- 1 | 2 | import java.lang.annotation.ElementType; 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | import java.lang.annotation.Target; 6 | 7 | @Retention(RetentionPolicy.RUNTIME) 8 | @Target(ElementType.TYPE_USE) 9 | public @interface Info { 10 | } 11 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/FunctionalInterface.java: -------------------------------------------------------------------------------- 1 | // build command: 2 | // javac -g -parameters FunctionalInterface.java 3 | 4 | package fake.java.lang; 5 | 6 | import java.lang.annotation.*; 7 | 8 | @Documented 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Target(ElementType.TYPE) 11 | public @interface FunctionalInterface {} 12 | -------------------------------------------------------------------------------- /tests/test_data/RandomExample.java: -------------------------------------------------------------------------------- 1 | package samples.javautil.random; 2 | 3 | import java.util.Random; 4 | 5 | public class RandomExample { 6 | public static void main(String[] args) { 7 | long seed = -466210000; 8 | Random random = new Random(seed); 9 | System.out.println(random.nextInt()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/test_data/SubDoubles.java: -------------------------------------------------------------------------------- 1 | package samples.arithmetics.sub.doubles; 2 | 3 | public class SubDoubles { 4 | public static void main(String[] args) { 5 | double first = 1.23456789e200; 6 | double second = 1e201; 7 | double result = first - second; 8 | System.out.println(result); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/test_data/ExitWithCodeDemo.java: -------------------------------------------------------------------------------- 1 | package samples.shutdown.exitwithcodedemo; 2 | 3 | public class ExitWithCodeDemo { 4 | public static void main(String[] args) throws Exception { 5 | int code = Integer.parseInt(args[0]); 6 | System.out.print("Exiting with code: " + code); 7 | System.exit(code); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /jclassfile/tests/test_data/Mutf8.java: -------------------------------------------------------------------------------- 1 | // build command: 2 | // javac -g -parameters Mutf8.java 3 | 4 | interface Mutf8 { 5 | String withZero = "\0abc"; 6 | String singleByteLatin = "A"; 7 | String twoByteUkrainian = "ї"; 8 | String threeByteSnowman = "☃"; 9 | String fourByteGothicLetterHwair = "𐍈"; 10 | String fourByteEmoji = "😂"; 11 | } 12 | -------------------------------------------------------------------------------- /tests/test_data/TrivialStringsCPool.java: -------------------------------------------------------------------------------- 1 | package samples.javacore.strings.cpool.trivial; 2 | 3 | public class TrivialStringsCPool { 4 | public static void main(String[] args) { 5 | String text = "Java is flexible"; 6 | String search = new String("flexible"); 7 | 8 | int index = text.indexOf(search); 9 | System.out.println(index); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/vm/method_area/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod attributes_helper; 2 | pub(crate) mod class_modifiers; 3 | pub(crate) mod cpool_helper; 4 | pub(crate) mod field; 5 | pub(crate) mod instance_checker; 6 | pub(crate) mod java_class; 7 | pub(crate) mod java_method; 8 | pub(crate) mod loaded_classes; 9 | pub(crate) mod method_area; 10 | pub(crate) mod module_helper; 11 | pub(crate) mod primitives_helper; 12 | -------------------------------------------------------------------------------- /utils/classfile_generators/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | group = 'com.github.hextriclosan.rustyjvm' 6 | version = '1.0' 7 | 8 | repositories { 9 | mavenCentral() 10 | maven { 11 | url "https://repository.ow2.org/nexus/content/repositories/snapshots" 12 | } 13 | } 14 | 15 | dependencies { 16 | implementation 'org.ow2.asm:asm:9.8-SNAPSHOT' 17 | } 18 | -------------------------------------------------------------------------------- /utils/jimage_generators/src/main/java/com/github/hextriclosan/rustyjvm/jimage/JImageBuilder.java: -------------------------------------------------------------------------------- 1 | package com.github.hextriclosan.rustyjvm.jimage; 2 | 3 | import picocli.CommandLine; 4 | 5 | public class JImageBuilder { 6 | public static void main(String[] args) { 7 | int exitCode = new CommandLine(new ImageCreator()).execute(args); 8 | System.exit(exitCode); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/test_data/AdderNegativeLong.java: -------------------------------------------------------------------------------- 1 | package samples.arithmetics.addernegative; 2 | 3 | public class AdderNegativeLong { 4 | 5 | public static void main(String[] args) { 6 | long result = add(-1_000_000_000_000_000L, -990_000_000_000_000L); 7 | System.out.println(result); 8 | } 9 | 10 | private static long add(long a, long b) { 11 | return a + b; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tests/test_data/AssertionExample.java: -------------------------------------------------------------------------------- 1 | package samples.javacore.assertions.trivial; 2 | 3 | public class AssertionExample { 4 | public static void main(String[] args) { 5 | System.out.print("Assertions: "); 6 | assert assertionEnabled(); 7 | } 8 | 9 | private static boolean assertionEnabled() { 10 | System.out.println("enabled"); 11 | return true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/test_data/SubLongs.java: -------------------------------------------------------------------------------- 1 | package samples.arithmetics.sub.longs; 2 | 3 | public class SubLongs { 4 | private static long first; 5 | private static long second; 6 | 7 | static { 8 | first = 100_000_000_000L; 9 | second = 99_000_000_000L; 10 | } 11 | 12 | public static void main(String[] args) { 13 | long result = second - first; 14 | System.out.println(result); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/test_data/NativeCallSystemCurrentTimeMillis.java: -------------------------------------------------------------------------------- 1 | package samples.nativecall.system; 2 | 3 | public class NativeCallSystemCurrentTimeMillis { 4 | public static void main(String[] args) { 5 | long currentTimeMillis = System.currentTimeMillis(); 6 | long nanoTime = System.nanoTime(); 7 | System.out.println("{\"currentTimeMillis\": " + currentTimeMillis + ", \"nanoTime\": " + nanoTime + "}"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/test_data/ParentStaticMethodCalledViaChild.java: -------------------------------------------------------------------------------- 1 | package samples.inheritance.staticmethod; 2 | 3 | public class ParentStaticMethodCalledViaChild { 4 | public static void main(String[] args) { 5 | Child.parentMethod(); 6 | } 7 | } 8 | 9 | class Parent { 10 | protected static void parentMethod() { 11 | System.out.println("Parent method called"); 12 | } 13 | } 14 | 15 | class Child extends Parent { 16 | } 17 | -------------------------------------------------------------------------------- /tests/test_data/StaticMethodReturnsInterface.java: -------------------------------------------------------------------------------- 1 | package samples.inheritance.staticmethodreturnsinterface; 2 | 3 | import java.util.Set; 4 | 5 | public class StaticMethodReturnsInterface { 6 | 7 | public static void main(String[] args) { 8 | Set set = getSet(); 9 | System.out.println(set); 10 | } 11 | 12 | private static Set getSet() { 13 | return Set.of("some string"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Enforce LF for all text files 2 | * text eol=lf 3 | 4 | # Force LF for known cross-platform files 5 | *.rs text eol=lf 6 | *.toml text eol=lf 7 | *.sh text eol=lf 8 | *.md text eol=lf 9 | *.yml text eol=lf 10 | *.yaml text eol=lf 11 | *.txt text eol=lf 12 | 13 | # Prevent line ending conversion for binary files 14 | *.png binary 15 | *.jpg binary 16 | *.exe binary 17 | *.dll binary 18 | *.wasm binary 19 | *.class binary 20 | *.jimage binary 21 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ], 6 | "enabledManagers": [ 7 | "cargo" 8 | ], 9 | "packageRules": [ 10 | { 11 | "managers": [ 12 | "cargo" 13 | ], 14 | "updateTypes": [ 15 | "minor", 16 | "patch", 17 | "major" 18 | ], 19 | "semanticCommits": "enabled" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /tests/test_data/NormalOutputWithErrorOutput.java: -------------------------------------------------------------------------------- 1 | package samples.system.normaloutputwitherroutput; 2 | 3 | public class NormalOutputWithErrorOutput { 4 | public static void main(String[] args) { 5 | System.out.println("This is normal output."); 6 | System.err.println("This is error output."); 7 | System.out.println("This is another normal output."); 8 | System.err.println("This is another error output."); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/test_data/AdderLong.java: -------------------------------------------------------------------------------- 1 | package samples.arithmetics.adder.longs; 2 | 3 | public class AdderLong { 4 | 5 | public static void main(String[] args) { 6 | long result = add( 7 | 42_949_672_980L/*h=10,l=20*/, 8 | 128_849_018_920L/*h=30,l=40*/ 9 | ); 10 | System.out.println(result); 11 | } 12 | 13 | private static long add(long a, long b) { 14 | return a + b; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/cli/help.rs: -------------------------------------------------------------------------------- 1 | pub fn help_msg() -> &'static str { 2 | r#"Usage: rusty-jvm [options] [args...] 3 | 4 | Options: 5 | -D= Set a system property 6 | -X