<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font face="monospace">java.lang.instrument is owned by the
Serviceability Team so I'm redirecting this<br>
message to that alias...<br>
<br>
Dan<br>
<br>
</font><br>
<div class="moz-cite-prefix">On 9/27/23 9:14 PM, Siddharth Jain
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAPqV3pR2QWd0sk1ADXdmfzMnVvRzBcWLs7j4iwNL8ZAJDO=pmg@mail.gmail.com">
<div dir="ltr">Hello,
<div><br>
</div>
<div>I am using this method to measure object size in Java:</div>
<div><a href="https://stackoverflow.com/a/52682/147530" moz-do-not-send="true" class="moz-txt-link-freetext">https://stackoverflow.com/a/52682/147530</a><br>
</div>
<div>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:</div>
<div><a href="https://stackoverflow.com/questions/77055455/java-lang-nullpointerexception-cannot-invoke-java-lang-instrument-instrumentat/77055526#77055526" moz-do-not-send="true" class="moz-txt-link-freetext">https://stackoverflow.com/questions/77055455/java-lang-nullpointerexception-cannot-invoke-java-lang-instrument-instrumentat/77055526#77055526</a><br>
</div>
<div>
<pre class="gmail-lang-java gmail-s-code-block" style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code class="gmail-hljs gmail-language-java" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit">java.lang.NullPointerException: Cannot invoke <span class="gmail-hljs-string" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">"java.lang.instrument.Instrumentation.getObjectSize(Object)"</span> because <span class="gmail-hljs-string" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">"com.github.jelmerk.ObjectSizeFetcher.instrumentation"</span> is <span class="gmail-hljs-literal" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">null</span>
at com.github.jelmerk.ObjectSizeFetcher.getObjectSize (ObjectSizeFetcher.java:<span class="gmail-hljs-number" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">18</span>)
at com.mycompany.app.App.main (App.java:<span class="gmail-hljs-number" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">48</span>)
at org.codehaus.mojo.exec.ExecJavaMojo$<span class="gmail-hljs-number" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1.</span>run (ExecJavaMojo.java:<span class="gmail-hljs-number" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">279</span>)
at java.lang.Thread.run (Thread.java:<span class="gmail-hljs-number" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1623</span>)</code></pre>
</div>
<div>any idea how I can fix this? thanks,</div>
<div><br>
</div>
<div>S.</div>
</div>
</blockquote>
<br>
</body>
</html>