Class.h (JV_STATE_LOADING): Added comment.
* java/lang/Class.h (JV_STATE_LOADING): Added comment. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natSystemClassLoader.cc. * gnu/gcj/runtime/natSystemClassLoader.cc: New file. * gnu/gcj/runtime/SystemClassLoader.java (nativeClasses): New field. (loadedClasses): Removed. (findClass): Declare. (addClass): Add to nativeClasses, not loadedClasses. From-SVN: r113530
This commit is contained in:
parent
5eedb0ce4e
commit
b149e89e77
@ -1,3 +1,15 @@
|
||||
2006-05-04 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* java/lang/Class.h (JV_STATE_LOADING): Added comment.
|
||||
* Makefile.in: Rebuilt.
|
||||
* Makefile.am (nat_source_files): Added natSystemClassLoader.cc.
|
||||
* gnu/gcj/runtime/natSystemClassLoader.cc: New file.
|
||||
* gnu/gcj/runtime/SystemClassLoader.java (nativeClasses):
|
||||
New field.
|
||||
(loadedClasses): Removed.
|
||||
(findClass): Declare.
|
||||
(addClass): Add to nativeClasses, not loadedClasses.
|
||||
|
||||
2006-05-04 Andrew Haley <aph@redhat.com>
|
||||
|
||||
PR java/26858
|
||||
|
@ -783,6 +783,7 @@ gnu/gcj/io/natSimpleSHSStream.cc \
|
||||
gnu/gcj/io/shs.cc \
|
||||
gnu/gcj/runtime/natFinalizerThread.cc \
|
||||
gnu/gcj/runtime/natSharedLibLoader.cc \
|
||||
gnu/gcj/runtime/natSystemClassLoader.cc \
|
||||
gnu/gcj/runtime/natStringBuffer.cc \
|
||||
gnu/gcj/util/natDebug.cc \
|
||||
gnu/java/lang/natMainThread.cc \
|
||||
|
@ -254,6 +254,7 @@ am__libgcj_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/natSystemClassLoader.cc \
|
||||
gnu/gcj/runtime/natStringBuffer.cc gnu/gcj/util/natDebug.cc \
|
||||
gnu/java/lang/natMainThread.cc \
|
||||
gnu/java/net/natPlainDatagramSocketImpl.cc \
|
||||
@ -294,6 +295,7 @@ am__objects_2 = gnu/classpath/natSystemProperties.lo \
|
||||
gnu/gcj/io/natSimpleSHSStream.lo gnu/gcj/io/shs.lo \
|
||||
gnu/gcj/runtime/natFinalizerThread.lo \
|
||||
gnu/gcj/runtime/natSharedLibLoader.lo \
|
||||
gnu/gcj/runtime/natSystemClassLoader.lo \
|
||||
gnu/gcj/runtime/natStringBuffer.lo gnu/gcj/util/natDebug.lo \
|
||||
gnu/java/lang/natMainThread.lo \
|
||||
gnu/java/net/natPlainDatagramSocketImpl.lo \
|
||||
@ -6749,6 +6751,7 @@ gnu/gcj/io/natSimpleSHSStream.cc \
|
||||
gnu/gcj/io/shs.cc \
|
||||
gnu/gcj/runtime/natFinalizerThread.cc \
|
||||
gnu/gcj/runtime/natSharedLibLoader.cc \
|
||||
gnu/gcj/runtime/natSystemClassLoader.cc \
|
||||
gnu/gcj/runtime/natStringBuffer.cc \
|
||||
gnu/gcj/util/natDebug.cc \
|
||||
gnu/java/lang/natMainThread.cc \
|
||||
@ -7084,6 +7087,9 @@ gnu/gcj/runtime/natFinalizerThread.lo: \
|
||||
gnu/gcj/runtime/natSharedLibLoader.lo: \
|
||||
gnu/gcj/runtime/$(am__dirstamp) \
|
||||
gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp)
|
||||
gnu/gcj/runtime/natSystemClassLoader.lo: \
|
||||
gnu/gcj/runtime/$(am__dirstamp) \
|
||||
gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp)
|
||||
gnu/gcj/runtime/natStringBuffer.lo: gnu/gcj/runtime/$(am__dirstamp) \
|
||||
gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp)
|
||||
gnu/gcj/util/$(am__dirstamp):
|
||||
@ -7415,6 +7421,8 @@ mostlyclean-compile:
|
||||
-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/natSystemClassLoader.$(OBJEXT)
|
||||
-rm -f gnu/gcj/runtime/natSystemClassLoader.lo
|
||||
-rm -f gnu/gcj/tools/gcj_dbtool/Main.$(OBJEXT)
|
||||
-rm -f gnu/gcj/tools/gcj_dbtool/natMain.$(OBJEXT)
|
||||
-rm -f gnu/gcj/util/natDebug.$(OBJEXT)
|
||||
@ -7588,6 +7596,7 @@ distclean-compile:
|
||||
@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)/natSystemClassLoader.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)/natDebug.Plo@am__quote@
|
||||
|
@ -22,7 +22,9 @@ public final class SystemClassLoader extends URLClassLoader
|
||||
super(new URL[0], parent);
|
||||
}
|
||||
|
||||
private HashMap loadedClasses;
|
||||
// This holds all the "native" classes linked into the executable
|
||||
// and registered with this loader.
|
||||
private HashMap nativeClasses = new HashMap();
|
||||
|
||||
// This is called to register a native class which was linked into
|
||||
// the application but which is registered with the system class
|
||||
@ -42,23 +44,11 @@ public final class SystemClassLoader extends URLClassLoader
|
||||
}
|
||||
|
||||
// Use reflection to access the package-private "loadedClasses" field.
|
||||
if (this.loadedClasses == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class cl = java.lang.ClassLoader.class;
|
||||
Field lcField = cl.getDeclaredField("loadedClasses");
|
||||
lcField.setAccessible(true);
|
||||
this.loadedClasses = (HashMap) lcField.get(this);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
}
|
||||
this.loadedClasses.put(className, klass);
|
||||
nativeClasses.put(className, klass);
|
||||
}
|
||||
|
||||
protected native Class findClass(String name);
|
||||
|
||||
// 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
|
||||
|
31
libjava/gnu/gcj/runtime/natSystemClassLoader.cc
Normal file
31
libjava/gnu/gcj/runtime/natSystemClassLoader.cc
Normal file
@ -0,0 +1,31 @@
|
||||
// natSystemClassLoader.cc - native code for system class loader
|
||||
|
||||
/* Copyright (C) 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 <platform.h>
|
||||
|
||||
#include <gcj/cni.h>
|
||||
#include <jvm.h>
|
||||
#include <execution.h>
|
||||
|
||||
#include <gnu/gcj/runtime/SystemClassLoader.h>
|
||||
#include <java/lang/ClassNotFoundException.h>
|
||||
#include <java/util/HashMap.h>
|
||||
|
||||
jclass
|
||||
gnu::gcj::runtime::SystemClassLoader::findClass (jstring name)
|
||||
{
|
||||
jclass result = (jclass) nativeClasses->get(name);
|
||||
if (! result)
|
||||
return URLClassLoader::findClass(name);
|
||||
// Never return a class whose supers are not installed.
|
||||
_Jv_Linker::wait_for_state (result, JV_STATE_LOADING);
|
||||
return result;
|
||||
}
|
@ -59,6 +59,14 @@ enum
|
||||
JV_STATE_NOTHING = 0, // Set by compiler.
|
||||
|
||||
JV_STATE_PRELOADING = 1, // Can do _Jv_FindClass.
|
||||
|
||||
// There is an invariant through libgcj that a class will always be
|
||||
// at a state greater than or equal to JV_STATE_LOADING when it is
|
||||
// returned by a class loader to user code. Hence, defineclass.cc
|
||||
// installs supers before returning a class, C++-ABI-compiled
|
||||
// classes are created with supers installed, and BC-ABI-compiled
|
||||
// classes are linked to this state before being returned by their
|
||||
// class loader.
|
||||
JV_STATE_LOADING = 3, // Has super installed.
|
||||
JV_STATE_READ = 4, // Has been completely defined.
|
||||
JV_STATE_LOADED = 5, // Has Miranda methods defined.
|
||||
|
Loading…
Reference in New Issue
Block a user