RFR: 8282823: javac should constrain more uses of preview APIs
Jan Lahoda
jlahoda at openjdk.java.net
Mon Mar 14 20:19:17 UTC 2022
On Thu, 10 Mar 2022 12:28:27 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider a class or interface with a method marked as preview. Subclassing the class or implementing the interface by itself should not cause a preview error/warning (as that would be problematic for Loom), but overriding the method should produce a preview error/warning.
>
> This patch adds the error/warning in case a preview method is overridden.
After a more detailed discussion, I've updated the patch in [3b8ac12](https://github.com/openjdk/jdk/pull/7774/commits/3b8ac122710e685b541b981fed9cbacf7a6027a7) to only report the error/warnings for the immediate overriders of the preview method, not all transitive overriders as before. This is a bit tricky, so the check is done using `Types.membersClosure` - the first method that the current method overrides must be the preview method, or no warning is produced. Tests are also extended to cover these cases.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7774
More information about the compiler-dev
mailing list