Path: blob/master/test/hotspot/jtreg/vmTestbase/gc/gctests/CallGC/CallGC02/CallGC02.java
41161 views
/*1* Copyright (c) 2007, 2020, 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*/222324/*25* @test26* @key stress randomness27*28* @summary converted from VM Testbase gc/gctests/CallGC/CallGC02.29* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent]30*31* @library /vmTestbase32* /test/lib33* @run main/othervm gc.gctests.CallGC.CallGC02.CallGC02 -t 100 -gp random(arrays)34*/3536package gc.gctests.CallGC.CallGC02;3738import nsk.share.gc.*;39import nsk.share.gc.gp.*;40import nsk.share.runner.*;4142/**43* This test starts a number of threads that do System.gc() and44* System.runFinalization() and checks that there are no crashes.45*46* There is also a thread that produces garbage.47*/48public class CallGC02 extends ThreadedGCTest implements GarbageProducerAware {49private GarbageProducer garbageProducer;50private final int objectSize = 100;5152private class GarbageProduction implements Runnable {53public void run() {54garbageProducer.create(objectSize);55}56}5758protected Runnable createRunnable(int i) {59if (i == 0)60return new GarbageProduction();61else if (i % 2 == 0)62return new GCRunner();63else64return new FinRunner();65}6667public final void setGarbageProducer(GarbageProducer garbageProducer) {68this.garbageProducer = garbageProducer;69}7071public static void main(String[] args) {72GC.runTest(new CallGC02(), args);73}74}757677