Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/lang/instrument/ParallelTransformerLoaderApp.java
38813 views
/*1* Copyright (c) 2008, 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 Java Program25*26* @author Daryl Puryear27* @copyright 1999-2004 Wily Technology, Inc. All rights reserved.28*/29public class ParallelTransformerLoaderApp30{31private static final int kNumIterations = 1000;3233public static void34main( String[] args)35throws Exception36{37System.out.println();38System.out.print("Starting test with " + kNumIterations + " iterations");39for (int i = 0; i < kNumIterations; i++)40{41// load some classes from multiple threads (this thread and one other)42Thread testThread = new TestThread(2);43testThread.start();44loadClasses(1);4546// log that it completed and reset for the next iteration47testThread.join();48System.out.print(".");49ParallelTransformerLoaderAgent.generateNewClassLoader();50}5152System.out.println();53System.out.println("Test completed successfully");54}5556private static class TestThread57extends Thread58{59private final int fIndex;6061public62TestThread( int index)63{64super("TestThread");6566fIndex = index;67}6869public void70run()71{72loadClasses(fIndex);73}74}7576public static void77loadClasses( int index)78{79ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader();80try81{82Class.forName("TestClass" + index, true, loader);83}84catch (Exception e)85{86e.printStackTrace();87}88}89}909192