Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach009/attach009Target.java
40951 views
1
/*
2
* Copyright (c) 2007, 2018, 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
package nsk.jvmti.AttachOnDemand.attach009;
24
25
import nsk.share.aod.TargetApplicationWaitingAgents;
26
27
class FirstLoadedClass {
28
29
}
30
31
class ClassToLoad0 {
32
33
}
34
35
class ClassToLoad1 {
36
37
}
38
39
class ClassToLoad2 {
40
41
}
42
43
class LastLoadedClass {
44
45
}
46
47
public class attach009Target extends TargetApplicationWaitingAgents {
48
49
private void loadClass(String className) {
50
try {
51
Class.forName(className, true, this.getClass().getClassLoader());
52
} catch (Throwable t ){
53
setStatusFailed("Unexpected exception during class loading: " + t);
54
t.printStackTrace(log.getOutStream());
55
}
56
}
57
58
class ClassLoadingThread extends Thread {
59
60
String className;
61
62
ClassLoadingThread(String className) {
63
this.className = className;
64
}
65
66
public void run() {
67
log.display(Thread.currentThread() + " is loading class '" + className + "'");
68
loadClass(className);
69
}
70
}
71
72
protected void targetApplicationActions() throws Throwable {
73
/*
74
* Test checks that ClassLoad event can be enabled only for one thread
75
* (for target application thread executing method targetApplicationActions()).
76
*
77
* Method targetApplicationActions() does following:
78
* - loads class 'FirstLoadedClass', after this ClassLoad evens enabled only for the current thread
79
* - starts several threads loading classes (for these threads ClassLoad events shoudn't be generated)
80
* - loads class 'LastLoadedClass', after this test agent should finish work
81
*/
82
83
ClassLoadingThread classLoadingThreads[] = new ClassLoadingThread[3];
84
for (int i = 0; i < classLoadingThreads.length; i++) {
85
classLoadingThreads[i] = new ClassLoadingThread("nsk.jvmti.AttachOnDemand.attach009.ClassToLoad" + i);
86
classLoadingThreads[i].setName("ClassLoadingThread-" + i);
87
}
88
89
loadClass("nsk.jvmti.AttachOnDemand.attach009.FirstLoadedClass");
90
91
for (ClassLoadingThread classLoadingThread : classLoadingThreads)
92
classLoadingThread.start();
93
94
for (ClassLoadingThread classLoadingThread : classLoadingThreads)
95
classLoadingThread.join();
96
97
loadClass("nsk.jvmti.AttachOnDemand.attach009.LastLoadedClass");
98
}
99
100
public static void main(String[] args) {
101
new attach009Target().runTargetApplication(args);
102
}
103
}
104
105