You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tim Ellison <t....@gmail.com> on 2006/06/06 19:04:26 UTC

[classlib] Enum ready to go

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.

I wrote a bunch of tests but if you could hammer on it and try to break
it that would be good :-)


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

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Andrew Zhang <zh...@gmail.com>.
Hi, Mikhail,

Of course I DID...


On 6/7/06, Mikhail Loenko <ml...@gmail.com> wrote:
>
> Hi Andrew
>
> Did you update your workspace?
>
> Thanks,
> Mikhail
>
> 2006/6/7, Andrew Zhang <zh...@gmail.com>:
> > 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: harmony-dev-unsubscribe@incubator.apache.org
> > > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >
> > >
> >
> >
> > --
> > Andrew Zhang
> > China Software Development Lab, IBM
> >
> >
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrew Zhang
China Software Development Lab, IBM

Re: [classlib] Enum ready to go

Posted by Mikhail Loenko <ml...@gmail.com>.
Hi Andrew

Did you update your workspace?

Thanks,
Mikhail

2006/6/7, Andrew Zhang <zh...@gmail.com>:
> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Andrew Zhang
> China Software Development Lab, IBM
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by "Jimmy, Jing Lv" <fi...@gmail.com>.
Mikhail Loenko wrote:
> javac and java are from the same distrib (javac does not print
> detailed version info,
> that is why I''m mentioning java version),
> so it is javac 1.5.0_b64
> 
> so I compile with JDK 1.5.0_b64, run on Harmony and it fails
> 

Yes, and please note RI's strange version style, 1.5.0_b64 is earlier 
than 1.5.0_01, and the latest is 1.5.0_06. (As we see, 1.5.0_b64 surely 
means 1.5.0_00_b64, and it really puzzles me at the first glance :) )

> Thanks,
> Mikhail
> 
> 2006/6/7, Jimmy, Jing Lv <fi...@gmail.com>:
>> Mikhail Loenko wrote:
>> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>> >> The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
>> >> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target 1.4
>> >> set.
>> >>
>> >> I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
>> >> empty, but seems a bit of a drag to work around the compilers.
>> >>
>> >> (which version of BEA javac?)
>> >
>> > javac -version prints just "1.5.0"
>> > java -version prints "build 1.5.0-b64"
>> >
>>
>> I would bet the tests shall pass if using javac of java-version "build
>> 1.5.0_01" or later :)
>> And as the tests also fail on RI of "build 1.5.0-b64" (I've just find
>> one:) ), I guess it is a bug of RI, which was fixed in the later version.
>>
>> What's more, shall we also suggest that everyone use a latest version of
>> javac to avoid such problem?
>>
>>
>> >
>> >>
>> >> Regards,
>> >> Tim
>> >>
>> >> Mikhail Loenko wrote:
>> >> > Are you compiling with "jsr14" as our build does?
>> >> >
>> >> > I'm using BEA javac with "jsr14" it compiles to something like this:
>> >> > for(i=0; i < values.length; i++ )
>> >> >   if( values[i].name().equals(argument) )
>> >> >      return values[i].name().equals(argument)
>> >> > throw IAE
>> >> >
>> >> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>> >> >> 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?
>> >> >
>> >> > We now have 3 tests failing
>> >> >
>> >> > Thanks,
>> >> > Mikhail
>> >> >
>> >> >
>> >> >
>> >> >>
>> >> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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:
>> >> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> >> For additional commands, e-mail:
>> >> harmony-dev-help@incubator.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >>
>> >> >> Tim Ellison (t.p.ellison@gmail.com)
>> >> >> IBM Java technology centre, UK.
>> >> >>
>> >> >> 
>> ---------------------------------------------------------------------
>> >> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> >> To unsubscribe, e-mail: 
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> For additional commands, e-mail: 
>> harmony-dev-help@incubator.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> > 
>> ---------------------------------------------------------------------
>> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> >> > For additional commands, e-mail: 
>> harmony-dev-help@incubator.apache.org
>> >> >
>> >> >
>> >>
>> >> --
>> >>
>> >> Tim Ellison (t.p.ellison@gmail.com)
>> >> IBM Java technology centre, UK.
>> >>
>> >> ---------------------------------------------------------------------
>> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>>
>> -- 
>>
>> Best Regards!
>>
>> Jimmy, Jing Lv
>> China Software Development Lab, IBM
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> 
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Tim Ellison <t....@gmail.com>.
Thanks Mikhail.  I updated the test in r412663.

