This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: RFA for 4.0: use system class loader


This patch addresses the problem Per is seeing with Kawa.

The story is, we ought to be using the bootstrap class loader in these
places.  However, existing code relies on us using the system class
loader.  If we use the bootstrap loader, then a precompiled
application cannot use Class.forName() and expect it to find classes
from the classpath -- since the main class will have been loaded by
the bootstrap loader, which doesn't search the classpath.

On the trunk we will fix this more correctly, by providing a mechanism
to distinguish between linked-in classes which should be loaded by the
system loader, and classes in libgcj, which should be loaded by the
bootstrap loader.

I would like to check this in to 4.0.

Tested with no regressions on x86 FC2.  I also tested this patch
against Eclipse and Jonas, two classloader-killing applications.
Finally, I tested it against kawa, which is where the problem was
discovered.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* java/lang/natClassLoader.cc (_Jv_FindClass): Use system loader,
	not boot loader.

Index: java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.76.6.3
diff -u -r1.76.6.3 natClassLoader.cc
--- java/lang/natClassLoader.cc 6 Apr 2005 22:40:52 -0000 1.76.6.3
+++ java/lang/natClassLoader.cc 14 Apr 2005 03:01:56 -0000
@@ -117,7 +117,7 @@
 _Jv_RegisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
 {
   if (! loader)
-    loader = java::lang::VMClassLoader::bootLoader;
+    loader = java::lang::ClassLoader::systemClassLoader;
   loader->loadedClasses->put(klass->name->toString(), klass);
 }
 
@@ -127,7 +127,7 @@
 _Jv_UnregisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
 {
   if (! loader)
-    loader = java::lang::VMClassLoader::bootLoader;
+    loader = java::lang::ClassLoader::systemClassLoader;
   loader->loadedClasses->remove(klass->name->toString());
 }
 
@@ -223,7 +223,8 @@
   // initiating loader checks, as we register classes with their
   // initiating loaders.
 
-  java::lang::ClassLoader *boot = java::lang::VMClassLoader::bootLoader;
+  // Note: this is incorrect, but compatible with older GCJ usage.
+  java::lang::ClassLoader *boot = java::lang::ClassLoader::systemClassLoader;
   java::lang::ClassLoader *real = loader;
   if (! real)
     real = boot;
@@ -252,7 +253,9 @@
       else if (boot)
 	{
 	  // Load using the bootstrap loader jvmspec 5.3.1.
-	  klass = java::lang::VMClassLoader::loadClass (sname, false); 
+	  // klass = java::lang::VMClassLoader::loadClass (sname, false); 
+	  // Note again that we're actually using the system loader here.
+	  klass = boot->loadClass (sname);
 
 	  // Register that we're an initiating loader.
 	  if (klass)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]