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

Make javac error on a generic enum friendlier

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 19
    • tools
    • None
    • b24

      Should an attempt to generify enum lead to a friendlier error?

      ```
      $ cat E.java
      public enum E<T> {}

      $ javac E.java
      E.java:1: error: '{' expected
      public enum E<T> {}
                   ^
      E.java:1: error: <identifier> expected
      public enum E<T> {}
                      ^
      E.java:1: error: reached end of file while parsing
      public enum E<T> {}
                         ^
      3 errors
      ```

      In comparison, here's how javac reports on an attempt to generify annotation:

      ```
      $ cat A.java
      public @interface A<T> {}

      $ javac A.java
      A.java:1: error: annotation interface A cannot be generic
      public @interface A<T> {}
                          ^
      1 error
      ```

            abimpoudis Angelos Bimpoudis
            prappo Pavel Rappo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: