Why "jobject" in JNI part is always outside Java heap?
dawn2004 at gmail.com
Tue Apr 7 22:33:46 PDT 2009
Thanks a lot!
I understand the jobject contains a point to a java object. So if GC moves
the corresponding java object, the content of the jobject can be updated,
and reference to the new location.
> Colin(Du Li) (dawn2004 at gmail.com) wrote:
>> Hello, I have a question related to JNI of hotspot.
>> According to my undestanding, a jobject is representation of java object
>> JNI part, so it should reside in Java heap.
> Because the garbage collector may move objects, addresses within the
> java heap cannot be visible to native (JNI) code. There's no way for
> the GC to find java object pointers in native code and update them so
> they refer to the new locations. So jobject is just an opaque data
> item that the JVM can use to identify the object--a level of
> indirection. See JNIHandles::resolve() in jniHandles.hpp.
>> I check the "jobject" on stack, I find it is always outside the java
>> (I give an example as follows.)
>> Is it correct?
>> for the method: virtual jobject
>> The stack is below:
>> - local [0x73f37e40] ; #0
>> - local [0x73f38c80] ; #1
>> - stack [0x73f38c80] ; #1
>> - stack [0x73f37e40] ; #0
>> - monitor[0xbfd21c78]
>> - bcp [0xb3f31194] ; @16
>> - locals [0xbfd21cf4]
>> - method [0xb3f311c0] ; virtual jobject
>> We can see two jobjects' addresses are:0x73f38c80, 0x73f37e40
>> But at this time I dump the heap layout, get information as below:
>> def new generation total 7936K, used 285K [0x73f40000, 0x747d0000,
>> eden space 7104K, 4% used [0x73f40000, 0x73f874c0, 0x74630000)
>> from space 832K, 0% used [0x74630000, 0x74630000, 0x74700000)
>> to space 832K, 0% used [0x74700000, 0x74700000, 0x747d0000)
>> tenured generation total 63360K, used 0K [0x7b100000, 0x7eee0000,
>> the space 63360K, 0% used [0x7b100000, 0x7b100000, 0x7b100200,
>> tenured generation total 6976K, used 0K [0xae440000, 0xaeb10000,
>> the space 6976K, 0% used [0xae440000, 0xae440000, 0xae440800,
>> compacting perm gen total 16384K, used 1826K [0xb3f40000, 0xb4f40000,
>> the space 16384K, 11% used [0xb3f40000, 0xb41089a0, 0xb4108a00,
>> No shared spaces configured.
>> The java heap starts from 0x73f40000, so I can tell two jobjects'
>> (0x73f38c80, 0x73f37e40) reside outside Java heap.
>> View this message in context:
>> Sent from the OpenJDK Hotspot Virtual Machine mailing list archive at
View this message in context: http://www.nabble.com/Why-%22jobject%22-in-JNI-part-is-always-outside-Java-heap--tp22939687p22943493.html
Sent from the OpenJDK Hotspot Virtual Machine mailing list archive at Nabble.com.
More information about the hotspot-dev