jdk/test/java/lang/invoke/LoopCombinatorTest.java
author mhaupt
Fri, 22 Apr 2016 13:36:22 +0200
changeset 37602 3a9532bbd89e
parent 37539 fc220bc54b59
child 37603 e802285989a7
permissions -rw-r--r--
8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type Reviewed-by: redestad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     1
/*
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     4
 *
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    10
 *
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    15
 * accompanied this code).
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    16
 *
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    20
 *
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    23
 * questions.
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    24
 */
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    25
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    26
/* @test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    27
 * @bug 8139885
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    28
 * @bug 8150635
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
    29
 * @bug 8150956
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
    30
 * @bug 8150957
37602
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
    31
 * @bug 8152667
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
    32
 * @bug 8153637
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    33
 * @run testng/othervm -ea -esa test.java.lang.invoke.LoopCombinatorTest
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    34
 */
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    35
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    36
package test.java.lang.invoke;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    37
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    38
import java.lang.invoke.MethodHandle;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    39
import java.lang.invoke.MethodHandles;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    40
import java.lang.invoke.MethodHandles.Lookup;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    41
import java.lang.invoke.MethodType;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    42
import java.util.*;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    43
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    44
import static java.lang.invoke.MethodType.methodType;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    45
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    46
import static org.testng.AssertJUnit.*;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    47
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    48
import org.testng.annotations.*;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    49
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    50
/**
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    51
 * Tests for the loop combinators introduced in JEP 274.
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    52
 */
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    53
public class LoopCombinatorTest {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    54
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    55
    static final Lookup LOOKUP = MethodHandles.lookup();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    56
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    57
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    58
    public static void testLoopFac() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    59
        MethodHandle[] counterClause = new MethodHandle[]{Fac.MH_zero, Fac.MH_inc};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    60
        MethodHandle[] accumulatorClause = new MethodHandle[]{Fac.MH_one, Fac.MH_mult, Fac.MH_pred, Fac.MH_fin};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    61
        MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    62
        assertEquals(Fac.MT_fac, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    63
        assertEquals(120, loop.invoke(5));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    64
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    65
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    66
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    67
    public static void testLoopFacNullInit() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    68
        // null initializer for counter, should initialize to 0
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    69
        MethodHandle[] counterClause = new MethodHandle[]{null, Fac.MH_inc};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    70
        MethodHandle[] accumulatorClause = new MethodHandle[]{Fac.MH_one, Fac.MH_mult, Fac.MH_pred, Fac.MH_fin};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    71
        MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    72
        assertEquals(Fac.MT_fac, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    73
        assertEquals(120, loop.invoke(5));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    74
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    75
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    76
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    77
    public static void testLoopNullInit() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    78
        // null initializer for counter, should initialize to 0, one-clause loop
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    79
        MethodHandle[] counterClause = new MethodHandle[]{null, Loop.MH_inc, Loop.MH_pred, Loop.MH_fin};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    80
        MethodHandle loop = MethodHandles.loop(counterClause);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    81
        assertEquals(Loop.MT_loop, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    82
        assertEquals(10, loop.invoke(10));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    83
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    84
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    85
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    86
    public static void testLoopVoid1() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    87
        // construct a post-checked loop that only does one iteration and has a void body and void local state
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    88
        MethodHandle loop = MethodHandles.loop(new MethodHandle[]{Empty.MH_f, Empty.MH_f, Empty.MH_pred, null});
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    89
        assertEquals(MethodType.methodType(void.class), loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    90
        loop.invoke();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    91
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    92
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    93
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    94
    public static void testLoopVoid2() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    95
        // construct a post-checked loop that only does one iteration and has a void body and void local state,
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    96
        // initialized implicitly from the step type
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    97
        MethodHandle loop = MethodHandles.loop(new MethodHandle[]{null, Empty.MH_f, Empty.MH_pred, null});
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    98
        assertEquals(MethodType.methodType(void.class), loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
    99
        loop.invoke();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   100
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   101
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   102
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   103
    public static void testLoopVoid3() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   104
        // construct a post-checked loop that only does one iteration and has a void body and void local state,
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   105
        // and that has a void finalizer
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   106
        MethodHandle loop = MethodHandles.loop(new MethodHandle[]{null, Empty.MH_f, Empty.MH_pred, Empty.MH_f});
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   107
        assertEquals(MethodType.methodType(void.class), loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   108
        loop.invoke();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   109
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   110
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   111
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   112
    public static void testLoopFacWithVoidState() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   113
        // like testLoopFac, but with additional void state that outputs a dot
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   114
        MethodHandle[] counterClause = new MethodHandle[]{Fac.MH_zero, Fac.MH_inc};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   115
        MethodHandle[] accumulatorClause = new MethodHandle[]{Fac.MH_one, Fac.MH_mult, Fac.MH_pred, Fac.MH_fin};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   116
        MethodHandle[] dotClause = new MethodHandle[]{null, Fac.MH_dot};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   117
        MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause, dotClause);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   118
        assertEquals(Fac.MT_fac, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   119
        assertEquals(120, loop.invoke(5));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   120
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   121
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   122
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   123
    public static void testLoopVoidInt() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   124
        // construct a post-checked loop that only does one iteration and has a void body and void local state,
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   125
        // and that returns a constant
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   126
        MethodHandle loop = MethodHandles.loop(new MethodHandle[]{null, Empty.MH_f, Empty.MH_pred, Empty.MH_c});
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   127
        assertEquals(MethodType.methodType(int.class), loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   128
        assertEquals(23, loop.invoke());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   129
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   130
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   131
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   132
    public static void testLoopWithVirtuals() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   133
        // construct a loop (to calculate factorial) that uses a mix of static and virtual methods
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   134
        MethodHandle[] counterClause = new MethodHandle[]{null, LoopWithVirtuals.permute(LoopWithVirtuals.MH_inc)};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   135
        MethodHandle[] accumulatorClause = new MethodHandle[]{
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   136
                // init function must indicate the loop arguments (there is no other means to determine them)
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   137
                MethodHandles.dropArguments(LoopWithVirtuals.MH_one, 0, LoopWithVirtuals.class),
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   138
                LoopWithVirtuals.permute(LoopWithVirtuals.MH_mult),
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   139
                LoopWithVirtuals.permute(LoopWithVirtuals.MH_pred),
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   140
                LoopWithVirtuals.permute(LoopWithVirtuals.MH_fin)
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   141
        };
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   142
        MethodHandle loop = MethodHandles.loop(counterClause, accumulatorClause);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   143
        assertEquals(LoopWithVirtuals.MT_loop, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   144
        assertEquals(120, loop.invoke(new LoopWithVirtuals(), 5));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   145
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   146
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   147
    @DataProvider
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   148
    static Object[][] negativeTestData() {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   149
        MethodHandle i0 = MethodHandles.constant(int.class, 0);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   150
        MethodHandle ii = MethodHandles.dropArguments(i0, 0, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   151
        MethodHandle id = MethodHandles.dropArguments(i0, 0, int.class, double.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   152
        MethodHandle i3 = MethodHandles.dropArguments(i0, 0, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   153
        List<MethodHandle> inits = Arrays.asList(ii, id, i3);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   154
        List<Class<?>> ints = Arrays.asList(int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   155
        List<MethodHandle> finis = Arrays.asList(Fac.MH_fin, Fac.MH_inc, Counted.MH_step);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   156
        List<MethodHandle> preds1 = Arrays.asList(null, null, null);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   157
        List<MethodHandle> preds2 = Arrays.asList(null, Fac.MH_fin, null);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   158
        MethodHandle eek = MethodHandles.dropArguments(i0, 0, int.class, int.class, double.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   159
        List<MethodHandle> nesteps = Arrays.asList(Fac.MH_inc, eek, Fac.MH_dot);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   160
        List<MethodHandle> nepreds = Arrays.asList(null, Fac.MH_pred, null);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   161
        List<MethodHandle> nefinis = Arrays.asList(null, Fac.MH_fin, null);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   162
        List<MethodHandle> lvsteps = Arrays.asList(LoopWithVirtuals.MH_inc, LoopWithVirtuals.MH_mult);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   163
        List<MethodHandle> lvpreds = Arrays.asList(null, LoopWithVirtuals.MH_pred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   164
        List<MethodHandle> lvfinis = Arrays.asList(null, LoopWithVirtuals.MH_fin);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   165
        return new Object[][] {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   166
                {null, "null or no clauses passed"},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   167
                {new MethodHandle[][]{}, "null or no clauses passed"},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   168
                {new MethodHandle[][]{{null, Fac.MH_inc}, {Fac.MH_one, null, Fac.MH_mult, Fac.MH_pred, Fac.MH_fin}},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   169
                        "All loop clauses must be represented as MethodHandle arrays with at most 4 elements."},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   170
                {new MethodHandle[][]{{null, Fac.MH_inc}, null}, "null clauses are not allowed"},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   171
                {new MethodHandle[][]{{Fac.MH_zero, Fac.MH_dot}},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   172
                        "clause 0: init and step return types must match: int != void"},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   173
                {new MethodHandle[][]{{ii}, {id}, {i3}},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   174
                        "found non-effectively identical init parameter type lists: " + inits +
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   175
                                " (common suffix: " + ints + ")"},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   176
                {new MethodHandle[][]{{null, Fac.MH_inc, null, Fac.MH_fin}, {null, Fac.MH_inc, null, Fac.MH_inc},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   177
                        {null, Counted.MH_start, null, Counted.MH_step}},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   178
                        "found non-identical finalizer return types: " + finis + " (return type: int)"},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   179
                {new MethodHandle[][]{{Fac.MH_zero, Fac.MH_inc}, {Fac.MH_one, Fac.MH_mult, null, Fac.MH_fin},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   180
                        {null, Fac.MH_dot}}, "no predicate found: " + preds1},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   181
                {new MethodHandle[][]{{Fac.MH_zero, Fac.MH_inc}, {Fac.MH_one, Fac.MH_mult, Fac.MH_fin, Fac.MH_fin},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   182
                        {null, Fac.MH_dot}}, "predicates must have boolean return type: " + preds2},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   183
                {new MethodHandle[][]{{Fac.MH_zero, Fac.MH_inc}, {Fac.MH_one, eek, Fac.MH_pred, Fac.MH_fin},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   184
                        {null, Fac.MH_dot}},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   185
                        "found non-effectively identical parameter type lists:\nstep: " + nesteps +
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   186
                                "\npred: " + nepreds + "\nfini: " + nefinis + " (common parameter sequence: " + ints + ")"},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   187
                {new MethodHandle[][]{{null, LoopWithVirtuals.MH_inc},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   188
                        {LoopWithVirtuals.MH_one, LoopWithVirtuals.MH_mult, LoopWithVirtuals.MH_pred, LoopWithVirtuals.MH_fin}},
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   189
                        "found non-effectively identical parameter type lists:\nstep: " + lvsteps +
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   190
                                "\npred: " + lvpreds + "\nfini: " + lvfinis + " (common parameter sequence: " + ints + ")"}
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   191
        };
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   192
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   193
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   194
    static final MethodHandle MH_loop;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   195
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   196
    static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   197
        try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   198
            MH_loop = LOOKUP.findStatic(MethodHandles.class, "loop", methodType(MethodHandle.class, MethodHandle[][].class));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   199
        } catch (NoSuchMethodException | IllegalAccessException e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   200
            throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   201
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   202
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   203
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   204
    @Test(dataProvider = "negativeTestData")
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   205
    public static void testLoopNegative(MethodHandle[][] clauses, String expectedMessage) throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   206
        boolean caught = false;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   207
        try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   208
            MH_loop.invokeWithArguments(clauses);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   209
        } catch (IllegalArgumentException iae) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   210
            assertEquals(expectedMessage, iae.getMessage());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   211
            caught = true;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   212
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   213
        assertTrue(caught);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   214
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   215
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   216
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   217
    public static void testWhileLoop() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   218
        // int i = 0; while (i < limit) { ++i; } return i; => limit
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   219
        MethodHandle loop = MethodHandles.whileLoop(While.MH_zero, While.MH_pred, While.MH_step);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   220
        assertEquals(While.MT_while, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   221
        assertEquals(23, loop.invoke(23));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   222
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   223
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   224
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   225
    public static void testWhileLoopNoIteration() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   226
        // a while loop that never executes its body because the predicate evaluates to false immediately
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   227
        MethodHandle loop = MethodHandles.whileLoop(While.MH_initString, While.MH_predString, While.MH_stepString);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   228
        assertEquals(While.MT_string, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   229
        assertEquals("a", loop.invoke());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   230
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   231
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   232
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   233
    public static void testDoWhileLoop() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   234
        // int i = 0; do { ++i; } while (i < limit); return i; => limit
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   235
        MethodHandle loop = MethodHandles.doWhileLoop(While.MH_zero, While.MH_step, While.MH_pred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   236
        assertEquals(While.MT_while, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   237
        assertEquals(23, loop.invoke(23));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   238
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   239
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   240
    @Test
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   241
    public static void testDoWhileNullInit() throws Throwable {
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   242
        While w = new While();
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   243
        int v = 5;
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   244
        MethodHandle loop = MethodHandles.doWhileLoop(null, While.MH_voidBody.bindTo(w), While.MH_voidPred.bindTo(w));
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   245
        assertEquals(While.MT_void, loop.type());
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   246
        loop.invoke(v);
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   247
        assertEquals(v, w.i);
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   248
    }
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   249
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   250
    @Test
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   251
    public static void testWhileZip() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   252
        MethodHandle loop = MethodHandles.doWhileLoop(While.MH_zipInitZip, While.MH_zipStep, While.MH_zipPred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   253
        assertEquals(While.MT_zip, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   254
        List<String> a = Arrays.asList("a", "b", "c", "d");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   255
        List<String> b = Arrays.asList("e", "f", "g", "h");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   256
        List<String> zipped = Arrays.asList("a", "e", "b", "f", "c", "g", "d", "h");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   257
        assertEquals(zipped, (List<String>) loop.invoke(a.iterator(), b.iterator()));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   258
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   259
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   260
    @Test
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   261
    public static void testWhileNullInit() throws Throwable {
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   262
        While w = new While();
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   263
        int v = 5;
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   264
        MethodHandle loop = MethodHandles.whileLoop(null, While.MH_voidPred.bindTo(w), While.MH_voidBody.bindTo(w));
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   265
        assertEquals(While.MT_void, loop.type());
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   266
        loop.invoke(v);
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   267
        assertEquals(v, w.i);
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   268
    }
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   269
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   270
    @Test
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   271
    public static void testWhileVoidInit() throws Throwable {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   272
        While w = new While();
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   273
        int v = 5;
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   274
        MethodHandle loop = MethodHandles.whileLoop(While.MH_voidInit.bindTo(w), While.MH_voidPred.bindTo(w),
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   275
                While.MH_voidBody.bindTo(w));
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   276
        assertEquals(While.MT_void, loop.type());
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   277
        loop.invoke(v);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   278
        assertEquals(v, w.i);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   279
    }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   280
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   281
    @Test
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   282
    public static void testDoWhileVoidInit() throws Throwable {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   283
        While w = new While();
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   284
        int v = 5;
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   285
        MethodHandle loop = MethodHandles.doWhileLoop(While.MH_voidInit.bindTo(w), While.MH_voidBody.bindTo(w),
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   286
                While.MH_voidPred.bindTo(w));
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   287
        assertEquals(While.MT_void, loop.type());
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   288
        loop.invoke(v);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   289
        assertEquals(v, w.i);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   290
    }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   291
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   292
    @Test
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   293
    public static void testCountedLoop() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   294
        // String s = "Lambdaman!"; for (int i = 0; i < 13; ++i) { s = "na " + s; } return s; => a variation on a well known theme
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   295
        MethodHandle fit13 = MethodHandles.constant(int.class, 13);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   296
        MethodHandle loop = MethodHandles.countedLoop(fit13, Counted.MH_start, Counted.MH_step);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   297
        assertEquals(Counted.MT_counted, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   298
        assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("Lambdaman!"));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   299
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   300
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   301
    @Test
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   302
    public static void testCountedLoopVoidInit() throws Throwable {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   303
        MethodHandle fit5 = MethodHandles.constant(int.class, 5);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   304
        MethodHandle loop = MethodHandles.countedLoop(fit5, MethodHandles.zero(void.class), Counted.MH_printHello);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   305
        assertEquals(Counted.MT_countedPrinting, loop.type());
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   306
        loop.invoke();
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   307
    }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   308
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   309
    @Test
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   310
    public static void testCountedArrayLoop() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   311
        // int[] a = new int[]{0}; for (int i = 0; i < 13; ++i) { ++a[0]; } => a[0] == 13
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   312
        MethodHandle fit13 = MethodHandles.dropArguments(MethodHandles.constant(int.class, 13), 0, int[].class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   313
        MethodHandle loop = MethodHandles.countedLoop(fit13, null, Counted.MH_stepUpdateArray);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   314
        assertEquals(Counted.MT_arrayCounted, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   315
        int[] a = new int[]{0};
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   316
        loop.invoke(a);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   317
        assertEquals(13, a[0]);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   318
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   319
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   320
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   321
    public static void testCountedPrintingLoop() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   322
        MethodHandle fit5 = MethodHandles.constant(int.class, 5);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   323
        MethodHandle loop = MethodHandles.countedLoop(fit5, null, Counted.MH_printHello);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   324
        assertEquals(Counted.MT_countedPrinting, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   325
        loop.invoke();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   326
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   327
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   328
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   329
    public static void testCountedRangeLoop() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   330
        // String s = "Lambdaman!"; for (int i = -5; i < 8; ++i) { s = "na " + s; } return s; => a well known theme
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   331
        MethodHandle fitm5 = MethodHandles.dropArguments(Counted.MH_m5, 0, String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   332
        MethodHandle fit8 = MethodHandles.dropArguments(Counted.MH_8, 0, String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   333
        MethodHandle loop = MethodHandles.countedLoop(fitm5, fit8, Counted.MH_start, Counted.MH_step);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   334
        assertEquals(Counted.MT_counted, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   335
        assertEquals("na na na na na na na na na na na na na Lambdaman!", loop.invoke("Lambdaman!"));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   336
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   337
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   338
    @Test
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   339
    public static void testCountedLoopCounterInit() throws Throwable {
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   340
        // int x = 0; for (int i = 0; i < 5; ++i) { x += i; } return x; => 10
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   341
        // (only if counter's first value in body is 0)
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   342
        MethodHandle iter = MethodHandles.constant(int.class, 5);
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   343
        MethodHandle init = MethodHandles.constant(int.class, 0);
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   344
        MethodHandle body = Counted.MH_addCounter;
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   345
        MethodHandle loop = MethodHandles.countedLoop(iter, init, body);
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   346
        assertEquals(Counted.MT_counterInit, loop.type());
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   347
        assertEquals(10, loop.invoke());
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   348
    }
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   349
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   350
    @Test
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   351
    public static void testIterateSum() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   352
        // Integer[] a = new Integer[]{1,2,3,4,5,6}; int sum = 0; for (int e : a) { sum += e; } return sum; => 21
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   353
        MethodHandle loop = MethodHandles.iteratedLoop(Iterate.MH_sumIterator, Iterate.MH_sumInit, Iterate.MH_sumStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   354
        assertEquals(Iterate.MT_sum, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   355
        assertEquals(21, loop.invoke(new Integer[]{1, 2, 3, 4, 5, 6}));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   356
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   357
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   358
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   359
    public static void testIterateReverse() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   360
        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_reverseInit, Iterate.MH_reverseStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   361
        assertEquals(Iterate.MT_reverse, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   362
        List<String> list = Arrays.asList("a", "b", "c", "d", "e");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   363
        List<String> reversedList = Arrays.asList("e", "d", "c", "b", "a");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   364
        assertEquals(reversedList, (List<String>) loop.invoke(list));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   365
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   366
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   367
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   368
    public static void testIterateLength() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   369
        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_lengthInit, Iterate.MH_lengthStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   370
        assertEquals(Iterate.MT_length, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   371
        List<Double> list = Arrays.asList(23.0, 148.0, 42.0);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   372
        assertEquals(list.size(), (int) loop.invoke(list));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   373
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   374
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   375
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   376
    public static void testIterateMap() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   377
        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_mapInit, Iterate.MH_mapStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   378
        assertEquals(Iterate.MT_map, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   379
        List<String> list = Arrays.asList("Hello", "world", "!");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   380
        List<String> upList = Arrays.asList("HELLO", "WORLD", "!");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   381
        assertEquals(upList, (List<String>) loop.invoke(list));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   382
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   383
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   384
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   385
    public static void testIteratePrint() throws Throwable {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   386
        MethodHandle loop = MethodHandles.iteratedLoop(null, null, Iterate.MH_printStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   387
        assertEquals(Iterate.MT_print, loop.type());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   388
        loop.invoke(Arrays.asList("hello", "world"));
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   389
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   390
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   391
    @Test
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   392
    public static void testIterateNullBody() {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   393
        boolean caught = false;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   394
        try {
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   395
            MethodHandles.iteratedLoop(MethodHandles.empty(methodType(Iterator.class, int.class)),
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   396
                    MethodHandles.identity(int.class), null);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   397
        } catch (IllegalArgumentException iae) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   398
            assertEquals("iterated loop body must not be null", iae.getMessage());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   399
            caught = true;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   400
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   401
        assertTrue(caught);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   402
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   403
37602
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   404
    @DataProvider
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   405
    static Object[][] wrongIteratorTypes() {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   406
        return new Object[][]{{void.class}, {Object.class}, {Iterable.class}};
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   407
    }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   408
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   409
    @Test(dataProvider = "wrongIteratorTypes")
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   410
    public static void testIterateVoidIterator(Class<?> it) {
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   411
        boolean caught = false;
37602
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   412
        MethodType v = methodType(it);
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   413
        try {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   414
            MethodHandles.iteratedLoop(MethodHandles.empty(v), null, MethodHandles.empty(v));
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   415
        } catch(IllegalArgumentException iae) {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   416
            assertEquals("iteratedLoop first argument must have Iterator return type", iae.getMessage());
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   417
            caught = true;
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   418
        }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   419
        assertTrue(caught);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   420
    }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   421
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   422
    @Test
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   423
    public static void testIterateVoidInit() throws Throwable {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   424
        MethodHandle loop = MethodHandles.iteratedLoop(null, Iterate.MH_voidInit, Iterate.MH_printStep);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   425
        assertEquals(Iterate.MT_print, loop.type());
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   426
        loop.invoke(Arrays.asList("hello", "world"));
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   427
    }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   428
37602
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   429
    @DataProvider
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   430
    static Object[][] iterateParameters() {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   431
        MethodType i = methodType(int.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   432
        MethodType sil_i = methodType(int.class, String.class, int.class, List.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   433
        MethodType sl_v = methodType(void.class, String.class, List.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   434
        MethodType l_it = methodType(Iterator.class, List.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   435
        MethodType li_it = methodType(Iterator.class, List.class, int.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   436
        MethodType l_i = methodType(int.class, List.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   437
        MethodType _it = methodType(Iterator.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   438
        MethodType si_i = methodType(int.class, String.class, int.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   439
        MethodType s_i = methodType(int.class, String.class);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   440
        return new Object[][]{
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   441
                {null, null, sl_v},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   442
                {null, i, sil_i},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   443
                {null, l_i, sil_i},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   444
                {l_it, null, sl_v},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   445
                {l_it, i, sil_i},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   446
                {li_it, l_i, sil_i},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   447
                {l_it, null, sil_i},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   448
                {li_it, null, sl_v},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   449
                {_it, l_i, si_i},
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   450
                {_it, l_i, s_i}
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   451
        };
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   452
    }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   453
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   454
    @Test(dataProvider = "iterateParameters")
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   455
    public static void testIterateParameters(MethodType it, MethodType in, MethodType bo) throws Throwable {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   456
        MethodHandle iterator = it == null ? null : MethodHandles.empty(it);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   457
        MethodHandle init = in == null ? null : MethodHandles.empty(in);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   458
        MethodHandle loop = MethodHandles.iteratedLoop(iterator, init, MethodHandles.empty(bo));
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   459
        MethodType lt = loop.type();
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   460
        if (it == null && in == null) {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   461
            assertEquals(bo.dropParameterTypes(0, 1), lt);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   462
        } else if (it == null) {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   463
            if (in.parameterCount() == 0) {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   464
                assertEquals(bo.dropParameterTypes(0, in.returnType() == void.class ? 1 : 2), lt);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   465
            } else {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   466
                assertEquals(methodType(bo.returnType(), in.parameterArray()), lt);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   467
            }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   468
        } else if (in == null) {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   469
            assertEquals(methodType(bo.returnType(), it.parameterArray()), lt);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   470
        } else if (it.parameterCount() > in.parameterCount()) {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   471
            assertEquals(methodType(bo.returnType(), it.parameterArray()), lt);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   472
        } else if (it.parameterCount() < in.parameterCount()) {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   473
            assertEquals(methodType(bo.returnType(), in.parameterArray()), lt);
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   474
        } else {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   475
            // both it, in present; with equal parameter list lengths
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   476
            assertEquals(it.parameterList(), lt.parameterList());
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   477
            assertEquals(in.parameterList(), lt.parameterList());
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   478
            assertEquals(bo.returnType(), lt.returnType());
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   479
        }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   480
    }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   481
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   482
    @Test
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   483
    public static void testIteratorSubclass() throws Throwable {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   484
        MethodHandle loop = MethodHandles.iteratedLoop(MethodHandles.empty(methodType(BogusIterator.class, List.class)),
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   485
                null, MethodHandles.empty(methodType(void.class, String.class)));
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   486
        assertEquals(methodType(void.class, List.class), loop.type());
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   487
    }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   488
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   489
    static class BogusIterator implements Iterator {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   490
        @Override
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   491
        public boolean hasNext() {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   492
            return false;
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   493
        }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   494
        @Override
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   495
        public Object next() {
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   496
            return null;
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   497
        }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   498
    }
3a9532bbd89e 8152667: MHs.iteratedLoop(...) throws unexpected WMTE, disallows Iterator subclasses, generates inconsistent loop result type
mhaupt
parents: 37539
diff changeset
   499
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   500
    static class Empty {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   501
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   502
        static void f() { }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   503
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   504
        static boolean pred() {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   505
            return false;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   506
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   507
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   508
        static int c() {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   509
            return 23;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   510
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   511
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   512
        static final Class<Empty> EMPTY = Empty.class;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   513
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   514
        static final MethodType MT_f = methodType(void.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   515
        static final MethodType MT_pred = methodType(boolean.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   516
        static final MethodType MT_c = methodType(int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   517
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   518
        static final MethodHandle MH_f;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   519
        static final MethodHandle MH_pred;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   520
        static final MethodHandle MH_c;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   521
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   522
        static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   523
            try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   524
                MH_f = LOOKUP.findStatic(EMPTY, "f", MT_f);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   525
                MH_pred = LOOKUP.findStatic(EMPTY, "pred", MT_pred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   526
                MH_c = LOOKUP.findStatic(EMPTY, "c", MT_c);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   527
            } catch (Exception e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   528
                throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   529
            }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   530
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   531
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   532
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   533
    static class Fac {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   534
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   535
        static int zero(int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   536
            return 0;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   537
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   538
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   539
        static int one(int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   540
            return 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   541
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   542
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   543
        static boolean pred(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   544
            return i < k;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   545
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   546
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   547
        static int inc(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   548
            return i + 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   549
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   550
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   551
        static int mult(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   552
            return i * acc;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   553
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   554
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   555
        static void dot(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   556
            System.out.print('.');
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   557
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   558
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   559
        static int fin(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   560
            return acc;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   561
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   562
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   563
        static final Class<Fac> FAC = Fac.class;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   564
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   565
        static final MethodType MT_init = methodType(int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   566
        static final MethodType MT_fn = methodType(int.class, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   567
        static final MethodType MT_dot = methodType(void.class, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   568
        static final MethodType MT_pred = methodType(boolean.class, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   569
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   570
        static final MethodHandle MH_zero;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   571
        static final MethodHandle MH_one;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   572
        static final MethodHandle MH_pred;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   573
        static final MethodHandle MH_inc;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   574
        static final MethodHandle MH_mult;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   575
        static final MethodHandle MH_dot;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   576
        static final MethodHandle MH_fin;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   577
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   578
        static final MethodType MT_fac = methodType(int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   579
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   580
        static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   581
            try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   582
                MH_zero = LOOKUP.findStatic(FAC, "zero", MT_init);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   583
                MH_one = LOOKUP.findStatic(FAC, "one", MT_init);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   584
                MH_pred = LOOKUP.findStatic(FAC, "pred", MT_pred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   585
                MH_inc = LOOKUP.findStatic(FAC, "inc", MT_fn);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   586
                MH_mult = LOOKUP.findStatic(FAC, "mult", MT_fn);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   587
                MH_dot = LOOKUP.findStatic(FAC, "dot", MT_dot);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   588
                MH_fin = LOOKUP.findStatic(FAC, "fin", MT_fn);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   589
            } catch (Exception e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   590
                throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   591
            }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   592
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   593
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   594
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   595
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   596
    static class Loop {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   597
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   598
        static int inc(int i, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   599
            return i + 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   600
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   601
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   602
        static boolean pred(int i, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   603
            return i < k;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   604
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   605
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   606
        static int fin(int i, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   607
            return k;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   608
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   609
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   610
        static final Class<Loop> LOOP = Loop.class;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   611
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   612
        static final MethodType MT_inc = methodType(int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   613
        static final MethodType MT_pred = methodType(boolean.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   614
        static final MethodType MT_fin = methodType(int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   615
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   616
        static final MethodHandle MH_inc;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   617
        static final MethodHandle MH_pred;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   618
        static final MethodHandle MH_fin;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   619
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   620
        static final MethodType MT_loop = methodType(int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   621
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   622
        static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   623
            try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   624
                MH_inc = LOOKUP.findStatic(LOOP, "inc", MT_inc);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   625
                MH_pred = LOOKUP.findStatic(LOOP, "pred", MT_pred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   626
                MH_fin = LOOKUP.findStatic(LOOP, "fin", MT_fin);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   627
            } catch (Exception e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   628
                throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   629
            }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   630
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   631
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   632
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   633
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   634
    static class LoopWithVirtuals {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   635
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   636
        static int one(int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   637
            return 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   638
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   639
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   640
        int inc(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   641
            return i + 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   642
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   643
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   644
        int mult(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   645
            return i * acc;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   646
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   647
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   648
        boolean pred(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   649
            return i < k;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   650
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   651
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   652
        int fin(int i, int acc, int k) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   653
            return acc;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   654
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   655
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   656
        static final Class<LoopWithVirtuals> LOOP_WITH_VIRTUALS = LoopWithVirtuals.class;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   657
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   658
        static final MethodType MT_one = methodType(int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   659
        static final MethodType MT_inc = methodType(int.class, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   660
        static final MethodType MT_mult = methodType(int.class, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   661
        static final MethodType MT_pred = methodType(boolean.class, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   662
        static final MethodType MT_fin = methodType(int.class, int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   663
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   664
        static final MethodHandle MH_one;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   665
        static final MethodHandle MH_inc;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   666
        static final MethodHandle MH_mult;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   667
        static final MethodHandle MH_pred;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   668
        static final MethodHandle MH_fin;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   669
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   670
        static final MethodType MT_loop = methodType(int.class, LOOP_WITH_VIRTUALS, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   671
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   672
        static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   673
            try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   674
                MH_one = LOOKUP.findStatic(LOOP_WITH_VIRTUALS, "one", MT_one);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   675
                MH_inc = LOOKUP.findVirtual(LOOP_WITH_VIRTUALS, "inc", MT_inc);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   676
                MH_mult = LOOKUP.findVirtual(LOOP_WITH_VIRTUALS, "mult", MT_mult);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   677
                MH_pred = LOOKUP.findVirtual(LOOP_WITH_VIRTUALS, "pred", MT_pred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   678
                MH_fin = LOOKUP.findVirtual(LOOP_WITH_VIRTUALS, "fin", MT_fin);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   679
            } catch (Exception e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   680
                throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   681
            }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   682
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   683
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   684
        static MethodHandle permute(MethodHandle h) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   685
            // The handles representing virtual methods need to be rearranged to match the required order of arguments
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   686
            // (loop-local state comes first, then loop arguments). As the receiver comes first in the signature but is
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   687
            // a loop argument, it must be moved to the appropriate position in the signature.
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   688
            return MethodHandles.permuteArguments(h,
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   689
                    methodType(h.type().returnType(), int.class, int.class, LOOP_WITH_VIRTUALS, int.class), 2, 0, 1, 3);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   690
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   691
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   692
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   693
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   694
    static class While {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   695
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   696
        static int zero(int limit) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   697
            return 0;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   698
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   699
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   700
        static boolean pred(int i, int limit) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   701
            return i < limit;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   702
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   703
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   704
        static int step(int i, int limit) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   705
            return i + 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   706
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   707
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   708
        static String initString() {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   709
            return "a";
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   710
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   711
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   712
        static boolean predString(String s) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   713
            return s.length() != 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   714
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   715
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   716
        static String stepString(String s) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   717
            return s + "a";
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   718
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   719
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   720
        static List<String> zipInitZip(Iterator<String> a, Iterator<String> b) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   721
            return new ArrayList<>();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   722
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   723
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   724
        static boolean zipPred(List<String> zip, Iterator<String> a, Iterator<String> b) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   725
            return a.hasNext() && b.hasNext();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   726
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   727
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   728
        static List<String> zipStep(List<String> zip, Iterator<String> a, Iterator<String> b) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   729
            zip.add(a.next());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   730
            zip.add(b.next());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   731
            return zip;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   732
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   733
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   734
        private int i = 0;
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   735
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   736
        void voidInit(int k) {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   737
            // empty
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   738
        }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   739
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   740
        void voidBody(int k) {
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   741
            ++i;
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   742
        }
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   743
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   744
        boolean voidPred(int k) {
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   745
            return i < k;
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   746
        }
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   747
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   748
        static final Class<While> WHILE = While.class;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   749
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   750
        static final MethodType MT_zero = methodType(int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   751
        static final MethodType MT_pred = methodType(boolean.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   752
        static final MethodType MT_fn = methodType(int.class, int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   753
        static final MethodType MT_initString = methodType(String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   754
        static final MethodType MT_predString = methodType(boolean.class, String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   755
        static final MethodType MT_stepString = methodType(String.class, String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   756
        static final MethodType MT_zipInitZip = methodType(List.class, Iterator.class, Iterator.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   757
        static final MethodType MT_zipPred = methodType(boolean.class, List.class, Iterator.class, Iterator.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   758
        static final MethodType MT_zipStep = methodType(List.class, List.class, Iterator.class, Iterator.class);
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   759
        static final MethodType MT_voidInit = methodType(void.class, int.class);
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   760
        static final MethodType MT_voidBody = methodType(void.class, int.class);
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   761
        static final MethodType MT_voidPred = methodType(boolean.class, int.class);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   762
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   763
        static final MethodHandle MH_zero;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   764
        static final MethodHandle MH_pred;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   765
        static final MethodHandle MH_step;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   766
        static final MethodHandle MH_initString;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   767
        static final MethodHandle MH_predString;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   768
        static final MethodHandle MH_stepString;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   769
        static final MethodHandle MH_zipInitZip;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   770
        static final MethodHandle MH_zipPred;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   771
        static final MethodHandle MH_zipStep;
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   772
        static final MethodHandle MH_voidInit;
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   773
        static final MethodHandle MH_voidBody;
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   774
        static final MethodHandle MH_voidPred;
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   775
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   776
        static final MethodType MT_while = methodType(int.class, int.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   777
        static final MethodType MT_string = methodType(String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   778
        static final MethodType MT_zip = methodType(List.class, Iterator.class, Iterator.class);
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   779
        static final MethodType MT_void = methodType(void.class, int.class);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   780
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   781
        static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   782
            try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   783
                MH_zero = LOOKUP.findStatic(WHILE, "zero", MT_zero);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   784
                MH_pred = LOOKUP.findStatic(WHILE, "pred", MT_pred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   785
                MH_step = LOOKUP.findStatic(WHILE, "step", MT_fn);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   786
                MH_initString = LOOKUP.findStatic(WHILE, "initString", MT_initString);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   787
                MH_predString = LOOKUP.findStatic(WHILE, "predString", MT_predString);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   788
                MH_stepString = LOOKUP.findStatic(WHILE, "stepString", MT_stepString);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   789
                MH_zipInitZip = LOOKUP.findStatic(WHILE, "zipInitZip", MT_zipInitZip);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   790
                MH_zipPred = LOOKUP.findStatic(WHILE, "zipPred", MT_zipPred);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   791
                MH_zipStep = LOOKUP.findStatic(WHILE, "zipStep", MT_zipStep);
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   792
                MH_voidInit = LOOKUP.findVirtual(WHILE, "voidInit", MT_voidInit);
36227
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   793
                MH_voidBody = LOOKUP.findVirtual(WHILE, "voidBody", MT_voidBody);
0149fa1848eb 8150957: j.l.i.MethodHandles.whileLoop(...) fails with IOOBE in the case init is null, step and pred have parameters
mhaupt
parents: 36221
diff changeset
   794
                MH_voidPred = LOOKUP.findVirtual(WHILE, "voidPred", MT_voidPred);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   795
            } catch (Exception e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   796
                throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   797
            }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   798
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   799
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   800
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   801
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   802
    static class Counted {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   803
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   804
        static String start(String arg) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   805
            return arg;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   806
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   807
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   808
        static String step(int counter, String v, String arg) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   809
            return "na " + v;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   810
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   811
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   812
        static void stepUpdateArray(int counter, int[] a) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   813
            ++a[0];
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   814
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   815
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   816
        static void printHello(int counter) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   817
            System.out.print("hello");
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   818
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   819
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   820
        static int addCounter(int counter, int x) {
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   821
            return x + counter;
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   822
        }
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   823
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   824
        static final Class<Counted> COUNTED = Counted.class;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   825
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   826
        static final MethodType MT_start = methodType(String.class, String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   827
        static final MethodType MT_step = methodType(String.class, int.class, String.class, String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   828
        static final MethodType MT_stepUpdateArray = methodType(void.class, int.class, int[].class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   829
        static final MethodType MT_printHello = methodType(void.class, int.class);
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   830
        static final MethodType MT_addCounter = methodType(int.class, int.class, int.class);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   831
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   832
        static final MethodHandle MH_13;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   833
        static final MethodHandle MH_m5;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   834
        static final MethodHandle MH_8;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   835
        static final MethodHandle MH_start;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   836
        static final MethodHandle MH_step;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   837
        static final MethodHandle MH_stepUpdateArray;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   838
        static final MethodHandle MH_printHello;
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   839
        static final MethodHandle MH_addCounter;
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   840
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   841
        static final MethodType MT_counted = methodType(String.class, String.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   842
        static final MethodType MT_arrayCounted = methodType(void.class, int[].class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   843
        static final MethodType MT_countedPrinting = methodType(void.class);
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   844
        static final MethodType MT_counterInit = methodType(int.class);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   845
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   846
        static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   847
            try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   848
                MH_13 = MethodHandles.constant(int.class, 13);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   849
                MH_m5 = MethodHandles.constant(int.class, -5);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   850
                MH_8 = MethodHandles.constant(int.class, 8);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   851
                MH_start = LOOKUP.findStatic(COUNTED, "start", MT_start);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   852
                MH_step = LOOKUP.findStatic(COUNTED, "step", MT_step);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   853
                MH_stepUpdateArray = LOOKUP.findStatic(COUNTED, "stepUpdateArray", MT_stepUpdateArray);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   854
                MH_printHello = LOOKUP.findStatic(COUNTED, "printHello", MT_printHello);
37340
81f996e37e7f 8153637: MethodHandles.countedLoop/3 initialises loop counter to 1 instead of 0
mhaupt
parents: 36227
diff changeset
   855
                MH_addCounter = LOOKUP.findStatic(COUNTED, "addCounter", MT_addCounter);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   856
            } catch (Exception e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   857
                throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   858
            }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   859
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   860
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   861
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   862
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   863
    static class Iterate {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   864
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   865
        static Iterator<Integer> sumIterator(Integer[] a) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   866
            return Arrays.asList(a).iterator();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   867
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   868
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   869
        static int sumInit(Integer[] a) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   870
            return 0;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   871
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   872
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   873
        static int sumStep(int s, int e, Integer[] a) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   874
            return s + e;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   875
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   876
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   877
        static List<String> reverseInit(List<String> l) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   878
            return new ArrayList<>();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   879
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   880
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   881
        static List<String> reverseStep(String e, List<String> r, List<String> l) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   882
            r.add(0, e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   883
            return r;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   884
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   885
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   886
        static int lengthInit(List<Double> l) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   887
            return 0;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   888
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   889
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   890
        static int lengthStep(Object o, int len, List<Double> l) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   891
            return len + 1;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   892
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   893
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   894
        static List<String> mapInit(List<String> l) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   895
            return new ArrayList<>();
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   896
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   897
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   898
        static List<String> mapStep(String e, List<String> r, List<String> l) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   899
            r.add(e.toUpperCase());
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   900
            return r;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   901
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   902
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   903
        static void printStep(String s, List<String> l) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   904
            System.out.print(s);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   905
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   906
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   907
        static void voidInit() {
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   908
            // empty
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   909
        }
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   910
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   911
        static final Class<Iterate> ITERATE = Iterate.class;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   912
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   913
        static final MethodType MT_sumIterator = methodType(Iterator.class, Integer[].class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   914
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   915
        static final MethodType MT_sumInit = methodType(int.class, Integer[].class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   916
        static final MethodType MT_reverseInit = methodType(List.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   917
        static final MethodType MT_lenghInit = methodType(int.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   918
        static final MethodType MT_mapInit = methodType(List.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   919
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   920
        static final MethodType MT_sumStep = methodType(int.class, int.class, int.class, Integer[].class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   921
        static final MethodType MT_reverseStep = methodType(List.class, String.class, List.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   922
        static final MethodType MT_lengthStep = methodType(int.class, Object.class, int.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   923
        static final MethodType MT_mapStep = methodType(List.class, String.class, List.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   924
        static final MethodType MT_printStep = methodType(void.class, String.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   925
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   926
        static final MethodType MT_voidInit = methodType(void.class);
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   927
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   928
        static final MethodHandle MH_sumIterator;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   929
        static final MethodHandle MH_sumInit;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   930
        static final MethodHandle MH_sumStep;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   931
        static final MethodHandle MH_printStep;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   932
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   933
        static final MethodHandle MH_reverseInit;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   934
        static final MethodHandle MH_reverseStep;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   935
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   936
        static final MethodHandle MH_lengthInit;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   937
        static final MethodHandle MH_lengthStep;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   938
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   939
        static final MethodHandle MH_mapInit;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   940
        static final MethodHandle MH_mapStep;
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   941
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   942
        static final MethodHandle MH_voidInit;
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   943
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   944
        static final MethodType MT_sum = methodType(int.class, Integer[].class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   945
        static final MethodType MT_reverse = methodType(List.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   946
        static final MethodType MT_length = methodType(int.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   947
        static final MethodType MT_map = methodType(List.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   948
        static final MethodType MT_print = methodType(void.class, List.class);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   949
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   950
        static {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   951
            try {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   952
                MH_sumIterator = LOOKUP.findStatic(ITERATE, "sumIterator", MT_sumIterator);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   953
                MH_sumInit = LOOKUP.findStatic(ITERATE, "sumInit", MT_sumInit);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   954
                MH_sumStep = LOOKUP.findStatic(ITERATE, "sumStep", MT_sumStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   955
                MH_reverseInit = LOOKUP.findStatic(ITERATE, "reverseInit", MT_reverseInit);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   956
                MH_reverseStep = LOOKUP.findStatic(ITERATE, "reverseStep", MT_reverseStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   957
                MH_lengthInit = LOOKUP.findStatic(ITERATE, "lengthInit", MT_lenghInit);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   958
                MH_lengthStep = LOOKUP.findStatic(ITERATE, "lengthStep", MT_lengthStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   959
                MH_mapInit = LOOKUP.findStatic(ITERATE, "mapInit", MT_mapInit);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   960
                MH_mapStep = LOOKUP.findStatic(ITERATE, "mapStep", MT_mapStep);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   961
                MH_printStep = LOOKUP.findStatic(ITERATE, "printStep", MT_printStep);
37539
fc220bc54b59 8150956: j.l.i.MethodHandles.whileLoop(...) and .iteratedLoop(...) throw unexpected exceptions in the case of 'init' return type is void
mhaupt
parents: 37340
diff changeset
   962
                MH_voidInit = LOOKUP.findStatic(ITERATE, "voidInit", MT_voidInit);
36221
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   963
            } catch (Exception e) {
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   964
                throw new ExceptionInInitializerError(e);
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   965
            }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   966
        }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   967
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   968
    }
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   969
0543ccb78f27 8150832: split T8139885 into several tests by functionality
mhaupt
parents:
diff changeset
   970
}