incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r527253 - in /incubator/yoko/trunk: rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ rmi-spec/src/main/java/javax/rmi/ rmi-spec/src/main/java/javax/rmi/CORBA/ rmi-spec/src/main/java/org/apache/yoko/rmispec/util/
Date Tue, 10 Apr 2007 19:13:47 GMT
Author: rickmcguire
Date: Tue Apr 10 12:13:46 2007
New Revision: 527253

URL: http://svn.apache.org/viewvc?view=rev&rev=527253
Log:
YOKO-338 RMI Util.loadClass() not using proper search order when not installed in the endorsed
dirs.

Modified:
    incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java
    incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/CORBA/Util.java
    incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/PortableRemoteObject.java
    incubator/yoko/trunk/rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java

Modified: incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java?view=diff&rev=527253&r1=527252&r2=527253
==============================================================================
--- incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java (original)
+++ incubator/yoko/trunk/rmi-impl/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java Tue
Apr 10 12:13:46 2007
@@ -547,16 +547,34 @@
         }
 
         ClassLoader stackLoader = null;
+        ClassLoader thisLoader = Util.class.getClassLoader(); 
         Class[] stack = _secman.getClassContext();
         for (int i = 1; i < stack.length; i++) {
-            stackLoader = stack[i].getClassLoader();
-            if (stackLoader != null)
-                break;
+            ClassLoader testLoader = stack[i].getClassLoader();
+            if (testLoader != null && testLoader != thisLoader)
+            {
+                stackLoader = thisLoader; 
+                break; 
+            }
         }
 
         if (stackLoader != null) {
             try {
                 result = stackLoader.loadClass(name);
+            } catch (ClassNotFoundException ex) {
+                // skip //
+            }
+
+            if (result != null) {
+                return result;
+            }
+        }
+
+        // try loading using our loader, just in case we really were loaded
+        // using the same classloader the delegate is in.
+        if (thisLoader != null) {
+            try {
+                result = thisLoader.loadClass(name);
             } catch (ClassNotFoundException ex) {
                 // skip //
             }

Modified: incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/CORBA/Util.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/CORBA/Util.java?view=diff&rev=527253&r1=527252&r2=527253
==============================================================================
--- incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/CORBA/Util.java (original)
+++ incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/CORBA/Util.java Tue Apr 10 12:13:46
2007
@@ -44,7 +44,7 @@
             // this is a little bit recursive, but this will use the full default search
order for locating
             // this.
             delegate = (UtilDelegate)Util.loadClass(delegateName, null, null).newInstance();
-        } catch (Exception e) {
+        } catch (Throwable e) {
             org.omg.CORBA.INITIALIZE ex = new org.omg.CORBA.INITIALIZE("Can not create Util
delegate: "+delegateName);
             ex.initCause(e); 
             throw ex; 

Modified: incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/PortableRemoteObject.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/PortableRemoteObject.java?view=diff&rev=527253&r1=527252&r2=527253
==============================================================================
--- incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/PortableRemoteObject.java (original)
+++ incubator/yoko/trunk/rmi-spec/src/main/java/javax/rmi/PortableRemoteObject.java Tue Apr
10 12:13:46 2007
@@ -35,7 +35,7 @@
         String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction("javax.rmi.CORBA.PortableRemoteObjectClass",
defaultDelegate));
         try {
             delegate = (PortableRemoteObjectDelegate)Util.loadClass(delegateName, null, null).newInstance();
-        } catch (Exception e) {
+        } catch (Throwable e) {
            org.omg.CORBA.INITIALIZE ex = new org.omg.CORBA.INITIALIZE("Can not create PortableRemoteObject
delegate: "+delegateName);
            ex.initCause(e); 
            throw ex; 

Modified: incubator/yoko/trunk/rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java?view=diff&rev=527253&r1=527252&r2=527253
==============================================================================
--- incubator/yoko/trunk/rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java
(original)
+++ incubator/yoko/trunk/rmi-spec/src/main/java/org/apache/yoko/rmispec/util/UtilLoader.java
Tue Apr 10 12:13:46 2007
@@ -50,16 +50,34 @@
         }
 
         ClassLoader stackLoader = null;
+        ClassLoader thisLoader = UtilLoader.class.getClassLoader(); 
         Class[] stack = _secman.getClassContext();
         for (int i = 1; i < stack.length; i++) {
-            stackLoader = stack[i].getClassLoader();
-            if (stackLoader != null)
-                break;
+            ClassLoader testLoader = stack[i].getClassLoader();
+            if (testLoader != null && testLoader != thisLoader)
+            {
+                stackLoader = thisLoader; 
+                break; 
+            }
         }
 
         if (stackLoader != null) {
             try {
                 result = stackLoader.loadClass(name);
+            } catch (ClassNotFoundException ex) {
+                // skip //
+            }
+
+            if (result != null) {
+                return result;
+            }
+        }
+
+        // try loading using our loader, just in case we really were loaded
+        // using the same classloader the delegate is in.
+        if (thisLoader != null) {
+            try {
+                result = thisLoader.loadClass(name);
             } catch (ClassNotFoundException ex) {
                 // skip //
             }



Mime
View raw message