Details
-
Bug
-
Resolution: Fixed
-
P2
-
8
-
None
-
b117
-
generic
-
generic
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8028910 | port-stage-ppc-aix | Vladimir Ivanov | P2 | Resolved | Fixed | master |
Description
Run this:
import java.lang.invoke.*;
public class TestCatchException {
public static void main(String[] args) throws Throwable {
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle h = MethodHandles.catchException(
lookup.findStatic(TestCatchException.class, "target", MethodType.methodType(int.class, Object.class, Object.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class)),
Exception.class,
lookup.findStatic(TestCatchException.class, "handler", MethodType.methodType(int.class, Exception.class)));
int x = (int)h.invokeExact(new Object(), new Object(), 1, 2, 3, 4, 5, 6, 7);
}
private static int target(Object o1, Object o2, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
return 42;
}
private static int handler(Exception e) {
return 17;
}
}
It throws:
Exception in thread "main" java.lang.invoke.WrongMethodTypeException: expected (Throwable,Object[])int but found (Throwable,Object[])Object
at java.lang.invoke.Invokers.newWrongMethodTypeException(Invokers.java:351)
at java.lang.invoke.Invokers.checkExactType(Invokers.java:362)
at TestCatchException.main(TestCatchException.java:13)
If "int i7" argument is removed from the target() method, it runs, so there's obviously a bug in handling more than 8 arguments.
import java.lang.invoke.*;
public class TestCatchException {
public static void main(String[] args) throws Throwable {
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle h = MethodHandles.catchException(
lookup.findStatic(TestCatchException.class, "target", MethodType.methodType(int.class, Object.class, Object.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class)),
Exception.class,
lookup.findStatic(TestCatchException.class, "handler", MethodType.methodType(int.class, Exception.class)));
int x = (int)h.invokeExact(new Object(), new Object(), 1, 2, 3, 4, 5, 6, 7);
}
private static int target(Object o1, Object o2, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
return 42;
}
private static int handler(Exception e) {
return 17;
}
}
It throws:
Exception in thread "main" java.lang.invoke.WrongMethodTypeException: expected (Throwable,Object[])int but found (Throwable,Object[])Object
at java.lang.invoke.Invokers.newWrongMethodTypeException(Invokers.java:351)
at java.lang.invoke.Invokers.checkExactType(Invokers.java:362)
at TestCatchException.main(TestCatchException.java:13)
If "int i7" argument is removed from the target() method, it runs, so there's obviously a bug in handling more than 8 arguments.
Attachments
Issue Links
- backported by
-
JDK-8028910 catchException combinator fails with 9 argument target
- Resolved