Exception message for bad Enum.valueOf has spurious "class"

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 7
    • Affects Version/s: 6
    • Component/s: core-libs
    • None
    • b48
    • generic
    • generic

      If you have an enum such as this
          enum Test {FOO, BAR}
      and you call
          Enum.valueOf(Test.class, "BAZ")
      then you get this exception:
          java.lang.IllegalArgumentException: No enum const class Test.BAZ
      The word "class" is spurious and confusing. The code that throws the exception:
          throw new IllegalArgumentException("No enum const " + enumType +"." + name);
      should say enumType.getName() because Class.toString() includes the word "class" in its output.

      Also, abbreviating "constant" to "const" seems a bit gratuitous.

            Assignee:
            Joe Darcy
            Reporter:
            Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: