Skip to content

Commit

Permalink
Merge pull request #231 from theseus-rs/update-to-support-lts-versions
Browse files Browse the repository at this point in the history
chore: update VM to support LTS and latest Java versions only
  • Loading branch information
brianheineman authored Jan 22, 2025
2 parents fe81c27 + b4cf7cb commit 2fd8ee5
Show file tree
Hide file tree
Showing 43 changed files with 236 additions and 483 deletions.
8 changes: 0 additions & 8 deletions ristretto_classloader/tests/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ async fn test_native_classes() -> Result<()> {
// write_classes("8.442.06.1").await?;
// write_classes("11.0.26.4.1").await?;
// write_classes("17.0.14.7.1").await?;
// write_classes("18.0.2.9.1").await?;
// write_classes("19.0.2.7.1").await?;
// write_classes("20.0.2.10.1").await?;
// write_classes("21.0.6.7.1").await?;
// write_classes("22.0.2.9.1").await?;
// write_classes("23.0.2.7.1").await?;
Ok(())
}
Expand All @@ -179,11 +175,7 @@ async fn test_native_methods() -> Result<()> {
// write_native("8.442.06.1").await?;
// write_native("11.0.26.4.1").await?;
// write_native("17.0.14.7.1").await?;
// write_native("18.0.2.9.1").await?;
// write_native("19.0.2.7.1").await?;
// write_native("20.0.2.10.1").await?;
// write_native("21.0.6.7.1").await?;
// write_native("22.0.2.9.1").await?;
// write_native("23.0.2.7.1").await?;
Ok(())
}
20 changes: 0 additions & 20 deletions ristretto_classloader/tests/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,11 @@ async fn test_get_runtime_v17() -> Result<()> {
test_runtime("17.0.14.7.1", "java.lang.Object").await
}

#[tokio::test]
async fn test_get_runtime_v18() -> Result<()> {
test_runtime("18.0.2.9.1", "java.lang.Object").await
}

#[tokio::test]
async fn test_get_runtime_v19() -> Result<()> {
test_runtime("19.0.2.7.1", "java.lang.Object").await
}

#[tokio::test]
async fn test_get_runtime_v20() -> Result<()> {
test_runtime("20.0.2.10.1", "java.lang.Object").await
}

#[tokio::test]
async fn test_get_runtime_v21() -> Result<()> {
test_runtime("21.0.6.7.1", "java.lang.Object").await
}

#[tokio::test]
async fn test_get_runtime_v22() -> Result<()> {
test_runtime("22.0.2.9.1", "java.lang.Object").await
}

#[tokio::test]
async fn test_get_runtime_v23() -> Result<()> {
test_runtime("23.0.2.7.1", "java.lang.Object").await
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_22};
use crate::native_methods::registry::{MethodRegistry, JAVA_21};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand All @@ -10,7 +10,7 @@ const CLASS_NAME: &str = "apple/security/KeychainStore";

