ClassFile.build() is loading result file
Chen Liang
liangchenblue at gmail.com
Sun Jan 5 22:06:03 UTC 2025
Hi Mark,
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.
Can you post your modifyClass?
Chen
On Sun, Jan 5, 2025, 2:57 PM Mark Roberts <markro at cs.washington.edu> wrote:
> 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/11e70393/attachment.htm>
More information about the classfile-api-dev
mailing list