Regards,
Tim

Mikhail Loenko wrote:
> now two out of three yesterday's tests pass, one still fails:
> tests.api.java.net.AuthenticatorTest
> 
> Thanks,
> Mikhail
> 
> 2006/6/7, Tim Ellison <t....@gmail.com>:
>> So the ECJ folk are going to modify their compiler to dispatch to
>> Enum#valueOf(Class, String) too [1] -- which means we get to decide the
>> exception thrown by a null name.
>>
>> The old Sun-based compilers (like the BEA one referenced below) and
>> current ECJ will throw an IAE for empty enums and NPE for non-empty
>> enums, and I don't see that we can influence that code.
>>
>> If we want the same tests to pass on both old and new compilers we'll
>> have to allow either exception.
>>
>> [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=145746
>>
>> Regards,
>> Tim
>>
>> Mikhail Loenko wrote:
>> > javac and java are from the same distrib (javac does not print
>> > detailed version info,
>> > that is why I''m mentioning java version),
>> > so it is javac 1.5.0_b64
>> >
>> > so I compile with JDK 1.5.0_b64, run on Harmony and it fails
>> >
>> > Thanks,
>> > Mikhail
>> >
>> > 2006/6/7, Jimmy, Jing Lv <fi...@gmail.com>:
>> >> Mikhail Loenko wrote:
>> >> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>> >> >> The Sun 1.5.0_06 compiler was driven directly by our build
>> scripts (so
>> >> >> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5
>> target 1.4
>> >> >> set.
>> >> >>
>> >> >> I could throw an IAE from Enum#valueOf(Class, null) when the
>> Enum is
>> >> >> empty, but seems a bit of a drag to work around the compilers.
>> >> >>
>> >> >> (which version of BEA javac?)
>> >> >
>> >> > javac -version prints just "1.5.0"
>> >> > java -version prints "build 1.5.0-b64"
>> >> >
>> >>
>> >> I would bet the tests shall pass if using javac of java-version "build
>> >> 1.5.0_01" or later :)
>> >> And as the tests also fail on RI of "build 1.5.0-b64" (I've just find
>> >> one:) ), I guess it is a bug of RI, which was fixed in the later
>> version.
>> >>
>> >> What's more, shall we also suggest that everyone use a latest
>> version of
>> >> javac to avoid such problem?
>> >>
>> >>
>> >> >
>> >> >>
>> >> >> Regards,
>> >> >> Tim
>> >> >>
>> >> >> Mikhail Loenko wrote:
>> >> >> > Are you compiling with "jsr14" as our build does?
>> >> >> >
>> >> >> > I'm using BEA javac with "jsr14" it compiles to something like
>> this:
>> >> >> > for(i=0; i < values.length; i++ )
>> >> >> >   if( values[i].name().equals(argument) )
>> >> >> >      return values[i].name().equals(argument)
>> >> >> > throw IAE
>> >> >> >
>> >> >> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>> >> >> >> 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?
>> >> >> >
>> >> >> > We now have 3 tests failing
>> >> >> >
>> >> >> > Thanks,
>> >> >> > Mikhail
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >>
>> >> >> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com >
>> 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:
>> >> >> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> >> >> For additional commands, e-mail:
>> >> >> harmony-dev-help@incubator.apache.org
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >> --
>> >> >> >>
>> >> >> >> Tim Ellison (t.p.ellison@gmail.com)
>> >> >> >> IBM Java technology centre, UK.
>> >> >> >>
>> >> >> >>
>> >> ---------------------------------------------------------------------
>> >> >> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> >> >> To unsubscribe, e-mail:
>> >> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> >> For additional commands, e-mail:
>> >> harmony-dev-help@incubator.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> ---------------------------------------------------------------------
>> >> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> >> > To unsubscribe, e-mail:
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> > For additional commands, e-mail:
>> >> harmony-dev-help@incubator.apache.org
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >>
>> >> >> Tim Ellison (t.p.ellison@gmail.com)
>> >> >> IBM Java technology centre, UK.
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> >> To unsubscribe, e-mail:
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> For additional commands, e-mail:
>> harmony-dev-help@incubator.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> >> > For additional commands, e-mail:
>> harmony-dev-help@incubator.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >>
>> >> Best Regards!
>> >>
>> >> Jimmy, Jing Lv
>> >> China Software Development Lab, IBM
>> >>
>> >> ---------------------------------------------------------------------
>> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>> -- 
>>
>> Tim Ellison (t.p.ellison@gmail.com)
>> IBM Java technology centre, UK.
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Mikhail Loenko <ml...@gmail.com>.
now two out of three yesterday's tests pass, one still fails:
tests.api.java.net.AuthenticatorTest

Thanks,
Mikhail

2006/6/7, Tim Ellison <t....@gmail.com>:
> So the ECJ folk are going to modify their compiler to dispatch to
> Enum#valueOf(Class, String) too [1] -- which means we get to decide the
> exception thrown by a null name.
>
> The old Sun-based compilers (like the BEA one referenced below) and
> current ECJ will throw an IAE for empty enums and NPE for non-empty
> enums, and I don't see that we can influence that code.
>
> If we want the same tests to pass on both old and new compilers we'll
> have to allow either exception.
>
> [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=145746
>
> Regards,
> Tim
>
> Mikhail Loenko wrote:
> > javac and java are from the same distrib (javac does not print
> > detailed version info,
> > that is why I''m mentioning java version),
> > so it is javac 1.5.0_b64
> >
> > so I compile with JDK 1.5.0_b64, run on Harmony and it fails
> >
> > Thanks,
> > Mikhail
> >
> > 2006/6/7, Jimmy, Jing Lv <fi...@gmail.com>:
> >> Mikhail Loenko wrote:
> >> > 2006/6/7, Tim Ellison <t....@gmail.com>:
> >> >> The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
> >> >> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target 1.4
> >> >> set.
> >> >>
> >> >> I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
> >> >> empty, but seems a bit of a drag to work around the compilers.
> >> >>
> >> >> (which version of BEA javac?)
> >> >
> >> > javac -version prints just "1.5.0"
> >> > java -version prints "build 1.5.0-b64"
> >> >
> >>
> >> I would bet the tests shall pass if using javac of java-version "build
> >> 1.5.0_01" or later :)
> >> And as the tests also fail on RI of "build 1.5.0-b64" (I've just find
> >> one:) ), I guess it is a bug of RI, which was fixed in the later version.
> >>
> >> What's more, shall we also suggest that everyone use a latest version of
> >> javac to avoid such problem?
> >>
> >>
> >> >
> >> >>
> >> >> Regards,
> >> >> Tim
> >> >>
> >> >> Mikhail Loenko wrote:
> >> >> > Are you compiling with "jsr14" as our build does?
> >> >> >
> >> >> > I'm using BEA javac with "jsr14" it compiles to something like this:
> >> >> > for(i=0; i < values.length; i++ )
> >> >> >   if( values[i].name().equals(argument) )
> >> >> >      return values[i].name().equals(argument)
> >> >> > throw IAE
> >> >> >
> >> >> > 2006/6/7, Tim Ellison <t....@gmail.com>:
> >> >> >> 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?
> >> >> >
> >> >> > We now have 3 tests failing
> >> >> >
> >> >> > Thanks,
> >> >> > Mikhail
> >> >> >
> >> >> >
> >> >> >
> >> >> >>
> >> >> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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:
> >> >> harmony-dev-unsubscribe@incubator.apache.org
> >> >> >> >> For additional commands, e-mail:
> >> >> harmony-dev-help@incubator.apache.org
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >> --
> >> >> >>
> >> >> >> Tim Ellison (t.p.ellison@gmail.com)
> >> >> >> IBM Java technology centre, UK.
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> >> To unsubscribe, e-mail:
> >> harmony-dev-unsubscribe@incubator.apache.org
> >> >> >> For additional commands, e-mail:
> >> harmony-dev-help@incubator.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> >> > For additional commands, e-mail:
> >> harmony-dev-help@incubator.apache.org
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >>
> >> >> Tim Ellison (t.p.ellison@gmail.com)
> >> >> IBM Java technology centre, UK.
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >>
> >> Best Regards!
> >>
> >> Jimmy, Jing Lv
> >> China Software Development Lab, IBM
> >>
> >> ---------------------------------------------------------------------
> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Tim Ellison <t....@gmail.com>.
So the ECJ folk are going to modify their compiler to dispatch to
Enum#valueOf(Class, String) too [1] -- which means we get to decide the
exception thrown by a null name.

The old Sun-based compilers (like the BEA one referenced below) and
current ECJ will throw an IAE for empty enums and NPE for non-empty
enums, and I don't see that we can influence that code.

If we want the same tests to pass on both old and new compilers we'll
have to allow either exception.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=145746

Regards,
Tim

Mikhail Loenko wrote:
> javac and java are from the same distrib (javac does not print
> detailed version info,
> that is why I''m mentioning java version),
> so it is javac 1.5.0_b64
> 
> so I compile with JDK 1.5.0_b64, run on Harmony and it fails
> 
> Thanks,
> Mikhail
> 
> 2006/6/7, Jimmy, Jing Lv <fi...@gmail.com>:
>> Mikhail Loenko wrote:
>> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>> >> The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
>> >> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target 1.4
>> >> set.
>> >>
>> >> I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
>> >> empty, but seems a bit of a drag to work around the compilers.
>> >>
>> >> (which version of BEA javac?)
>> >
>> > javac -version prints just "1.5.0"
>> > java -version prints "build 1.5.0-b64"
>> >
>>
>> I would bet the tests shall pass if using javac of java-version "build
>> 1.5.0_01" or later :)
>> And as the tests also fail on RI of "build 1.5.0-b64" (I've just find
>> one:) ), I guess it is a bug of RI, which was fixed in the later version.
>>
>> What's more, shall we also suggest that everyone use a latest version of
>> javac to avoid such problem?
>>
>>
>> >
>> >>
>> >> Regards,
>> >> Tim
>> >>
>> >> Mikhail Loenko wrote:
>> >> > Are you compiling with "jsr14" as our build does?
>> >> >
>> >> > I'm using BEA javac with "jsr14" it compiles to something like this:
>> >> > for(i=0; i < values.length; i++ )
>> >> >   if( values[i].name().equals(argument) )
>> >> >      return values[i].name().equals(argument)
>> >> > throw IAE
>> >> >
>> >> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>> >> >> 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?
>> >> >
>> >> > We now have 3 tests failing
>> >> >
>> >> > Thanks,
>> >> > Mikhail
>> >> >
>> >> >
>> >> >
>> >> >>
>> >> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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:
>> >> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> >> For additional commands, e-mail:
>> >> harmony-dev-help@incubator.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >>
>> >> >> Tim Ellison (t.p.ellison@gmail.com)
>> >> >> IBM Java technology centre, UK.
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> >> To unsubscribe, e-mail:
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> For additional commands, e-mail:
>> harmony-dev-help@incubator.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> >> > For additional commands, e-mail:
>> harmony-dev-help@incubator.apache.org
>> >> >
>> >> >
>> >>
>> >> --
>> >>
>> >> Tim Ellison (t.p.ellison@gmail.com)
>> >> IBM Java technology centre, UK.
>> >>
>> >> ---------------------------------------------------------------------
>> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>>
>> -- 
>>
>> Best Regards!
>>
>> Jimmy, Jing Lv
>> China Software Development Lab, IBM
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Mikhail Loenko <ml...@gmail.com>.
javac and java are from the same distrib (javac does not print
detailed version info,
that is why I''m mentioning java version),
so it is javac 1.5.0_b64

