|
Quick Lists
|
|
Bug ID:
|
6378701
|
|
Votes
|
0
|
|
Synopsis
|
(enum) Unclear purpose of EnumConstantNotPresentException
|
|
Category
|
java:classes_lang
|
|
Reported Against
|
|
|
Release Fixed
|
7(b71)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
6327048
,
6548433
|
|
Submit Date
|
30-JAN-2006
|
|
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
Posted Date : 2006-01-30 18:45:22.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
This exception is discussed in java.lang.reflect.AnnotatedElement. It may be reasonble to add @throws tags for this and related exceptions to the getAnnotation methods or to just add an @see link in EnumConstantNotPresentException to AnnotatedElement.
Posted Date : 2006-03-02 05:32:40.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |