This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
PATCH for system class loader simplification
- To: java-patches at gcc dot gnu dot org
- Subject: PATCH for system class loader simplification
- From: Per Bothner <per at bothner dot com>
- Date: 30 Aug 2001 15:05:48 -0700
The initial trigger for this patch was the use of the system field
without checking it for null. But I got to thinking things owuld be
cleaner and simpler if we just got rid of the field and used the
VMClassLoader.instance instance field directly instead.
I guess I could see that having ClassLoader.system allows other
kinds of system class loaders. Perhaps it might be cleaner to
go the other way: Replace all uses of VMClassLoader.instance
by ClassLoader.system?
Comments? Should I check this in?
2001-08-30 Per Bothner <per@bothner.com>
* java/lang/ClassLoader.java (system): Remove static field.
(getSystemClassLoader): Get gnu.gcj.runtime.VMClassLoader.instance
directly instead of using it to set the system field.
(loadClass): Use VMClassLoader.instance instead of system field.
(findSystemClass): Similar.
* prims.cc (_Jv_RunMain): Clear VMClassLoader::instance rather
than ClassLoader::system which no longer exists.
* java/lang/natClassLoader.java (_Jv_FindClass): Simplify.
Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.57
diff -u -p -r1.57 prims.cc
--- prims.cc 2001/08/26 11:30:07 1.57
+++ prims.cc 2001/08/30 21:41:16
@@ -64,6 +64,7 @@ details. */
#include <java/lang/reflect/Modifier.h>
#include <java/io/PrintStream.h>
#include <java/lang/UnsatisfiedLinkError.h>
+#include <gnu/gcj/runtime/VMClassLoader.h>
#ifdef USE_LTDL
#include <ltdl.h>
@@ -921,7 +922,7 @@ _Jv_RunMain (jclass klass, const char *n
// jar file only. The easiest way to do this is to lose our
// reference to the previous classloader.
_Jv_Jar_Class_Path = strdup (name);
- java::lang::ClassLoader::system = NULL;
+ gnu::gcj::runtime::VMClassLoader::instance = NULL;
}
}
catch (java::lang::Throwable *t)
Index: java/lang/ClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/ClassLoader.java,v
retrieving revision 1.13
diff -u -p -r1.13 ClassLoader.java
--- ClassLoader.java 2001/05/06 13:42:11 1.13
+++ ClassLoader.java 2001/08/30 21:41:16
@@ -34,7 +34,6 @@
public abstract class ClassLoader
{
- static private ClassLoader system;
private ClassLoader parent;
private HashMap definedPackages = new HashMap();
@@ -46,9 +46,7 @@ public abstract class ClassLoader
public static ClassLoader getSystemClassLoader ()
{
- if (system == null)
- system = gnu.gcj.runtime.VMClassLoader.instance;
- return system;
+ return gnu.gcj.runtime.VMClassLoader.instance;
}
/**
@@ -120,7 +118,7 @@ public abstract class ClassLoader
if (parent != null)
return parent.loadClass (name, link);
else
- c = system.findClass (name);
+ c = gnu.gcj.runtime.VMClassLoader.instance.findClass (name);
} catch (ClassNotFoundException ex) {
/* ignore, we'll try findClass */;
}
@@ -464,7 +462,7 @@ public abstract class ClassLoader
protected final Class findSystemClass(String name)
throws java.lang.ClassNotFoundException
{
- return getSystemClassLoader ().loadClass (name);
+ return gnu.gcj.runtime.VMClassLoader.instance.loadClass (name);
}
/*
Index: java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.33
diff -u -p -r1.33 natClassLoader.cc
--- natClassLoader.cc 2001/08/22 23:10:07 1.33
+++ natClassLoader.cc 2001/08/30 21:41:17
@@ -481,12 +495,8 @@ _Jv_FindClass (_Jv_Utf8Const *name, java
}
else
{
- java::lang::ClassLoader *sys = java::lang::ClassLoader::system;
- if (sys == NULL)
- {
- _Jv_InitClass (&ClassLoaderClass);
- sys = java::lang::ClassLoader::getSystemClassLoader ();
- }
+ java::lang::ClassLoader *sys
+ = java::lang::ClassLoader::getSystemClassLoader ();
// Load using the bootstrap loader jvmspec 5.3.1.
klass = sys->loadClass (sname, false);
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/