Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8027823

catchException combinator fails with 9 argument target

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P2
    • Resolution: Fixed
    • 8
    • 8
    • core-libs
    • None
    • b117
    • generic
    • generic
    • Verified

    Backports

      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.

        Attachments

          Issue Links

            Activity

              People

                vlivanov Vladimir Ivanov
                attila Attila Szegedi
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: