jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
author kshefov
Wed, 17 Jun 2015 20:19:51 +0300
changeset 31179 a823fb6fdf2e
parent 27758 dfba484228ed
child 33495 64a266b772e8
permissions -rw-r--r--
8062904: TEST_BUG: Tests java/lang/invoke/LFCaching fail when run with -Xcomp option Reviewed-by: vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26600
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     1
/*
31179
a823fb6fdf2e 8062904: TEST_BUG: Tests java/lang/invoke/LFCaching fail when run with -Xcomp option
kshefov
parents: 27758
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
26600
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     4
 *
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     8
 *
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    13
 * accompanied this code).
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    14
 *
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    18
 *
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    21
 * questions.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    22
 */
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    23
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    24
/*
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    25
 * @test LFSingleThreadCachingTest
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    26
 * @bug 8046703
31179
a823fb6fdf2e 8062904: TEST_BUG: Tests java/lang/invoke/LFCaching fail when run with -Xcomp option
kshefov
parents: 27758
diff changeset
    27
 * @key randomness
26600
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    28
 * @summary Test verifies that lambda forms are cached when run with single thread
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    29
 * @author kshefov
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    30
 * @library /lib/testlibrary/jsr292 /lib/testlibrary
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    31
 * @build TestMethods
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    32
 * @build LambdaFormTestCase
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    33
 * @build LFCachingTestCase
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    34
 * @build LFSingleThreadCachingTest
27758
dfba484228ed 8059070: [TESTBUG] java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed - timeout
kshefov
parents: 27755
diff changeset
    35
 * @run main/othervm LFSingleThreadCachingTest
26600
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    36
 */
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    37
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    38
import java.lang.invoke.MethodHandle;
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    39
import java.util.EnumSet;
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    40
import java.util.Map;
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    41
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    42
/**
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    43
 * Single threaded lambda forms caching test class.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    44
 */
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    45
public final class LFSingleThreadCachingTest extends LFCachingTestCase {
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    46
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    47
    /**
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    48
     * Constructor for a single threaded lambda forms caching test case.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    49
     *
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    50
     * @param testMethod A method from {@code j.l.i.MethodHandles} class that
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    51
     * returns a {@code j.l.i.MethodHandle} instance.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    52
     */
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    53
    public LFSingleThreadCachingTest(TestMethods testMethod) {
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    54
        super(testMethod);
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    55
    }
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    56
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    57
    @Override
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    58
    public void doTest() {
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    59
        MethodHandle adapter1;
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    60
        MethodHandle adapter2;
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    61
        Map<String, Object> data = getTestMethod().getTestCaseData();
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    62
        try {
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    63
            adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    64
            adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO);
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    65
        } catch (NoSuchMethodException | IllegalAccessException ex) {
31179
a823fb6fdf2e 8062904: TEST_BUG: Tests java/lang/invoke/LFCaching fail when run with -Xcomp option
kshefov
parents: 27758
diff changeset
    66
            throw new Error("Unexpected exception", ex);
26600
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    67
        }
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    68
        checkLFCaching(adapter1, adapter2);
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    69
    }
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    70
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    71
    /**
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    72
     * Main routine for single threaded lambda forms caching test.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    73
     *
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    74
     * @param args Accepts no arguments.
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    75
     */
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    76
    public static void main(String[] args) {
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    77
        LambdaFormTestCase.runTests(LFSingleThreadCachingTest::new, EnumSet.allOf(TestMethods.class));
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    78
    }
27b115fe8b3c 8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff changeset
    79
}