MethodHandles: Better detail message for WrongMethodTypeExceptions
We now include the type of the callee and the callsite.
This change also fixes a call to ThrowWrongMethodTypeException that
passed arguments in the wrong order.
Test: make test-art-host
Change-Id: I3ced2e331cb49b616a8374f5a604dafa37330059
diff --git a/test/956-methodhandles/src/Main.java b/test/956-methodhandles/src/Main.java
index 2802dfa..72ed6b5 100644
--- a/test/956-methodhandles/src/Main.java
+++ b/test/956-methodhandles/src/Main.java
@@ -57,6 +57,7 @@
public static void main(String[] args) throws Throwable {
testfindSpecial_invokeSuperBehaviour();
testfindSpecial_invokeDirectBehaviour();
+ testExceptionDetailMessages();
}
public static void testfindSpecial_invokeSuperBehaviour() throws Throwable {
@@ -131,6 +132,18 @@
} catch (IllegalAccessException expected) {
}
}
+
+ public static void testExceptionDetailMessages() throws Throwable {
+ MethodHandle handle = MethodHandles.lookup().findVirtual(String.class, "concat",
+ MethodType.methodType(String.class, String.class));
+
+ try {
+ handle.invokeExact("a", new Object());
+ System.out.println("invokeExact(\"a\", new Object()) unexpectedly succeeded.");
+ } catch (WrongMethodTypeException ex) {
+ System.out.println("Received exception: " + ex.getMessage());
+ }
+ }
}