Question: pointer to klass

Andrew Kondratovich andrew.kondratovich at gmail.com
Fri Mar 9 14:54:50 PST 2012


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 ?)

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 [1].
> 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.
>
> HTH,
> Kris Mok
>
> [1]: 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:
>
>> Hello.
>>
>> I'm working on object serialization through Unsafe API.
>> Every java object in memory is header + field values. Header contains
>> pointer to klass
>> (
>> http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/d61c7c22b25c/src/share/vm/oops/klass.hpp
>> ).
>> 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 ?
>>
>> Thanks.
>> --
>> --
>> Andrew
>>
>


-- 
--
Andrew


More information about the hotspot-runtime-dev mailing list