On Mon, 28 Apr 2025 01:43:32 GMT, Chen Liang <li...@openjdk.org> wrote:
> Transforms can run on a stream of class file elements. Currently, that stream > can only be from a CompoundElement. We can allow a ClassFileBuilder to > provide such a stream too; a recent request > https://mail.openjdk.org/pipermail/classfile-api-dev/2025-April/000698.html > asks for this as well. > > With this patch, we can now emulate this ASM pattern easily: > > > // ASM > ClassVisitor cv = new DelegateClassVisitor(new ClassWriter(...)); > cv.visitXxx(); // write elements through the delegate > > // ClassFile API > cf.build(..., clb0 -> clb0.transforming((clb, cle) -> /*process */, clb -> { > // write elements through delegate > })); > > > Notably, this patch introduces a source incompatibility (but not binary) in > order to allow users to call `transform(model, (xb, xe) -> {})` or > `transforming((xb1, xe) -> {}, xb1 -> {})`. This has little impact if users > don't use `ClassFileBuilder` as a type directly (which according to grep.app, > there are only two sites on whole GitHub, both updated in this PR). A release > note has been created for this incompatibility at > https://bugs.openjdk.org/browse/JDK-8355665; please review too. This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/jdk/pull/24908