MethodHandles: Fix MethodType::IsConvertible() error.
Conversions between non-numeric primitives and their boxed equivalents
were being rejected.
Test: m test-art-host-run-test-956-methodhandles
Bug: 30550796
Change-Id: I4ee255be3a4549246548185e362789561382ba1b
diff --git a/test/956-methodhandles/src/Main.java b/test/956-methodhandles/src/Main.java
index 3d714c9..aab9f50 100644
--- a/test/956-methodhandles/src/Main.java
+++ b/test/956-methodhandles/src/Main.java
@@ -843,6 +843,42 @@
long l = (long) mh.invoke();
if (l != 0) fail();
+ // boolean -> Boolean
+ mh = MethodHandles.lookup().findStatic(Boolean.class, "parseBoolean",
+ MethodType.methodType(boolean.class, String.class));
+ Boolean z = (Boolean) mh.invoke("True");
+ if (!z.booleanValue()) fail();
+
+ // boolean -> int
+ try {
+ int dummy = (int) mh.invoke("True");
+ fail();
+ } catch (WrongMethodTypeException e) {}
+
+ // boolean -> Integer
+ try {
+ Integer dummy = (Integer) mh.invoke("True");
+ fail();
+ } catch (WrongMethodTypeException e) {}
+
+ // Boolean -> boolean
+ mh = MethodHandles.lookup().findStatic(Boolean.class, "valueOf",
+ MethodType.methodType(Boolean.class, boolean.class));
+ boolean w = (boolean) mh.invoke(false);
+ if (w) fail();
+
+ // Boolean -> int
+ try {
+ int dummy = (int) mh.invoke(false);
+ fail();
+ } catch (WrongMethodTypeException e) {}
+
+ // Boolean -> Integer
+ try {
+ Integer dummy = (Integer) mh.invoke("True");
+ fail();
+ } catch (WrongMethodTypeException e) {}
+
System.out.println("testPrimitiveReturnValueConversions done.");
}