Skip to content

Commit

Permalink
Merge pull request #230 from theseus-rs/update-java-runtime-versions
Browse files Browse the repository at this point in the history
chore: update java runtime versions
  • Loading branch information
brianheineman authored Jan 22, 2025
2 parents c9ed8b2 + e9c72fb commit fe81c27
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ visit the [ristretto](https://theseus-rs.github.io/ristretto/ristretto_cli/) sit

- Deterministic memory allocation / deallocation
- No tracing garbage collector
- Runtime classes based on any version of [AWS Corretto](https://github.com/corretto)
- Runtime classes based on LTS versions of [AWS Corretto](https://github.com/corretto)
- Load classes from directories, jars, modules
- Url class loading from jars and modules
- Reading, writing, verifying classes
Expand Down
8 changes: 4 additions & 4 deletions ristretto_classloader/benches/class_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ fn benchmarks(criterion: &mut Criterion) {
fn bench_lifecycle(criterion: &mut Criterion) -> Result<()> {
let runtime = Runtime::new()?;
let (_java_home, _version, class_loader) =
runtime.block_on(async { runtime::version_class_loader("21.0.5.11.1").await })?;
runtime.block_on(async { runtime::version_class_loader("21.0.6.7.1").await })?;
let class_loader = Arc::new(class_loader);

criterion.bench_function("runtime_v8", |bencher| {
bencher.iter(|| {
runtime.block_on(async {
boot_class_loader("8.432.06.1").await.ok();
boot_class_loader("8.442.06.1").await.ok();
});
});
});
criterion.bench_function("runtime_v11", |bencher| {
bencher.iter(|| {
runtime.block_on(async {
boot_class_loader("11.0.25.9.1").await.ok();
boot_class_loader("11.0.26.4.1").await.ok();
});
});
});
Expand All @@ -37,7 +37,7 @@ fn bench_lifecycle(criterion: &mut Criterion) -> Result<()> {
criterion.bench_function("runtime_v21", |bencher| {
bencher.iter(|| {
runtime.block_on(async {
boot_class_loader("21.0.5.11.1").await.ok();
boot_class_loader("21.0.6.7.1").await.ok();
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion ristretto_classloader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//!
//! Implementation of a [JVM Class Loader](https://docs.oracle.com/javase/specs/jvms/se23/html/jvms-4.html)
//! that is used to load Java classes. Classes can be loaded from the file system or from a URL;
//! jar and modules are supported. A runtime Java class loader can be created from any version of
//! jar and modules are supported. A runtime Java class loader can be created from a LTS version of
//! [AWS Corretto](https://github.com/corretto). The runtime class loader will download and install
//! the requested version of Corretto and create a class loader that can be used to load Java
//! classes.
Expand Down
2 changes: 1 addition & 1 deletion ristretto_classloader/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ mod tests {

async fn java8_string_class() -> Result<Arc<Class>> {
let (_java_home, _java_version, class_loader) =
runtime::version_class_loader("8.432.06.1").await?;
runtime::version_class_loader("8.442.06.1").await?;
class_loader.load("java.lang.String").await
}

Expand Down
6 changes: 3 additions & 3 deletions ristretto_classloader/src/runtime/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{env, io};
use tar::Archive;
use tracing::{debug, instrument, warn};

pub const DEFAULT_JAVA_VERSION: &str = "21.0.5.11.1";
pub const DEFAULT_JAVA_VERSION: &str = "21.0.6.7.1";

/// Get a class loader for the default Java runtime version. If the version is not installed, the
/// archive will be downloaded and extracted.
Expand Down Expand Up @@ -224,7 +224,7 @@ mod tests {

#[tokio::test]
async fn test_class_loader_v8() -> Result<()> {
let version = "8.432.06.1";
let version = "8.442.06.1";
let (_java_home, java_version, class_loader) = version_class_loader(version).await?;
assert_eq!(version, java_version);
assert_eq!("bootstrap", class_loader.name());
Expand All @@ -233,7 +233,7 @@ mod tests {

#[tokio::test]
async fn test_class_loader_v21() -> Result<()> {
let version = "21.0.5.11.1";
let version = "21.0.6.7.1";
let (_java_home, java_version, class_loader) = version_class_loader(version).await?;
assert_eq!(version, java_version);
assert_eq!("bootstrap", class_loader.name());
Expand Down
8 changes: 4 additions & 4 deletions ristretto_classloader/src/runtime/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ mod tests {

#[tokio::test]
async fn test_get_runtime_archive_latest_exact() -> Result<()> {
let expected_version = "11.0.25.9.1";
let expected_version = "11.0.26.4.1";
let (version, file_name, archive) = get_runtime_archive(expected_version).await?;
assert_eq!(expected_version, version);
assert!(file_name.contains(expected_version));
Expand Down Expand Up @@ -243,7 +243,7 @@ mod tests {

#[tokio::test]
async fn test_download_archive() -> Result<()> {
let version = "21.0.5.11.1";
let version = "21.0.6.7.1";
let (_file_name, archive) = download_archive(version).await?;
assert!(!archive.is_empty());
Ok(())
Expand All @@ -253,15 +253,15 @@ mod tests {
async fn test_get_release_versions() -> Result<()> {
let major_version = "21";
let release_versions = get_release_versions(major_version).await?;
let expected_version = "21.0.5.11.1".to_string();
let expected_version = "21.0.6.7.1".to_string();
assert!(release_versions.contains(&expected_version));
Ok(())
}

#[test]
fn test_parse_major_version() {
assert_eq!(11, parse_major_version("11"));
assert_eq!(8, parse_major_version("8.432.06.1"));
assert_eq!(8, parse_major_version("8.442.06.1"));
assert_eq!(0, parse_major_version(""));
assert_eq!(0, parse_major_version("a"));
}
Expand Down
20 changes: 10 additions & 10 deletions ristretto_classloader/tests/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,29 @@ async fn write_native(version: &str) -> Result<()> {
#[tokio::test]
async fn test_native_classes() -> Result<()> {
// Enable to generate native class lists
// write_classes("8.432.06.1").await?;
// write_classes("11.0.25.9.1").await?;
// write_classes("17.0.12.7.1").await?;
// 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.5.11.1").await?;
// write_classes("21.0.6.7.1").await?;
// write_classes("22.0.2.9.1").await?;
// write_classes("23.0.1.8.1").await?;
// write_classes("23.0.2.7.1").await?;
Ok(())
}

#[tokio::test]
async fn test_native_methods() -> Result<()> {
// Enable to generate native method stubs
// write_native("8.432.06.1").await?;
// write_native("11.0.25.9.1").await?;
// write_native("17.0.12.7.1").await?;
// 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.5.11.1").await?;
// write_native("21.0.6.7.1").await?;
// write_native("22.0.2.9.1").await?;
// write_native("23.0.1.8.1").await?;
// write_native("23.0.2.7.1").await?;
Ok(())
}
10 changes: 5 additions & 5 deletions ristretto_classloader/tests/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ async fn test_runtime(version: &str, class_name: &str) -> Result<()> {

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

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

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

#[tokio::test]
Expand All @@ -47,7 +47,7 @@ async fn test_get_runtime_v20() -> Result<()> {

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

#[tokio::test]
Expand All @@ -57,5 +57,5 @@ async fn test_get_runtime_v22() -> Result<()> {

#[tokio::test]
async fn test_get_runtime_v23() -> Result<()> {
test_runtime("23.0.1.8.1", "java.lang.Object").await
test_runtime("23.0.2.7.1", "java.lang.Object").await
}
2 changes: 1 addition & 1 deletion ristretto_vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//!
//! Implementation of a [JVM Class Loader](https://docs.oracle.com/javase/specs/jvms/se23/html/jvms-4.html)
//! that is used to load Java classes. Classes can be loaded from the file system or from a URL;
//! jar and modules are supported. A runtime Java class loader can be created from any version of
//! jar and modules are supported. A runtime Java class loader can be created from a LTS version of
//! [AWS Corretto](https://github.com/corretto). The runtime class loader will download and install
//! the requested version of Corretto into and create a class loader that can be used to load Java
//! classes.
Expand Down
10 changes: 5 additions & 5 deletions ristretto_vm/src/native_methods/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,17 +768,17 @@ mod tests {

#[tokio::test]
async fn test_runtime_v8() -> Result<()> {
test_runtime("8.432.06.1").await
test_runtime("8.442.06.1").await
}

#[tokio::test]
async fn test_runtime_v11() -> Result<()> {
test_runtime("11.0.25.9.1").await
test_runtime("11.0.26.4.1").await
}

#[tokio::test]
async fn test_runtime_v17() -> Result<()> {
test_runtime("17.0.12.7.1").await
test_runtime("17.0.14.7.1").await
}

#[tokio::test]
Expand All @@ -798,7 +798,7 @@ mod tests {

#[tokio::test]
async fn test_runtime_v21() -> Result<()> {
test_runtime("21.0.5.11.1").await
test_runtime("21.0.6.7.1").await
}

#[tokio::test]
Expand All @@ -808,6 +808,6 @@ mod tests {

#[tokio::test]
async fn test_runtime_v23() -> Result<()> {
test_runtime("23.0.1.8.1").await
test_runtime("23.0.2.7.1").await
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::native_methods::registry::{
MethodRegistry, JAVA_11, JAVA_17, JAVA_18, JAVA_19, JAVA_22, JAVA_8,
MethodRegistry, JAVA_11, JAVA_17, JAVA_18, JAVA_19, JAVA_21, JAVA_22, JAVA_23, JAVA_8,
};
use crate::parameters::Parameters;
use crate::thread::Thread;
Expand Down Expand Up @@ -48,9 +48,11 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
if registry.java_major_version() <= JAVA_19 {
registry.register(CLASS_NAME, "stat1", "(J)I", stat_1);
}
if registry.java_major_version() <= JAVA_22 {

if registry.java_major_version() != JAVA_21 && registry.java_major_version() <= JAVA_22 {
registry.register(CLASS_NAME, "exists0", "(J)Z", exists_0);
}

registry.register(CLASS_NAME, "close0", "(I)V", close_0);
registry.register(CLASS_NAME, "getlinelen", "(J)I", getlinelen);
}
Expand Down Expand Up @@ -97,10 +99,10 @@ pub(crate) fn register(registry: &mut MethodRegistry) {
registry.register(CLASS_NAME, "write0", "(IJI)I", write_0);
}

if registry.java_major_version() <= JAVA_22 {
registry.register(CLASS_NAME, "access0", "(JI)V", access_0);
} else {
if registry.java_major_version() == JAVA_21 || registry.java_major_version() >= JAVA_23 {
registry.register(CLASS_NAME, "access0", "(JI)I", access_0);
} else {
registry.register(CLASS_NAME, "access0", "(JI)V", access_0);
}

registry.register(CLASS_NAME, "chmod0", "(JI)V", chmod_0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const CLASS_NAME: &str = "sun/security/pkcs11/wrapper/PKCS11";
/// Register all native methods for `sun.security.pkcs11.wrapper.PKCS11`.
#[expect(clippy::too_many_lines)]
pub(crate) fn register(registry: &mut MethodRegistry) {
if registry.java_major_version() <= JAVA_11 {
if registry.java_major_version() <= JAVA_17 {
registry.register(
CLASS_NAME,
"C_GCMDecryptInitWithRetry",
Expand Down
10 changes: 5 additions & 5 deletions ristretto_vm/tests/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ async fn test_helloworld(java_verison: &str) -> Result<()> {

// #[tokio::test]
// async fn test_helloworld_v8() -> Result<()> {
// test_helloworld("8.432.06.1").await
// test_helloworld("8.442.06.1").await
// }

#[tokio::test]
async fn test_helloworld_v11() -> Result<()> {
test_helloworld("11.0.25.9.1").await
test_helloworld("11.0.26.4.1").await
}

#[tokio::test]
async fn test_helloworld_v17() -> Result<()> {
test_helloworld("17.0.12.7.1").await
test_helloworld("17.0.14.7.1").await
}

#[tokio::test]
Expand All @@ -52,7 +52,7 @@ async fn test_helloworld_v20() -> Result<()> {

#[tokio::test]
async fn test_helloworld_v21() -> Result<()> {
test_helloworld("21.0.5.11.1").await
test_helloworld("21.0.6.7.1").await
}

#[tokio::test]
Expand All @@ -62,5 +62,5 @@ async fn test_helloworld_v22() -> Result<()> {

#[tokio::test]
async fn test_helloworld_v23() -> Result<()> {
test_helloworld("23.0.1.8.1").await
test_helloworld("23.0.2.7.1").await
}

0 comments on commit fe81c27

Please sign in to comment.