/* * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ import java.io.*; import java.net.*; import java.lang.reflect.Field; // This test helper is parameterized by: // - class transformation mode: property "appcds.parallel.transform.mode" // - class loader test types // // In the case of transformMode == "cflh", the transformation is performed // by AppCDS/jvmti/TransformerAgent.java. The classes to be transformed, such as // ParallelClassTr0, are defined in ./jvmti/parallelLoad/ParallelClasses.java public class ParallelLoad { public static int MAX_CLASSES = 40; public static int NUM_THREADS = 4; public final static int SYSTEM_LOADER = 0; public final static int SINGLE_CUSTOM_LOADER = 1; public final static int MULTI_CUSTOM_LOADER = 2; public static final int FINGERPRINT_MODE = 1; public static final int API_MODE = 2; public static int loaderType = SYSTEM_LOADER; public static ClassLoader classLoaders[]; public static int mode = FINGERPRINT_MODE; public static float timeoutFactor = Float.parseFloat(System.getProperty("test.timeout.factor", "1.0")); public static void main(String args[]) throws Throwable { run(args, null); } public static void run(String args[], ClassLoader loaders[]) throws Throwable { String customJar = null; System.out.println("ParallelLoad: timeoutFactor = " + timeoutFactor); if (args.length >= 1) { if ("SINGLE_CUSTOM_LOADER".equals(args[0])) { loaderType = SINGLE_CUSTOM_LOADER; customJar = args[2]; } else if ("MULTI_CUSTOM_LOADER".equals(args[0])) { loaderType = MULTI_CUSTOM_LOADER; customJar = args[2]; } else if ("SYSTEM_LOADER".equals(args[0])) { loaderType = SYSTEM_LOADER; } else { throw new RuntimeException("Unexpected loaderType" + args[0]); } } if (customJar != null) { if ("FINGERPRINT_MODE".equals(args[1])) { mode = FINGERPRINT_MODE; classLoaders = new ClassLoader[NUM_THREADS]; for (int i=0; i