Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/lang/instrument/ParallelTransformerLoaderApp.java
38813 views
1
/*
2
* Copyright (c) 2008, 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 Java Program
26
*
27
* @author Daryl Puryear
28
* @copyright 1999-2004 Wily Technology, Inc. All rights reserved.
29
*/
30
public class ParallelTransformerLoaderApp
31
{
32
private static final int kNumIterations = 1000;
33
34
public static void
35
main( String[] args)
36
throws Exception
37
{
38
System.out.println();
39
System.out.print("Starting test with " + kNumIterations + " iterations");
40
for (int i = 0; i < kNumIterations; i++)
41
{
42
// load some classes from multiple threads (this thread and one other)
43
Thread testThread = new TestThread(2);
44
testThread.start();
45
loadClasses(1);
46
47
// log that it completed and reset for the next iteration
48
testThread.join();
49
System.out.print(".");
50
ParallelTransformerLoaderAgent.generateNewClassLoader();
51
}
52
53
System.out.println();
54
System.out.println("Test completed successfully");
55
}
56
57
private static class TestThread
58
extends Thread
59
{
60
private final int fIndex;
61
62
public
63
TestThread( int index)
64
{
65
super("TestThread");
66
67
fIndex = index;
68
}
69
70
public void
71
run()
72
{
73
loadClasses(fIndex);
74
}
75
}
76
77
public static void
78
loadClasses( int index)
79
{
80
ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader();
81
try
82
{
83
Class.forName("TestClass" + index, true, loader);
84
}
85
catch (Exception e)
86
{
87
e.printStackTrace();
88
}
89
}
90
}
91
92