Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 21657 invoked from network); 4 Oct 2006 21:47:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Oct 2006 21:47:46 -0000 Received: (qmail 50930 invoked by uid 500); 4 Oct 2006 21:47:45 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 50900 invoked by uid 500); 4 Oct 2006 21:47:45 -0000 Mailing-List: contact harmony-commits-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-commits@incubator.apache.org Received: (qmail 50889 invoked by uid 99); 4 Oct 2006 21:47:45 -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, 04 Oct 2006 14:47:45 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received: from [140.211.166.113] ([140.211.166.113:58478] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 90/15-20288-00C24254 for ; Wed, 04 Oct 2006 14:47:44 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id E5BE21A981A; Wed, 4 Oct 2006 14:47:41 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r453042 - in /incubator/harmony/enhanced/drlvm/trunk: src/test/package_tests/ vm/vmcore/include/ vm/vmcore/src/kernel_classes/javasrc/java/lang/ Date: Wed, 04 Oct 2006 21:47:41 -0000 To: harmony-commits@incubator.apache.org From: geirm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061004214741.E5BE21A981A@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: geirm Date: Wed Oct 4 14:47:40 2006 New Revision: 453042 URL: http://svn.apache.org/viewvc?view=rev&rev=453042 Log: HARMONY-1651 Mostly - rejected the catch(NPE) and did something to be explicit about what we are doing when there is no specVersion. All three tests pass. Note, I had to also add a manifest to the kernel.jar for this to work - not sure how this worked without it. All three tests pass, and nothing else seems to have broken. Ubuntu 6, smoke, c-unit, ~kernel Added: incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/ incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test1.java (with props) incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test2.java (with props) incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test3.java (with props) Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java Added: incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test1.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test1.java?view=auto&rev=453042 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test1.java (added) +++ incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test1.java Wed Oct 4 14:47:40 2006 @@ -0,0 +1,18 @@ +public class Test1 { + public static void main(final String[] args) throws Exception { + Package p = Package.getPackage("java.lang"); + if (p==null) { + System.out.println("Error0: test didn't work"); + return; + } + try { + p.isCompatibleWith(""); + System.out.println("Error1: NumberFormatException should be thrown"); + } catch (NumberFormatException _) { + System.out.println("Test passed."); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Error2: " + e.toString()); + } + } +} Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test1.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test2.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test2.java?view=auto&rev=453042 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test2.java (added) +++ incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test2.java Wed Oct 4 14:47:40 2006 @@ -0,0 +1,15 @@ +public class Test2 { + public static void main(final String[] args) throws Exception { + try { + Package p = Package.getPackage("java.lang"); + if (p==null) { + System.out.println("Error0: test didn't work"); + return; + } + p.isSealed((java.net.URL)null); + System.out.println("Test failed."); + } catch (NullPointerException _) { + System.out.println("Test passed."); + } + } +} Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test2.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test3.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test3.java?view=auto&rev=453042 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test3.java (added) +++ incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test3.java Wed Oct 4 14:47:40 2006 @@ -0,0 +1,90 @@ +package j.l; +public class Test3 { + public static void main(final String[] args) throws Exception { + Package p = org.apache.xalan.Version.class.getPackage(); + if (p==null) { + System.out.println("Error0: test didn't work"); + return; + } + System.out.println(p.getName()); + System.out.println(p.getSpecificationVersion()); + if (p.getSpecificationVersion()!=null) { + try { + p.isCompatibleWith(""); + System.out.println("Test failed (1)"); + } catch (NumberFormatException e) { + System.out.println("Test case #1 passed"); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed (2)"); + } + try { + System.out.println(p.isCompatibleWith(null)); + System.out.println("Test failed (3)"); + } catch (NullPointerException e) { + System.out.println("Test case #2 passed"); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed (4)"); + } + try { + System.out.println(p.isCompatibleWith("1")); + System.out.println("Test case #3 passed"); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed (5)"); + } + try { + System.out.println(p.isCompatibleWith("a")); + System.out.println("Test failed (6)"); + } catch (NumberFormatException e) { + System.out.println("Test case #4 passed"); + } + } else { + System.out.println("Test case #1 failed"); + System.out.println("Test case #2 failed"); + System.out.println("Test case #3 failed"); + System.out.println("Test case #4 failed"); + } + System.out.println("-----------------------------------"); + p = Package.getPackage("j.l"); + System.out.println(p.getSpecificationVersion()); + try { + p.isCompatibleWith(""); + System.out.println("Test failed (7)"); + } catch (NumberFormatException e) { + System.out.println("Test case #5 passed"); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed (8)"); + } + try { + System.out.println(p.isCompatibleWith(null)); + System.out.println("Test failed (9)"); + } catch (NumberFormatException e) { + System.out.println("Test case #6 passed"); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed (10)"); + } + + try { + System.out.println(p.isCompatibleWith("1")); + System.out.println("Test failed (11)"); + } catch (NumberFormatException e) { + System.out.println("Test case #7 passed"); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed (12)"); + } + try { + System.out.println(p.isCompatibleWith("a")); + System.out.println("Test failed (13)"); + } catch (NumberFormatException e) { + System.out.println("Test case #8 passed"); + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed (14)"); + } + } +} Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/package_tests/Test3.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h?view=diff&rev=453042&r1=453041&r2=453042 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h Wed Oct 4 14:47:40 2006 @@ -18,6 +18,6 @@ #ifndef _VERSION_SVN_TAG_ #define _VERSION_SVN_TAG_ -#define VERSION_SVN_TAG "452436" +#define VERSION_SVN_TAG "452887" #endif // _VERSION_SVN_TAG_ Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java?view=diff&rev=453042&r1=453041&r2=453042 ============================================================================== --- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java (original) +++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java Wed Oct 4 14:47:40 2006 @@ -258,15 +258,31 @@ */ public boolean isCompatibleWith(String desiredVersion) throws NumberFormatException { + if (jar != null) { init(); } + /* + * yes, it's not as performant as catching an NPE down below when + * something blows up, but it's very clear to those that read this. + * Spec says that an NFE is thrown if the current or desired version + * is not of the correct dotted form. Lack of a version is such... + */ + if (specVersion == null) { + throw new NumberFormatException("No version defined for implementation"); + } + StringTokenizer specVersionTokens = new StringTokenizer(specVersion, "."); + StringTokenizer desiredVersionTokens = new StringTokenizer( desiredVersion, "."); + try { + if (!specVersionTokens.hasMoreElements() || !desiredVersionTokens.hasMoreElements()) { + throw new NumberFormatException("Empty version string"); + } while (specVersionTokens.hasMoreElements()) { int desiredVer = Integer.parseInt(desiredVersionTokens .nextToken()); @@ -294,7 +310,6 @@ return false; } } - return true; } @@ -316,7 +331,7 @@ if (jar != null) { init(); } - return sealBase != null && sealBase.equals(url); + return url.equals(sealBase); } /** @@ -342,8 +357,10 @@ if (jarCache != null && (map = jarCache.get()) != null) { manifest = map.get(jar); } + if (manifest == null) { final URL url = sealURL = new URL(jar); + manifest = AccessController.doPrivileged( new PrivilegedAction() { public Manifest run() @@ -366,33 +383,34 @@ } Attributes mainAttrs = manifest.getMainAttributes(); - Attributes pkgAttrs = manifest.getAttributes(name); - specTitle = (specTitle = pkgAttrs + Attributes pkgAttrs = manifest.getAttributes(name.replace('.','/')+"/"); + + specTitle = pkgAttrs == null || (specTitle = pkgAttrs .getValue(Attributes.Name.SPECIFICATION_TITLE)) == null ? mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE) : specTitle; - specVersion = (specVersion = pkgAttrs + specVersion = pkgAttrs == null || (specVersion = pkgAttrs .getValue(Attributes.Name.SPECIFICATION_VERSION)) == null ? mainAttrs.getValue(Attributes.Name.SPECIFICATION_VERSION) : specVersion; - specVendor = (specVendor = pkgAttrs + specVendor = pkgAttrs == null || (specVendor = pkgAttrs .getValue(Attributes.Name.SPECIFICATION_VENDOR)) == null ? mainAttrs.getValue(Attributes.Name.SPECIFICATION_VENDOR) : specVendor; - implTitle = (implTitle = pkgAttrs + implTitle = pkgAttrs == null || (implTitle = pkgAttrs .getValue(Attributes.Name.IMPLEMENTATION_TITLE)) == null ? mainAttrs.getValue(Attributes.Name.IMPLEMENTATION_TITLE) : implTitle; - implVersion = (implVersion = pkgAttrs + implVersion = pkgAttrs == null || (implVersion = pkgAttrs .getValue(Attributes.Name.IMPLEMENTATION_VERSION)) == null ? mainAttrs .getValue(Attributes.Name.IMPLEMENTATION_VERSION) : implVersion; - implVendor = (implVendor = pkgAttrs + implVendor = pkgAttrs == null || (implVendor = pkgAttrs .getValue(Attributes.Name.IMPLEMENTATION_VENDOR)) == null ? mainAttrs.getValue(Attributes.Name.IMPLEMENTATION_VENDOR) : implVendor; - String sealed = (sealed = pkgAttrs + String sealed = pkgAttrs == null || (sealed = pkgAttrs .getValue(Attributes.Name.SEALED)) == null ? mainAttrs .getValue(Attributes.Name.SEALED) : sealed; if (Boolean.valueOf(sealed).booleanValue()) {