Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 36034 invoked from network); 7 Jul 2006 02:11:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Jul 2006 02:11:55 -0000 Received: (qmail 39301 invoked by uid 500); 7 Jul 2006 02:11:52 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 39250 invoked by uid 500); 7 Jul 2006 02:11: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 39239 invoked by uid 99); 7 Jul 2006 02:11: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 19:11: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 paulex.yang@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 19:11:50 -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 k672GFUJ071912 for ; Fri, 7 Jul 2006 12:16:15 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.250.243]) by sd0208e0.au.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k672EpOx176160 for ; Fri, 7 Jul 2006 12:14:51 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k672AEwG010626 for ; Fri, 7 Jul 2006 12:10:14 +1000 Received: from d23m0011.cn.ibm.com ([9.181.32.74]) by d23av02.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k672ADDr009233 for ; Fri, 7 Jul 2006 12:10:14 +1000 Received: from [127.0.0.1] ([9.181.106.114]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.5.5HF262) with ESMTP id 2006070710084037-1742 ; Fri, 7 Jul 2006 10:08:40 +0800 Message-ID: <44ADC228.9040108@gmail.com> Date: Fri, 07 Jul 2006 10:08:40 +0800 From: Paulex Yang 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> <44AD1599.908@gmail.com> In-Reply-To: <44AD1599.908@gmail.com> X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 07/07/2006 10:08:41, Serialize by Router on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 07/07/2006 10:11:27, Serialize complete at 07/07/2006 10:11:27 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 Richard Liang wrote: > > > 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? Oops, so just forget what I said:). Sorry if I made confusion, I didn't look closely, just wondering why the regex exception is thrown from Scanner, and I thought it may be straightforward to separately test the regex API invocation, probably I'm wrong. > > 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 >>> } >>> } >>> >> >> > -- 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