so I compile with JDK 1.5.0_b64, run on Harmony and it fails

Thanks,
Mikhail

2006/6/7, Jimmy, Jing Lv <fi...@gmail.com>:
> Mikhail Loenko wrote:
> > 2006/6/7, Tim Ellison <t....@gmail.com>:
> >> The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
> >> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target 1.4
> >> set.
> >>
> >> I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
> >> empty, but seems a bit of a drag to work around the compilers.
> >>
> >> (which version of BEA javac?)
> >
> > javac -version prints just "1.5.0"
> > java -version prints "build 1.5.0-b64"
> >
>
> I would bet the tests shall pass if using javac of java-version "build
> 1.5.0_01" or later :)
> And as the tests also fail on RI of "build 1.5.0-b64" (I've just find
> one:) ), I guess it is a bug of RI, which was fixed in the later version.
>
> What's more, shall we also suggest that everyone use a latest version of
> javac to avoid such problem?
>
>
> >
> >>
> >> Regards,
> >> Tim
> >>
> >> Mikhail Loenko wrote:
> >> > Are you compiling with "jsr14" as our build does?
> >> >
> >> > I'm using BEA javac with "jsr14" it compiles to something like this:
> >> > for(i=0; i < values.length; i++ )
> >> >   if( values[i].name().equals(argument) )
> >> >      return values[i].name().equals(argument)
> >> > throw IAE
> >> >
> >> > 2006/6/7, Tim Ellison <t....@gmail.com>:
> >> >> 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?
> >> >
> >> > We now have 3 tests failing
> >> >
> >> > Thanks,
> >> > Mikhail
> >> >
> >> >
> >> >
> >> >>
> >> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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:
> >> harmony-dev-unsubscribe@incubator.apache.org
> >> >> >> For additional commands, e-mail:
> >> harmony-dev-help@incubator.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >>
> >> >> Tim Ellison (t.p.ellison@gmail.com)
> >> >> IBM Java technology centre, UK.
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >> >
> >> >
> >>
> >> --
> >>
> >> Tim Ellison (t.p.ellison@gmail.com)
> >> IBM Java technology centre, UK.
> >>
> >> ---------------------------------------------------------------------
> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
>
> Best Regards!
>
> Jimmy, Jing Lv
> China Software Development Lab, IBM
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Tim Ellison <t....@gmail.com>.
Jimmy, Jing Lv wrote:
> Mikhail Loenko wrote:
>> 2006/6/7, Tim Ellison <t....@gmail.com>:
>>> The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
>>> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target
>>> 1.4 set.
>>>
>>> I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
>>> empty, but seems a bit of a drag to work around the compilers.
>>>
>>> (which version of BEA javac?)
>>
>> javac -version prints just "1.5.0"
>> java -version prints "build 1.5.0-b64"
>>
> 
> I would bet the tests shall pass if using javac of java-version "build
> 1.5.0_01" or later :)
> And as the tests also fail on RI of "build 1.5.0-b64" (I've just find
> one:) ), I guess it is a bug of RI, which was fixed in the later version.
> 
> What's more, shall we also suggest that everyone use a latest version of
> javac to avoid such problem?

