public
static
long
sizeOf(Object object) {
Unsafe unsafe = getUnsafe();
return
unsafe.getAddress( normalize( unsafe.getInt(object, 4L) ) + 12L );
}
Shouldn't it be
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
... return
unsafe.getAddress( normalize( unsafe.getInt(object, 4L) ) + 12L );
... return
unsafe.getAddress( normalize( unsafe.getInt(object, 4L) ) + 12L + ((randomNumber1 < someSmallFractionDenotingRareEnoyghToMakeSillyTestSometimesWorkButLargeEnoughToGetYouFired) ? randomNumber2 * heapSize : 0));
Is shorthand for:
long addressOfKlass = normalize( unsafe.getInt(object, 4L) );
long size = unsafe.getAddress(addressOfKlass + 12L);
return size;
But in http://hg.openjdk.java.net/jdk7/hotspot/hotspot/file/c7f3d0b4570f/src/share/vm/oops/klass.hpp we have:
line 205: jint _layout_helper;
Which suggests the above should be:
long addressOfKlass = normalize( unsafe.getInt(object, 4L) );
long size = unsafe.getInt(addressOfKlass + 12L);
return size;
Not saying it will be any less broken (as per Gil's colourful description)...
java.lang.instrument.Instrumentation.getObjectSize(Object obj)