Classfile API support for JSR and RET instructions
-
liangchenblue at gmail.com
Wed Apr 19 14:13:30 UTC 2023
Thanks for your great work, Adam!
I took a peek at the patch. Looks great to me. I believe this should
suffice to handle transforming all older bytecode without upgrading
them.
In the future, we might have a code transform in the components that
migrates code from jsr/ret to modern StackMapTable-friendly bytecode
as well.
Chen Liang
On Wed, Apr 19, 2023 at 8:30 AM Adam Sotona <adam.sotona at oracle.com> wrote:
>
> Hi,
>
> Work on javap conversion from ASM to Classfile API and recent bug (JDK-8305990) discovered in StripJavaDebugAttributesPlugin brought attention to missing JSR and RET instructions support in Classfile API.
>
>
>
> I’m proposing following changes to Classfile API:
>
> Drop Opcode.Kind.UNSUPPORTED and add Opcode.Kind.DISCONTINUED_JSR and DISCONTINUED_RET
> Add DiscontinuedInstruction interface with inner JsrInstruction and RetInstruction with standard factory methods
> CodeImpl will parse and stream these instructions when present in the Code attribute
> Do not add any new conveniency methods to CodeBuilder, the only way to build a code with these instructions will be cob.with(DiscontinuedInstruction. JsrInstruction.of(…)) and similar for RetInstruction
> Fix DirectCodeBuilder so it invokes StackMapGenerator only for class file version >= 51.0 (BufWriterImpl must hold class version for that purpose)
> Fix StackMapGenerator error message when these instruction appear in during generation
> Implement fallback to jump target inflation in CodeImpl when the StackMapTable attribute is missing and class file version is < 51.0
> Extend tests to verify JSR and RET instructions are correctly generated, transformed and reported as error (based on class file version).
>
>
>
> Please review and comment this proposal under following pull request:
>
> https://github.com/openjdk/jdk/pull/13478
>
>
>
> Next step is to implement simple maxStack and maxLocals counter into DirectCodeBuilder for the cases where StackMapGenerator is not involved. Actual default to maxStack = maxLocals = 255 is not correct.
>
>
>
> Thanks,
>
> Adam
More information about the classfile-api-dev
mailing list