Let me ask the compiler folk what they think first [1], I think we can
work with both (modulo the empty enum case in ECJ) if we have to since
at least in one case it is delegated straight back to us.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=145732

Regards,
Tim

>>> Mikhail Loenko wrote:
>>> > Are you compiling with "jsr14" as our build does?
>>> >
>>> > I'm using BEA javac with "jsr14" it compiles to something like this:
>>> > for(i=0; i < values.length; i++ )
>>> >   if( values[i].name().equals(argument) )
>>> >      return values[i].name().equals(argument)
>>> > throw IAE
>>> >
>>> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>>> >> 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?
>>> >
>>> > We now have 3 tests failing
>>> >
>>> > Thanks,
>>> > Mikhail
>>> >
>>> >
>>> >
>>> >>
>>> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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:
>>> harmony-dev-unsubscribe@incubator.apache.org
>>> >> >> For additional commands, e-mail:
>>> harmony-dev-help@incubator.apache.org
>>> >> >>
>>> >> >>
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >>
>>> >> Tim Ellison (t.p.ellison@gmail.com)
>>> >> IBM Java technology centre, UK.
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>>> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>>> >> For additional commands, e-mail:
>>> harmony-dev-help@incubator.apache.org
>>> >>
>>> >>
>>> >
>>> > ---------------------------------------------------------------------
>>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>> >
>>> >
>>>
>>> -- 
>>>
>>> Tim Ellison (t.p.ellison@gmail.com)
>>> IBM Java technology centre, UK.
>>>
>>> ---------------------------------------------------------------------
>>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by "Jimmy, Jing Lv" <fi...@gmail.com>.
Mikhail Loenko wrote:
> 2006/6/7, Tim Ellison <t....@gmail.com>:
>> The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
>> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target 1.4 
>> set.
>>
>> I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
>> empty, but seems a bit of a drag to work around the compilers.
>>
>> (which version of BEA javac?)
> 
> javac -version prints just "1.5.0"
> java -version prints "build 1.5.0-b64"
> 

