Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 69790 invoked from network); 6 Jul 2006 13:53:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Jul 2006 13:53:55 -0000 Received: (qmail 81523 invoked by uid 500); 6 Jul 2006 13:53:52 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 81460 invoked by uid 500); 6 Jul 2006 13:53:51 -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 81440 invoked by uid 99); 6 Jul 2006 13:53:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 06:53:51 -0700 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 202.81.18.152 is neither permitted nor denied by domain of richard.liangyx@gmail.com) Received: from [202.81.18.152] (HELO ausmtp04.au.ibm.com) (202.81.18.152) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 06:53:47 -0700 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp04.au.ibm.com (8.13.6/8.13.5) with ESMTP id k66DwBA3180876 for ; Thu, 6 Jul 2006 23:58:11 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.250.237]) by sd0208e0.au.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k66DugOx105968 for ; Thu, 6 Jul 2006 23:56:48 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k66DrJ6B001754 for ; Thu, 6 Jul 2006 23:53:19 +1000 Received: from d23m0011.cn.ibm.com ([9.181.32.74]) by d23av04.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k66DrHxE000881 for ; Thu, 6 Jul 2006 23:53:19 +1000 Received: from [127.0.0.1] ([9.181.106.154]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.5.5HF262) with ESMTP id 2006070621522877-5466 ; Thu, 6 Jul 2006 21:52:28 +0800 Message-ID: <44AD1599.908@gmail.com> Date: Thu, 06 Jul 2006 21:52:25 +0800 From: Richard Liang User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [classlib] Exception throwing compatibility: java.util.Scanner References: <44AD076F.1040708@gmail.com> <44AD13A9.8050109@gmail.com> In-Reply-To: <44AD13A9.8050109@gmail.com> X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 06/07/2006 21:52:28, Serialize by Router on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 06/07/2006 21:53:19, Serialize complete at 06/07/2006 21:53:19 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Paulex Yang wrote: > Richard Liang wrote: >> Hello All, >> >> When I'm trying to implement Scanner.nextInt(int radix), I met a >> problem. >> >> As we all know, Character.MIN_RADIX equals 2 and Character.MAX_RADIX >> equals 36, so the parameter radix can not less than 2 or greater than >> 36, Otherwise that parameter is illegal. >> >> But on RI, when the parameter radix is illegal, there are different >> kinds of Exception thrown. >> >> * If the parameter is less than 0 or greater than 36, RI throws a >> StringIndexOutOfBoundsException. Obviously this exception depends >> an RI's implementation. >> * If the parameter equals 1, RI throws an InputMismatchException >> with an additional information "The radix 1 is less than the >> Character.MIN_RADIX". >> * If the parameter equals 0, RI throws a >> java.util.regex.PatternSyntaxException whose constructor has three >> parameters. And the parameters depends on RI's implementation, >> that makes me can not follow RI. > Is this exception thrown by RegEx class? Should we identify at first > if our regular expression has different behavior with RI on some > certain input parameter? Hello Paulex, Yes, this exception is thrown by regex, but it depends on RI's implementation. I don't know how to get the "input parameter", any comments? Richard >> >> And nothing is documented in the spec. Shall I follow RI's behavior? >> Thanks a lot. >> >> Here is the test case to demo this issue. >> >> public void test_nextIntI(){ >> Scanner s = new Scanner("123 456"); >> >> try { >> s.nextInt(-1); >> fail("Should throw StringIndexOutOfBoundsException"); >> } catch (StringIndexOutOfBoundsException e) { >> // Expected >> } >> try { >> s.nextInt(0); >> fail("Should throw PatternSyntaxException"); >> } catch (PatternSyntaxException e) { >> // Expected >> } >> try { >> s.nextInt(1); >> fail("Should throw InputMismatchException"); >> } catch (InputMismatchException e) { >> // Expected >> } >> try { >> s.nextInt(40); >> fail("Should throw StringIndexOutOfBoundsException"); >> } catch (StringIndexOutOfBoundsException e) { >> // Expected >> } >> } >> > > -- Richard Liang 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