harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r468831 - in /incubator/harmony/enhanced/classlib/trunk/modules/rmi: ./ src/main/java/org/apache/harmony/rmi/ src/test/api/java/org/apache/harmony/rmi/server/ src/test/resources/org/ src/test/resources/org/apache/ src/test/resources/org/apa...
Date Sun, 29 Oct 2006 04:12:49 GMT
Author: ndbeyer
Date: Sat Oct 28 21:12:48 2006
New Revision: 468831

URL: http://svn.apache.org/viewvc?view=rev&rev=468831
Log:
Apply modified patch for HARMONY-1944: [classlib][rmi] default RMIClassLoader provider should
not sort codebase URLs

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/harmony/
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/harmony/rmi/
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/harmony/rmi/server/
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/harmony/rmi/server/testClass.jar
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/.classpath
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/.classpath
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/.classpath?view=diff&rev=468831&r1=468830&r2=468831
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/.classpath (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/.classpath Sat Oct 28 21:12:48 2006
@@ -1,8 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry output="bin/main" kind="src" path="src/main/java"/>
-	<classpathentry output="bin/test" kind="src" path="src/test/api/java"/>
+	<classpathentry kind="src" output="bin/main" path="src/main/java"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/resources"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/api/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
-	<classpathentry kind="output" path="bin"/>
+	<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/>
+	<classpathentry kind="output" path="bin/main"/>
 </classpath>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java?view=diff&rev=468831&r1=468830&r2=468831
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
Sat Oct 28 21:12:48 2006
@@ -622,28 +622,22 @@
     }
 
     /*
-     * Converts string representation of urls to sorted array of URLs.
+     * Converts string representation of urls to array of URLs.
      *
      * @param list list of urls separated by spaces
      *
-     * @return sorted array of URLs from specified list
+     * @return array of URLs from specified list
      */
-    private static URL[] getSortedURLs(String list)
+    private static URL[] stringToURLs(String list)
             throws MalformedURLException {
         if (list == null) {
             return null;
         }
         StringTokenizer tok = new StringTokenizer(list);
-        String[] strs = new String[tok.countTokens()];
+        URL[] urls = new URL[tok.countTokens()];
 
-        for (int i = 0; i < strs.length; ++i) {
-            strs[i] = tok.nextToken();
-        }
-        Arrays.sort(strs);
-        URL[] urls = new URL[strs.length];
-
-        for (int i = 0; i < strs.length; ++i) {
-            urls[i] = new URL(strs[i]);
+        for (int i = 0; i < urls.length; ++i) {
+            urls[i] = new URL(tok.nextToken());
         }
         return urls;
     }
@@ -680,9 +674,9 @@
         private Permissions perms;
 
         /*
-         * Constructs URLLoader from sorted list of URLs and parent ClassLoader.
+         * Constructs URLLoader from list of URLs and parent ClassLoader.
          *
-         * @param urls sorted list of URLs
+         * @param urls list of URLs
          * @param parent parent ClassLoader
          */
         URLLoader(URL[] urls, ClassLoader parent) {
@@ -740,19 +734,19 @@
          * Constructs TableKey from string representation of the list of URLs.
          *
          * @param loader ClassLoader
-         * @param codebase String represented codebase list (possibly unsorted)
+         * @param codebase String represented codebase list
          *        separated by <space>
          */
         TableKey(ClassLoader loader, String codebase)
                 throws MalformedURLException {
-            this(loader, getSortedURLs(codebase));
+            this(loader, stringToURLs(codebase));
         }
 
         /*
-         * Constructs TableKey from the specified sorted array of URLs.
+         * Constructs TableKey from the specified array of URLs.
          *
          * @param loader ClassLoader
-         * @param urls array of URLs (possibly unsorted)
+         * @param urls array of URLs
          */
          TableKey(ClassLoader loader, URL[] urls) {
              this.loader = loader;
@@ -776,9 +770,9 @@
         }
 
         /*
-         * Returns sorted list of URLs contained in this TableKey.
+         * Returns list of URLs contained in this TableKey.
          *
-         * @return sorted list of URLs contained in this TableKey
+         * @return list of URLs contained in this TableKey
          */
         public URL[] getURLs() {
             return urls;

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java?view=auto&rev=468831
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java
Sat Oct 28 21:12:48 2006
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.rmi.server;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.server.RMIClassLoader;
+import java.security.Permission;
+import junit.framework.TestCase;
+
+public class RMIClassLoaderTest extends TestCase {
+    /**
+     * Test for java.rmi.server.RMIclassLoader.loadClass() method testing that
+     * RMI runtime does not change the order of the incoming codebase string
+     * (regression test for HARMONY-1944).
+     */
+    public void testLoadClassCodebaseOrder() throws Exception {
+        SecurityManager previous = System.getSecurityManager();
+        System.setSecurityManager(new SecurityManager() {
+            @Override
+            public void checkPermission(Permission perm) {
+                /*
+                 * Override checkPermission to allow everything. Specifically,
+                 * we want to allow the SecurityManager to be set to null at the
+                 * end of the test and we want to allow the 'testClass.jar' file
+                 * to be allowed to load.
+                 */
+                return;
+            }
+        });
+        try {
+            URL testJarURL = getClass().getResource("testClass.jar");
+            String[] paths = new String[] { testJarURL.getPath(),
+            /*
+             * to be sure this path will be the first after sorting
+             */
+            "/_fake.jar" };
+            Class<?> c = RMIClassLoader.loadClass("file://" + paths[0] + " file://"
+ paths[1],
+                    "TestClass", null);
+            ClassLoader cl = c.getClassLoader();
+            if (cl instanceof URLClassLoader) {
+                URL[] urls = ((URLClassLoader) cl).getURLs();
+                if (urls.length != 2) {
+                    fail("Unexpected number of URLs: " + urls.length);
+                }
+                String failStr = "";
+                for (int i = 0; i < urls.length; ++i) {
+                    if (!urls[i].getPath().equals(paths[i])) {
+                        failStr += "\nURL[" + i + "].getPath() = " + urls[i].getPath()
+                                + ", expected: " + paths[i];
+                    }
+                }
+                if (!failStr.equals("")) {
+                    fail(failStr);
+                }
+            } else {
+                fail("Class is loaded by non-URLClassLoader");
+            }
+        } finally {
+            // reset the security manager back to null state
+            System.setSecurityManager(previous);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/api/java/org/apache/harmony/rmi/server/RMIClassLoaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/harmony/rmi/server/testClass.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/harmony/rmi/server/testClass.jar?view=auto&rev=468831
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/test/resources/org/apache/harmony/rmi/server/testClass.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message