ClassFile.build() is loading result file

Mark Roberts markro at cs.washington.edu
Sun Jan 5 20:57:33 UTC 2025


I am using ClassFileTransformer.transform() to instrument class files as
they are loaded.   Within my transform method I call



byte[] newBytes =  classFile.build(classModel.thisClass().asSymbol(),

                          classBuilder -> modifyClass(classBuilder,
classModel, loader));



where modifyClass does all the instrumentation.



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().



What is going on?



Thank you,

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20250105/c1ae98f6/attachment-0001.htm>


More information about the classfile-api-dev mailing list