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

Compiler treats 'sealed' keyword as 'var' keyword

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 16, 17
    • Fix Version/s: 17
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b08

      Description

      Code sample:

      public class Main {
        public static void main(String[] args) {
          sealed s = "s";
          System.out.println(s);
        }
      }

      Compile with --enable-preview, or just run `java` on this file. E.g:
      "C:\Program Files\Java\jdk-16\bin\java.exe" --enable-preview --source=16 Main.java

      Expected:
      Compilation error at line #3

      Actual:
      Successfully compiled and launched, as if `sealed` were `var`.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                tvaleev Tagir Valeev
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: