defineclass.cc (handleClassBegin): Use _Jv_RegisterInitiatingLoader.

* defineclass.cc (handleClassBegin): Use
	_Jv_RegisterInitiatingLoader.
	* java/lang/Class.h (_Jv_UnregisterInitiatingLoader): Declare.
	* java/lang/natVMClassLoader.cc (resolveClass): Don't register
	class.  Use _Jv_UnregisterInitiatingLoader.
	* java/lang/natClassLoader.cc (_Jv_UnregisterInitiatingLoader):
	New function.

From-SVN: r94717
This commit is contained in:
Tom Tromey 2005-02-07 21:29:04 +00:00 committed by Tom Tromey
parent b0ad2de203
commit f55db9c2fc
5 changed files with 30 additions and 15 deletions

View File

@ -1,3 +1,13 @@
2005-02-07 Tom Tromey <tromey@redhat.com>
* defineclass.cc (handleClassBegin): Use
_Jv_RegisterInitiatingLoader.
* java/lang/Class.h (_Jv_UnregisterInitiatingLoader): Declare.
* java/lang/natVMClassLoader.cc (resolveClass): Don't register
class. Use _Jv_UnregisterInitiatingLoader.
* java/lang/natClassLoader.cc (_Jv_UnregisterInitiatingLoader):
New function.
2005-02-07 Mark Wielaard <mark@klomp.org>
Reported by Timo Lindfors <timo.lindfors@iki.fi>

View File

@ -908,16 +908,14 @@ _Jv_ClassReader::handleClassBegin (int access_flags, int this_class, int super_c
throw_no_class_def_found_error ("loading java.lang.Object");
}
// In the pre-loading state, it can be looked up in the
// cache only by this thread! This allows the super-class
// to include references to this class.
def->state = JV_STATE_PRELOADING;
{
JvSynchronize sync (&java::lang::Class::class$);
_Jv_RegisterClass (def);
}
// Register this class with its defining loader as well (despite the
// name of the function we're calling), so that super class lookups
// work properly. If there is an error, our caller will unregister
// this class from the class loader. Also, we don't need to hold a
// lock here, as our caller has acquired it.
_Jv_RegisterInitiatingLoader (def, def->loader);
if (super_class != 0)
{

View File

@ -212,6 +212,7 @@ class java::io::ObjectStreamClass;
void _Jv_RegisterClassHookDefault (jclass klass);
void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
void _Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
void _Jv_UnregisterClass (jclass);
jclass _Jv_FindClass (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);
@ -436,6 +437,7 @@ private:
size_t count);
friend void ::_Jv_RegisterClassHookDefault (jclass klass);
friend void ::_Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
friend void ::_Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
friend void ::_Jv_UnregisterClass (jclass);
friend jclass (::_Jv_FindClass) (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);

View File

@ -110,6 +110,16 @@ _Jv_RegisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
loader->loadedClasses->put(klass->name->toString(), klass);
}
// If we found an error while defining an interpreted class, we must
// go back and unregister it.
void
_Jv_UnregisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
{
if (! loader)
loader = java::lang::ClassLoader::getSystemClassLoader();
loader->loadedClasses->remove(klass->name->toString());
}
// This function is called many times during startup, before main() is
// run. At that point in time we know for certain we are running
// single-threaded, so we don't need to lock when adding classes to the

View File

@ -57,13 +57,8 @@ java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader,
jclass klass = VMCompiler::compileClass(loader, name, data,
offset, length, pd);
if (klass != NULL)
{
JvSynchronize sync (&java::lang::Class::class$);
_Jv_RegisterClass (klass);
}
#ifdef INTERPRETER
else
if (klass == NULL)
{
klass = new java::lang::Class ();
@ -96,7 +91,7 @@ java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader,
klass->state = JV_STATE_ERROR;
klass->notifyAll ();
_Jv_UnregisterClass (klass);
_Jv_UnregisterInitiatingLoader (klass, klass->loader);
// If EX is not a ClassNotFoundException, that's ok, because we
// account for the possibility in defineClass().