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:
Tom Tromey
2006-05-04 15:29:22 +00:00
committed by Tom Tromey
parent 5eedb0ce4e
commit b149e89e77
6 changed files with 67 additions and 16 deletions
+6 -16
View File
@@ -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
@@ -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;
}