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

Broken enum produce inconvenient errors and AST

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b10

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: