test/java/lang/invoke/MethodHandles/TestCatchException.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
jdk Cdiff test/java/lang/invoke/MethodHandles/TestCatchException.java
test/java/lang/invoke/MethodHandles/TestCatchException.java
Print this page
rev 9328 : 8027827: Improve performance of catchException combinator
8034120: MethodHandles.catchException doesn't handle VarargsCollector right
Reviewed-by: lagergren, psandoz, ?
*** 70,81 ****
--- 70,116 ----
int x = (int)h.invokeExact(new Object(), new Object(), 1, 2, 3, 4, 5, 6, 7);
assertEquals(x, 17);
}
+
+ public static Object m1(Object o1, Object o2, Object o3, Object o4, Object o5,
+ Object o6, Object o7, Object o8, Object... tail) {
+ return tail;
+ }
+
+ public static Object m2(Exception e, Object o1, Object o2, Object o3, Object o4,
+ Object o5, Object o6, Object o7, Object o8, Object... tail) {
+ return tail;
+ }
+
+ @Test
+ public void testVarargsCollector() throws Throwable {
+ MethodType t1 = MethodType.methodType(Object.class, Object.class, Object.class, Object.class, Object.class,
+ Object.class, Object.class, Object.class, Object.class, Object[].class);
+
+ MethodType t2 = t1.insertParameterTypes(0, Exception.class);
+
+ MethodHandle target = LOOKUP.findStatic(TestCatchException.class, "m1", t1)
+ .asVarargsCollector(Object[].class);
+
+ MethodHandle catcher = LOOKUP.findStatic(TestCatchException.class, "m2", t2);
+
+ MethodHandle gwc = MethodHandles.catchException(target, Exception.class, catcher);
+
+ Object o = new Object();
+ Object[] obj1 = new Object[] { "str" };
+
+ Object r1 = target.invokeExact(o, o, o, o, o, o, o, o, obj1);
+ Object r2 = gwc.invokeExact(o, o, o, o, o, o, o, o, obj1);
+ assertEquals(r1, obj1);
+ assertEquals(r2, obj1);
+ }
+
public static void main(String[] args) throws Throwable {
TestCatchException test = new TestCatchException();
test.testNoThrowPath();
test.testThrowPath();
+ test.testVarargsCollector();
System.out.println("TEST PASSED");
}
}
test/java/lang/invoke/MethodHandles/TestCatchException.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File