summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/142-classloader2/smali/B.smali10
-rw-r--r--test/142-classloader2/src/Main.java15
2 files changed, 25 insertions, 0 deletions
diff --git a/test/142-classloader2/smali/B.smali b/test/142-classloader2/smali/B.smali
new file mode 100644
index 0000000000..01bd593e00
--- /dev/null
+++ b/test/142-classloader2/smali/B.smali
@@ -0,0 +1,10 @@
+.class public LB;
+
+.super Ljava/lang/Object;
+
+.method public constructor <init>()V
+ .registers 1
+ invoke-direct {p1}, Ljava/lang/Object;-><init>()V
+ return-void
+.end method
+
diff --git a/test/142-classloader2/src/Main.java b/test/142-classloader2/src/Main.java
index 86c61ebc3a..89dadcee68 100644
--- a/test/142-classloader2/src/Main.java
+++ b/test/142-classloader2/src/Main.java
@@ -71,6 +71,21 @@ public class Main {
throw new IllegalStateException("Expected Ex-A, found " + exValue);
}
+ // Try to load a dex file with bad dex code. Use new instance to force verification.
+ try {
+ Class<?> badClass = Main.class.getClassLoader().loadClass("B");
+ badClass.newInstance();
+ System.out.println("Should not be able to load class from bad dex file.");
+ } catch (VerifyError e) {
+ }
+
+ // Make sure the same error is rethrown when reloading the bad class.
+ try {
+ Class<?> badClass = Main.class.getClassLoader().loadClass("B");
+ System.out.println("Should not be able to load class from bad dex file.");
+ } catch (VerifyError e) {
+ }
+
System.out.println("Everything OK.");
}
}