From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19345 invoked by alias); 18 Aug 2011 15:46:10 -0000 Received: (qmail 19336 invoked by uid 22791); 18 Aug 2011 15:46:09 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,T_HK_NAME_DR X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Aug 2011 15:45:50 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7IFjo8g001527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Aug 2011 11:45:50 -0400 Received: from rivendell.middle-earth.co.uk ([10.3.113.13]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7IFjktO012638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 18 Aug 2011 11:45:49 -0400 Date: Thu, 18 Aug 2011 15:46:00 -0000 From: Dr Andrew John Hughes To: Pavel Tisnovsky Cc: mauve-discuss@sourceware.org Subject: Re: Fix for test gnu/testlet/java/lang/Integer/parseInt.java Message-ID: <20110818154546.GF9583@rivendell.middle-earth.co.uk> References: <4E4BEA69.9040702@redhat.com> <20110817162659.GB9583@rivendell.middle-earth.co.uk> <4E4D08C8.8010307@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E4D08C8.8010307@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact mauve-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sourceware.org X-SW-Source: 2011-q3/txt/msg00006.txt.bz2 On 14:42 Thu 18 Aug , Pavel Tisnovsky wrote: > Dr Andrew John Hughes wrote: > > > As the old behaviour is specific to versions of Sun/Oracle's JDK implementation, > > it should check that this implementation is being used as well, rather than just > > the version. > > Hi Andrew, > > I've tried to add check for JDK/JRE implementation as you suggested. Patch for > parseInt Mauve test is stored in an attachment. > > Cheers, > Pavel This looks better, but you're still changing the old behaviour. Not all Classpath VMs are produced by the FSF. As it's a workaround for Sun: String[] javaVersion = System.getProperty("java.version").split("\\."); String vendorID = System.getProperty("java.vendor"); // test of OpenJDK if ("Sun Microsystems Inc.".equals(vendorID)) { return Integer.parseInt(javaVersion[1]) >= 7; } return true; > --- gnu/testlet/java/lang/Integer/parseInt.java 2008-05-12 23:35:49.000000000 +0200 > +++ gnu/testlet/java/lang/Integer/parseInt.java 2011-08-17 17:17:16.000000000 +0200 > @@ -27,6 +27,26 @@ > > public class parseInt implements Testlet > { > + /** > + * Returns true if tested JRE conformns to JDK 1.7 specification. > + */ > + private static boolean conformToJDK17() > + { > + String[] javaVersion = System.getProperty("java.version").split("\\."); > + String vendorID = System.getProperty("java.vendor"); > + // GNU CLASSPATH conform to JDK1.7, at least in case of Integer.parseInt() method > + if ("Free Software Foundation, Inc.".equals(vendorID)) > + { > + return true; > + } > + // test of OpenJDK > + if ("Sun Microsystems Inc.".equals(vendorID)) > + { > + return Integer.parseInt(javaVersion[1]) >= 7; > + } > + return false; // questionable > + } > + > public void test(TestHarness harness) > { > int i; > @@ -106,15 +126,30 @@ > } > > // In JDK1.7, '+' is considered a valid character. > - try > - { > - i = Integer.parseInt("+10"); > - harness.check(true); > - harness.check(i, 10); > - } > - catch (NumberFormatException nfe) > - { > - harness.fail("Leading '+' does not throw NumberFormatException"); > + // it means that the following step should be divided > + // for pre JDK1.7 case and >= JDK1.7 > + if (conformToJDK17()) { > + try > + { > + i = Integer.parseInt("+10"); > + harness.check(true); > + harness.check(i, 10); > + } > + catch (NumberFormatException nfe) > + { > + harness.fail("'+10' string is not parsed correctly as expected in JDK1.7"); > + } > + } > + else { // pre JDK1.7 branch > + try > + { > + i = Integer.parseInt("+10"); > + harness.fail("'+10' must throw NumberFormatException"); > + } > + catch (NumberFormatException nfe) > + { > + harness.check(true); > + } > } > > try -- Andrew :) Free Java Software Engineer Red Hat, Inc. (http://www.redhat.com) Support Free Java! Contribute to GNU Classpath and IcedTea http://www.gnu.org/software/classpath http://icedtea.classpath.org PGP Key: F5862A37 (https://keys.indymedia.org/) Fingerprint = EA30 D855 D50F 90CD F54D 0698 0713 C3ED F586 2A37