kud1ing / rucaja

Calling the JVM from Rust via JNI
https://docs.rs/rucaja
Apache License 2.0
31 stars 7 forks source link

Test object arrays #22

Closed fpoli closed 6 years ago

fpoli commented 6 years ago

Here I add an integration test that uses arrays built from Rucaja. Unfortunately, it fails with a NullPointerException. Either I'm doing something wrong (probably) or there is a bug in some library. Any idea?

running 1 test
Exception in thread "Thread-7" java.lang.NullPointerException
    at java.util.Arrays.binarySearch0(Arrays.java:2439)
    at java.util.Arrays.binarySearch(Arrays.java:2379)
test test_java_arrays ... FAILED

failures:

---- test_java_arrays stdout ----
    thread 'test_java_arrays' panicked at 'An exception occurred', src/jvm.rs:83:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
            at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
            at /checkout/src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
            at /checkout/src/libstd/sys_common/backtrace.rs:60
            at /checkout/src/libstd/panicking.rs:381
3: std::panicking::default_hook
            at /checkout/src/libstd/panicking.rs:391
4: std::panicking::rust_panic_with_hook
            at /checkout/src/libstd/panicking.rs:611
5: std::panicking::begin_panic
            at /checkout/src/libstd/panicking.rs:572
6: rucaja::jvm::print_and_panic_on_jvm_exception
            at src/jvm.rs:83
7: rucaja::jvm::Jvm::call_static_int_method
            at src/jvm.rs:303
8: java_array::test_java_arrays
            at tests/java_array.rs:44
9: <F as test::FnBox<T>>::call_box
            at /checkout/src/libtest/lib.rs:1480
            at /checkout/src/libcore/ops/function.rs:223
            at /checkout/src/libtest/lib.rs:141
10: __rust_maybe_catch_panic
            at /checkout/src/libpanic_unwind/lib.rs:99

failures:
    test_java_arrays

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
kud1ing commented 6 years ago

From staring at it i can't figure out the cause. I think it's positive that this is a Java NPE and not a crash in JNI. But everything should be non-null. My only idea is to try to debug the Java objects using Java's print() methods to try to find out which of the arguments is null in the JVM.

kud1ing commented 6 years ago

I've merged it anyway. If there is no solution found anytime soon, we can disable the method call.