diff options
Diffstat (limited to 'libjava/jni.cc')
-rw-r--r-- | libjava/jni.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libjava/jni.cc b/libjava/jni.cc index a4a12a8..7b682f1 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -1068,8 +1068,13 @@ _Jv_JNI_GetAnyFieldID (JNIEnv *env, jclass clazz, // FIXME: what if field_class == NULL? + java::lang::ClassLoader *loader = clazz->getClassLoader (); while (clazz != NULL) { + // We acquire the class lock so that fields aren't resolved + // while we are running. + JvSynchronize sync (clazz); + jint count = (is_static ? JvNumStaticFields (clazz) : JvNumInstanceFields (clazz)); @@ -1078,12 +1083,11 @@ _Jv_JNI_GetAnyFieldID (JNIEnv *env, jclass clazz, : JvGetFirstInstanceField (clazz)); for (jint i = 0; i < count; ++i) { - // The field is resolved as a side effect of class - // initialization. - JvAssert (field->isResolved ()); - _Jv_Utf8Const *f_name = field->getNameUtf8Const(clazz); + // The field might be resolved or it might not be. It + // is much simpler to always resolve it. + _Jv_ResolveField (field, loader); if (_Jv_equalUtf8Consts (f_name, a_name) && field->getClass() == field_class) return field; |