NullPointerException in tests/java_array #24
Comments
I think the bug is in https://github.com/kud1ing/rucaja/blob/master/src/jvm_method.rs |
If only i could remember why |
This SO question has a lot of useful information. They say Similarly, from Android JNI Tips:
I suspect that a |
Stack of the fatal error mentioned above: --------------- T H R E A D --------------- Current thread (0x00007f50a1e1d800): JavaThread "Thread-2" [_thread_in_vm, id=15784, stack(0x00007f50a21ff000,0x00007f50a2400000)]
So, in |
Yes, you are correct. A method is not a |
I don't know. Rucaja's functions should in theory be Rust-thread-safe. Do C++-thread-safe functions look any different? I could imagine we could do more work in fewer functions. Like calling a method: we could do look up of the class and the method and calling the method at the same time. But this would waste some cycles when looking up the same classes/methods multiple times. |
Since we create a global reference to them, i would expect that this is not the case. But i have not seen any statement one way or another. |
Maybe we just call |
I phrased it in the wrong way, I wanted to say that in the C++ examples that I looked at they don't detach before calling the
Yes, I also suspect that anticipating If my understanding is correct, it seems that local references must have a lifetime shorter than the However, there are still a lot of things that are not clear to me. For example, what happens if we attach twice and detach once? Can we still use a local reference created before the detach? If we want to ignore this kind of questions I think that It's much easier to convert everything to global reference (before the detach) or to use a single |
I think this is not a problem:
|
So, imagine that we have a function
It seems to me that is easier to have just one jni_env in each thread, with one "attach" at the beginning of the thread. |
Yes, that makes sense. We should modify every function to accept a reference to a |
Hm, for |
I just found this library https://github.com/prevoty/jni-rs/blob/980cf3e23fdcef7302e864011101c3d65a6d3843/src/wrapper/objects/global_ref.rs They keep a Actually, |
Some time ago i've tried to cache the See also https://stackoverflow.com/a/12421377 Also my understanding was that the purpose of |
Fixed with 4a93eef |
Thanks for the test and your help in identifiying and solving this problem. |
I open this issue to track the NullPointerException in
tests/java_array.rs
(introduced in #22).Starting the JVM with
-Xcheck:jni
gives a (slightly) better error message:Disabling
-Xcheck:jni
and running the test with a debug JVM the message becomes more interesting:Looking at
hotspot/src/share/vm/runtime/jniHandles.hpp:178
the content is this:The text was updated successfully, but these errors were encountered: