This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Fix registration of array classes
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 19 May 2005 18:22:06 -0400
- Subject: FYI: Fix registration of array classes
We were not correctly registering Array classes with their initiating
classloader. Worse, _Jv_RegisterClass was being called, which should now
only be used for native classes.
There is a small problem in that the first array classes are created
very early during VM bootstrapping, when the bootstrap classloader has
not been constructed yet. This patch works around that by ignoring them,
which probably isn't the right thing to do, but its no worse than what
we were doing already. I've added a FIXME with a suggestion of how this
could be handled.
I'm checking this in.
Bryce
2005-05-19 Bryce McKinlay <mckinlay@redhat.com>
* java/lang/natClassLoader.cc (_Jv_NewClass): Use
_Jv_RegisterInitiatingLoader to register array classes, not
_Jv_RegisterClass.
(_Jv_RegisterInitiatingLoader): Give up if called very early during
bootstrapping. Add a FIXME to handle this case better.
Index: natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.82
diff -u -r1.82 natClassLoader.cc
--- natClassLoader.cc 12 May 2005 01:27:15 -0000 1.82
+++ natClassLoader.cc 19 May 2005 22:17:02 -0000
@@ -127,6 +127,14 @@
{
if (! loader)
loader = java::lang::VMClassLoader::bootLoader;
+ if (! loader)
+ {
+ // Very early in the bootstrap process, the Bootstrap classloader may
+ // not exist yet.
+ // FIXME: We could maintain a list of these and come back and register
+ // them later.
+ return;
+ }
loader->loadedClasses->put(klass->name->toString(), klass);
}
@@ -346,7 +354,7 @@
ret->superclass = superclass;
ret->loader = loader;
- _Jv_RegisterClass (ret);
+ _Jv_RegisterInitiatingLoader (ret, loader);
return ret;
}