I would bet the tests shall pass if using javac of java-version "build 
1.5.0_01" or later :)
And as the tests also fail on RI of "build 1.5.0-b64" (I've just find 
one:) ), I guess it is a bug of RI, which was fixed in the later version.

What's more, shall we also suggest that everyone use a latest version of 
javac to avoid such problem?


> 
>>
>> Regards,
>> Tim
>>
>> Mikhail Loenko wrote:
>> > Are you compiling with "jsr14" as our build does?
>> >
>> > I'm using BEA javac with "jsr14" it compiles to something like this:
>> > for(i=0; i < values.length; i++ )
>> >   if( values[i].name().equals(argument) )
>> >      return values[i].name().equals(argument)
>> > throw IAE
>> >
>> > 2006/6/7, Tim Ellison <t....@gmail.com>:
>> >> 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?
>> >
>> > We now have 3 tests failing
>> >
>> > Thanks,
>> > Mikhail
>> >
>> >
>> >
>> >>
>> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: 
>> harmony-dev-unsubscribe@incubator.apache.org
>> >> >> For additional commands, e-mail: 
>> harmony-dev-help@incubator.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >>
>> >> Tim Ellison (t.p.ellison@gmail.com)
>> >> IBM Java technology centre, UK.
>> >>
>> >> ---------------------------------------------------------------------
>> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > Terms of use : http://incubator.apache.org/harmony/mailing.html
>> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >
>> >
>>
>> -- 
>>
>> Tim Ellison (t.p.ellison@gmail.com)
>> IBM Java technology centre, UK.
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> 
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Mikhail Loenko <ml...@gmail.com>.
2006/6/7, Tim Ellison <t....@gmail.com>:
> The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
> using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target 1.4 set.
>
> I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
> empty, but seems a bit of a drag to work around the compilers.
>
> (which version of BEA javac?)

