PreviewFeature on packages and modules
Alex Buckley
alex.buckley at oracle.com
Mon Feb 8 18:13:42 UTC 2021
On 2/8/2021 8:00 AM, Nikita Eshkeev wrote:
> Additional questions:
> 1. If a module is annotated with PreviewFeature then javac raises a
> compile-time errors/warnings when it's used in a requires statement of
> another module. Is this true?
It should be.
> 2. If a module is not annotated with PreviewFeature then each export
> statement of a package that is annotated with PreviewFeaturein in
> module-info.java should lead to compile-time errors/warnings. Is this true?
Package annotations are a no-op. Don't expect any warnings/errors from
javac if your module `exports` a package annotated @PreviewFeature.
> 3. If a module is not annotated with PreviewFeature then each provides
> statement of a class that is annotated with PreviewFeature in
> module-info.java should lead to compile-time errors/warnings. Is this true?
Yes, that counts as a source code reference to a preview API element.
> 4. If a class inherits/implements a class/interface that is marked as
> PreviewFeature then the class is considered a PreviewFeature. Is this true?
No, that's an over-reading of JEP 12. Assuming that the
inheriting/implementing class C is not "participating" for the preview
class P, C's `extends`/`implements` clause will generate a warning/error
and C.class will be marked as depending on preview features, just as if
C had declared a field of type P or C's code had used a preview language
feature. The javadoc for C will display that C's
superclass/superinterface is a preview API.
Alex
More information about the compiler-dev
mailing list