measuring object size in Java

daniel.daugherty at oracle.com daniel.daugherty at oracle.com
Thu Sep 28 20:42:30 UTC 2023


java.lang.instrument is owned by the Serviceability Team so I'm 
redirecting this
message to that alias...

Dan


On 9/27/23 9:14 PM, Siddharth Jain wrote:
> Hello,
>
> I am using this method to measure object size in Java:
> https://stackoverflow.com/a/52682/147530
> and it was (it still does) working with JDK17 on a x64 Intel based 
> Mac. But today I tried it with JDK20 on a AARch64 based Mac and it 
> does not work. I get runtime exception:
> https://stackoverflow.com/questions/77055455/java-lang-nullpointerexception-cannot-invoke-java-lang-instrument-instrumentat/77055526#77055526
> |java.lang.NullPointerException: Cannot invoke 
> "java.lang.instrument.Instrumentation.getObjectSize(Object)" because 
> "com.github.jelmerk.ObjectSizeFetcher.instrumentation" is null at 
> com.github.jelmerk.ObjectSizeFetcher.getObjectSize 
> (ObjectSizeFetcher.java:18) at com.mycompany.app.App.main 
> (App.java:48) at org.codehaus.mojo.exec.ExecJavaMojo$1.run 
> (ExecJavaMojo.java:279) at java.lang.Thread.run (Thread.java:1623)|
> any idea how I can fix this? thanks,
>
> S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20230928/d2eedcfe/attachment.htm>


More information about the jdk-dev mailing list