javac -version prints just "1.5.0"
java -version prints "build 1.5.0-b64"


>
> Regards,
> Tim
>
> Mikhail Loenko wrote:
> > Are you compiling with "jsr14" as our build does?
> >
> > I'm using BEA javac with "jsr14" it compiles to something like this:
> > for(i=0; i < values.length; i++ )
> >   if( values[i].name().equals(argument) )
> >      return values[i].name().equals(argument)
> > throw IAE
> >
> > 2006/6/7, Tim Ellison <t....@gmail.com>:
> >> 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?
> >
> > We now have 3 tests failing
> >
> > Thanks,
> > Mikhail
> >
> >
> >
> >>
> >> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: harmony-dev-unsubscribe@incubator.apache.org
> >> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >>
> >> Tim Ellison (t.p.ellison@gmail.com)
> >> IBM Java technology centre, UK.
> >>
> >> ---------------------------------------------------------------------
> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Tim Ellison <t....@gmail.com>.
The Sun 1.5.0_06 compiler was driven directly by our build scripts (so
using jsr14) and the Eclipse 3.2RC4 compiler has source 1.5 target 1.4 set.

I could throw an IAE from Enum#valueOf(Class, null) when the Enum is
empty, but seems a bit of a drag to work around the compilers.

(which version of BEA javac?)

