harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
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 GMT
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<Manifest>() {
                         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()) {



Mime
View raw message