Re-application of code builder and explicit reset
Rafael Winterhalter
rafael.wth at gmail.com
Wed Aug 14 08:12:51 UTC 2024
Hello,
I find that the re-appliction of a code builder in case of overflowing
labels is one less intuitive thing in the code builder API. In any case, I
would add this very explicitly to the javadoc. Finally, I wanted to suggest
to add an overload:
MethodBuilder withCode(Consumer<? super CodeBuilder> code, Runnable
onReset);
In case that the code builder is stateful, this allows to reset some cached
properties that become invalid after the first run. I understand that
statefulness of the consumer might not be intended, but since ASM is
stateful today, I think I will not be the only one in need.
Currently, I prepend the reset to the builder, but it requires an extra
check for the first run making it rather clunky.
Personally: ASM patches the byte code without reapplication of the visitor.
Was this considered for the Class File builder API?
Best regards, Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20240814/b3e6e4be/attachment.htm>
More information about the classfile-api-dev
mailing list