Don't wrap VerifyError into NoClassDefFoundError.
Follow RI behavior by returning the VerifyError. NoClassDefFoundError
only wraps initializer errors.
Also rename the field in ClassExt from verifyError to
erroneousStateError for better clarity.
And remove now unused feature of storing a class in the verifyError
field.
Test: test.py
Test: 824-verification-rethrow
Bug: 28313047
Change-Id: I19383f7b74f22a62ab1e0b8a13bea75a14c7b33f
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index d411a24..f4849b4 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -232,7 +232,7 @@
ObjPtr<ClassExt> ext(EnsureExtDataPresent(h_this, self));
if (!ext.IsNull()) {
self->AssertPendingException();
- ext->SetVerifyError(self->GetException());
+ ext->SetErroneousStateError(self->GetException());
} else {
self->AssertPendingOOMException();
}
diff --git a/runtime/mirror/class_ext-inl.h b/runtime/mirror/class_ext-inl.h
index b8493c1..ddd46b9 100644
--- a/runtime/mirror/class_ext-inl.h
+++ b/runtime/mirror/class_ext-inl.h
@@ -144,9 +144,8 @@
return !arr.IsNull() && !arr->IsArrayInstance();
}
-
-inline ObjPtr<Object> ClassExt::GetVerifyError() {
- return GetFieldObject<ClassExt>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_));
+inline ObjPtr<Throwable> ClassExt::GetErroneousStateError() {
+ return GetFieldObject<Throwable>(OFFSET_OF_OBJECT_MEMBER(ClassExt, erroneous_state_error_));
}
inline ObjPtr<ObjectArray<DexCache>> ClassExt::GetObsoleteDexCaches() {
diff --git a/runtime/mirror/class_ext.cc b/runtime/mirror/class_ext.cc
index 7543ab6..097e0de 100644
--- a/runtime/mirror/class_ext.cc
+++ b/runtime/mirror/class_ext.cc
@@ -118,11 +118,11 @@
return ObjPtr<ClassExt>::DownCast(GetClassRoot<ClassExt>()->AllocObject(self));
}
-void ClassExt::SetVerifyError(ObjPtr<Object> err) {
+void ClassExt::SetErroneousStateError(ObjPtr<Throwable> err) {
if (Runtime::Current()->IsActiveTransaction()) {
- SetFieldObject<true>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_), err);
+ SetFieldObject<true>(OFFSET_OF_OBJECT_MEMBER(ClassExt, erroneous_state_error_), err);
} else {
- SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_), err);
+ SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ClassExt, erroneous_state_error_), err);
}
}
diff --git a/runtime/mirror/class_ext.h b/runtime/mirror/class_ext.h
index 2fd8c39..4ce3b10 100644
--- a/runtime/mirror/class_ext.h
+++ b/runtime/mirror/class_ext.h
@@ -42,9 +42,9 @@
return sizeof(ClassExt);
}
- void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_);
+ void SetErroneousStateError(ObjPtr<Throwable> obj) REQUIRES_SHARED(Locks::mutator_lock_);
- ObjPtr<Object> GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_);
+ ObjPtr<Throwable> GetErroneousStateError() REQUIRES_SHARED(Locks::mutator_lock_);
ObjPtr<ObjectArray<DexCache>> GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_);
@@ -156,6 +156,9 @@
bool EnsureJniIdsArrayPresent(MemberOffset off, size_t count)
REQUIRES_SHARED(Locks::mutator_lock_);
+ // The saved error for this class being erroneous.
+ HeapReference<Throwable> erroneous_state_error_;
+
// Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
// An array containing the jfieldIDs assigned to each field in the corresponding position in the
// classes ifields_ array or '0' if no id has been assigned to that field yet.
@@ -178,9 +181,6 @@
// classes sfields_ array or '0' if no id has been assigned to that field yet.
HeapReference<PointerArray> static_jfield_ids_;
- // The saved verification error of this class.
- HeapReference<Object> verify_error_;
-
// Native pointer to DexFile and ClassDef index of this class before it was JVMTI-redefined.
int64_t pre_redefine_dex_file_ptr_;
int32_t pre_redefine_class_def_index_;