java.rmi.server patch

Frank Ch. Eigler fche@redhat.com
Tue Aug 26 10:44:00 GMT 2003


Hi -

This is my first libjava patch, and I need your help advising
how it should be tested (mauve and libjava/testsuite don't touch
this area), and whether this is the right place to send this sort
of little widget.  Thanks!


2003-08-25  Frank Ch. Eigler  <fche@redhat.com>

	* java/rmi/server/RMIClassLoader.java (getClassLoader): New
	implementation based on pieces moved from loadClass().
	(loadClass): Call new function.
	

Index: java/rmi/server/RMIClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/rmi/server/RMIClassLoader.java,v
retrieving revision 1.3.8.3
diff -u -r1.3.8.3 RMIClassLoader.java
--- java/rmi/server/RMIClassLoader.java	17 Jan 2003 19:55:13 -0000	1.3.8.3
+++ java/rmi/server/RMIClassLoader.java	25 Aug 2003 20:58:58 -0000
@@ -1,5 +1,5 @@
 /* RMIClassLoader.java
-  Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+  Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -151,6 +151,26 @@
     if (c != null)
       return c;
 
+    try
+      {
+	loader = getClassLoader(codebases);
+      }
+    catch(SecurityException e)
+      {
+        throw new ClassNotFoundException("Permission problems with URL path", e);
+      }
+
+    return loader.loadClass(name);
+  }
+
+
+  /**
+   * @since 1.3
+   */
+  public static ClassLoader getClassLoader(String codebases)
+    throws MalformedURLException, SecurityException
+  {
+    ClassLoader loader;
     if (codebases.length() == 0) //==""
       loader = defaultLoader;
     else 
@@ -165,14 +185,17 @@
 	    ArrayList urls = new ArrayList();
 	    while (tok.hasMoreTokens())
 	      urls.add(new URL(tok.nextToken()));
-  
+
+	    // XXX: check URLs' reachability to see whether SecurityException
+	    // should be thrown.
+
 	    loader = new MyClassLoader((URL[])urls.toArray(new URL[urls.size()]),
 					null, codebases);
 	    cacheLoaders.put(codebases, loader);
 	  }
       }
 
-    return loader.loadClass(name);
+    return loader;    
   }
   
   public static String getClassAnnotation(Class cl)



More information about the Java-patches mailing list