RFR: 8343540: Report preview error for inherited effectively-preview methods
Alex Buckley
alex.buckley at oracle.com
Thu Nov 7 16:29:16 UTC 2024
On 11/7/2024 7:44 AM, Jan Lahoda wrote:
> The proposal herein is that invoking a method on a receiver that is
> not of preview type itself, but the method is declared in a preview
> class or interface, the method will be considered to be a preview
> method, and the appropriate error or warning will be printed.
> Similar behavior is implementing for dereferencing fields.
> The proposal herein is to produce an error or warning for method
> declared inside a non-preview class or interface, which is
> overridden by a method declared inside a preview class or interface.
Thank you Jan, these are important improvements to javac's handling of
preview APIs.
For the second proposal above, I think you mean "... which ~is
overridden by~ +overrides+ a method declared inside a preview class or
interface."
javac will give a warning/error where the non-preview class Test1
declares the test method, because Test1 overrides the test method
declared in the preview interface NewAPI.
I would add that the JDK class ExistingRetrofittedClass, which
implements NewAPI, can override the test method without a warning/error.
This is because ExistingRetrofittedClass is "participating" in the
preview API.
Suppose ExistingRetrofittedClass does indeed override the test method. I
would expect both of the examples in your original mail to give a
warning/error. Both the invocation of `c.test()`, and the overriding of
test in Test1, refer to an "effectively" preview method.
Alex
More information about the compiler-dev
mailing list