]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libgcj/19681 (extension loading currently incorrect)
authorTom Tromey <tromey@redhat.com>
Wed, 2 Feb 2005 20:59:41 +0000 (20:59 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 2 Feb 2005 20:59:41 +0000 (20:59 +0000)
PR libgcj/19681:
* Makefile.in: Rebuilt.
* Makefile.am (ordinary_java_source_files): Added new class.
* java/lang/natVMClassLoader.cc (getSystemClassLoaderInternal):
Use system_instance, not instance.
* gnu/gcj/runtime/SystemClassLoader.java: New file.
* gnu/gcj/runtime/VMClassLoader.java (init): Don't search
java.class.path.
(system_instance): New field.
(initialize): Initialize the system loader as well.
(VMClassLoader): Default to LIB_CACHE.

From-SVN: r94611

libjava/ChangeLog
libjava/Makefile.am
libjava/Makefile.in
libjava/gnu/gcj/runtime/SystemClassLoader.java [new file with mode: 0644]
libjava/gnu/gcj/runtime/VMClassLoader.java
libjava/java/lang/VMClassLoader.java
libjava/java/lang/natVMClassLoader.cc

index 4ee35337ce18495cf35f408d9007074fdcbed29a..31c14656ff610a133c3342938aa06aa6edf2c0bc 100644 (file)
@@ -1,3 +1,17 @@
+2005-02-02  Tom Tromey  <tromey@redhat.com>
+
+       PR libgcj/19681:
+       * Makefile.in: Rebuilt.
+       * Makefile.am (ordinary_java_source_files): Added new class.
+       * java/lang/natVMClassLoader.cc (getSystemClassLoaderInternal):
+       Use system_instance, not instance.
+       * gnu/gcj/runtime/SystemClassLoader.java: New file.
+       * gnu/gcj/runtime/VMClassLoader.java (init): Don't search
+       java.class.path.
+       (system_instance): New field.
+       (initialize): Initialize the system loader as well.
+       (VMClassLoader): Default to LIB_CACHE.
+
 2005-02-02  Tom Tromey  <tromey@redhat.com>
 
        * gnu/gcj/runtime/PersistentByteMap.java: Fixed typo.
index d7465d8a95c1b485c1ee553ec2c038059cdf6e25..a3ad469f3e13d2a82b552c1d37242753ccfe6e29 100644 (file)
@@ -2872,6 +2872,7 @@ gnu/gcj/runtime/SharedLibHelper.java \
 gnu/gcj/runtime/SharedLibLoader.java \
 gnu/gcj/runtime/StackTrace.java \
 gnu/gcj/runtime/StringBuffer.java \
+gnu/gcj/runtime/SystemClassLoader.java \
 gnu/gcj/runtime/VMClassLoader.java \
 gnu/gcj/util/Debug.java \
 gnu/java/io/ASN1ParsingException.java \
index ae0d981fd4c901e1f17573c34123c8a8dd058832..cf43aceabbef3c62e9f0db74ec2cf143a32d0e9e 100644 (file)
@@ -557,6 +557,7 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc link.cc \
        gnu/gcj/runtime/SharedLibLoader.java \
        gnu/gcj/runtime/StackTrace.java \
        gnu/gcj/runtime/StringBuffer.java \
+       gnu/gcj/runtime/SystemClassLoader.java \
        gnu/gcj/runtime/VMClassLoader.java gnu/gcj/util/Debug.java \
        gnu/java/io/ASN1ParsingException.java \
        gnu/java/io/Base64InputStream.java \
@@ -3863,6 +3864,7 @@ am__objects_15 = $(am__objects_9) gnu/classpath/ServiceFactory.lo \
        gnu/gcj/runtime/SharedLibHelper.lo \
        gnu/gcj/runtime/SharedLibLoader.lo \
        gnu/gcj/runtime/StackTrace.lo gnu/gcj/runtime/StringBuffer.lo \
+       gnu/gcj/runtime/SystemClassLoader.lo \
        gnu/gcj/runtime/VMClassLoader.lo gnu/gcj/util/Debug.lo \
        gnu/java/io/ASN1ParsingException.lo \
        gnu/java/io/Base64InputStream.lo \
@@ -7064,6 +7066,7 @@ gnu/gcj/runtime/SharedLibHelper.java \
 gnu/gcj/runtime/SharedLibLoader.java \
 gnu/gcj/runtime/StackTrace.java \
 gnu/gcj/runtime/StringBuffer.java \
+gnu/gcj/runtime/SystemClassLoader.java \
 gnu/gcj/runtime/VMClassLoader.java \
 gnu/gcj/util/Debug.java \
 gnu/java/io/ASN1ParsingException.java \
@@ -9334,6 +9337,8 @@ gnu/gcj/runtime/StackTrace.lo: gnu/gcj/runtime/$(am__dirstamp) \
        gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp)
 gnu/gcj/runtime/StringBuffer.lo: gnu/gcj/runtime/$(am__dirstamp) \
        gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp)
