On Thu, 26 Jun 2025 11:52:36 GMT, Coleen Phillimore <cole...@openjdk.org> wrote:
>> test/lib/RedefineClassHelper.java line 92: >> >>> 90: byte[] buf = getBytecodes(loader, oldClassName); >>> 91: ClassModel classModel = ClassFile.of().parse(buf); >>> 92: return ClassFile.of().build(ClassDesc.of(newClassName), >>> classModel::forEach); >> >> That's cool! I have no idea how to read it to understand what it does, but >> it is cool it can be done in one line. :) >> >> Seriously though, which part of that is doing the actual replace?? > > 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. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25857#discussion_r2169460161