JOL object header information
Aleksey Shipilev
aleksey.shipilev at oracle.com
Mon Dec 15 14:10:38 UTC 2014
Hi Rafael,
On 15.12.2014 16:03, Rafael Winterhalter wrote:
> To be certain, I wrote a minor extension to JOL which allows to print more
> detailed header information by something like:
>
> ClassLayout layout = ClassLayout.parseClass(Foo.class).withDetailedHeader();
>
> where each header value is then mapped to its content in JOL's tabular
> overview instead of just printing "(object header)". My (minor)
> modification can found here:
> https://gist.github.com/raphw/7345bae62abd424fb040
Thanks! Not sure it belongs in JOL codebase though, see below:
> However, it seems like the layout JOL retrieves diverges from the layout
> that is described in markOop.hpp - As one exemplary divergence, I found
> that the identity hash code seems to reach one bit further than the
> described 31 bit, e.g. when running
JOL deliberately back away from trying to parse the object metadata,
because that would diverge from the current VM layout without warning.
It is scary to replicate something written out in the HotSpot comments
into the otherwise VM oblivious tools.
I still think the right way to do this is to involve the Serviceability
Agent that ships with each VM version, and follows/queries the VM
internals:
http://mail.openjdk.java.net/pipermail/jol-dev/2014-September/000016.html
I admit, using the SA is PITA. For one, you can not attach to yourself,
and therefore you need to fork out the VM to get this kind of data.
Still, this is doable, and is more maintainable than trying to keep the
JOL code in sync.
That also highlights the route to follow-up with hashcode sizes and
such: SA is the source of truth, not the HotSpot comments.
Thanks,
-Aleksey.
More information about the jol-dev
mailing list