Question: pointer to klass
david.holmes at oracle.com
Sat Mar 10 04:54:57 PST 2012
On 10/03/2012 8:54 AM, Andrew Kondratovich wrote:
> Yep, you're right.
> Simple check shows that pointer is changing the position.
> Can anybody give an advise, how to save object class in serialization
> in fast way ?)
What do you mean? The type of the object serialized is part of the
serialization information. You can't just save a pointer as the Class
may have to be loaded as part of de-serialization.
> On 3/10/12, Krystal Mok<rednaxelafx at gmail.com> wrote:
>> Hi Andrew,
>> 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.
>> Kris Mok
>> : http://hllvm.group.iteye.com/group/topic/17806
>> 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 ?
More information about the hotspot-runtime-dev