+gnu/gcj/runtime/SystemClassLoader.lo: gnu/gcj/runtime/$(am__dirstamp) \
+       gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp)
 gnu/gcj/runtime/VMClassLoader.lo: gnu/gcj/runtime/$(am__dirstamp) \
        gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp)
 gnu/gcj/util/Debug.lo: gnu/gcj/util/$(am__dirstamp) \
@@ -15834,6 +15839,8 @@ mostlyclean-compile:
        -rm -f gnu/gcj/runtime/StackTrace.lo
        -rm -f gnu/gcj/runtime/StringBuffer.$(OBJEXT)
        -rm -f gnu/gcj/runtime/StringBuffer.lo
+       -rm -f gnu/gcj/runtime/SystemClassLoader.$(OBJEXT)
+       -rm -f gnu/gcj/runtime/SystemClassLoader.lo
        -rm -f gnu/gcj/runtime/VMClassLoader.$(OBJEXT)
        -rm -f gnu/gcj/runtime/VMClassLoader.lo
        -rm -f gnu/gcj/runtime/natFinalizerThread.$(OBJEXT)
@@ -21293,6 +21300,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/SharedLibLoader.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/StackTrace.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/StringBuffer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/SystemClassLoader.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/VMClassLoader.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/natFinalizerThread.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/natNameFinder.Plo@am__quote@
diff --git a/libjava/gnu/gcj/runtime/SystemClassLoader.java b/libjava/gnu/gcj/runtime/SystemClassLoader.java
new file mode 100644 (file)
index 0000000..163d3dd
--- /dev/null
@@ -0,0 +1,57 @@
+/* Copyright (C) 2005  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+package gnu.gcj.runtime;
+
+import java.io.*;
+import java.util.StringTokenizer;
+import java.util.HashSet;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public final class SystemClassLoader extends URLClassLoader
+{
+  SystemClassLoader(ClassLoader parent)
+  {
+    super(new URL[0], parent);
+  }
+
+  // We add the URLs to the system class loader late.  The reason for
+  // this is that during bootstrap we don't want to parse URLs or
+  // create URL connections, since that will result in circularities
+  // causing a crash.
+  void init()
+  {
+    StringTokenizer st
+      = new StringTokenizer (System.getProperty ("java.class.path", "."),
+                            File.pathSeparator);
+    while (st.hasMoreElements ()) 
+      {  
+       String e = st.nextToken ();
+       try
+         {
+           if ("".equals(e))
+             e = ".";
+
+           File path = new File(e);
+           // Ignore invalid paths.
+           if (!path.exists())
+             continue;
+           if (!e.endsWith (File.separator) && path.isDirectory ())
+             addURL(new URL("file", "", -1, e + File.separator));
+           else
+             addURL(new URL("file", "", -1, e));
+         } 
+       catch (java.net.MalformedURLException x)
+         {
+           // This should never happen.
+           throw new RuntimeException(x);
+         }
+      }
+  }
+}
index 2d46ebcb770dfaf17f4f93d50fdc7785e565e3ab..1ded892a06d19927efc3429c14f07ef0dbed5788 100644 (file)
@@ -14,8 +14,12 @@ import java.io.*;
 import java.util.StringTokenizer;
 import java.util.HashSet;
 import java.net.URL;
+import java.net.URLClassLoader;
 
-public final class VMClassLoader extends java.net.URLClassLoader
+// Despite its name, this class is really the extension loader for
+// libgcj.  Class loader bootstrap is a bit tricky, see prims.cc and
+// SystemClassLoader for some details.
+public final class VMClassLoader extends URLClassLoader
 {
   private VMClassLoader ()
   {    
@@ -28,44 +32,17 @@ public final class VMClassLoader extends java.net.URLClassLoader
     else if ("cache".equals(p))
       lib_control = LIB_CACHE;
     else if ("full".equals(p))
-      {
-       // In case we ever want to change the default.
-       lib_control = LIB_FULL;
-      }
-    else
       lib_control = LIB_FULL;
+    else
+      lib_control = LIB_CACHE;
   }
 
   private void init() 
   {
-    StringTokenizer st
-       = new StringTokenizer (System.getProperty ("java.class.path", "."),
-                              System.getProperty ("path.separator", ":"));
-
-    while (st.hasMoreElements ()) 
-      {  
-       String e = st.nextToken ();
-       try
-         {
-           File path = new File(e);
-           // Ignore invalid paths.
-           if (!path.exists())
-             continue;
-           if (!e.endsWith (File.separator) && path.isDirectory ())
-             addURL(new URL("file", "", -1, e + File.separator));
-           else
-             addURL(new URL("file", "", -1, e));
-         } 
-       catch (java.net.MalformedURLException x)
-         {
-           // This should never happen.
-           throw new RuntimeException(x);
-         }
-      }
-
     // Add the contents of the extensions directories.  
-    st = new StringTokenizer (System.getProperty ("java.ext.dirs"),
-                             System.getProperty ("path.separator", ":"));
+    StringTokenizer st
+      = new StringTokenizer (System.getProperty ("java.ext.dirs"),
+                            File.pathSeparator);
 
     try
       {
@@ -91,8 +68,8 @@ public final class VMClassLoader extends java.net.URLClassLoader
             }
          }
 
-       // Add core:/ to the end of the java.class.path so any resources
-       // compiled into this executable may be found.
+       // Add core:/ to the end so any resources compiled into this
+       // executable may be found.
        addURL(new URL("core", "", -1, "/"));
       }
     catch (java.net.MalformedURLException x)
@@ -116,6 +93,7 @@ public final class VMClassLoader extends java.net.URLClassLoader
   static void initialize ()
   {
     instance.init();
+    system_instance.init();
   }
 
   // Define a package for something loaded natively.
@@ -148,6 +126,8 @@ public final class VMClassLoader extends java.net.URLClassLoader
 
   // The only VMClassLoader that can exist.
   static VMClassLoader instance = new VMClassLoader();
+  // The system class loader.
+  static SystemClassLoader system_instance = new SystemClassLoader(instance);
 
   private static final int LIB_FULL = 0;
   private static final int LIB_CACHE = 1;
index 1afda4570ea363d32a5ab5c2fb47abb0cc385cd2..e21bb649542659b6fdad016b05f3502377c3dc6f 100644 (file)
@@ -40,15 +40,19 @@ package java.lang;
 
 import gnu.java.util.EmptyEnumeration;
 import java.lang.reflect.Constructor;
+import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.net.URLClassLoader;
 import java.security.AllPermission;
 import java.security.Permission;
 import java.security.Permissions;
 import java.security.ProtectionDomain;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 /**
  * java.lang.VMClassLoader is a package-private helper for VMs to implement
index e34be99296dee8771a867d2c2560446e7c3bd435..cd98e7e45615edcb850f094de7239a6db28c654c 100644 (file)
@@ -24,6 +24,7 @@ details.  */
 #include <java/lang/VMClassLoader.h>
 #include <java/lang/VMCompiler.h>
 #include <gnu/gcj/runtime/VMClassLoader.h>
+#include <gnu/gcj/runtime/SystemClassLoader.h>
 #include <java/lang/ClassLoader.h>
 #include <java/lang/Class.h>
 #include <java/lang/Throwable.h>
@@ -114,7 +115,7 @@ java::lang::ClassLoader *
 java::lang::VMClassLoader::getSystemClassLoaderInternal()
 {
   _Jv_InitClass (&gnu::gcj::runtime::VMClassLoader::class$);
-  return gnu::gcj::runtime::VMClassLoader::instance;
+  return gnu::gcj::runtime::VMClassLoader::system_instance;
 }
 
 jclass