Community
Participate
Working Groups
Build 3.2RC4 When compiling an enum type with the Eclipse compiler for Java, the code for valueOf(String) apparently looks like this: public static Type valueOf(String s) { Type atype[]; Type type1; for(int i = (atype = ENUM$VALUES).length; --i >= 0;) if(s.equals((type1 = atype[i]).name())) return type1; throw new IllegalArgumentException(s); } Assume the actual argument for 's' is null. If the ENUM$VALUES is not empty the message s.equals(...) causes a NullPointerException; however, if the array is empty then the code falls through to explicitly throwing an IllegalArgumentException. I would expect the behavior for a null argument to consistently throw a NPE for empty and non-empty enum types.
Agreed, a NPE should occur in both cases.
Also see bug 145746
Added EnumTest#test131(disabled) and test132.
Fixed along with change for bug 145746
Released for 3.2.1 Fix also released for 3.3M1
Verified for 3.3 M1 using build I20060807-2000.
Verified for 3.2.1 using build M20060908-1655