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

(enum) Unclear purpose of EnumConstantNotPresentException

    Details

    • Subcomponent:
    • Resolved In Build:
      b71
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      A DESCRIPTION OF THE PROBLEM :
      The JavaDoc for java.lang.EnumConstantNotPresentException states:

      "Thrown when an application tries to access an enum constant by name and the enum type contains no constant with the specified name"

      A reasonable conclusion drawn from this sentence is that this exception will be thrown by java.lang.Enum.valueOf in case an invalid enum name is supplied.

      This conclusion is wrong, since EnumConstantNotPresentException is used solely to indicate absent enum values for value-returning methods of Java Annotation classes.
      (Which raises another question: Why is this exception declared in package java.lang?)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "Thrown when an application tries to access an enum constant through an Annotation and the enum constant used by the annotated element is no longer present in the application."
      ACTUAL -
      "Thrown when an application tries to access an enum constant by name and the enum type contains no constant with the specified name"

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.5.0/docs/api/java/lang/EnumConstantNotPresentException.html

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: