Path: blob/master/test/hotspot/jtreg/compiler/jsr292/InvokerGC.java
41149 views
/*1* Copyright (c) 2016, 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* @test25* @bug 806724726* @modules java.base/jdk.internal.misc27* @library /test/lib28*29* @run main/bootclasspath/othervm -Xcomp -Xbatch30* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI31* -XX:CompileCommand=compileonly,compiler.jsr292.InvokerGC::test32* compiler.jsr292.InvokerGC33*/3435package compiler.jsr292;3637import sun.hotspot.WhiteBox;3839import java.lang.invoke.MethodHandle;40import java.lang.invoke.MethodHandles;41import java.lang.invoke.MethodType;4243public class InvokerGC {44static final WhiteBox WB = WhiteBox.getWhiteBox();4546static MethodHandle mh;47static {48try {49mh = MethodHandles.lookup().findStatic(InvokerGC.class, "dummy", MethodType.methodType(void.class));50} catch (Exception e) {51throw new Error(e);52}53}5455static void dummy() {}5657static void test() {58try {59mh.invoke();60} catch (Throwable e) {61throw new Error(e);62}63}6465public static void main(String[] args) throws Throwable {66mh.invoke(); // Pre-generate an invoker for ()V signature6768test(); // trigger method compilation69test();7071WB.fullGC(); // WB.fullGC has always clear softref policy.7273test();7475WB.clearInlineCaches(true); // Preserve static stubs.7677test(); // Trigger call site re-resolution. Invoker LambdaForm should stay the same.7879System.out.println("TEST PASSED");80}81}828384