jdk/test/java/lang/invoke/MethodHandles/TestCatchException.java
author alanb
Fri, 10 Feb 2017 09:04:39 +0000
changeset 43712 5dfd0950317c
parent 32649 2ee9017c7597
permissions -rw-r--r--
8173393: Module system implementation refresh (2/2017) Reviewed-by: dfuchs, psandoz, mchung, alanb Contributed-by: alan.bateman@oracle.com, mandy.chung@oracle.com, claes.redestad@oracle.com, alex.buckley@oracle.com, mark.reinhold@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21649
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     1
/*
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     4
 *
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    10
 *
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    15
 * accompanied this code).
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    16
 *
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    20
 *
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    23
 * questions.
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    24
 */
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    25
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    26
/**
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    27
 * @test
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    28
 * @bug 8027823
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    29
 * @run junit test.java.lang.invoke.TestCatchException
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    30
 */
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    31
package test.java.lang.invoke;
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    32
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    33
import java.lang.invoke.*;
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    34
import org.junit.*;
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    35
import static org.junit.Assert.*;
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    36
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    37
public class TestCatchException {
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 23338
diff changeset
    38
    static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 23338
diff changeset
    39
    static final MethodType M_TYPE = MethodType.methodType(int.class, Object.class, Object.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class);
21649
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    40
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    41
    private static int noThrow(Object o1, Object o2, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    42
        return 42;
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    43
    }
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    44
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    45
    private static int throwEx(Object o1, Object o2, int i1, int i2, int i3, int i4, int i5, int i6, int i7) throws Exception {
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    46
        throw new Exception();
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    47
    }
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    48
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    49
    private static int handler(Exception e) {
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    50
        return 17;
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    51
    }
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    52
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    53
    @Test
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    54
    public void testNoThrowPath() throws Throwable {
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    55
        MethodHandle target = LOOKUP.findStatic(TestCatchException.class, "noThrow", M_TYPE);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    56
        MethodHandle handler = LOOKUP.findStatic(TestCatchException.class, "handler", MethodType.methodType(int.class, Exception.class));
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    57
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    58
        MethodHandle h = MethodHandles.catchException(target, Exception.class, handler);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    59
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    60
        int x = (int)h.invokeExact(new Object(), new Object(), 1, 2, 3, 4, 5, 6, 7);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    61
        assertEquals(x, 42);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    62
    }
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    63
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    64
    @Test
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    65
    public void testThrowPath() throws Throwable {
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    66
        MethodHandle target = LOOKUP.findStatic(TestCatchException.class, "throwEx", M_TYPE);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    67
        MethodHandle handler = LOOKUP.findStatic(TestCatchException.class, "handler", MethodType.methodType(int.class, Exception.class));
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    68
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    69
        MethodHandle h = MethodHandles.catchException(target, Exception.class, handler);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    70
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    71
        int x = (int)h.invokeExact(new Object(), new Object(), 1, 2, 3, 4, 5, 6, 7);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    72
        assertEquals(x, 17);
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    73
    }
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
    74
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 23338
diff changeset
    75
    static final Object masterParam = new Object();
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 23338
diff changeset
    76
    static final Object[] masterTail = new Object[] { "str" };
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    77
    static Exception masterEx = new Exception();
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    78
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    79
    public static Object m1(Object o1, Object o2, Object o3, Object o4, Object o5,
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    80
                            Object o6, Object o7, Object o8, Object... tail) {
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    81
        assertEquals(masterParam, o1);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    82
        assertEquals(masterParam, o2);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    83
        assertEquals(masterParam, o3);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    84
        assertEquals(masterParam, o4);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    85
        assertEquals(masterParam, o5);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    86
        assertEquals(masterParam, o6);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    87
        assertEquals(masterParam, o7);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    88
        assertEquals(masterParam, o8);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    89
        assertEquals(masterTail, tail);
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    90
        return tail;
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    91
    }
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    92
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    93
    public static Object m2(Exception e, Object o1, Object o2, Object o3, Object o4,
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
    94
                            Object o5, Object o6, Object o7, Object o8, Object... tail) {
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    95
        assertEquals(masterEx, e);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    96
        assertEquals(masterParam, o1);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    97
        assertEquals(masterParam, o2);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    98
        assertEquals(masterParam, o3);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
    99
        assertEquals(masterParam, o4);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   100
        assertEquals(masterParam, o5);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   101
        assertEquals(masterParam, o6);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   102
        assertEquals(masterParam, o7);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   103
        assertEquals(masterParam, o8);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   104
        assertEquals(masterTail, tail);
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   105
        return tail;
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   106
    }
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   107
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   108
    public static Object throwEx(Object o1, Object o2, Object o3, Object o4, Object o5,
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   109
                                 Object o6, Object o7, Object o8, Object... tail) throws Exception {
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   110
        assertEquals(masterParam, o1);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   111
        assertEquals(masterParam, o2);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   112
        assertEquals(masterParam, o3);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   113
        assertEquals(masterParam, o4);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   114
        assertEquals(masterParam, o5);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   115
        assertEquals(masterParam, o6);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   116
        assertEquals(masterParam, o7);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   117
        assertEquals(masterParam, o8);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   118
        assertEquals(masterTail, tail);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   119
        throw masterEx;
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   120
    }
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   121
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   122
    @Test
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   123
    public void testVarargsCollectorNoThrow() throws Throwable {
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   124
        MethodType t1 = MethodType.methodType(Object.class, Object.class, Object.class, Object.class, Object.class,
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   125
                Object.class, Object.class, Object.class, Object.class, Object[].class);
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   126
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   127
        MethodType t2 = t1.insertParameterTypes(0, Exception.class);
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   128
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   129
        MethodHandle target = LOOKUP.findStatic(TestCatchException.class, "m1", t1)
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   130
                                    .asVarargsCollector(Object[].class);
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   131
        MethodHandle catcher = LOOKUP.findStatic(TestCatchException.class, "m2", t2)
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   132
                                     .asVarargsCollector(Object[].class);
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   133
        MethodHandle gwc = MethodHandles.catchException(target, Exception.class, catcher);
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   134
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   135
        Object o = masterParam;
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   136
        Object[] obj1 = masterTail;
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   137
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   138
        Object r2 = gwc.invokeExact(o, o, o, o, o, o, o, o, obj1);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   139
        assertEquals(r2, obj1);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   140
    }
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   141
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   142
    @Test
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   143
    public void testVarargsCollectorThrow() throws Throwable {
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   144
        MethodType t1 = MethodType.methodType(Object.class, Object.class, Object.class, Object.class, Object.class,
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   145
                Object.class, Object.class, Object.class, Object.class, Object[].class);
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   146
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   147
        MethodType t2 = t1.insertParameterTypes(0, Exception.class);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   148
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   149
        MethodHandle target = LOOKUP.findStatic(TestCatchException.class, "throwEx", t1)
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   150
                                    .asVarargsCollector(Object[].class);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   151
        MethodHandle catcher = LOOKUP.findStatic(TestCatchException.class, "m2", t2)
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   152
                                     .asVarargsCollector(Object[].class);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   153
        MethodHandle gwc = MethodHandles.catchException(target, Exception.class, catcher);
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   154
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   155
        Object o = masterParam;
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   156
        Object[] obj1 = masterTail;
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   157
23038
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   158
        Object r2 = gwc.invokeExact(o, o, o, o, o, o, o, o, obj1);
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   159
        assertEquals(r2, obj1);
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   160
    }
bb8b3b23af3a 8027827: Improve performance of catchException combinator
vlivanov
parents: 21649
diff changeset
   161
21649
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
   162
    public static void main(String[] args) throws Throwable {
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
   163
        TestCatchException test = new TestCatchException();
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
   164
        test.testNoThrowPath();
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
   165
        test.testThrowPath();
23338
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   166
        test.testVarargsCollectorNoThrow();
0a84d339822a 8036117: MethodHandles.catchException doesn't handle VarargsCollector right (8034120 failed)
vlivanov
parents: 23038
diff changeset
   167
        test.testVarargsCollectorThrow();
21649
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
   168
        System.out.println("TEST PASSED");
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
   169
    }
1aca56f8780c 8027823: catchException combinator fails with 9 argument target
vlivanov
parents:
diff changeset
   170
}