Classfile API support for JSR and RET instructions
Adam Sotona
adam.sotona at oracle.com
Wed Apr 19 13:29:50 UTC 2023
Hi,
Work on javap conversion from ASM to Classfile API and recent bug (JDK-8305990<https://bugs.openjdk.org/browse/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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20230419/6c8a0ad8/attachment.htm>
More information about the classfile-api-dev
mailing list