[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: URLClassLoader patchlet from libgcj plus Extension Cla
From: |
Mark Wielaard |
Subject: |
[cp-patches] FYI: URLClassLoader patchlet from libgcj plus Extension ClassLoader cleanup |
Date: |
Tue, 15 Feb 2005 16:19:57 +0100 |
Hi,
This brings in a small patchlet from libgcj that makes
ClassNotFoundExceptions much more clear (by incorporating any parent
class loaders searched). This showed that we would install an empty
extension classloader making the search path larger then necessary. So
this patch only installs it when there are extensions installed.
2005-02-14 Mark Wielaard <address@hidden>
* java/net/URLClassLoader.java (findClass): Throw
ClassNotFoundExceptions including urls, plus parent using toString().
(thisString): New field.
(toString): New method.
* java/lang/ClassLoader (defaultGetSystemClassLoader): Only install
ExtensionClassLoader when there are actual extension URLs.
Committed,
Mark
Index: java/lang/ClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ClassLoader.java,v
retrieving revision 1.45
diff -u -r1.45 ClassLoader.java
--- java/lang/ClassLoader.java 16 Jan 2005 15:24:35 -0000 1.45
+++ java/lang/ClassLoader.java 15 Feb 2005 15:02:55 -0000
@@ -1052,8 +1052,13 @@
static ClassLoader defaultGetSystemClassLoader()
{
- ClassLoader extClassLoader =
- new URLClassLoader(getExtClassLoaderUrls(), null);
+ URL[] extURLs = getExtClassLoaderUrls();
+ ClassLoader extClassLoader;
+ if (extURLs.length > 0)
+ extClassLoader = new URLClassLoader(getExtClassLoaderUrls(), null);
+ else
+ extClassLoader = null;
+
ClassLoader systemClassLoader =
new URLClassLoader(getSystemClassLoaderUrls(), extClassLoader)
{
Index: java/net/URLClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URLClassLoader.java,v
retrieving revision 1.25
diff -u -r1.25 URLClassLoader.java
--- java/net/URLClassLoader.java 16 Nov 2004 11:32:36 -0000 1.25
+++ java/net/URLClassLoader.java 15 Feb 2005 15:02:55 -0000
@@ -1,5 +1,6 @@
/* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation,
Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -745,7 +746,7 @@
String resourceName = className.replace('.', '/') + ".class";
Resource resource = findURLResource(resourceName);
if (resource == null)
- throw new ClassNotFoundException(className + " not found in " + urls);
+ throw new ClassNotFoundException(className + " not found in " + this);
// Try to read the class data, create the CodeSource, Package and
// construct the class (and watch out for those nasty IOExceptions)
@@ -837,9 +838,43 @@
}
catch (IOException ioe)
{
- throw new ClassNotFoundException(className, ioe);
+ ClassNotFoundException cnfe;
+ cnfe = new ClassNotFoundException(className + " not found in " + this);
+ cnfe.initCause(ioe);
+ throw cnfe;
}
}
+
+ // Cached String representation of this URLClassLoader
+ private String thisString;
+
+ /**
+ * Returns a String representation of this URLClassLoader giving the
+ * actual Class name, the URLs that are searched and the parent
+ * ClassLoader.
+ */
+ public String toString()
+ {
+ if (thisString == null)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(this.getClass().getName());
+ sb.append("{urls=[" );
+ URL[] thisURLs = getURLs();
+ for (int i = 0; i < thisURLs.length; i++)
+ {
+ sb.append(thisURLs[i]);
+ if (i < thisURLs.length - 1)
+ sb.append(',');
+ }
+ sb.append(']');
+ sb.append(", parent=");
+ sb.append(getParent());
+ sb.append('}');
+ thisString = sb.toString();
+ }
+ return thisString;
+ }
/**
* Finds the first occurrence of a resource that can be found. The locations
signature.asc
Description: This is a digitally signed message part
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: URLClassLoader patchlet from libgcj plus Extension ClassLoader cleanup,
Mark Wielaard <=