Preview features and class file formats
Chen Liang
chen.l.liang at oracle.com
Fri Apr 18 22:55:31 UTC 2025
Hi Alex and others,
I am currently enhancing java.lang.reflect.AccessFlag to be able to handle access flags introduced by preview features of the runtime Java SE; for example, project valhalla recognizes ACC_IDENTITY and ACC_STRICT_INIT when running with preview features enabled.
In AccessFlag, there are two APIs: locations() and locations(ClassFileFormatVersion). Currently, both are affected by the enabling of preview features: when preview features are enabled, for both new flags, both locations() and locations(ClassFileFormatVersion.RELEASE_25) (where RELEASE_25 is ClassFileFormatVersion.current()) return their supported locations as preview features; otherwise, they report they support no location. However, I felt that was wrong: when preview features are enabled, applications should still be able to obtain right reflective information applicable to 69.0 class files.
I have been looking at java.lang.reflect.ClassFileFormatVersion, and it seems the versions here never represent class file versions that depend on preview features of specific versions of the Java SE platform. My logical conclusion was that for these flags, locations(ClassFileFormatVersion.RELEASE_25) should report they support no location even when preview features are enabled; ClassFileFormatVersion.RELEASE_25 represents the class file format 69.0, which does not support the new flags, instead of 69.65535. In addition, it does not make sense for locations(ClassFileFormatVersion.RELEASE_25) to differ for a preview-enabled Java SE runtime 25 and any Java SE runtime of a future Java SE release, whether or not preview features are enabled.
Are my understandings of class file format versions and treatment of those APIs correct?
Regards,
Chen Liang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20250418/f18c0173/attachment.htm>
More information about the compiler-dev
mailing list