Patch: ClassLoader fix
Tom Tromey
tromey@cygnus.com
Thu Jul 20 12:31:00 GMT 2000
I'm checking this in. It fixes a bug in a previous patch of mine.
Apparently _Jv_PrepareCompiledClass is called for interpreted classes
as well. Instead of trying to understand this, I decide to fix it in
a simplistic way. Class loading and initialization needs a serious
overhaul.
2000-07-20 Tom Tromey <tromey@cygnus.com>
* java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Only
initialize String fields for interpreted classes. Fixes bug
reported by Hans Boehm.
Tom
Index: java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.24
diff -u -r1.24 natClassLoader.cc
--- natClassLoader.cc 2000/07/07 20:54:32 1.24
+++ natClassLoader.cc 2000/07/20 19:29:52
@@ -165,9 +165,7 @@
#ifdef INTERPRETER
if (_Jv_IsInterpretedClass (klass))
- {
- _Jv_PrepareClass (klass);
- }
+ _Jv_PrepareClass (klass);
#endif
_Jv_PrepareCompiledClass (klass);
@@ -230,7 +228,7 @@
lives in resolve.cc which is entirely conditionally compiled.
*/
void
-_Jv_PrepareCompiledClass(jclass klass)
+_Jv_PrepareCompiledClass (jclass klass)
{
if (klass->state >= JV_STATE_LINKED)
return;
@@ -270,23 +268,33 @@
}
}
- jfieldID f = JvGetFirstStaticField (klass);
- for (int n = JvNumStaticFields (klass); n > 0; --n)
+#ifdef INTERPRETER
+ // FIXME: although the comment up top says that this function is
+ // only called for compiled classes, it is actually called for every
+ // class.
+ if (! _Jv_IsInterpretedClass (klass))
{
- int mod = f->getModifiers ();
- // Maybe the compiler should mark these with
- // _Jv_FIELD_CONSTANT_VALUE? For now we just know that this
- // only happens for constant strings.
- if (f->getClass () == &StringClass
- && java::lang::reflect::Modifier::isStatic (mod)
- && java::lang::reflect::Modifier::isFinal (mod))
+#endif /* INTERPRETER */
+ jfieldID f = JvGetFirstStaticField (klass);
+ for (int n = JvNumStaticFields (klass); n > 0; --n)
{
- jstring *strp = (jstring *) f->u.addr;
- if (*strp)
- *strp = _Jv_NewStringUtf8Const ((_Jv_Utf8Const *) *strp);
+ int mod = f->getModifiers ();
+ // Maybe the compiler should mark these with
+ // _Jv_FIELD_CONSTANT_VALUE? For now we just know that this
+ // only happens for constant strings.
+ if (f->getClass () == &StringClass
+ && java::lang::reflect::Modifier::isStatic (mod)
+ && java::lang::reflect::Modifier::isFinal (mod))
+ {
+ jstring *strp = (jstring *) f->u.addr;
+ if (*strp)
+ *strp = _Jv_NewStringUtf8Const ((_Jv_Utf8Const *) *strp);
+ }
+ f = f->getNextField ();
}
- f = f->getNextField ();
+#ifdef INTERPRETER
}
+#endif /* INTERPRETER */
klass->notifyAll ();
}
More information about the Java-patches
mailing list