Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/value/value004.java
41160 views
1
/*
2
* Copyright (c) 2000, 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
package nsk.jdi.Argument.value;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import com.sun.jdi.connect.*;
32
import java.io.*;
33
import javax.naming.directory.Attribute;
34
import java.util.*;
35
36
import jtreg.SkippedException;
37
38
/**
39
* Test for the control of
40
*
41
* Interface: com.sun.jdi.connect.Connector.Argument
42
* Method: public java.lang.String value()
43
* Assertion: "Returns the current value of the argument."
44
*
45
*
46
* Comments: The test aims on the concrete Sun's JDI
47
* reference implementations. It uses
48
* com.sun.jdi.RawCommandLineLaunch connector and its
49
* "command" argument.
50
* The test sets up the new "command" argument
51
* value and then checks that new value remains previously
52
* after connection establishing with debugee VM and
53
* after debugee VM finishing.
54
*/
55
56
public class value004 {
57
private static Log log;
58
59
public static void main( String argv[] ) {
60
System.exit(run(argv, System.out)+95); // JCK-compatible exit status
61
}
62
63
public static int run(String argv[],PrintStream out) {
64
ArgumentHandler argHandler = new ArgumentHandler(argv);
65
log = new Log(out, argHandler);
66
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
67
68
String address = argHandler.getTransportPort();
69
70
List lcl = vmm.launchingConnectors();
71
if (lcl.size() > 0) {
72
log.display("Number of all known JDI launching connectors: "
73
+ lcl.size());
74
} else {
75
log.complain("FAILURE: no JDI launching connectors found!");
76
return 2;
77
}
78
79
boolean skipped = true;
80
Iterator lci = lcl.iterator();
81
while (lci.hasNext()) {
82
Connector c = (Connector) lci.next();
83
if (!"com.sun.jdi.RawCommandLineLaunch".equals(c.name())) {
84
log.display("skipping " + c);
85
continue;
86
}
87
log.display("Connector's transport is: " + c.transport().name());
88
Map<java.lang.String,? extends com.sun.jdi.connect.Connector.Argument> cdfltArgmnts = c.defaultArguments();
89
int ksz = cdfltArgmnts.size();
90
String av[] = new String[ksz + 1];
91
Set ks = cdfltArgmnts.keySet();
92
if (ks.isEmpty()) {
93
log.complain("FAILURE: empty default arguments set is "
94
+ "found for " + c.name() + " connector!");
95
return 2;
96
}
97
98
log.display("Looking over " + c.name() + " connector arguments: ");
99
100
boolean flg = false;
101
Iterator argi = ks.iterator();
102
String ovl = null;
103
String nvl = null;
104
for (int j = 1; argi.hasNext(); j++) {
105
String argkey = (String) argi.next();
106
Connector.Argument argval =
107
(Connector.Argument)cdfltArgmnts.get((Object) argkey);
108
log.display("Connector.Argument argval = "+ argval);
109
if (argkey.compareTo("command") != 0 &&
110
argkey.compareTo("address") != 0) {
111
continue;
112
}
113
if (argkey.compareTo("address") == 0) {
114
if (argval.isValid(address)) {
115
argval.setValue(address);
116
} else {
117
log.complain("FAILURE: Can't set up new value "
118
+ "for address-argument");
119
return 2;
120
}
121
continue;
122
}
123
flg = true;
124
ovl = argHandler.getLaunchExecPath() + " "
125
+ "-Xdebug -Xnoagent -Djava.compiler=NONE "
126
+ "-Xrunjdwp:transport=" + c.transport().name() + ",suspend=y,"
127
+ "address=" + address + " nsk.jdi.Argument.value.value004a";
128
if (argval.isValid(ovl)) {
129
argval.setValue(ovl);
130
} else {
131
log.complain("FAILURE: Can't set up new value for "
132
+ "command-argument");
133
return 2;
134
}
135
136
nvl = argval.value();
137
if (nvl.compareTo(ovl) != 0) {
138
log.complain("FAILURE: Can't set up argument value!");
139
return 2;
140
}
141
log.display("Changed " + argval.name() + " argument's "
142
+ "value is: " + nvl);
143
};
144
145
Binder binder = new Binder(argHandler, log);
146
Debugee debugee = null;
147
148
try {
149
if (flg) {
150
flg = false;
151
VirtualMachine vm =
152
((LaunchingConnector)c).launch(cdfltArgmnts);
153
log.display("VM = (" + vm + ")");
154
debugee = binder.enwrapDebugee(vm, vm.process());
155
156
if (((Connector.Argument) cdfltArgmnts
157
.get((Object) "command")).value()
158
.compareTo(ovl) != 0) {
159
log.complain("FAILURE: Current 'command' argument "
160
+ "value is not coinsides with the "
161
+ "last setted up value.");
162
return 2;
163
}
164
165
debugee.resume();
166
}
167
} catch ( java.io.IOException exc) {
168
log.complain("FAILURE: Unable to launch, so "
169
+ "java.io.IOException is arisen.");
170
log.complain(exc.getMessage());
171
return 2;
172
} catch ( com.sun.jdi.connect.IllegalConnectorArgumentsException
173
exc) {
174
log.complain("FAILURE: One of the connector arguments "
175
+ "is invalid, so "
176
+ "IllegalConnectorArgumentsException is arisen.");
177
log.complain(exc.getMessage());
178
return 2;
179
} catch ( com.sun.jdi.connect.VMStartException exc) {
180
log.complain("FAILURE: VM was terminated with error before "
181
+ "a connection could be established, so "
182
+ "VMStartException is arisen.");
183
log.complain(exc.getMessage());
184
log.complain(Binder.readVMStartExceptionOutput(exc, log.getOutStream()));
185
return 2;
186
} finally {
187
if (debugee != null) {
188
try {
189
debugee.dispose();
190
} catch (VMDisconnectedException ignore) {
191
}
192
193
int extcd = debugee.waitFor();
194
if (extcd != 95) {
195
log.complain("FAILURE: Launching VM crushes "
196
+ "with " + extcd + " exit code.");
197
return 2;
198
}
199
}
200
}
201
skipped = false;
202
}
203
if (skipped) {
204
throw new SkippedException("no suitable connectors");
205
}
206
log.display("Test PASSED!");
207
return 0;
208
}
209
}
210
211