/// Register all native methods for `apple.security.KeychainStore`.
pub(crate) fn register(registry: &mut MethodRegistry) {
if registry.java_major_version() <= JAVA_22 {
if registry.java_major_version() <= JAVA_21 {
registry.register(CLASS_NAME, "_scanKeychain", "()V", scan_keychain);
} else {
registry.register(
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/io/console.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_20};
use crate::native_methods::registry::{MethodRegistry, JAVA_17};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand All @@ -10,7 +10,7 @@ const CLASS_NAME: &str = "java/io/Console";

/// Register all native methods for `java.io.Console`.
pub(crate) fn register(registry: &mut MethodRegistry) {
if registry.java_major_version() <= JAVA_20 {
if registry.java_major_version() <= JAVA_17 {
registry.register(CLASS_NAME, "echo", "(Z)Z", echo);
}

Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/io/filedescriptor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_20};
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand All @@ -16,7 +16,7 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
registry.register(CLASS_NAME, "getHandle", "(I)J", get_handle);
}

if registry.java_major_version() <= JAVA_20 {
if registry.java_major_version() <= JAVA_17 {
registry.register(CLASS_NAME, "sync", "()V", sync);
} else {
registry.register(CLASS_NAME, "sync0", "()V", sync_0);
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/io/randomaccessfile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_18, JAVA_8};
use crate::native_methods::registry::{MethodRegistry, JAVA_17, JAVA_8};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand All @@ -14,7 +14,7 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
registry.register(CLASS_NAME, "close0", "()V", close_0);
}

if registry.java_major_version() <= JAVA_18 {
if registry.java_major_version() <= JAVA_17 {
registry.register(CLASS_NAME, "length", "()J", length);
registry.register(CLASS_NAME, "readBytes", "([BII)I", read_bytes);
registry.register(CLASS_NAME, "setLength", "(J)V", set_length);
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/io/unixfilesystem.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_18};
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Error::InternalError;
Expand Down Expand Up @@ -34,7 +34,7 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
);
}

if registry.java_major_version() <= JAVA_18 {
if registry.java_major_version() <= JAVA_17 {
registry.register(
CLASS_NAME,
"checkAccess",
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/io/winntfilesystem.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_18};
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand All @@ -19,7 +19,7 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
);
}

if registry.java_major_version() <= JAVA_18 {
if registry.java_major_version() <= JAVA_17 {
registry.register(
CLASS_NAME,
"canonicalizeWithPrefix0",
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/lang/class.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::java_object::JavaObject;
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17, JAVA_20, JAVA_8};
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17, JAVA_21, JAVA_8};
use crate::parameters::Parameters;
use crate::rust_value::RustValue;
use crate::thread::Thread;
Expand Down Expand Up @@ -81,7 +81,7 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
registry.register(CLASS_NAME, "isRecord0", "()Z", is_record_0);
}

if registry.java_major_version() >= JAVA_20 {
if registry.java_major_version() >= JAVA_21 {
registry.register(
CLASS_NAME,
"getClassAccessFlagsRaw0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17, JAVA_20, JAVA_8};
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17, JAVA_8};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand Down Expand Up @@ -42,6 +42,9 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
);
}

if registry.java_major_version() <= JAVA_17 {
registry.register(CLASS_NAME, "getMembers", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Class;I[Ljava/lang/invoke/MemberName;)I", get_members);
}
if registry.java_major_version() >= JAVA_17 {
registry.register(
CLASS_NAME,
Expand All @@ -51,10 +54,6 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
);
}

if registry.java_major_version() <= JAVA_20 {
registry.register(CLASS_NAME, "getMembers", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Class;I[Ljava/lang/invoke/MemberName;)I", get_members);
}

registry.register(
CLASS_NAME,
"expand",
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/lang/object.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::java_object::JavaObject;
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_18};
use crate::native_methods::registry::{MethodRegistry, JAVA_11, JAVA_17};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Error::InternalError;
Expand All @@ -17,7 +17,7 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
registry.register(CLASS_NAME, "registerNatives", "()V", register_natives);
}

if registry.java_major_version() <= JAVA_18 {
if registry.java_major_version() <= JAVA_17 {
registry.register(CLASS_NAME, "wait", "(J)V", wait);
} else {
registry.register(CLASS_NAME, "wait0", "(J)V", wait_0);
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/lang/ref/reference.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_17, JAVA_18};
use crate::native_methods::registry::{MethodRegistry, JAVA_17};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand All @@ -10,7 +10,7 @@ const CLASS_NAME: &str = "java/lang/ref/Reference";

/// Register all native methods for `java.lang.ref.Reference`.
pub(crate) fn register(registry: &mut MethodRegistry) {
if registry.java_major_version() == JAVA_17 || registry.java_major_version() >= JAVA_18 {
if registry.java_major_version() >= JAVA_17 {
registry.register(CLASS_NAME, "clear0", "()V", clear_0);
registry.register(
CLASS_NAME,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_18, JAVA_21};
use crate::native_methods::registry::{MethodRegistry, JAVA_17, JAVA_21};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Result;
Expand All @@ -10,7 +10,7 @@ const CLASS_NAME: &str = "java/lang/StackStreamFactory$AbstractStackWalker";

/// Register all native methods for `java.lang.StackStreamFactory$AbstractStackWalker`.
pub(crate) fn register(registry: &mut MethodRegistry) {
if registry.java_major_version() <= JAVA_18 {
if registry.java_major_version() <= JAVA_17 {
registry.register(
CLASS_NAME,
"callStackWalk",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_18};
use crate::native_methods::registry::{MethodRegistry, JAVA_17};
use crate::parameters::Parameters;
use crate::thread::Thread;
use crate::Error::InternalError;
Expand All @@ -11,7 +11,7 @@ const CLASS_NAME: &str = "java/lang/StackTraceElement";

/// Register all native methods for `java.lang.StackTraceElement`.
pub(crate) fn register(registry: &mut MethodRegistry) {
if registry.java_major_version() <= JAVA_18 {
if registry.java_major_version() <= JAVA_17 {
registry.register(
CLASS_NAME,
"initStackTraceElements",
Expand Down
4 changes: 2 additions & 2 deletions ristretto_vm/src/native_methods/java/lang/strictmath.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::native_methods::registry::{MethodRegistry, JAVA_20, JAVA_8};
use crate::native_methods::registry::{MethodRegistry, JAVA_17, JAVA_8};
use crate::parameters::Parameters;
use crate::thread::Thread;
#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -26,7 +26,7 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
registry.register(CLASS_NAME, "pow", "(DD)D", pow);
}

if use_optimizations || registry.java_major_version() <= JAVA_20 {
if use_optimizations || registry.java_major_version() <= JAVA_17 {
registry.register(CLASS_NAME, "IEEEremainder", "(DD)D", ieee_remainder);
registry.register(CLASS_NAME, "acos", "(D)D", acos);
registry.register(CLASS_NAME, "asin", "(D)D", asin);
Expand Down
Loading

0 comments on commit 2fd8ee5

Please sign in to comment.