From harmony-dev-return-8380-apmail-incubator-harmony-dev-archive=incubator.apache.org@incubator.apache.org Thu Jun 08 03:59:35 2006 Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 16117 invoked from network); 8 Jun 2006 03:59:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Jun 2006 03:59:34 -0000 Received: (qmail 38264 invoked by uid 500); 8 Jun 2006 03:59:31 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 38216 invoked by uid 500); 8 Jun 2006 03:59:29 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 38205 invoked by uid 99); 8 Jun 2006 03:59:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2006 20:59:29 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=RCVD_IN_BL_SPAMCOP_NET,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of mloenko@gmail.com designates 66.249.92.169 as permitted sender) Received: from [66.249.92.169] (HELO ug-out-1314.google.com) (66.249.92.169) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2006 20:59:28 -0700 Received: by ug-out-1314.google.com with SMTP id y2so580382uge for ; Wed, 07 Jun 2006 20:59:07 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Jh8Ntjya08o21sOXWZEpnoJz8IT4mRm4xR8VqNaF5K/sbHUZY3MXT6A4YCdL7QhCNLuAXr9uLVFaSfdYgAPiua3HQ4jGkO8IylNpLE6MCjeG8thCVyN7JNQ7Jicge/2VrNlq0A8c92MKiEAjdnlBJmaHoY+jLHvevb1rWLO+Sa4= Received: by 10.67.25.9 with SMTP id c9mr1154888ugj; Wed, 07 Jun 2006 20:59:07 -0700 (PDT) Received: by 10.67.25.13 with HTTP; Wed, 7 Jun 2006 20:59:06 -0700 (PDT) Message-ID: <906dd82e0606072059s4d7c86d8hd2bc7b8d22235eee@mail.gmail.com> Date: Thu, 8 Jun 2006 10:59:06 +0700 From: "Mikhail Loenko" To: harmony-dev@incubator.apache.org Subject: Re: [classlib] Enum ready to go In-Reply-To: <4486ED62.10805@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4485B59A.1090901@gmail.com> <6e47b64f0606062250p2ac0a283t3665dd72e847219f@mail.gmail.com> <4d0b24970606070023x3ac81970q57e097504fc1fe9a@mail.gmail.com> <44869CFC.1030007@gmail.com> <906dd82e0606070245t2b657820o958ea72cf7c0556d@mail.gmail.com> <4486A50C.6080200@gmail.com> <906dd82e0606070312k747964d6sd7db47a5a952008@mail.gmail.com> <4486A89D.8030609@gmail.com> <906dd82e0606070339x72324d0cn58762443f8fa15@mail.gmail.com> <4486ED62.10805@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N now two out of three yesterday's tests pass, one still fails: tests.api.java.net.AuthenticatorTest Thanks, Mikhail 2006/6/7, Tim Ellison : > 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 : > >> Mikhail Loenko wrote: > >> > 2006/6/7, Tim Ellison : > >> >> 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 : > >> >> >> 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 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 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