Fix some reflection errors
Fixed incorrectly using 2nd frame instead of 1st in VerifyAccess.
Added regression test to ART. Fixed broken setShort,
getDeclaredFieldInternal.
Change-Id: I4b21d52d998cb768fe9503b8bccec506b7b972e5
diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc
index 0fe78b3..721b7a3 100644
--- a/runtime/native/java_lang_reflect_Field.cc
+++ b/runtime/native/java_lang_reflect_Field.cc
@@ -44,7 +44,7 @@
}
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 @@
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: