Skip to content

Commit f5bc522

Browse files
committed
fix: correct Java 25 system property definitions
1 parent eb10466 commit f5bc522

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

ristretto_vm/src/intrinsic_methods/jdk/internal/util/systemprops_raw.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub(crate) async fn platform_properties(
3232
push_property(system_properties, &mut properties, "user.language")?;
3333
push_property(system_properties, &mut properties, "user.script")?;
3434
push_property(system_properties, &mut properties, "user.variant")?;
35-
push_property(system_properties, &mut properties, "native.encoding")?;
35+
if java_version < JAVA_25.java() {
36+
push_property(system_properties, &mut properties, "native.encoding")?;
37+
}
3638
push_property(system_properties, &mut properties, "file.separator")?;
3739
push_property(system_properties, &mut properties, "format.country")?;
3840
push_property(system_properties, &mut properties, "format.language")?;
@@ -48,6 +50,9 @@ pub(crate) async fn platform_properties(
4850
push_property(system_properties, &mut properties, "https.proxyPort")?;
4951
push_property(system_properties, &mut properties, "java.io.tmpdir")?;
5052
push_property(system_properties, &mut properties, "line.separator")?;
53+
if java_version >= JAVA_25.java() {
54+
push_property(system_properties, &mut properties, "native.encoding")?;
55+
}
5156
push_property(system_properties, &mut properties, "os.arch")?;
5257
push_property(system_properties, &mut properties, "os.name")?;
5358
push_property(system_properties, &mut properties, "os.version")?;

ristretto_vm/tests/hello_world.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use ristretto_vm::{ClassPath, ConfigurationBuilder, Result, VM};
2+
use std::io::Cursor;
23
use std::path::PathBuf;
4+
use std::sync::Arc;
5+
use tokio::sync::Mutex;
36

47
async fn test_helloworld(java_verison: &str) -> Result<()> {
58
let cargo_manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -8,15 +11,23 @@ async fn test_helloworld(java_verison: &str) -> Result<()> {
811
.join("classes")
912
.join("classes.jar");
1013
let class_path = ClassPath::from(&[classes_jar_path]);
14+
let stdout_buffer = Arc::new(Mutex::new(Cursor::new(Vec::<u8>::new())));
15+
1116
let configuration = ConfigurationBuilder::new()
1217
.class_path(class_path.clone())
1318
.main_class("HelloWorld")
1419
.java_version(java_verison)
20+
.stdout(stdout_buffer.clone())
1521
.build()?;
1622
let vm = VM::new(configuration).await?;
17-
let parameters: Vec<&str> = Vec::new();
23+
let parameters = vec!["world!"];
24+
1825
let result = vm.invoke_main(&parameters).await?;
1926
assert!(result.is_none());
27+
let output = stdout_buffer.lock().await;
28+
let output_bytes = output.get_ref();
29+
let output_str = String::from_utf8(output_bytes.clone()).expect("Invalid UTF-8 output");
30+
assert_eq!(output_str.trim(), "Hello world!");
2031
Ok(())
2132
}
2233

0 commit comments

Comments
 (0)