Regards,
Tim

Mikhail Loenko wrote:
> Are you compiling with "jsr14" as our build does?
> 
> I'm using BEA javac with "jsr14" it compiles to something like this:
> for(i=0; i < values.length; i++ )
>   if( values[i].name().equals(argument) )
>      return values[i].name().equals(argument)
> throw IAE
> 
> 2006/6/7, Tim Ellison <t....@gmail.com>:
>> 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?
> 
> We now have 3 tests failing
> 
> Thanks,
> Mikhail
> 
> 
> 
>>
>> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: harmony-dev-unsubscribe@incubator.apache.org
>> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>> >>
>> >>
>> >
>> >
>>
>> -- 
>>
>> Tim Ellison (t.p.ellison@gmail.com)
>> IBM Java technology centre, UK.
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Mikhail Loenko <ml...@gmail.com>.
Are you compiling with "jsr14" as our build does?

I'm using BEA javac with "jsr14" it compiles to something like this:
for(i=0; i < values.length; i++ )
   if( values[i].name().equals(argument) )
      return values[i].name().equals(argument)
throw IAE

2006/6/7, Tim Ellison <t....@gmail.com>:
> 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?

We now have 3 tests failing

Thanks,
Mikhail



>
> 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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: harmony-dev-unsubscribe@incubator.apache.org
> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >>
> >>
> >
> >
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Tim Ellison <t....@gmail.com>.
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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Andrew Zhang <zh...@gmail.com>.
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 <st...@gmail.com> 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 <stepan.mishura@gmail.com > 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: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrew Zhang
China Software Development Lab, IBM

Re: [classlib] Enum ready to go

Posted by "Jimmy, Jing Lv" <fi...@gmail.com>.
Stepan Mishura 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.
> 

Hi:
     It works well on my workspace, with windows XP sp2, RI (1.5.0_06, 
the latest version). By the way, it also passes all test on RI 1.5.0_01, 
and on Linux(kernel 2.4.2, RI 1.5.0_02).
     Look into code, I doubt perhaps it is compiler who cause the 
problem. I would try an early version of RI 1.5.0, but currently I can 
not find one.

> 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 <st...@gmail.com> 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: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Stepan Mishura <st...@gmail.com>.
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 <st...@gmail.com> 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: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Re: [classlib] Enum ready to go

Posted by Stepan Mishura <st...@gmail.com>.
Hi Andrew,


On 6/7/06, Andrew Zhang wrote:
>
> Hello Stepan and Mikhail,
>
> All tests passed on my machine.


OK ... will look into the tests

Which test case was failed in your environment, on RI or Harmony?


Testcase: test_valueOfLjava_lang_String
I've run test against Harmony on Linux.

Thanks,
Stepan.

