diff options
Diffstat (limited to 'runtime/native')
| -rw-r--r-- | runtime/native/java_lang_Class.cc | 5 | ||||
| -rw-r--r-- | runtime/native/java_lang_reflect_Field.cc | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 3cb6b367f0..0ca9d24824 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -253,7 +253,10 @@ static jobject Class_getDeclaredField(JNIEnv* env, jobject javaThis, jstring nam mirror::Field* result = GetDeclaredField(soa.Self(), klass, name_string); if (result == nullptr) { std::string name_str = name_string->ToModifiedUtf8(); - soa.Self()->ThrowNewException("Ljava/lang/NoSuchFieldException;", name_str.c_str()); + // We may have a pending exception if we failed to resolve. + if (!soa.Self()->IsExceptionPending()) { + soa.Self()->ThrowNewException("Ljava/lang/NoSuchFieldException;", name_str.c_str()); + } return nullptr; } return soa.AddLocalReference<jobject>(result); diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc index 0fe78b3281..721b7a3b76 100644 --- a/runtime/native/java_lang_reflect_Field.cc +++ b/runtime/native/java_lang_reflect_Field.cc @@ -44,7 +44,7 @@ ALWAYS_INLINE inline static bool VerifyFieldAccess(Thread* self, mirror::Field* } mirror::Class* calling_class = nullptr; if (!VerifyAccess(self, obj, field->GetDeclaringClass(), field->GetAccessFlags(), - &calling_class)) { + &calling_class, 1)) { ThrowIllegalAccessException( StringPrintf("Class %s cannot access %s field %s of class %s", calling_class == nullptr ? "null" : PrettyClass(calling_class).c_str(), @@ -276,9 +276,9 @@ ALWAYS_INLINE inline static void SetFieldValue(mirror::Object* o, mirror::Field* break; case Primitive::kPrimShort: if (is_volatile) { - o->SetFieldShortVolatile<false>(offset, new_value.GetZ()); + o->SetFieldShortVolatile<false>(offset, new_value.GetS()); } else { - o->SetFieldShort<false>(offset, new_value.GetZ()); + o->SetFieldShort<false>(offset, new_value.GetS()); } break; case Primitive::kPrimNot: |
