1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test 26 * @bug 8156034 27 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") 28 * @library / /testlibrary 29 * @library ../common/patches 30 * @modules java.base/jdk.internal.org.objectweb.asm 31 * java.base/jdk.internal.org.objectweb.asm.tree 32 * jdk.vm.ci/jdk.vm.ci.hotspot 33 * jdk.vm.ci/jdk.vm.ci.code 34 * jdk.vm.ci/jdk.vm.ci.meta 35 * jdk.vm.ci/jdk.vm.ci.runtime 36 * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper 37 * @build compiler.jvmci.common.JVMCIHelpers 38 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 39 * @run main jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/ 40 * @run main jdk.test.lib.FileInstaller ./JvmciNotifyBootstrapFinishedEventTest.config 41 * ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener 42 * @run main ClassFileInstaller 43 * compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler 44 * compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory 45 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 46 * jdk.test.lib.Asserts 47 * jdk.test.lib.Utils 48 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI 49 * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. 50 * -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI 51 * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=false 52 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 53 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI 54 * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. 55 * -XX:+UseJVMCICompiler -XX:+BootstrapJVMCI 56 * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=true 57 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 58 */ 59 60 package compiler.jvmci.events; 61 62 import jdk.test.lib.Asserts; 63 import jdk.vm.ci.hotspot.services.HotSpotVMEventListener; 64 65 public class JvmciNotifyBootstrapFinishedEventTest extends HotSpotVMEventListener { 66 private static final boolean BOOTSTRAP = Boolean 67 .getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap"); 68 private static volatile int gotBoostrapNotification = 0; 69 70 public static void main(String args[]) { 71 if (BOOTSTRAP) { 72 Asserts.assertEQ(gotBoostrapNotification, 1, "Did not receive expected number of bootstrap events"); 73 } else { 74 Asserts.assertEQ(gotBoostrapNotification, 0, "Got unexpected bootstrap event"); 75 } 76 } 77 78 @Override 79 public void notifyBootstrapFinished() { 80 gotBoostrapNotification++; 81 } 82 }