Clarification on what the JNI spec means by nonmovable
Jon V.
sybersnake at gmail.com
Thu Sep 8 16:30:47 UTC 2016
Hello everyone!
I’m trying to document the exact behavior of direct pointer access of
passed arguments into JNI in HotSpot. I have a huge post on StackOverflow
for posterity purposes as it seems to be a commonly misunderstood behavior.
http://stackoverflow.com/questions/39381339/understanding-safe-access-of-jni-arguments
from
https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html#wp16789
The JNI spec says, “To implement local references, the Java VM creates a
registry for each transition of control from Java to a native method. A
registry maps nonmovable local references to Java objects, and keeps the
objects from being garbage collected.”
I’m trying to understand if “nonmovable” actually means that the objects in
the map WILL NOT be compacted/moved (heap memory) or if it just means they
won’t be garbage-collected. The answer dictates if the use of critical
sections are actually necessary.
What are the effects for each garbage collector?
I found an email on the archives that says that JNI critical sections do
not effect operation of CMS and I’m interested in understanding the
behavior for G1 as well.
This all boils down to the ability to use unsafe raw direct pointers in JNI
without critical sections in HotSpot.
Thank you,
J
More information about the hotspot-dev
mailing list