diff options
| author | 2016-06-08 04:03:56 +0000 | |
|---|---|---|
| committer | 2016-06-08 04:03:56 +0000 | |
| commit | 923b26fb78b1dfb0054aad39f9ff5d6546e4979c (patch) | |
| tree | 12678002742b30b5e692d5887bab038331ffb0fe /test | |
| parent | 06fead330f66f3a3ec19cf5b466ca848482d16bf (diff) | |
| parent | c92a7a14ce44c4bb7e63e4c447a008b558bc0bca (diff) | |
Merge "Wrap certain exception types when loading an erroneous class."
Diffstat (limited to 'test')
| -rw-r--r-- | test/142-classloader2/smali/B.smali | 10 | ||||
| -rw-r--r-- | test/142-classloader2/src/Main.java | 15 |
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."); } } |