Preview features and class file formats
Alex Buckley
alex.buckley at oracle.com
Mon Apr 21 17:26:58 UTC 2025
On 4/21/2025 9:20 AM, Chen Liang wrote:
> That said, I wish to come back to the non SourceVersion/
> ClassFileFormatVersion-aware query methods - should they just return the
> behavior when preview is enabled in the current release even when
> preview is not enabled?
I thought we had agreed that if version-sensitive query methods can only
be made aware of "25", not "25 with preview enabled", then their results
should indicate the permanent behavior of 25 _regardless of whether the
Java runtime was started with --enable-preview_.
> Coming back to the JEP 12 example of reserving _ as a keyword, the
> SourceVersion.isIdentifier API will return false for _ in an
> implementation of Java SE 8, regardless if the runtime has preview
> features enabled or not, instead of only declaring that _ is not an
> identifier when preview is enabled
That's tricky because _ in 8 caused a warning but was technically legal.
We knew there would be code compiled and run on 8 for many years, and
did not wish to break it. _ only caused an error in 8 with
--enable-preview. So, consistent with my cautious position above,
SourceVersion.isIdentifier("_") would have returned true on an 8 runtime
_regardless of whether the runtime was started with --enable-preview_.
Alex
More information about the compiler-dev
mailing list