Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach001/attach001TestRunner.java
40951 views
1
/*
2
* Copyright (c) 2008, 2021, 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
26
*
27
* @summary converted from VM Testbase nsk/jvmti/AttachOnDemand/attach001.
28
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
29
* VM Testbase readme:
30
* Description :
31
* Test tries to load java and jvmti agents to the VM after the VM has started using
32
* Attach API (com.sun.tools.attach).
33
* Test is based on the nsk.share.aod framework. In the terms of this framework
34
* java application running in the VM where agent is loaded to is called 'target application'.
35
* In this test target application tries to attach java and native agents to the same VM where target application
36
* is running. Test just checks that agents can connect and run (agents don't perform any specific
37
* checks).
38
*
39
* @library /vmTestbase
40
* /test/lib
41
* @build nsk.jvmti.AttachOnDemand.attach001.attach001TestRunner
42
*
43
* @comment create SimpleAgent00.jar in current directory
44
* @build nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
45
* @run driver jdk.test.lib.helpers.ClassFileInstaller nsk.jvmti.AttachOnDemand.sharedAgents.SimpleAgent00
46
* @run driver ExecDriver --cmd
47
* ${compile.jdk}/bin/jar
48
* -cfm SimpleAgent00.jar ${test.src}/../sharedAgents/SimpleAgent00.mf
49
* nsk/jvmti/AttachOnDemand/sharedAgents/SimpleAgent00.class
50
*
51
* @run main/othervm/native
52
* -XX:+UsePerfData
53
* -Djdk.attach.allowAttachSelf
54
* nsk.jvmti.AttachOnDemand.attach001.attach001TestRunner
55
* -jdk ${test.jdk}
56
* -javaOpts="-XX:+UsePerfData -Djdk.attach.allowAttachSelf ${test.vm.opts} ${test.java.opts}"
57
* -ja SimpleAgent00.jar
58
* -na simpleAgent00
59
*/
60
61
package nsk.jvmti.AttachOnDemand.attach001;
62
63
import nsk.share.Failure;
64
import nsk.share.aod.*;
65
import nsk.share.test.TestUtils;
66
67
/*
68
* Test tries to attach agents to the same VM where target application is running
69
* (test starts target application class in the separate thread instead of separate process).
70
*/
71
public class attach001TestRunner extends AODTestRunner {
72
attach001TestRunner(String[] args) {
73
super(args);
74
}
75
76
class TargetThread extends Thread {
77
boolean finishedSuccessfully;
78
79
public void run() {
80
try {
81
new TargetApplicationWaitingAgents().runTargetApplication(new String[] {
82
"-" + AODTargetArgParser.agentsNumberParam,
83
Integer.valueOf(argParser.getAgents().size()).toString() });
84
85
finishedSuccessfully = true;
86
} catch (Throwable t) {
87
log.complain("Unexpected exception: " + t);
88
t.printStackTrace(log.getOutStream());
89
}
90
}
91
}
92
93
protected void runTest() {
94
try {
95
TargetThread thread = new TargetThread();
96
thread.start();
97
98
// default test actions - attach agents to the given VM
99
doTestActions(getCurrentVMId());
100
101
thread.join();
102
103
if (!thread.finishedSuccessfully) {
104
TestUtils.testFailed("Unexpected error during test execution (see log for details)");
105
}
106
} catch (Failure f) {
107
throw f;
108
} catch (Throwable t) {
109
TestUtils.unexpctedException(t);
110
}
111
}
112
113
public static void main(String[] args) {
114
new attach001TestRunner(args).runTest();
115
}
116
}
117
118