RFR: 8282823: javac should constrain more uses of preview APIs

Remi Forax forax at univ-mlv.fr
Thu Mar 10 22:20:45 UTC 2022


----- Original Message -----
> From: "Jan Lahoda" <jlahoda at openjdk.java.net>
> To: "compiler-dev" <compiler-dev at openjdk.java.net>
> Sent: Thursday, March 10, 2022 1:36:09 PM
> Subject: RFR: 8282823: javac should constrain more uses of preview APIs

Hi Jan,

> 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.

I don't think you can do that because it means that the view at compile time and the view at runtime now disagree.

>From the VM POW, a class is in preview mode or not, if a class contains a preview method, this class is marked as in preview mode,
so even if javac allows the compilation, it will not work at runtime.

Rémi


More information about the compiler-dev mailing list