Maybe compiler specific. Looking at Proxy.Type it appears that the Sun compiler 1.5.0_06 delegates to the Enum type:
public static Type valueOf(String name) { return (Type)Enum.valueOf( Proxy.class$java$net$Proxy$Type != null ? Proxy.class$java$net$Proxy$Type : ( Proxy.class$java$net$Proxy$Type = Proxy._mthclass$("java.net.Proxy$Type") ), name); } and the Eclipse compiler 3.2RC4 looks up the constant itself: 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); } In the Sun compiler a null name argument gets passed to Enum#valueOf(Class, String) where I check and throw NPE. In the Eclipse compiler the line if(s.equals(...)... will cause a NPE iff there are entries in the VALUES array (otherwise it doesn't go into the for-loop) and throws an IAE without going into my code. Maybe I can withdraw the null name test while we settle this? Regards, Tim Andrew Zhang wrote: > Hi, Stepan, > > The test you metioned is passed in my environment: > RI version: 1.5.0_02. > Linux: Read hat Enterprise Linux AS(2.4.21-15.EL) > > Is the problem caused by earlier version javac? > > I remember that RI of earlier verion throws IAE instead of NPE when the > arguement is null. > > Would you please check "java" version? > > Thanks. > > > > > > On 6/7/06, Stepan Mishura <[EMAIL PROTECTED]> wrote: >> >> I found the reason - tests expect NPE when valueOf(null) is invoked but >> IAE >> is thrown instead. For example, >> >> java.lang.IllegalArgumentException >> at org.apache.harmony.tests.java.lang.EnumTest$Sample.valueOf( >> EnumTest.java >> :22) >> at >> org.apache.harmony.tests.java.lang.EnumTest.test_valueOfLjava_lang_String >> (EnumTest.java :113) >> at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:205) >> >> Thanks, >> Stepan. >> >> On 6/7/06, Andrew Zhang wrote: >> > >> > Hello Stepan and Mikhail, >> > >> > All tests passed on my machine. >> > >> > Which test case was failed in your environment, on RI or Harmony? >> > >> > Thanks! >> > >> > >> > On 6/7/06, Stepan Mishura <[EMAIL PROTECTED] > wrote: >> > > >> > > Hi Tim, >> > > >> > > On 6/7/06, Tim Ellison wrote: >> > > > >> > > > Heads up that I completed the implementation of j.l.Enum today; so >> you >> > > > can go mad and use enum types in classlib code for real now. >> > > >> > > >> > > Cool! >> > > >> > > I wrote a bunch of tests but if you could hammer on it and try to >> break >> > > > it that would be good :-) >> > > >> > > >> > > And did you run it? :-) It fails for me :-( >> > > >> > > Thanks, >> > > Stepan. >> > > >> > > If you take a look at the implementation [1] of valueOf(Class, >> String) >> > > > it uses reflection to get the enum constant values. I'm not sure >> how >> > > > 'popular' the valueOf() method is, but since the values don't >> change >> > > > they are a good candidate for being cached if it proves to be >> called >> > > > frequently. I'm happy to do that if people think it is worthwhile. >> > > > >> > > > Regards, >> > > > Tim >> > > > >> > > > >> > > > [1] >> > > > >> > > > >> > > >> > >> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Enum.java?revision=412166&view=markup >> >> > > > >> > >> > >> > >> >> >> ------------------------------------------------------ >> Terms of use : http://incubator.apache.org/harmony/mailing.html >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > -- Tim Ellison ([EMAIL PROTECTED]) IBM Java technology centre, UK. --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]