On Thu, 26 Jun 2025 16:34:06 GMT, Chen Liang <li...@openjdk.org> wrote:
>> Java's gone overly terse, but if you look at the n-1 commit, the >> classModel::forEach copies everything in the class to the new class. At >> least that's what Chen told me and it seems to do. Isn't this cool? > >> 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 :( ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25857#discussion_r2169481261