Heads up: Recent news in the ClassFile API since Java 24
Chen Liang
chen.l.liang at oracle.com
Mon Apr 28 02:25:02 UTC 2025
Hello all,
Since the release of Java 24, I wish to share some latest news about the upcoming features in the ClassFile API.
1.
UnknownAttribute and CustomAttribute are now delivered in traversal of CodeModel. https://bugs.openjdk.org/browse/JDK-8347472
2.
StackMapsTableAttribute reused for NO_STACK_MAPS transformation (such as System.out.println on method entry) now updates its BCIs. (Same above, JDK-8347472)
3.
The default flags of ClassBuilder is now ACC_PUBLIC + ACC_SUPER, in anticipation of identity classes when Value Objects JEP is integrated.
And there are a few proposed features, please don't hesitate to comment or review:
1.
Add matches() methods to CP entries for convenient and fast checking. https://github.com/openjdk/jdk/pull/23548
2.
Add explicit counter support for performance-sensitive code building. https://github.com/openjdk/jdk/pull/24903
3.
Add XxxBuilder::transforming the same way CodeBuilder::transforming behaves. https://github.com/openjdk/jdk/pull/24908
Note for XxxBuilder::transforming:
It covers this ASM usage pattern currently not supported by the ClassFile API:
// 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
}));
And it introduces a source incompatibility if you are using ClassFileBuilder as a variable type, like ClassFileBuilder<?, ?>.
See this draft release note https://bugs.openjdk.org/browse/JDK-8355665 for migration help.
Also on the Valhalla side: ClassFile API is providing first-class support for strict fields and the updated stack map table format, including parsing, manual creation, and automatic generation.
Please feel free to review the PRs linked! And don't hesitate to reply with any comment or question.
Regards,
Chen Liang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20250428/4f063c8d/attachment-0001.htm>
More information about the classfile-api-dev
mailing list