ART: Change behavior for rethrowing init failures (2)
Always store the pending exception when making a class erroneous.
Instead of filtering by ExceptionInInitializerError, add an option
to the rethrow that enforces a NoClassDefFoundError, which is required
by the specification.
Use the libcore companion change to add the stored error (if any) as
a cause to the NoClassDefFoundError, which should significantly help
tracking down issues.
Fix run-test 008 to expect spec-compliant behavior. Test that a cause
has been set.
Bug: 25445103
Change-Id: I6a0dc54e78312283faf23415887eff387531407f
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 73f9d4b..a35ba3e 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -848,9 +848,7 @@
// Throw the class initialization failure recorded when first trying to initialize the given
// class.
- // Note: Currently we only store the descriptor, so we cannot throw the exact throwable, only
- // a recreation with a custom string.
- void ThrowEarlierClassFailure(mirror::Class* c)
+ void ThrowEarlierClassFailure(mirror::Class* c, bool wrap_in_no_class_def = false)
SHARED_REQUIRES(Locks::mutator_lock_)
REQUIRES(!dex_lock_);