Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionFinish/gcfinish001.java
40948 views
/*1* Copyright (c) 2003, 2018, 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*/2223package nsk.jvmti.GarbageCollectionFinish;2425import java.io.*;26import java.math.*;2728import nsk.share.*;2930/**31* This test exercises the JVMTI event <code>GarbageCollectionFinish</code>.32* <br>It verifies that the raw monitor functions and memory management33* functions (<code>Allocate, Deallocate</code>) can be used during processing34* this event. Usage of these functions is allowed by the JVMTI spec.35*/36public class gcfinish001 {37/* number of interations to provoke garbage collecting */38final static int ITERATIONS = 2;3940static {41try {42System.loadLibrary("gcfinish001");43} catch (UnsatisfiedLinkError ule) {44System.err.println("Could not load \"gcfinish001\" library");45System.err.println("java.library.path:"46+ System.getProperty("java.library.path"));47throw ule;48}49}5051public static void main(String[] argv) {52argv = nsk.share.jvmti.JVMTITest.commonInit(argv);5354// produce JCK-like exit status55System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);56}5758public static int run(String argv[], PrintStream out) {59return new gcfinish001().runThis(argv, out);60}6162private int runThis(String argv[], PrintStream out) {63try {64for (int i=0; i<ITERATIONS; i++)65ClassUnloader.eatMemory(); // provoke garbage collecting66} catch (OutOfMemoryError e) {67// ignoring68}6970return Consts.TEST_PASSED;71}72}737475