RFR: JDK-8246704: --release => "unknown enum constant PreviewFeature$Feature.TEXT_BLOCKS"
Jan Lahoda
jan.lahoda at oracle.com
Thu Jun 11 13:26:42 UTC 2020
Hi,
When compiling with --release 14, warnings like this may be printed:
warning: unknown enum constant PreviewFeature$Feature.TEXT_BLOCKS
reason: class file for jdk.internal.PreviewFeature$Feature not found
The cause is fairly simple - the APIs associated with preview features
(like new methods in j.l.String) are annotated with a JDK-internal
annotation, which allows javac to detect them a provide an error/warning
as appropriate. The issues is that the internal annotation is not inside
the ct.sym, and loading an element annotated with it leads to resolution
of the annotation, and to the warning above.
Unfortunately, this is not very trivial to fix, as javac needs the
annotation to detect the API elements associated with preview features
(and so the annotation needs to be in ct.sym). And, when compiling
without --release, not resolving an annotation that is part of the
classfile would provide inconsistent results.
So, the proposal is to use a different, synthetic, "annotation" (or
rather name) inside ct.sym, and use that name only for detection of APIs
associated with preview features and not resolve that annotation.
Proposed webrev:
http://cr.openjdk.java.net/~jlahoda/8246704/webrev.00/
JBS:
https://bugs.openjdk.java.net/browse/JDK-8246704
Any comments on this?
Thanks,
Jan
More information about the compiler-dev
mailing list