Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine09/VirtualMachine09.java
41160 views
1
/*
2
* Copyright (c) 2008, 2020, 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/aod/VirtualMachine/VirtualMachine09.
28
* VM Testbase keywords: [feature_282, jdk]
29
* VM Testbase readme:
30
* Description :
31
* Test checks work of Attach API (com.sun.tools.attach).
32
* Test is based on the nsk.share.aod framework.
33
* This test checks method VirtualMachine.loadAgentLibrary(String agent).
34
* Test checks following spec clause: "Agent_OnAttach function is invoked even if the agent library was loaded
35
* prior to invoking this method". In this test the same agent library first loaded via VM command line
36
* option 'agentlib:', then it is loaded using method 'System.loadLibrary' and than dynamically attached.
37
*
38
* @library /vmTestbase /test/hotspot/jtreg/vmTestbase
39
* /test/lib
40
* @build nsk.aod.VirtualMachine.VirtualMachine09.VM09Target
41
* @run main/othervm/native
42
* -XX:+UsePerfData
43
* nsk.aod.VirtualMachine.VirtualMachine09.VirtualMachine09
44
* -jdk ${test.jdk}
45
* -javaOpts="-agentlib:VirtualMachine09agent00 -XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
46
* -target nsk.aod.VirtualMachine.VirtualMachine09.VM09Target
47
* -na VirtualMachine09agent00
48
* -testedMethod loadAgentLibrary
49
*/
50
51
package nsk.aod.VirtualMachine.VirtualMachine09;
52
53
import com.sun.tools.attach.VirtualMachine;
54
import nsk.aod.VirtualMachine.VirtualMachine07.VirtualMachine07;
55
import nsk.share.TestBug;
56
import nsk.share.aod.AgentInformation;
57
58
import java.util.List;
59
60
/*
61
* Test checks methods VirtualMachine.loadAgentLib and VirtualMachineloadAgentPath.
62
*
63
* Test checks following spec clause: "Agent_OnAttach function is invoked even if the agent library was loaded
64
* prior to invoking this method"
65
*/
66
public class VirtualMachine09 extends VirtualMachine07 {
67
68
public VirtualMachine09(String[] args) {
69
super(args);
70
}
71
72
public void doTestActions(String targetVMId) throws Throwable {
73
// check that all required parameters were passed to the test
74
List<AgentInformation> agents = argParser.getAgents();
75
if (agents.size() != 1) {
76
throw new TestBug("Test requires 1 agent, actually " + agents.size() + " were specified");
77
}
78
for (AgentInformation agent : agents) {
79
if (agent.jarAgent) {
80
throw new TestBug("Non native agent was specified");
81
}
82
}
83
84
VirtualMachine vm = VirtualMachine.attach(targetVMId);
85
86
try {
87
AgentInformation agent;
88
agent = agents.get(0);
89
loadAgent(vm, agent.pathToAgent, agent.agentOptions);
90
} finally {
91
vm.detach();
92
}
93
}
94
95
public static void main(String[] args) {
96
new VirtualMachine09(args).runTest();
97
}
98
}
99
100