andreabergia/rjvm

Access violation reading location

Clownsw opened this issue · 2 comments

Test for Java Code:

package rjvm.test;

import java.io.PrintStream;

public class Test {
    public static void main(String[] args) {
        final PrintStream p = System.out;
    }
}
#[test_log::test]
fn invoke_test() {
    let mut vm = Vm::new(DEFAULT_MAX_MEMORY);

    let src_dir = env!("CARGO_MANIFEST_DIR");

    vm.append_class_path(&format!("{src_dir}/rt.jar;{src_dir}/tests/resources"))
        .expect("should be able to add entries to the classpath");

    let _ = invoke(
        &mut vm,
        "rjvm/test/Test",
        "main",
        "([Ljava/lang/String;)V",
    );
}

run result (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

I was just tinkering with this and I found out that you can't use System.out or its methods like println you have to provide the private static native void tempPrint(String value); method in your class and use this instead for printing. if you use Windows, it will fail btw if you use let src_dir = env!("CARGO_MANIFEST_DIR"); as it provides the full path with "C://..." which will not work, because the classpath will get split at :.

Thanks for the report and for your interest!
As I've written in the readme, I don't intend to work on this anymore, and therefore I won't address any bug report.