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

Compiler treats 'sealed' keyword as 'var' keyword

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 16, 17
    • tools
    • None
    • b08

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

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

              Created:
              Updated:
              Resolved: