Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 32902 invoked from network); 20 Sep 2006 07:34:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Sep 2006 07:34:06 -0000 Received: (qmail 22279 invoked by uid 500); 20 Sep 2006 07:34:00 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 21931 invoked by uid 500); 20 Sep 2006 07:33:59 -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 21920 invoked by uid 99); 20 Sep 2006 07:33:59 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Sep 2006 00:33:59 -0700 X-ASF-Spam-Status: No, hits=0.4 required=5.0 tests=DNS_FROM_RFC_ABUSE Received: from ([202.81.18.152:37596] helo=ausmtp04.au.ibm.com) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 8E/B0-01762-2EEE0154 for ; Wed, 20 Sep 2006 00:33:55 -0700 Received: from sd0112e0.au.ibm.com (d23rh903.au.ibm.com [202.81.18.201]) by ausmtp04.au.ibm.com (8.13.6/8.13.5) with ESMTP id k8K7g7sX015702 for ; Wed, 20 Sep 2006 17:42:09 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.250.244]) by sd0112e0.au.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id k8K7asO4074852 for ; Wed, 20 Sep 2006 17:36:58 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k8K7XQp3005433 for ; Wed, 20 Sep 2006 17:33:26 +1000 Received: from d23m0011.cn.ibm.com (d23m0011.cn.ibm.com [9.181.32.74]) by d23av03.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k8K7XPcb005410 for ; Wed, 20 Sep 2006 17:33:26 +1000 Received: from [127.0.0.1] ([9.181.106.74]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.5.5HF262) with ESMTP id 2006092015315452-4660 ; Wed, 20 Sep 2006 15:31:54 +0800 Message-ID: <4510EEB7.4050302@gmail.com> Date: Wed, 20 Sep 2006 15:33:11 +0800 From: Paulex Yang User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [classlib][luni] JIRA 1492 Constructor of HashMap throw unexpected exception References: <451096F0.4010207@gmail.com> <45109740.1010703@gmail.com> <4510DF78.4020208@gmail.com> In-Reply-To: X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 20/09/2006 15:31:54, Serialize by Router on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 20/09/2006 15:32:14 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Alexey Petrenko wrote: > But we can create such test case for every difference in used methods > between RI and Harmony. Right? Sure we can:), I guess the issue is just if it is necessary. I've=20 described why I think it is necessary for HashMap's constructor in=20 another post of this thread - HashMap is fundamental and widely used,=20 so it should be tolerant; constructor is special, so it should be taken=20 care of. > > 2006/9/20, Paulex Yang : >> Alexey Petrenko wrote: >> > Are you trying to say that the methods in Harmony can use only methods >> > used in corresponding RI implementations? >> Let Spark speak for himself, but IMHO let's discuss the specific case >> before considering it as a rule, this is not yet another "reverse >> engineering", the testcase is clear, without injection or reflection, >> and the method under test is a constructor which invokes a public >> method, so that user may have risk cannot to init their subclass of >> HashMap. >> > >> > 2006/9/20, Spark Shen : >> >> Spark Shen =E5=86=99=E9=81=93: >> >> > Hi : >> >> > Following is the discussion about JIRA 1492, shall we discuss it=20 >> here? >> >> > >> >> > public class SubMapTest extends TestCase { >> >> > public void testSubclass() { >> >> > HashMap map =3D new HashMap(); >> >> > map.put("a", "a"); >> >> > SubMap map2 =3D new SubMap(map); // Harmony will throw an unexpected >> >> > exception here. >> >> > } >> >> > } >> >> > >> >> > class SubMap extends HashMap { >> >> > >> >> > public V put(K key, V value) { >> >> > throw new RuntimeException(); >> >> > } >> >> > } >> >> > >> >> > >> >> > >Nathan Beyer >> >> > >Harmony's behavior may be different in this case, but I'm not=20 >> sure I >> >> > would consider this a valid issue. What's a real use case for this >> >> > type of sub-classing? >> >> > [ Show =C2=BB ] >> >> > Nathan Beyer >> >> > >> >> > [18/Sep/06 08:41 PM] Harmony's behavior may be different in this=20 >> case, >> >> > but I'm not sure I would consider this a valid issue. What's a real >> >> > use case for this type of sub-classing? >> >> > >> >> > >> >>=20 >> >Spark=20 >> >> >> >> >> > Shen >> >> > >What if change the RuntimeException to=20 >> UnsupportedOperationException? >> >> > [ Show =C2=BB ] >> >> > spark shen >> >> > >> >>=20 >> >> >> > [18/Sep/06 08:48 PM] What if change the RuntimeException to >> >> > UnsupportedOperationException? >> >> > >> >> > >Alexey Petrenko >> >> > >I'm not sure that this is a valid issue to. >> >> > >As far as I understood the issue is that Harmony calls put=20 >> method in >> >> > constructor while RI does not. Right? >> >> > >> >> > >If so I do not see any issue here. >> >> > >> >> I can not figure out what RI does. And please refer to JIRA 839, it >> >> reports similar use case. >> >> My point here is >> >> 1. we may not be able to predict how users will use our library. >> >> 2. Users could guess our implementation w/o difficulty, which >> >> contradicts the encapulation priciple. >> >> So I prefer to follow RI on this behavior. >> >> >> >> When changing to UnsupportedOperationException, the use case is more >> >> practical, since it is highly like that put operation is not=20 >> supported. >> >> But it seems not so practical that this sub-hashMap can not be >> >> instantiated. May be one more assertion can convince you that this is >> >> bug. >> >> >> >> public class SubMapTest extends TestCase { >> >> public void testSubclass() { >> >> HashMap map =3D new HashMap(); >> >> map.put("a", "a"); >> >> SubMap map2 =3D new SubMap(map); >> >> assertEquals(1, map2.size()); >> >> } >> >> } >> >> >> >> class SubMap extends HashMap { >> >> public SubMap(Map m) { >> >> super(m); >> >> } >> >> >> >> public V put(K key, V value) { >> >> throw new RuntimeException(); >> >> } >> >> } >> >> >> >> Best regards >> >> >> >> -- >> >> Spark Shen >> >> 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:=20 >> harmony-dev-help@incubator.apache.org >> >> >> >> >> > >> > >> >> >> --=20 >> Paulex Yang >> 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 >> >> > > --=20 Paulex Yang 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