RFR: 8359707: Add classfile modification code to RedefineClassHelper [v6]
Coleen Phillimore
coleenp at openjdk.org
Thu Jun 26 18:44:29 UTC 2025
On Thu, 26 Jun 2025 16:47:35 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>>> Seriously though, which part of that is doing the actual replace??
>>
>> `ClassDesc.of(newClassName)` defines a new class with the new name, and the lambda just copies everything over as-is.
>
> It can be also written as:
> `return ClassFile.of().transform(classModel, ClassDesc.of(newClassName), ClassTransform.ACCEPT_ALL`
>
> But be aware this code does not change the class name use anywhere in the code, descriptors, handles, annotation, etc..., just the class name itself.
>
> Full class remapping was a job of https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/classfile/components/ClassRemapper.html which unfortunately didn't make it from 23 preview to 24 :(
Yes, I wanted to use the ClassRemapper but all the tests that used RedefineClassHelper would have had to add @modules. We can change it later when ClassRemapper becomes available without adding modules.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25857#discussion_r2169711642
More information about the serviceability-dev
mailing list