Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach036/attach036TestRunner.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/attach036.
28
* VM Testbase keywords: [jpda, jvmti, noras, feature_282, vm6, jdk]
29
* VM Testbase readme:
30
* Description :
31
* Test tries to load java agents to the VM after the VM has started using
32
* Attach API (com.sun.tools.attach).
33
* This is negative test, it checks that attempt to attach java agent fails if
34
* main agent class has no proper 'agentmain' method.
35
*
36
* @library /vmTestbase
37
* /test/lib
38
* @build nsk.jvmti.AttachOnDemand.attach036.attach036TestRunner
39
*
40
* @comment create attach036Agent00.jar in current directory
41
* @build nsk.jvmti.AttachOnDemand.attach036.attach036Agent00
42
* @run driver jdk.test.lib.helpers.ClassFileInstaller nsk.jvmti.AttachOnDemand.attach036.attach036Agent00
43
* @run driver ExecDriver --cmd
44
* ${compile.jdk}/bin/jar
45
* -cfm attach036Agent00.jar ${test.src}/attach036Agent00.mf
46
* nsk/jvmti/AttachOnDemand/attach036/attach036Agent00.class
47
*
48
* @run main/othervm
49
* -XX:+UsePerfData
50
* -Djdk.attach.allowAttachSelf
51
* nsk.jvmti.AttachOnDemand.attach036.attach036TestRunner
52
* -jdk ${test.jdk}
53
* -ja attach036Agent00.jar
54
*/
55
56
package nsk.jvmti.AttachOnDemand.attach036;
57
58
import com.sun.tools.attach.AgentInitializationException;
59
import nsk.share.*;
60
import nsk.share.aod.*;
61
import nsk.share.test.TestUtils;
62
63
/*
64
* Negative test: checks that java agent fails to attach if main agent class
65
* has no proper agentmain method
66
* (test tries to attach java agent to the same VM where attach036TestRunner is running)
67
*/
68
public class attach036TestRunner extends AODTestRunner {
69
70
public attach036TestRunner(String[] args) {
71
super(args);
72
}
73
74
protected void runTest() {
75
try {
76
String currentVMId = getCurrentVMId();
77
78
AgentsAttacher attacher = new AgentsAttacher(currentVMId, argParser.getAgents(), log);
79
80
try {
81
attacher.attachAgents();
82
TestUtils.testFailed("Expected AgentLoadException wasn't thrown");
83
} catch (Failure failure) {
84
if (failure.getCause() != null) {
85
if (failure.getCause() instanceof AgentInitializationException)
86
log.display("Expected AgentInitializationException was thrown");
87
else
88
TestUtils.testFailed("Unexpected exception was thrown instead of AgentInitializationException: " + failure);
89
} else
90
throw failure;
91
}
92
} catch (Failure f) {
93
throw f;
94
} catch (Throwable t) {
95
TestUtils.unexpctedException(t);
96
}
97
}
98
99
public static void main(String[] args) {
100
new attach036TestRunner(args).runTest();
101
}
102
}
103
104