<p dir="ltr">Hi Mark,<br>
why do you need to supply the ClassLoader to the modifyClass method? Class file transformation should have no dependency on the CHA process, and the only need is encapsulated within the ClassFile context object.</p>
<p dir="ltr">Can you post your modifyClass?</p>
<p dir="ltr">Chen</p>
<br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Jan 5, 2025, 2:57 PM Mark Roberts <<a href="mailto:markro@cs.washington.edu">markro@cs.washington.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word"><div class="m_4363925205896099277WordSection1"><p class="MsoNormal">I am using ClassFileTransformer.transform() to instrument class files as they are loaded. Within my transform method I call</p><p class="MsoNormal"> </p><p class="MsoNormal">byte[] newBytes = classFile.build(classModel.thisClass().asSymbol(),</p><p class="MsoNormal"> classBuilder -> modifyClass(classBuilder, classModel, loader));</p><p class="MsoNormal"> </p><p class="MsoNormal">where modifyClass does all the instrumentation.</p><p class="MsoNormal"> </p><p class="MsoNormal">The problem is some where inside of classFile.build() the class is actually being loaded! Thus, when I return newBytes from the transform method I get an error ‘attempted duplicate abstract class definition’. I have verified that the class has not be loaded prior to the return from modifyClass().</p><p class="MsoNormal"> </p><p class="MsoNormal">What is going on?</p><p class="MsoNormal"> </p><p class="MsoNormal">Thank you,</p><p class="MsoNormal">Mark</p></div></div>
</blockquote></div>