[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] RFC: New system class loader implementation
From: |
Archie Cobbs |
Subject: |
Re: [cp-patches] RFC: New system class loader implementation |
Date: |
Mon, 11 Oct 2004 11:11:38 -0500 (CDT) |
Jeroen Frijters wrote:
> I would like to move my implementation of the System class loader into
> Classpath. I've been running with this implementation (minus the new
> checkPackageAccess) for a while and it seems to work very well. The
> current version in Classpath is known to be broken and I don't think
> anybody uses it.
>
> Not included in the patch, but this removes the need for
> gnu/java/lang/SystemClassLoader.java.
>
> The hook in VMClassLoader continues to exist, for those that want to
> implement the system class loader in another way.
Looks good.
I'd also like to add this patch which I've been using.. though I'm a
bit suspicious of why the exising code has the comment "this requires
native help"... it doesn't seem to me that native help is required,
at least for non-specialized VMs.
-Archie
__________________________________________________________________________
Archie Cobbs * CTO, Awarix * http://www.awarix.com
--- /home/archie/classpath/cvs/vm/reference/java/lang/VMClassLoader.java
Mon Oct 11 11:03:25 2004
+++ /home/archie/xx Mon Oct 11 11:11:02 2004
@@ -40,10 +40,14 @@
import java.security.ProtectionDomain;
import java.net.URL;
+import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.util.Enumeration;
import java.util.Map;
import java.util.HashMap;
+import java.util.StringTokenizer;
+import java.util.Vector;
import java.lang.reflect.Constructor;
import gnu.java.lang.SystemClassLoader;
@@ -136,28 +140,44 @@
/**
* Helper to load a resource from the bootstrap class loader.
*
- * XXX - Not implemented; this requires native help.
- *
* @param name the resource to find
* @return the URL to the resource
*/
static URL getResource(String name)
{
+ Enumeration e = getResources(name);
+ if (e.hasMoreElements())
+ return (URL)e.nextElement();
return null;
}
/**
* Helper to get a list of resources from the bootstrap class loader.
*
- * XXX - Not implemented; this requires native help.
- *
* @param name the resource to find
* @return an enumeration of resources
* @throws IOException if one occurs
*/
- static Enumeration getResources(String name) throws IOException
+ static Enumeration getResources(String name)
{
- return EmptyEnumeration.getInstance();
+ StringTokenizer st = new StringTokenizer(
+ System.getProperty("java.boot.class.path", "."), File.pathSeparator);
+ Vector v = new Vector();
+ while (st.hasMoreTokens())
+ {
+ File file = new File(st.nextToken(), name);
+ if (!file.exists())
+ continue;
+ try
+ {
+ v.add(new URL("file://" + file.getAbsolutePath()));
+ }
+ catch (MalformedURLException e)
+ {
+ throw new Error(e);
+ }
+ }
+ return v.elements();
}
/**