natClassLoader.cc (_Jv_PrepareCompiledClass): Initialize static final String fields.
authorTom Tromey <tromey@cygnus.com>
Fri, 7 Jul 2000 20:54:32 +0000 (20:54 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Fri, 7 Jul 2000 20:54:32 +0000 (20:54 +0000)
* java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass):
Initialize static final String fields.

From-SVN: r34910

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

index e0ac2f31b91d0b3b9d529f25f3fe3b701fb99a7c..779aef4184219af99d6cc4080d6585b1215b8755 100644 (file)
@@ -1,3 +1,8 @@
+2000-07-06  Tom Tromey  <tromey@cygnus.com>
+
+       * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass):
+       Initialize static final String fields.
+
 2000-07-03  Tom Tromey  <tromey@cygnus.com>
 
        * java/io/PrintWriter.java (print): Call write(String), not
index b4a9e49b71c1126720a0bb44df30c0c9feaa8e98..65da6135787d1edef6a87afd877a3300f2db0848 100644 (file)
@@ -261,7 +261,6 @@ _Jv_PrepareCompiledClass(jclass klass)
          pool->data[index].clazz = found;
          pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
        }
-           
       else if (pool->tags[index] == JV_CONSTANT_String)
        {
          jstring str;
@@ -271,6 +270,24 @@ _Jv_PrepareCompiledClass(jclass klass)
        }
     }
 
+  jfieldID f = JvGetFirstStaticField (klass);
+  for (int n = JvNumStaticFields (klass); n > 0; --n)
+    {
+      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 ();
+    }
+
   klass->notifyAll ();
 }