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]

Re: PR 12001 - ClassLoader fix


>>>>> "Nathan" == Nathan Bryant <nbryant@optonline.net> writes:

Nathan> Sorry if this is posted to too many lists, I'm not sure which is
Nathan> correct. This is my suggested patch for PR 12001 which I would like to
Nathan> get reviewed.

Sorry this took me so long to get to.  The patch as-is didn't work for
me, but there have been changes in this area.  Instead I'm checking in
the appended, which is similar.  The idea, as you mentioned, is to get
the bootstrap loader initialized before telling it about the classpath
(and turning it into a kind of system loader).

Tom

Index: ChangeLog
from  Nathan Bryant  <nbryant@optonline.net>
	Tom Tromey  <tromey@redhat.com>

	PR libgcj/12001:
	* gnu/gcj/runtime/VMClassLoader.java (VMClassLoader): Pass empty
	array to superclass.
	(init): Changed interface; add URLs here.
	(initialize): New static method.
	* prims.cc (_Jv_CreateJavaVM): Initialize ClassLoader here...
	(_Jv_RunMain): ... not here.

Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.86
diff -u -r1.86 prims.cc
--- prims.cc 16 Oct 2003 21:19:53 -0000 1.86
+++ prims.cc 14 Jan 2004 22:41:03 -0000
@@ -1,6 +1,6 @@
 // prims.cc - Code for core of runtime environment.
 
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -927,15 +927,24 @@
   _Jv_InitClass (&java::lang::VMThrowable::class$);
   java::lang::VMThrowable::trace_enabled = 0;
   
+  // We have to initialize this fairly early, to avoid circular class
+  // initialization.  In particular we want to start the
+  // initialization of ClassLoader before we start the initialization
+  // of VMClassLoader.
+  _Jv_InitClass (&java::lang::ClassLoader::class$);
+  // Once the bootstrap loader is in place, change it into a kind of
+  // system loader, by having it read the class path.
+  gnu::gcj::runtime::VMClassLoader::initialize();
+
   INIT_SEGV;
 #ifdef HANDLE_FPE
   INIT_FPE;
 #endif
   
   no_memory = new java::lang::OutOfMemoryError;
-  
+
   java::lang::VMThrowable::trace_enabled = 1;
-  
+
 #ifdef USE_LTDL
   LTDL_SET_PRELOADED_SYMBOLS ();
 #endif
@@ -987,12 +996,6 @@
 #else      
       arg_vec = JvConvertArgv (argc - 1, argv + 1);
 #endif
-
-      // We have to initialize this fairly early, to avoid circular
-      // class initialization.  In particular we want to start the
-      // initialization of ClassLoader before we start the
-      // initialization of VMClassLoader.
-      _Jv_InitClass (&java::lang::ClassLoader::class$);
 
       using namespace gnu::gcj::runtime;
       if (klass)
Index: gnu/gcj/runtime/VMClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/VMClassLoader.java,v
retrieving revision 1.11
diff -u -r1.11 VMClassLoader.java
--- gnu/gcj/runtime/VMClassLoader.java 25 Sep 2003 07:46:19 -0000 1.11
+++ gnu/gcj/runtime/VMClassLoader.java 14 Jan 2004 22:41:03 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001, 2002, 2003  Free Software Foundation
+/* Copyright (C) 1999, 2001, 2002, 2003, 2004  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -19,7 +19,7 @@
 {
   private VMClassLoader ()
   {	
-    super (init());
+    super (new URL[0]);
     String p
       = System.getProperty ("gnu.gcj.runtime.VMClassLoader.library_control",
 			    "");
@@ -36,22 +36,21 @@
       lib_control = LIB_FULL;
   }
 
-  private static URL[] init() 
+  private void init() 
   {
     StringTokenizer st
 	= new StringTokenizer (System.getProperty ("java.class.path", "."),
 			       System.getProperty ("path.separator", ":"));
 
-    java.util.Vector p = new java.util.Vector();
     while (st.hasMoreElements ()) 
       {  
 	String e = st.nextToken ();
 	try
 	  {
 	    if (!e.endsWith (File.separator) && new File (e).isDirectory ())
-	      p.addElement (new URL("file", "", -1, e + File.separator));
+	      addURL(new URL("file", "", -1, e + File.separator));
 	    else
-	      p.addElement (new URL("file", "", -1, e));
+	      addURL(new URL("file", "", -1, e));
 	  } 
 	catch (java.net.MalformedURLException x)
 	  {
@@ -62,16 +61,12 @@
     // compiled into this executable may be found.
     try
       {
-	p.addElement (new URL("core", "", -1, "/"));
+	addURL(new URL("core", "", -1, "/"));
       }
     catch (java.net.MalformedURLException x)
       {
 	// This should never happen.
       }
-
-    URL[] urls = new URL[p.size()];
-    p.copyInto (urls);
-    return urls;
   }
 
   /** This is overridden to search the internal hash table, which 
@@ -81,6 +76,13 @@
    */
   protected native Class findClass(String name) 
     throws java.lang.ClassNotFoundException;
+
+  // This can be package-private because we only call it from native
+  // code during startup.
+  static void initialize ()
+  {
+    instance.init();
+  }
 
   // This keeps track of shared libraries we've already tried to load.
   private HashSet tried_libraries = new HashSet();


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