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

Broken enum produce inconvenient errors and AST

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 14
    • 14
    • tools
    • None
    • b10

      Consider this input code:
      ---
      public enum BrokenEnum {
          A,
          void t() {}
          B;
      }
      ---

      When compiled, this leads to these errors:
      ---
      $ javac BrokenEnum.java
      BrokenEnum.java:2: error: <identifier> expected
          A,
            ^
      BrokenEnum.java:3: error: ',', '}', or ';' expected
          void t() {}
          ^
      BrokenEnum.java:3: error: '}' expected
          void t() {}
              ^
      BrokenEnum.java:5: error: class, interface, or enum expected
      }
      ^
      4 errors
      ---

      And the AST is:
      ---
      public enum BrokenEnum {
          /*public static final*/ A /* = new BrokenEnum() */ /*enum*/ ,
          /*public static final*/ <error> /* = new BrokenEnum() */ /*enum*/ ;
          (ERROR)
      }(ERROR)
      ---

      Both of these are fairly inconvenient.

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

              Created:
              Updated:
              Resolved: