dawnstar
dawnstar

Reputation: 497

How to obtain Java "object" address in Java Native Interface

Is it possible to get the address of a Java object in a JNI method? Or by any other method.

If it is not possible to get real address of an object, then is there a way to determine the memory layout of a data structure?


(This is just an example, description of my question is above this line.)

For instance, I have an array(or any other kinds of container, e.g. ArrayList, LinkedList etc.) of "objects", I want to know how these "objects" (not the references within the container) are allocated on the heap, they may not be allocated continuously, or even randomly ordered. So can I get any information about that?


Edit: Here is another thought, is there any other Java virtual machine can handle this kind of low level thing? For example, Jikes, or even Dalvik.

Upvotes: 4

Views: 1137

Answers (1)

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 136002

You can try http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/misc/Unsafe.java.html. It provides some low-level operations

Upvotes: 1

Related Questions