Thanks!
>
>
> On 6/7/06, Stepan Mishura <st...@gmail.com> 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
> > >
> > > --
> > >
> > > Tim Ellison (t.p.ellison@gmail.com)
> > > IBM Java technology centre, UK.
> > >
> > > ---------------------------------------------------------------------
> > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >
> > >
> >
> >
> > --
> > Thanks,
> > Stepan Mishura
> > Intel Middleware Products Division
> >
> > ------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Andrew Zhang
> China Software Development Lab, IBM
>
>


-- 
Thanks,
Stepan Mishura
Intel Middleware Products Division

------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Re: [classlib] Enum ready to go

Posted by Andrew Zhang <zh...@gmail.com>.
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 <st...@gmail.com> 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
> >
> > --
> >
> > Tim Ellison (t.p.ellison@gmail.com)
> > IBM Java technology centre, UK.
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Thanks,
> Stepan Mishura
> Intel Middleware Products Division
>
> ------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrew Zhang
China Software Development Lab, IBM

Re: [classlib] Enum ready to go

Posted by Stepan Mishura <st...@gmail.com>.
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
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Thanks,
Stepan Mishura
Intel Middleware Products Division

------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Re: [classlib] Enum ready to go

Posted by Stepan Mishura <st...@gmail.com>.
Yes, both tests fail for me. Also
tests.api.java.net.AuthenticatorTestfailed too.

Thanks,
Stepan.


On 6/7/06, Mikhail Loenko wrote:
>
> I see two failing tests. Does anybody see them too?
>    org.apache.harmony.tests.java.lang.EnumTest
>    tests.api.java.net.ProxyTest
>
> Thanks,
> Mikhail
>
>
> 2006/6/7, Geir Magnusson Jr <ge...@pobox.com>:
> > cool!  (I didn't remember you were working on it... excellent)
> >
> > 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.
> > >
> > > I wrote a bunch of tests but if you could hammer on it and try to
> break
> > > it that would be good :-)
> > >
> > >
> > > 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: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Thanks,
Stepan Mishura
Intel Middleware Products Division

------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Re: [classlib] Enum ready to go

Posted by Mikhail Loenko <ml...@gmail.com>.
I see two failing tests. Does anybody see them too?
    org.apache.harmony.tests.java.lang.EnumTest
    tests.api.java.net.ProxyTest

Thanks,
Mikhail


2006/6/7, Geir Magnusson Jr <ge...@pobox.com>:
> cool!  (I didn't remember you were working on it... excellent)
>
> 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.
> >
> > I wrote a bunch of tests but if you could hammer on it and try to break
> > it that would be good :-)
> >
> >
> > 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: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Geir Magnusson Jr <ge...@pobox.com>.
cool!  (I didn't remember you were working on it... excellent)

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.
> 
> I wrote a bunch of tests but if you could hammer on it and try to break
> it that would be good :-)
> 
> 
> 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: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Enum ready to go

Posted by Andrew Zhang <zh...@gmail.com>.
Exciting news! :)

And I also found some mocked enum classes (e.g. java.net.Proxy.Type
java.net.Authenticator.Request) had already been updated as real enum style!
:)

But things don't end. We should be aware of serialization issue of enum type
class, that means  readObject method may be overridden.

Following test case,which is  passeed on RI but failed on Harmony,
shows serialization problem.
    public void test_Type_serialize() throws IOException,
ClassNotFoundException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(bout);

        Proxy.Type type = Proxy.Type.DIRECT;
        out.writeObject(type);
        out.flush();

        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray
());
        ObjectInputStream in = new ObjectInputStream(bin);

        Proxy.Type deType = (Proxy.Type) in.readObject();
        assertSame(Proxy.Type.DIRECT, deType);
    }
Many enum type class serialization JIRAs are expected in the following days.
:)
On 6/7/06, Tim Ellison <t....@gmail.com> 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.
>
> I wrote a bunch of tests but if you could hammer on it and try to break
> it that would be good :-)
>
>
> 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
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrew Zhang
China Software Development Lab, IBM