Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8343540

Report preview error for inherited effectively-preview methods

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 24
    • tools
    • None
    • b27

      Consider a class or interface, marked as preview. And let this class or interface have a a method, not itself marked as preview. This method is "effectively-preview". And a class inside the JDK, which extends the class or implements the interface, but is itself not a preview (i.e. it is participating in preview, not being preview itself). In particular:
      ```
      package jdk.test;
      @PreviewFeature
      public interface PreviewInterface {
           public default void test() {}
      }
      ```

      ````
      package jdk.test;
      public final class NotPreview implements PreviewInterface {}
      ```

      javac will produce no error or warning in the following two cases, involving the effectively-preview "test" method:
      - when invoking the method on `NotPreview`:
      ```
      NotPreview np = ...;
      np.test();
      ```
      - when extending `NotPreview` and overriding the method:
      ```
      public class C extends NotPreview {
           public void test() {}
      }
      ```

      javac should produce preview errors/warnings for these cases.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: