diff options
author | Tom Tromey <tromey@redhat.com> | 2005-04-01 19:19:13 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-04-01 19:19:13 +0000 |
commit | ef87438639663154314e2cc5cd692eddaebfc799 (patch) | |
tree | 3d09f5cb569908269df7399fc0b8e4ca62d64f71 | |
parent | 35913faefbd7d9de8847f449ac4fd750b383e75f (diff) | |
download | gcc-ef87438639663154314e2cc5cd692eddaebfc799.zip gcc-ef87438639663154314e2cc5cd692eddaebfc799.tar.gz gcc-ef87438639663154314e2cc5cd692eddaebfc799.tar.bz2 |
natVMClassLoader.cc (getSystemClassLoaderInternal): Updated for name change.
* java/lang/natVMClassLoader.cc (getSystemClassLoaderInternal):
Updated for name change.
(nativeFindClass): New method.
(loadClass): Use nativeFindClass.
* java/lang/natClassLoader.cc (_Jv_FindClass): Use single-argument
form of loadClass.
* java/lang/VMClassLoader.java (tried_libraries, lib_control,
LIB_FULL, LIB_CACHE, LIB_NEVER): New fields from old
VMClassLoader.
(initialize): New method.
(nativeFindClass): Declare.
* gnu/gcj/runtime/natVMClassLoader.cc: Removed.
* gnu/gcj/runtime/VMClassLoader.java: Removed.
* gnu/gcj/runtime/ExtensionClassLoader.java: Renamed from
VMClassLoader.java.
(definePackageForNative): Removed.
(tried_libraries, LIB_CACHE, LIB_FULL, LIB_NEVER, lib_control):
Moved to VMClassLoader.java.
* prims.cc (_Jv_CreateJavaVM): Updated for renaming.
* Makefile.am (gnu/gcj/runtime/ExtensionClassLoader.h): Renamed.
(ordinary_java_source_files): Added ExtensionClassLoader.java,
removed VMClassLoader.java.
(nat_source_files): Removed natVMClassLoader.cc.
From-SVN: r97414
-rw-r--r-- | libjava/ChangeLog | 26 | ||||
-rw-r--r-- | libjava/Makefile.am | 5 | ||||
-rw-r--r-- | libjava/Makefile.in | 35 | ||||
-rw-r--r-- | libjava/gnu/gcj/runtime/ExtensionClassLoader.java | 40 | ||||
-rw-r--r-- | libjava/gnu/gcj/runtime/VMClassLoader.java | 94 | ||||
-rw-r--r-- | libjava/gnu/gcj/runtime/natVMClassLoader.cc | 79 | ||||
-rw-r--r-- | libjava/java/lang/VMClassLoader.java | 36 | ||||
-rw-r--r-- | libjava/java/lang/natClassLoader.cc | 6 | ||||
-rw-r--r-- | libjava/java/lang/natVMClassLoader.cc | 73 | ||||
-rw-r--r-- | libjava/prims.cc | 6 |
10 files changed, 194 insertions, 206 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 996c32a..0b53eaa 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,31 @@ 2005-04-01 Tom Tromey <tromey@redhat.com> + * java/lang/natVMClassLoader.cc (getSystemClassLoaderInternal): + Updated for name change. + (nativeFindClass): New method. + (loadClass): Use nativeFindClass. + * java/lang/natClassLoader.cc (_Jv_FindClass): Use single-argument + form of loadClass. + * java/lang/VMClassLoader.java (tried_libraries, lib_control, + LIB_FULL, LIB_CACHE, LIB_NEVER): New fields from old + VMClassLoader. + (initialize): New method. + (nativeFindClass): Declare. + * gnu/gcj/runtime/natVMClassLoader.cc: Removed. + * gnu/gcj/runtime/VMClassLoader.java: Removed. + * gnu/gcj/runtime/ExtensionClassLoader.java: Renamed from + VMClassLoader.java. + (definePackageForNative): Removed. + (tried_libraries, LIB_CACHE, LIB_FULL, LIB_NEVER, lib_control): + Moved to VMClassLoader.java. + * prims.cc (_Jv_CreateJavaVM): Updated for renaming. + * Makefile.am (gnu/gcj/runtime/ExtensionClassLoader.h): Renamed. + (ordinary_java_source_files): Added ExtensionClassLoader.java, + removed VMClassLoader.java. + (nat_source_files): Removed natVMClassLoader.cc. + +2005-04-01 Tom Tromey <tromey@redhat.com> + * Makefile.in: Rebuilt. * Makefile.am (db_pathtail): Use $(gcc_version), not @gcc_version@. diff --git a/libjava/Makefile.am b/libjava/Makefile.am index f2d197a..7afbe19 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -811,7 +811,7 @@ java/lang/reflect/Proxy$$ProxyType.h: java/lang/reflect/Proxy.class $(GCJH) -classpath '' -bootclasspath $(top_builddir) \ 'java/lang/reflect/Proxy$$ProxyType' -gnu/gcj/runtime/VMClassLoader.h: gnu/gcj/runtime/VMClassLoader.class +gnu/gcj/runtime/ExtensionClassLoader.h: gnu/gcj/runtime/ExtensionClassLoader.class $(GCJH) -classpath '' -bootclasspath $(top_builddir) \ -friend 'class ::java::lang::ClassLoader;' \ $(basename $<) @@ -2991,6 +2991,7 @@ gnu/gcj/io/DefaultMimeTypes.java \ gnu/gcj/io/MimeTypes.java \ gnu/gcj/io/SimpleSHSStream.java \ gnu/gcj/runtime/BootClassLoader.java \ +gnu/gcj/runtime/ExtensionClassLoader.java \ gnu/gcj/runtime/FileDeleter.java \ gnu/gcj/runtime/FinalizerThread.java \ gnu/gcj/runtime/HelperClassLoader.java \ @@ -3001,7 +3002,6 @@ gnu/gcj/runtime/SharedLibHelper.java \ gnu/gcj/runtime/SharedLibLoader.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 \ @@ -3760,7 +3760,6 @@ gnu/gcj/io/shs.cc \ gnu/gcj/runtime/natFinalizerThread.cc \ gnu/gcj/runtime/natSharedLibLoader.cc \ gnu/gcj/runtime/natStringBuffer.cc \ -gnu/gcj/runtime/natVMClassLoader.cc \ gnu/gcj/util/natDebug.cc \ gnu/java/lang/natMainThread.cc \ gnu/java/net/natPlainDatagramSocketImpl.cc \ diff --git a/libjava/Makefile.in b/libjava/Makefile.in index 51787c9..4d959ed 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -338,8 +338,7 @@ am__libgcj0_convenience_la_SOURCES_DIST = prims.cc jni.cc exception.cc \ gnu/gcj/io/natSimpleSHSStream.cc gnu/gcj/io/shs.cc \ gnu/gcj/runtime/natFinalizerThread.cc \ gnu/gcj/runtime/natSharedLibLoader.cc \ - gnu/gcj/runtime/natStringBuffer.cc \ - gnu/gcj/runtime/natVMClassLoader.cc gnu/gcj/util/natDebug.cc \ + gnu/gcj/runtime/natStringBuffer.cc gnu/gcj/util/natDebug.cc \ gnu/java/lang/natMainThread.cc \ gnu/java/net/natPlainDatagramSocketImpl.cc \ gnu/java/net/natPlainSocketImpl.cc \ @@ -548,6 +547,7 @@ am__libgcj0_convenience_la_SOURCES_DIST = prims.cc jni.cc exception.cc \ gnu/gcj/RawDataManaged.java gnu/gcj/io/DefaultMimeTypes.java \ gnu/gcj/io/MimeTypes.java gnu/gcj/io/SimpleSHSStream.java \ gnu/gcj/runtime/BootClassLoader.java \ + gnu/gcj/runtime/ExtensionClassLoader.java \ gnu/gcj/runtime/FileDeleter.java \ gnu/gcj/runtime/FinalizerThread.java \ gnu/gcj/runtime/HelperClassLoader.java \ @@ -557,8 +557,7 @@ am__libgcj0_convenience_la_SOURCES_DIST = prims.cc jni.cc exception.cc \ gnu/gcj/runtime/SharedLibHelper.java \ gnu/gcj/runtime/SharedLibLoader.java \ gnu/gcj/runtime/StringBuffer.java \ - gnu/gcj/runtime/SystemClassLoader.java \ - gnu/gcj/runtime/VMClassLoader.java gnu/gcj/util/Debug.java \ + gnu/gcj/runtime/SystemClassLoader.java gnu/gcj/util/Debug.java \ gnu/java/io/ASN1ParsingException.java \ gnu/java/io/Base64InputStream.java \ gnu/java/io/ClassLoaderObjectInputStream.java \ @@ -2319,8 +2318,7 @@ am__objects_6 = gnu/gcj/natCore.lo \ gnu/gcj/io/natSimpleSHSStream.lo gnu/gcj/io/shs.lo \ gnu/gcj/runtime/natFinalizerThread.lo \ gnu/gcj/runtime/natSharedLibLoader.lo \ - gnu/gcj/runtime/natStringBuffer.lo \ - gnu/gcj/runtime/natVMClassLoader.lo gnu/gcj/util/natDebug.lo \ + gnu/gcj/runtime/natStringBuffer.lo gnu/gcj/util/natDebug.lo \ gnu/java/lang/natMainThread.lo \ gnu/java/net/natPlainDatagramSocketImpl.lo \ gnu/java/net/natPlainSocketImpl.lo \ @@ -3553,6 +3551,7 @@ am__objects_15 = $(am__objects_9) gnu/classpath/ServiceFactory.lo \ gnu/gcj/io/DefaultMimeTypes.lo gnu/gcj/io/MimeTypes.lo \ gnu/gcj/io/SimpleSHSStream.lo \ gnu/gcj/runtime/BootClassLoader.lo \ + gnu/gcj/runtime/ExtensionClassLoader.lo \ gnu/gcj/runtime/FileDeleter.lo \ gnu/gcj/runtime/FinalizerThread.lo \ gnu/gcj/runtime/HelperClassLoader.lo \ @@ -3561,8 +3560,7 @@ am__objects_15 = $(am__objects_9) gnu/classpath/ServiceFactory.lo \ gnu/gcj/runtime/SharedLibHelper.lo \ gnu/gcj/runtime/SharedLibLoader.lo \ gnu/gcj/runtime/StringBuffer.lo \ - gnu/gcj/runtime/SystemClassLoader.lo \ - gnu/gcj/runtime/VMClassLoader.lo gnu/gcj/util/Debug.lo \ + gnu/gcj/runtime/SystemClassLoader.lo gnu/gcj/util/Debug.lo \ gnu/java/io/ASN1ParsingException.lo \ gnu/java/io/Base64InputStream.lo \ gnu/java/io/ClassLoaderObjectInputStream.lo \ @@ -6753,6 +6751,7 @@ gnu/gcj/io/DefaultMimeTypes.java \ gnu/gcj/io/MimeTypes.java \ gnu/gcj/io/SimpleSHSStream.java \ gnu/gcj/runtime/BootClassLoader.java \ +gnu/gcj/runtime/ExtensionClassLoader.java \ gnu/gcj/runtime/FileDeleter.java \ gnu/gcj/runtime/FinalizerThread.java \ gnu/gcj/runtime/HelperClassLoader.java \ @@ -6763,7 +6762,6 @@ gnu/gcj/runtime/SharedLibHelper.java \ gnu/gcj/runtime/SharedLibLoader.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 \ @@ -7517,7 +7515,6 @@ gnu/gcj/io/shs.cc \ gnu/gcj/runtime/natFinalizerThread.cc \ gnu/gcj/runtime/natSharedLibLoader.cc \ gnu/gcj/runtime/natStringBuffer.cc \ -gnu/gcj/runtime/natVMClassLoader.cc \ gnu/gcj/util/natDebug.cc \ gnu/java/lang/natMainThread.cc \ gnu/java/net/natPlainDatagramSocketImpl.cc \ @@ -8227,8 +8224,6 @@ gnu/gcj/runtime/natSharedLibLoader.lo: \ gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) gnu/gcj/runtime/natStringBuffer.lo: gnu/gcj/runtime/$(am__dirstamp) \ gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) -gnu/gcj/runtime/natVMClassLoader.lo: gnu/gcj/runtime/$(am__dirstamp) \ - gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) gnu/gcj/util/$(am__dirstamp): @$(mkdir_p) gnu/gcj/util @: > gnu/gcj/util/$(am__dirstamp) @@ -9045,6 +9040,9 @@ gnu/gcj/io/SimpleSHSStream.lo: gnu/gcj/io/$(am__dirstamp) \ gnu/gcj/io/$(DEPDIR)/$(am__dirstamp) gnu/gcj/runtime/BootClassLoader.lo: gnu/gcj/runtime/$(am__dirstamp) \ gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) +gnu/gcj/runtime/ExtensionClassLoader.lo: \ + gnu/gcj/runtime/$(am__dirstamp) \ + gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) gnu/gcj/runtime/FileDeleter.lo: gnu/gcj/runtime/$(am__dirstamp) \ gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) gnu/gcj/runtime/FinalizerThread.lo: gnu/gcj/runtime/$(am__dirstamp) \ @@ -9065,8 +9063,6 @@ 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) \ gnu/gcj/util/$(DEPDIR)/$(am__dirstamp) gnu/java/io/$(am__dirstamp): @@ -14851,6 +14847,8 @@ mostlyclean-compile: -rm -f gnu/gcj/natCore.lo -rm -f gnu/gcj/runtime/BootClassLoader.$(OBJEXT) -rm -f gnu/gcj/runtime/BootClassLoader.lo + -rm -f gnu/gcj/runtime/ExtensionClassLoader.$(OBJEXT) + -rm -f gnu/gcj/runtime/ExtensionClassLoader.lo -rm -f gnu/gcj/runtime/FileDeleter.$(OBJEXT) -rm -f gnu/gcj/runtime/FileDeleter.lo -rm -f gnu/gcj/runtime/FinalizerThread.$(OBJEXT) @@ -14871,16 +14869,12 @@ mostlyclean-compile: -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) -rm -f gnu/gcj/runtime/natFinalizerThread.lo -rm -f gnu/gcj/runtime/natSharedLibLoader.$(OBJEXT) -rm -f gnu/gcj/runtime/natSharedLibLoader.lo -rm -f gnu/gcj/runtime/natStringBuffer.$(OBJEXT) -rm -f gnu/gcj/runtime/natStringBuffer.lo - -rm -f gnu/gcj/runtime/natVMClassLoader.$(OBJEXT) - -rm -f gnu/gcj/runtime/natVMClassLoader.lo -rm -f gnu/gcj/tools/gcj_dbtool/Main.$(OBJEXT) -rm -f gnu/gcj/tools/gcj_dbtool/natMain.$(OBJEXT) -rm -f gnu/gcj/util/Debug.$(OBJEXT) @@ -19828,6 +19822,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/io/$(DEPDIR)/natSimpleSHSStream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/io/$(DEPDIR)/shs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/BootClassLoader.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/ExtensionClassLoader.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/FileDeleter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/FinalizerThread.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/HelperClassLoader.Plo@am__quote@ @@ -19838,11 +19833,9 @@ 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)/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)/natSharedLibLoader.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/natStringBuffer.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/runtime/$(DEPDIR)/natVMClassLoader.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/tools/gcj_dbtool/$(DEPDIR)/Main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/tools/gcj_dbtool/$(DEPDIR)/natMain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/gcj/util/$(DEPDIR)/Debug.Plo@am__quote@ @@ -24245,7 +24238,7 @@ java/lang/reflect/Proxy$$ProxyType.h: java/lang/reflect/Proxy.class $(GCJH) -classpath '' -bootclasspath $(top_builddir) \ 'java/lang/reflect/Proxy$$ProxyType' -gnu/gcj/runtime/VMClassLoader.h: gnu/gcj/runtime/VMClassLoader.class +gnu/gcj/runtime/ExtensionClassLoader.h: gnu/gcj/runtime/ExtensionClassLoader.class $(GCJH) -classpath '' -bootclasspath $(top_builddir) \ -friend 'class ::java::lang::ClassLoader;' \ $(basename $<) diff --git a/libjava/gnu/gcj/runtime/ExtensionClassLoader.java b/libjava/gnu/gcj/runtime/ExtensionClassLoader.java new file mode 100644 index 0000000..690143a --- /dev/null +++ b/libjava/gnu/gcj/runtime/ExtensionClassLoader.java @@ -0,0 +1,40 @@ +/* Copyright (C) 1999, 2001, 2002, 2003, 2004, 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. */ + +/* Author: Kresten Krab Thorup <krab@gnu.org> */ + +package gnu.gcj.runtime; + +import java.net.URL; + +// The extension loader for libgcj. Class loader bootstrap is a bit +// tricky, see prims.cc and SystemClassLoader for some details. +public final class ExtensionClassLoader extends HelperClassLoader +{ + private ExtensionClassLoader () + { + } + + private void init() + { + addDirectoriesFromProperty("java.ext.dirs"); + } + + // This can be package-private because we only call it from native + // code during startup. + static void initialize () + { + instance.init(); + system_instance.init(); + } + + // The only ExtensionClassLoader that can exist. + static ExtensionClassLoader instance = new ExtensionClassLoader(); + // The system class loader. + static SystemClassLoader system_instance = new SystemClassLoader(instance); +} diff --git a/libjava/gnu/gcj/runtime/VMClassLoader.java b/libjava/gnu/gcj/runtime/VMClassLoader.java deleted file mode 100644 index 1ed0c02..0000000 --- a/libjava/gnu/gcj/runtime/VMClassLoader.java +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 1999, 2001, 2002, 2003, 2004, 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. */ - -/* Author: Kresten Krab Thorup <krab@gnu.org> */ - -package gnu.gcj.runtime; - -import java.net.URL; -import java.util.HashSet; - -// 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 HelperClassLoader -{ - private VMClassLoader () - { - String p - = System.getProperty ("gnu.gcj.runtime.VMClassLoader.library_control", - ""); - if ("never".equals(p)) - lib_control = LIB_NEVER; - else if ("cache".equals(p)) - lib_control = LIB_CACHE; - else if ("full".equals(p)) - lib_control = LIB_FULL; - else - lib_control = LIB_CACHE; - } - - private void init() - { - addDirectoriesFromProperty("java.ext.dirs"); - } - - /** This is overridden to search the internal hash table, which - * will only search existing linked-in classes. This will make - * the default implementation of loadClass (in ClassLoader) work right. - * The implementation of this method is in - * gnu/gcj/runtime/natVMClassLoader.cc. - */ - 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(); - system_instance.init(); - } - - // Define a package for something loaded natively. - void definePackageForNative(String className) - { - int lastDot = className.lastIndexOf('.'); - if (lastDot != -1) - { - String packageName = className.substring(0, lastDot); - if (getPackage(packageName) == null) - { - // FIXME: this assumes we're defining the core, which - // isn't necessarily so. We could detect this and set up - // appropriately. We could also look at a manifest file - // compiled into the .so. - definePackage(packageName, "Java Platform API Specification", - "GNU", "1.4", "gcj", "GNU", - null, // FIXME: gcj version. - null); - } - } - } - - // This keeps track of shared libraries we've already tried to load. - private HashSet tried_libraries = new HashSet(); - - // Holds one of the LIB_* constants; used to determine how shared - // library loads are done. - private int lib_control; - - // 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; - private static final int LIB_NEVER = 2; -} diff --git a/libjava/gnu/gcj/runtime/natVMClassLoader.cc b/libjava/gnu/gcj/runtime/natVMClassLoader.cc deleted file mode 100644 index 7f2ee34..0000000 --- a/libjava/gnu/gcj/runtime/natVMClassLoader.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Native code for VMClassLoader - -/* Copyright (C) 2002, 2003, 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. */ - -#include <config.h> - -#include <gcj/cni.h> -#include <jvm.h> - -#include <gnu/gcj/runtime/VMClassLoader.h> -#include <java/lang/Class.h> -#include <java/lang/StringBuffer.h> -#include <java/net/URLClassLoader.h> -#include <java/lang/Runtime.h> -#include <java/util/HashSet.h> - -jclass -gnu::gcj::runtime::VMClassLoader::findClass (jstring name) -{ - _Jv_Utf8Const *name_u = _Jv_makeUtf8Const (name); - jclass klass = _Jv_FindClassInCache (name_u); - - if (! klass && lib_control != LIB_NEVER) - { - // Turn `gnu.pkg.quux' into `lib-gnu-pkg-quux'. Then search for - // a module named (eg, on Linux) `lib-gnu-pkg-quux.so', followed - // by `lib-gnu-pkg.so' and `lib-gnu.so'. If loading one of - // these causes the class to appear in the cache, then use it. - java::lang::StringBuffer *sb = new java::lang::StringBuffer (JvNewStringLatin1("lib-")); - // Skip inner classes - jstring cn; - jint ci = name->indexOf('$'); - if (ci == -1) - cn = name; - else - cn = name->substring (0, ci); - jstring so_base_name = (sb->append (cn)->toString ())->replace ('.', '-'); - - using namespace ::java::lang; - Runtime *rt = Runtime::getRuntime(); - - // Compare against `3' because that is the length of "lib". - while (! klass && so_base_name && so_base_name->length() > 3) - { - if (lib_control == LIB_CACHE) - { - // If we've already tried this name, we're done. - if (tried_libraries->contains(so_base_name)) - break; - tried_libraries->add(so_base_name); - } - - jboolean loaded = rt->loadLibraryInternal (so_base_name); - - jint nd = so_base_name->lastIndexOf ('-'); - if (nd == -1) - so_base_name = NULL; - else - so_base_name = so_base_name->substring (0, nd); - - if (loaded) - klass = _Jv_FindClassInCache (name_u); - } - } - - // Either define the package, or try loading using the interpreter. - if (klass) - definePackageForNative(name); - else - klass = java::net::URLClassLoader::findClass (name); - - return klass; -} diff --git a/libjava/java/lang/VMClassLoader.java b/libjava/java/lang/VMClassLoader.java index dfbfba4..c48fc70 100644 --- a/libjava/java/lang/VMClassLoader.java +++ b/libjava/java/lang/VMClassLoader.java @@ -51,6 +51,7 @@ import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.StringTokenizer; import gnu.gcj.runtime.BootClassLoader; @@ -87,6 +88,17 @@ final class VMClassLoader // until we've initialized the system, at which point it is created. static BootClassLoader bootLoader; + // This keeps track of shared libraries we've already tried to load. + private static HashSet tried_libraries; + + // Holds one of the LIB_* constants; used to determine how shared + // library loads are done. + private static int lib_control; + + private static final int LIB_FULL = 0; + private static final int LIB_CACHE = 1; + private static final int LIB_NEVER = 2; + /** * Helper to define a class using a string of bytes. This assumes that * the security checks have already been performed, if necessary. @@ -298,6 +310,30 @@ final class VMClassLoader static native void initBootLoader(String libdir); + static void initialize(String libdir) + { + initBootLoader(libdir); + + String p + = System.getProperty ("gnu.gcj.runtime.VMClassLoader.library_control", + ""); + if ("never".equals(p)) + lib_control = LIB_NEVER; + else if ("cache".equals(p)) + lib_control = LIB_CACHE; + else if ("full".equals(p)) + lib_control = LIB_FULL; + else + lib_control = LIB_CACHE; + + tried_libraries = new HashSet(); + } + + /** + * Possibly load a .so and search it for classes. + */ + static native Class nativeFindClass(String name); + static ClassLoader getSystemClassLoader() { // This method is called as the initialization of systemClassLoader, diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index c3b1f7e..00292f9 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -26,7 +26,6 @@ details. */ #include <java/lang/Character.h> #include <java/lang/Thread.h> #include <java/lang/ClassLoader.h> -#include <gnu/gcj/runtime/VMClassLoader.h> #include <java/lang/InternalError.h> #include <java/lang/IllegalAccessError.h> #include <java/lang/LinkageError.h> @@ -226,8 +225,9 @@ _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader) { if (loader) { - // Load using a user-defined loader, jvmspec 5.3.2 - klass = loader->loadClass(sname, false); + // Load using a user-defined loader, jvmspec 5.3.2. + // Note that we explicitly must call the single-argument form. + klass = loader->loadClass(sname); // If "loader" delegated the loadClass operation to another // loader, explicitly register that it is also an initiating diff --git a/libjava/java/lang/natVMClassLoader.cc b/libjava/java/lang/natVMClassLoader.cc index c59e1d6..e6c3b94 100644 --- a/libjava/java/lang/natVMClassLoader.cc +++ b/libjava/java/lang/natVMClassLoader.cc @@ -23,7 +23,7 @@ details. */ #include <java/lang/VMClassLoader.h> #include <java/lang/VMCompiler.h> -#include <gnu/gcj/runtime/VMClassLoader.h> +#include <gnu/gcj/runtime/ExtensionClassLoader.h> #include <gnu/gcj/runtime/SystemClassLoader.h> #include <gnu/gcj/runtime/BootClassLoader.h> #include <java/lang/ClassLoader.h> @@ -31,6 +31,9 @@ details. */ #include <java/lang/Throwable.h> #include <java/security/ProtectionDomain.h> #include <java/lang/ClassFormatError.h> +#include <java/lang/StringBuffer.h> +#include <java/lang/Runtime.h> +#include <java/util/HashSet.h> void java::lang::VMClassLoader::resolveClass (jclass klass) @@ -110,8 +113,8 @@ java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader, java::lang::ClassLoader * java::lang::VMClassLoader::getSystemClassLoaderInternal() { - _Jv_InitClass (&gnu::gcj::runtime::VMClassLoader::class$); - return gnu::gcj::runtime::VMClassLoader::system_instance; + _Jv_InitClass (&gnu::gcj::runtime::ExtensionClassLoader::class$); + return gnu::gcj::runtime::ExtensionClassLoader::system_instance; } jclass @@ -130,6 +133,68 @@ java::lang::VMClassLoader::initBootLoader(jstring libdir) } jclass +java::lang::VMClassLoader::nativeFindClass (jstring name) +{ + jclass klass = NULL; + + if (lib_control != LIB_NEVER) + { + // Turn `gnu.pkg.quux' into `lib-gnu-pkg-quux'. Then search for + // a module named (eg, on Linux) `lib-gnu-pkg-quux.so', followed + // by `lib-gnu-pkg.so' and `lib-gnu.so'. If loading one of + // these causes the class to appear in the cache, then use it. + java::lang::StringBuffer *sb + = new java::lang::StringBuffer (JvNewStringLatin1("lib-")); + // Skip inner classes + jstring cn; + jint ci = name->indexOf('$'); + if (ci == -1) + cn = name; + else + cn = name->substring (0, ci); + jstring so_base_name + = (sb->append (cn)->toString ())->replace ('.', '-'); + + using namespace ::java::lang; + Runtime *rt = Runtime::getRuntime(); + + _Jv_Utf8Const *name_u = NULL; + + // Compare against `3' because that is the length of "lib". + while (! klass && so_base_name && so_base_name->length() > 3) + { + if (lib_control == LIB_CACHE) + { + // If we've already tried this name, we're done. + if (tried_libraries->contains(so_base_name)) + break; + tried_libraries->add(so_base_name); + } + + jboolean loaded = rt->loadLibraryInternal (so_base_name); + + jint nd = so_base_name->lastIndexOf ('-'); + if (nd == -1) + so_base_name = NULL; + else + so_base_name = so_base_name->substring (0, nd); + + if (loaded) + { + if (name_u == NULL) + name_u = _Jv_makeUtf8Const (name); + klass = _Jv_FindClassInCache (name_u); + } + } + } + + if (klass) + definePackageForNative(name); + + return klass; +} + +jclass java::lang::VMClassLoader::loadClass(jstring name, jboolean resolve) { // We try the boot loader first, so that the endorsed directory @@ -142,6 +207,8 @@ java::lang::VMClassLoader::loadClass(jstring name, jboolean resolve) _Jv_Utf8Const *utf = _Jv_makeUtf8Const (name); klass = _Jv_FindClassInCache (utf); } + if (! klass) + klass = nativeFindClass(name); if (klass) { // We never want to return a class without its supers linked. diff --git a/libjava/prims.cc b/libjava/prims.cc index a916edd..5643902 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -60,7 +60,7 @@ details. */ #include <java/io/PrintStream.h> #include <java/lang/UnsatisfiedLinkError.h> #include <java/lang/VirtualMachineError.h> -#include <gnu/gcj/runtime/VMClassLoader.h> +#include <gnu/gcj/runtime/ExtensionClassLoader.h> #include <gnu/gcj/runtime/FinalizerThread.h> #include <execution.h> #include <gnu/java/lang/MainThread.h> @@ -1132,8 +1132,8 @@ _Jv_CreateJavaVM (JvVMInitArgs* vm_args) _Jv_InitClass (&java::lang::ClassLoader::class$); // Set up the system class loader and the bootstrap class loader. - gnu::gcj::runtime::VMClassLoader::initialize(); - java::lang::VMClassLoader::initBootLoader(JvNewStringLatin1(TOOLEXECLIBDIR)); + gnu::gcj::runtime::ExtensionClassLoader::initialize(); + java::lang::VMClassLoader::initialize(JvNewStringLatin1(TOOLEXECLIBDIR)); _Jv_RegisterBootstrapPackages(); |