diff options
author | Ian Rogers <irogers@google.com> | 2013-02-27 08:32:07 -0800 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2013-04-08 14:24:13 -0700 |
commit | 62d6c772205b8859f0ebf7ad105402ec4c3e2e01 (patch) | |
tree | e2f2ba6d71ed5a39c9f6909e3f7c08e998053315 /test | |
parent | c9b17c7ee96cd04fac9048aab624ed554fe260bf (diff) | |
download | art-62d6c772205b8859f0ebf7ad105402ec4c3e2e01.zip art-62d6c772205b8859f0ebf7ad105402ec4c3e2e01.tar.gz art-62d6c772205b8859f0ebf7ad105402ec4c3e2e01.tar.bz2 |
Interpreter entries and instrumentation as a listener.
Make the instrumentation responsible for whether we want method entry/exit
stubs, and allow it to use interpreter entry stubs when instruction by
instruction instrumentation is required. Improve deoptimization so more JDWP
test cases are passing.
Refactor exception debug posting, in particular improve reporting in the
interpreter. Improve class linker exception throwing so that broken dex files
are more likely to be reported. Fixes the performance issue Bug: 8410519.
Fix some error reporting lock level errors for the large object space. Make
fast object verification faster.
Add some debug mode robustness to finding dex PCs in GC maps.
Add printf attributes to JniAbortF and fix errors.
Expand run-test 044 to test return behaviors and fix issues with not throwing
appropriate exceptions for proxies.
Ensure causes are reported with a class linker NoClassDefFoundError and JNI
NoSuchFieldError.
Remove unused debugMe and updateDebuggerFromCode.
There's a minor sizing tweak to the arg array builder, and an extra reference
array check in the interpreter.
Some clean-up of trace code.
Fix reg type cache destructor if it is called after the reg type cache is
shutdown (as is the case in oatdump).
Change-Id: I6519c7b35df77f978d011999354c864f4918e8ce
Diffstat (limited to 'test')
-rw-r--r-- | test/003-omnibus-opcodes/expected.txt | 8 | ||||
-rw-r--r-- | test/003-omnibus-opcodes/src/UnresTest2.java | 11 | ||||
-rw-r--r-- | test/044-proxy/src/ReturnsAndArgPassing.java | 302 | ||||
-rw-r--r-- | test/100-reflect2/expected.txt | 2 | ||||
-rw-r--r-- | test/201-built-in-exception-detail-messages/src/Main.java | 6 | ||||
-rw-r--r-- | test/StackWalk/stack_walk_jni.cc | 1 |
6 files changed, 293 insertions, 37 deletions
diff --git a/test/003-omnibus-opcodes/expected.txt b/test/003-omnibus-opcodes/expected.txt index c5e67e5..a62c498 100644 --- a/test/003-omnibus-opcodes/expected.txt +++ b/test/003-omnibus-opcodes/expected.txt @@ -70,14 +70,6 @@ Throw.rethrow UnresTest1... UnresTest1... UnresTest2... -java.lang.NoClassDefFoundError: Failed resolution of: LUnresClass; - at UnresTest2.run(UnresTest2.java:33) - at Main.run(Main.java:64) - at Main.main(Main.java:26) -java.lang.NoClassDefFoundError: Failed resolution of: LUnresClassSubclass; - at UnresTest2.run(UnresTest2.java:41) - at Main.run(Main.java:64) - at Main.main(Main.java:26) UnresTest2 done InternedString.run Done! diff --git a/test/003-omnibus-opcodes/src/UnresTest2.java b/test/003-omnibus-opcodes/src/UnresTest2.java index c94f226..4135d73 100644 --- a/test/003-omnibus-opcodes/src/UnresTest2.java +++ b/test/003-omnibus-opcodes/src/UnresTest2.java @@ -33,22 +33,23 @@ class UnresTest2 { un = new UnresClass(); Main.assertTrue(false); } catch (NoClassDefFoundError ncdfe) { - ncdfe.printStackTrace(); + Main.assertTrue(ncdfe.getCause() instanceof ClassNotFoundException); // good } try { - new UnresClassSubclass(); - Main.assertTrue(false); + new UnresClassSubclass(); + Main.assertTrue(false); } catch (NoClassDefFoundError ncdfe) { - ncdfe.printStackTrace(); - // good + Main.assertTrue(ncdfe.getCause() instanceof ClassNotFoundException); + // good } try { UnresClass[] uar = new UnresClass[3]; Main.assertTrue(false); } catch (NoClassDefFoundError ncdfe) { + Main.assertTrue(ncdfe.getCause() instanceof ClassNotFoundException); // good } diff --git a/test/044-proxy/src/ReturnsAndArgPassing.java b/test/044-proxy/src/ReturnsAndArgPassing.java index 50eff77..a173410 100644 --- a/test/044-proxy/src/ReturnsAndArgPassing.java +++ b/test/044-proxy/src/ReturnsAndArgPassing.java @@ -51,6 +51,8 @@ public class ReturnsAndArgPassing { static int barInvocations = 0; static class MyInvocationHandler implements InvocationHandler { + boolean causeNpeOnReturn = false; + Class<?> returnType = null; public Object invoke(Object proxy, Method method, Object[] args) { check(proxy instanceof Proxy); check(method.getDeclaringClass() == MyInterface.class); @@ -62,30 +64,29 @@ public class ReturnsAndArgPassing { check(args == null); barInvocations++; } - if (name.equals("voidFoo")) { return null; } - else if (name.equals("voidBar")) { return null; } - else if (name.equals("booleanFoo")) { return true; } - else if (name.equals("booleanBar")) { return false; } - else if (name.equals("byteFoo")) { return Byte.MAX_VALUE; } - else if (name.equals("byteBar")) { return Byte.MIN_VALUE; } - else if (name.equals("charFoo")) { return Character.MAX_VALUE; } - else if (name.equals("charBar")) { return Character.MIN_VALUE; } - else if (name.equals("shortFoo")) { return Short.MAX_VALUE; } - else if (name.equals("shortBar")) { return Short.MIN_VALUE; } - else if (name.equals("intFoo")) { return Integer.MAX_VALUE; } - else if (name.equals("intBar")) { return Integer.MIN_VALUE; } - else if (name.equals("longFoo")) { return Long.MAX_VALUE; } - else if (name.equals("longBar")) { return Long.MIN_VALUE; } - else if (name.equals("floatFoo")) { return Float.MAX_VALUE; } - else if (name.equals("floatBar")) { return Float.MIN_VALUE; } - else if (name.equals("doubleFoo")) { return Double.MAX_VALUE; } - else if (name.equals("doubleBar")) { return Double.MIN_VALUE; } - else if (name.equals("selectArg")) { + if (causeNpeOnReturn) { + return null; + } else if (name.equals("voidFoo") || name.equals("voidBar")) { + return null; + } else if (name.equals("booleanFoo")) { + return true; + } else if (name.equals("booleanBar")) { + return false; + } else if (name.equals("selectArg")) { check(args.length == 6); int select = (Integer)args[0]; return args[select]; } else { - throw new AssertionError("Unexpect method " + method); + try { + if (name.endsWith("Foo")) { + return returnType.getField("MAX_VALUE").get(null); + } else { + check(name.endsWith("Bar")); + return returnType.getField("MIN_VALUE").get(null); + } + } catch (Exception e) { + throw new Error("return type = " + returnType, e); + } } } } @@ -106,6 +107,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 1); check(fooInvocations == 1); + myHandler.returnType = Boolean.class; check(proxyMyInterface.booleanFoo() == true); check(fooInvocations == 2); @@ -114,6 +116,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 2); check(fooInvocations == 2); + myHandler.returnType = Byte.class; check(proxyMyInterface.byteFoo() == Byte.MAX_VALUE); check(fooInvocations == 3); @@ -122,6 +125,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 3); check(fooInvocations == 3); + myHandler.returnType = Character.class; check(proxyMyInterface.charFoo() == Character.MAX_VALUE); check(fooInvocations == 4); @@ -130,6 +134,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 4); check(fooInvocations == 4); + myHandler.returnType = Short.class; check(proxyMyInterface.shortFoo() == Short.MAX_VALUE); check(fooInvocations == 5); @@ -138,6 +143,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 5); check(fooInvocations == 5); + myHandler.returnType = Integer.class; check(proxyMyInterface.intFoo() == Integer.MAX_VALUE); check(fooInvocations == 6); @@ -146,6 +152,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 6); check(fooInvocations == 6); + myHandler.returnType = Long.class; check(proxyMyInterface.longFoo() == Long.MAX_VALUE); check(fooInvocations == 7); @@ -154,6 +161,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 7); check(fooInvocations == 7); + myHandler.returnType = Float.class; check(proxyMyInterface.floatFoo() == Float.MAX_VALUE); check(fooInvocations == 8); @@ -162,6 +170,7 @@ public class ReturnsAndArgPassing { check(barInvocations == 8); check(fooInvocations == 8); + myHandler.returnType = Double.class; check(proxyMyInterface.doubleFoo() == Double.MAX_VALUE); check(fooInvocations == 9); @@ -169,6 +178,259 @@ public class ReturnsAndArgPassing { check(proxyMyInterface.doubleBar() == Double.MIN_VALUE); check(barInvocations == 9); + // Toggle flag to get return values to cause NPEs + myHandler.causeNpeOnReturn = true; + + check(fooInvocations == 9); + try { + proxyMyInterface.booleanFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 10); + + check(barInvocations == 9); + try { + proxyMyInterface.booleanBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 10); + + check(fooInvocations == 10); + try { + proxyMyInterface.byteFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 11); + + check(barInvocations == 10); + try { + proxyMyInterface.byteBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 11); + + check(fooInvocations == 11); + try { + proxyMyInterface.charFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 12); + + check(barInvocations == 11); + try { + proxyMyInterface.charBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 12); + + check(fooInvocations == 12); + try { + proxyMyInterface.shortFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 13); + + check(barInvocations == 12); + try { + proxyMyInterface.shortBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 13); + + check(fooInvocations == 13); + try { + proxyMyInterface.intFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 14); + + check(barInvocations == 13); + try { + proxyMyInterface.intBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 14); + + check(fooInvocations == 14); + try { + proxyMyInterface.longFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 15); + + check(barInvocations == 14); + try { + proxyMyInterface.longBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 15); + + check(fooInvocations == 15); + try { + proxyMyInterface.floatFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 16); + + check(barInvocations == 15); + try { + proxyMyInterface.floatBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 16); + + check(fooInvocations == 16); + try { + proxyMyInterface.doubleFoo(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(fooInvocations == 17); + + check(barInvocations == 16); + try { + proxyMyInterface.doubleBar(); + throw new AssertionError("Expected NPE"); + } catch (NullPointerException e) { + } + check(barInvocations == 17); + + // Toggle flag to stop NPEs + myHandler.causeNpeOnReturn = false; + + check(fooInvocations == 17); + myHandler.returnType = Double.class; // Double -> byte == fail + try { + proxyMyInterface.byteFoo(); + throw new AssertionError("Expected ClassCastException"); + } catch (ClassCastException e) { + } + check(fooInvocations == 18); + + check(barInvocations == 17); + try { + proxyMyInterface.byteBar(); + throw new AssertionError("Expected NPE"); + } catch (ClassCastException e) { + } + check(barInvocations == 18); + + check(fooInvocations == 18); + myHandler.returnType = Float.class; // Float -> byte == fail + try { + proxyMyInterface.byteFoo(); + throw new AssertionError("Expected ClassCastException"); + } catch (ClassCastException e) { + } + check(fooInvocations == 19); + + check(barInvocations == 18); + try { + proxyMyInterface.byteBar(); + throw new AssertionError("Expected NPE"); + } catch (ClassCastException e) { + } + check(barInvocations == 19); + + check(fooInvocations == 19); + myHandler.returnType = Long.class; // Long -> byte == fail + try { + proxyMyInterface.byteFoo(); + throw new AssertionError("Expected ClassCastException"); + } catch (ClassCastException e) { + } + check(fooInvocations == 20); + + check(barInvocations == 19); + try { + proxyMyInterface.byteBar(); + throw new AssertionError("Expected NPE"); + } catch (ClassCastException e) { + } + check(barInvocations == 20); + + check(fooInvocations == 20); + myHandler.returnType = Integer.class; // Int -> byte == fail + try { + proxyMyInterface.byteFoo(); + throw new AssertionError("Expected ClassCastException"); + } catch (ClassCastException e) { + } + check(fooInvocations == 21); + + check(barInvocations == 20); + try { + proxyMyInterface.byteBar(); + throw new AssertionError("Expected NPE"); + } catch (ClassCastException e) { + } + check(barInvocations == 21); + + check(fooInvocations == 21); + myHandler.returnType = Short.class; // Short -> byte == fail + try { + proxyMyInterface.byteFoo(); + throw new AssertionError("Expected ClassCastException"); + } catch (ClassCastException e) { + } + check(fooInvocations == 22); + + check(barInvocations == 21); + try { + proxyMyInterface.byteBar(); + throw new AssertionError("Expected NPE"); + } catch (ClassCastException e) { + } + check(barInvocations == 22); + + check(fooInvocations == 22); + myHandler.returnType = Character.class; // Char -> byte == fail + try { + proxyMyInterface.byteFoo(); + throw new AssertionError("Expected ClassCastException"); + } catch (ClassCastException e) { + } + check(fooInvocations == 23); + + check(barInvocations == 22); + try { + proxyMyInterface.byteBar(); + throw new AssertionError("Expected NPE"); + } catch (ClassCastException e) { + } + check(barInvocations == 23); + + check(fooInvocations == 23); + myHandler.returnType = Character.class; // Char -> short == fail + try { + proxyMyInterface.shortFoo(); + throw new AssertionError("Expected ClassCastException"); + } catch (ClassCastException e) { + } + check(fooInvocations == 24); + + check(barInvocations == 23); + try { + proxyMyInterface.shortBar(); + throw new AssertionError("Expected NPE"); + } catch (ClassCastException e) { + } + check(barInvocations == 24); + System.out.println(testName + ".testProxyReturns PASSED"); } diff --git a/test/100-reflect2/expected.txt b/test/100-reflect2/expected.txt index 9417174..0c567d4 100644 --- a/test/100-reflect2/expected.txt +++ b/test/100-reflect2/expected.txt @@ -22,7 +22,7 @@ z 30 62 14 -java.lang.IllegalArgumentException: invalid primitive conversion from int to short +java.lang.IllegalArgumentException: Invalid primitive conversion from int to short at java.lang.reflect.Field.set(Native Method) at Main.testFieldReflection(Main.java:121) at Main.main(Main.java:269) diff --git a/test/201-built-in-exception-detail-messages/src/Main.java b/test/201-built-in-exception-detail-messages/src/Main.java index 9b67db6..f8da644 100644 --- a/test/201-built-in-exception-detail-messages/src/Main.java +++ b/test/201-built-in-exception-detail-messages/src/Main.java @@ -393,7 +393,7 @@ public class Main { m.invoke("hello"); // Wrong number of arguments. fail(); } catch (IllegalArgumentException iae) { - assertEquals("wrong number of arguments; expected 1, got 0", iae.getMessage()); + assertEquals("Wrong number of arguments; expected 1, got 0", iae.getMessage()); } try { Method m = String.class.getMethod("charAt", int.class); @@ -414,14 +414,14 @@ public class Main { m.invoke(new Integer(5)); // Wrong type for 'this'. fail(); } catch (IllegalArgumentException iae) { - assertEquals("expected receiver of type java.lang.String, but got java.lang.Integer", iae.getMessage()); + assertEquals("Expected receiver of type java.lang.String, but got java.lang.Integer", iae.getMessage()); } try { Method m = String.class.getMethod("charAt", int.class); m.invoke(null); // Null for 'this'. fail(); } catch (NullPointerException npe) { - assertEquals("expected receiver of type java.lang.String, but got null", npe.getMessage()); + assertEquals("null receiver", npe.getMessage()); } } diff --git a/test/StackWalk/stack_walk_jni.cc b/test/StackWalk/stack_walk_jni.cc index 92cfa99..4b472da 100644 --- a/test/StackWalk/stack_walk_jni.cc +++ b/test/StackWalk/stack_walk_jni.cc @@ -21,6 +21,7 @@ #include "gc_map.h" #include "mirror/abstract_method.h" #include "mirror/abstract_method-inl.h" +#include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" |