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/test/142-classloader2/src/Main.java b/test/142-classloader2/src/Main.java
index 193fd5d..dbb48e1 100644
--- a/test/142-classloader2/src/Main.java
+++ b/test/142-classloader2/src/Main.java
@@ -72,6 +72,7 @@
}
// Try to load a dex file with bad dex code. Use new instance to force verification.
+ VerifyError existing = null;
try {
Class<?> badClass = Main.class.getClassLoader().loadClass("B");
System.out.println("Loaded class B.");
@@ -79,6 +80,7 @@
System.out.println("Should not be able to instantiate B with bad dex bytecode.");
} catch (VerifyError e) {
System.out.println("Caught VerifyError.");
+ existing = e;
}
// Make sure the same error is rethrown when reloading the bad class.
@@ -87,9 +89,9 @@
System.out.println("Loaded class B.");
badClass.newInstance();
System.out.println("Should not be able to instantiate B with bad dex bytecode.");
- } catch (NoClassDefFoundError e) {
- if (e.getCause() instanceof VerifyError) {
- System.out.println("Caught wrapped VerifyError.");
+ } catch (VerifyError e) {
+ if (e == existing) {
+ System.out.println("Caught existing VerifyError.");
} else {
e.printStackTrace(System.out);
}