OSDN Git Service

* java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Only
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Jul 2000 19:31:16 +0000 (19:31 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Jul 2000 19:31:16 +0000 (19:31 +0000)
initialize String fields for interpreted classes.  Fixes bug
reported by Hans Boehm.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35150 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/lang/natClassLoader.cc

index 62dda82..fdbefa7 100644 (file)
@@ -1,5 +1,9 @@
 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.
+
        * java/io/File.java (getParentFile): New method, from Classpath
        via Oskar Liljeblad.
 
index 65da613..54ffc42 100644 (file)
@@ -165,9 +165,7 @@ java::lang::ClassLoader::linkClass0 (java::lang::Class *klass)
 
 #ifdef INTERPRETER
   if (_Jv_IsInterpretedClass (klass))
-    {
-      _Jv_PrepareClass (klass);
-    }
+    _Jv_PrepareClass (klass);
 #endif
 
   _Jv_PrepareCompiledClass (klass);
@@ -230,7 +228,7 @@ java::lang::ClassLoader::findLoadedClass (jstring name)
     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 @@ _Jv_PrepareCompiledClass(jclass klass)
        }
     }
 
-  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 ();
 }