Path: blob/jdk8u272-b10-aarch32-20201026/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
48795 views
/*1* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test LFSingleThreadCachingTest25* @bug 804670326* @summary Test verifies that lambda forms are cached when run with single thread27* @author kshefov28* @library /lib/testlibrary/jsr292 /lib/testlibrary29* @build TestMethods30* @build LambdaFormTestCase31* @build LFCachingTestCase32* @build LFSingleThreadCachingTest33* @run main/othervm LFSingleThreadCachingTest34*/3536import java.lang.invoke.MethodHandle;37import java.util.EnumSet;38import java.util.Map;3940/**41* Single threaded lambda forms caching test class.42*/43public final class LFSingleThreadCachingTest extends LFCachingTestCase {4445/**46* Constructor for a single threaded lambda forms caching test case.47*48* @param testMethod A method from {@code j.l.i.MethodHandles} class that49* returns a {@code j.l.i.MethodHandle} instance.50*/51public LFSingleThreadCachingTest(TestMethods testMethod) {52super(testMethod);53}5455@Override56public void doTest() {57MethodHandle adapter1;58MethodHandle adapter2;59Map<String, Object> data = getTestMethod().getTestCaseData();60try {61adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);62adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO);63} catch (NoSuchMethodException | IllegalAccessException ex) {64throw new Error("Unexpected exception", ex);65}66checkLFCaching(adapter1, adapter2);67}6869/**70* Main routine for single threaded lambda forms caching test.71*72* @param args Accepts no arguments.73*/74public static void main(String[] args) {75LambdaFormTestCase.runTests(LFSingleThreadCachingTest::new, EnumSet.allOf(TestMethods.class));76}77}787980