Question: pointer to klass
rednaxelafx at gmail.com
Fri Mar 9 14:13:43 PST 2012
In normal execution, the klass pointer of an object always points to the
same klass during its lifetime. But, you shouldn't expect to persist the
value of a klass pointer and use it later. The klass may move during a full
GC, so the value of the pointer may change, although it'd still be pointing
to the same klass. Class redefinition/retransformation doesn't affect the
klass pointer right now.
Just for fun: if you really want to see what happens when you mess with the
klass pointer, here's an example .
Do remember that it's just for fun, and the example only works in the
interpreter, without GC happening in between, or any concurrent access to
that klass pointer.
On Sat, Mar 10, 2012 at 5:55 AM, Andrew Kondratovich <
andrew.kondratovich at gmail.com> wrote:
> I'm working on object serialization through Unsafe API.
> Every java object in memory is header + field values. Header contains
> pointer to klass
> Can this pointer be changed in Runtime by JVM ? I mean, if I read
> address to `klass` for some Java Class, does it be the same (the same
> adress and klass structure for the same Java Class) in 10 minutes, 3
> hours, 2 days... Or can be changed by JIT for example ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-runtime-dev