Skip to content

Commit

Permalink
Fix NativeCallSystemArrayCopy test
Browse files Browse the repository at this point in the history
  • Loading branch information
hextriclosan committed Oct 23, 2024
1 parent c18374e commit c66377f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion tests/should_do_native_call_on_system_array_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use utils::get_long;
use utils::setup;

#[test]
#[ignore]
fn should_do_native_call_on_system_array_copy() {
let mut vm = setup();
let last_frame_value = vm
Expand Down
7 changes: 7 additions & 0 deletions tests/test_data/NativeCallSystemArrayCopy.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package samples.nativecall.system;

import java.util.Map;
import java.util.HashMap;

public class NativeCallSystemArrayCopy {
public static void main(String[] args) {
var props = new HashMap<String, String>();
props.put("java.class.version", "67.0"); // fixme: move to VM init stage
jdk.internal.misc.VM.saveProperties(props); // javac --add-exports java.base/jdk.internal.misc=ALL-UNNAMED -d . NativeCallSystemArrayCopy.java

long sum = intArr() + longArr() + intArrOverlapping() + fromBaseArray();
}

Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions vm/src/execution_engine/system_native_table.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::error::Error;
use crate::helper::i64_to_vec;
use crate::system_native::class::{get_modifiers_wrp, get_primitive_class_wrp};
use crate::system_native::string::intern_wrp;
use crate::system_native::system::{arraycopy_wrp, current_time_millis_wrp};
Expand Down Expand Up @@ -61,6 +62,13 @@ static SYSTEM_NATIVE_TABLE: Lazy<
"jdk/internal/misc/CDS:initializeFromArchive:(Ljava/lang/Class;)V",
void_stub as fn(&[i32]) -> crate::error::Result<Vec<i32>>,
);
table.insert(
"jdk/internal/misc/VM:initialize:()V",
void_stub as fn(&[i32]) -> crate::error::Result<Vec<i32>>,
);
table.insert("java/lang/Runtime:maxMemory:()J", |_args: &[i32]| {
return_argument_stub(&i64_to_vec(i64::MAX))
});

table
});
Expand Down

0 comments on commit c66377f

Please sign in to comment.