From a7679b67ca945194fa2442015e606cd250f0de2b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 24 Jan 2012 17:15:23 -0800 Subject: Improve exceptions thrown during class loading. We've always gone to a lot of trouble to have good detail messages when something goes wrong during class loading, but none of those exceptions would ever make it to the calling code. This adds missing exception chaining, and also adds a test for the case where a subclass is missing its superclass; before we'd have reported that the subclass was missing, but now we make it clear that the real error was an inability to find the superclass. Change-Id: I07ebc011ccdaed16be82bf08b323393e1d790989 --- test/003-omnibus-opcodes/expected.txt | 26 ++++++++++++++++++++++ .../src/UnresClassSubclass.java | 4 ++++ test/003-omnibus-opcodes/src/UnresTest2.java | 9 ++++++++ 3 files changed, 39 insertions(+) create mode 100644 test/003-omnibus-opcodes/src/UnresClassSubclass.java (limited to 'test') diff --git a/test/003-omnibus-opcodes/expected.txt b/test/003-omnibus-opcodes/expected.txt index 28b1813..746e702 100644 --- a/test/003-omnibus-opcodes/expected.txt +++ b/test/003-omnibus-opcodes/expected.txt @@ -68,6 +68,32 @@ Throw.rethrow UnresTest1... UnresTest1... UnresTest2... +java.lang.NoClassDefFoundError: Class "LUnresClass;" not found + at UnresTest2.run(UnresTest2.java:33) + at Main.run(Main.java:64) + at Main.main(Main.java:26) +Caused by: java.lang.ClassNotFoundException: Didn't find class "UnresClass" on path: /data/art-test/003-omnibus-opcodes.jar + at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) + at java.lang.ClassLoader.loadClass(ClassLoader.java:509) + at java.lang.ClassLoader.loadClass(ClassLoader.java:469) + ... 3 more +java.lang.NoClassDefFoundError: Class "LUnresClassSubclass;" not found + at UnresTest2.run(UnresTest2.java:41) + at Main.run(Main.java:64) + at Main.main(Main.java:26) +Caused by: java.lang.NoClassDefFoundError: Class "LUnresClass;" not found + at dalvik.system.DexFile.defineClass(Native Method) + at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:213) + at dalvik.system.DexPathList.findClass(DexPathList.java:315) + at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:58) + at java.lang.ClassLoader.loadClass(ClassLoader.java:509) + at java.lang.ClassLoader.loadClass(ClassLoader.java:469) + ... 3 more +Caused by: java.lang.ClassNotFoundException: Didn't find class "UnresClass" on path: /data/art-test/003-omnibus-opcodes.jar + at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) + at java.lang.ClassLoader.loadClass(ClassLoader.java:509) + at java.lang.ClassLoader.loadClass(ClassLoader.java:469) + ... 9 more UnresTest2 done InternedString.run Done! diff --git a/test/003-omnibus-opcodes/src/UnresClassSubclass.java b/test/003-omnibus-opcodes/src/UnresClassSubclass.java new file mode 100644 index 0000000..601f2f5 --- /dev/null +++ b/test/003-omnibus-opcodes/src/UnresClassSubclass.java @@ -0,0 +1,4 @@ +public class UnresClassSubclass extends UnresClass { + public UnresClassSubclass() { + } +} diff --git a/test/003-omnibus-opcodes/src/UnresTest2.java b/test/003-omnibus-opcodes/src/UnresTest2.java index f1e8dd1..c94f226 100644 --- a/test/003-omnibus-opcodes/src/UnresTest2.java +++ b/test/003-omnibus-opcodes/src/UnresTest2.java @@ -33,10 +33,19 @@ class UnresTest2 { un = new UnresClass(); Main.assertTrue(false); } catch (NoClassDefFoundError ncdfe) { + ncdfe.printStackTrace(); // good } try { + new UnresClassSubclass(); + Main.assertTrue(false); + } catch (NoClassDefFoundError ncdfe) { + ncdfe.printStackTrace(); + // good + } + + try { UnresClass[] uar = new UnresClass[3]; Main.assertTrue(false); } catch (NoClassDefFoundError ncdfe) { -- cgit v1.1