Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Locatable/location/location003.java
41161 views
1
/*
2
* Copyright (c) 2001, 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
24
package nsk.jdi.Locatable.location;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import java.util.*;
32
import java.io.*;
33
34
/**
35
* The test for the implementation of an object of the type <BR>
36
* Locatable. <BR>
37
* <BR>
38
* The test checks up that results of the method <BR>
39
* <code>com.sun.jdi.Locatable.location()</code> <BR>
40
* complies with its spec when a tested method <BR>
41
* is one of ReferenceTypes. <BR>
42
* <BR>
43
* The cases for testing are as follows. <BR>
44
* <BR>
45
* When a gebuggee creates an object of the following <BR>
46
* class type with methods returning ReferenceType objects:<BR>
47
* <BR>
48
* class TestClass { <BR>
49
* . <BR>
50
* . <BR>
51
* public ClassForCheck[] arraymethod () { <BR>
52
* return cfc; <BR>
53
* } <BR>
54
* public ClassForCheck classmethod () { <BR>
55
* return classFC; <BR>
56
* } <BR>
57
* public InterfaceForCheck ifacemethod () { <BR>
58
* return iface; <BR>
59
* } <BR>
60
* } <BR>
61
* a debugger checks up that for all of the above
62
* methods returning ReferenceType objects, <BR>
63
* the invocation of the method Locatable.location() <BR>
64
* returns non-null value. <BR>
65
* <BR>
66
*/
67
68
public class location003 {
69
70
//----------------------------------------------------- templete section
71
static final int PASSED = 0;
72
static final int FAILED = 2;
73
static final int PASS_BASE = 95;
74
75
//----------------------------------------------------- templete parameters
76
static final String
77
sHeader1 = "\n==> nsk/jdi/Locatable/location/location003 ",
78
sHeader2 = "--> location003: ",
79
sHeader3 = "##> location003: ";
80
81
//----------------------------------------------------- main method
82
83
public static void main (String argv[]) {
84
int result = run(argv, System.out);
85
System.exit(result + PASS_BASE);
86
}
87
88
public static int run (String argv[], PrintStream out) {
89
return new location003().runThis(argv, out);
90
}
91
92
//-------------------------------------------------- log procedures
93
94
//private static boolean verbMode = false;
95
96
private static Log logHandler;
97
98
private static void log1(String message) {
99
logHandler.display(sHeader1 + message);
100
}
101
private static void log2(String message) {
102
logHandler.display(sHeader2 + message);
103
}
104
private static void log3(String message) {
105
logHandler.complain(sHeader3 + message);
106
}
107
108
// ************************************************ test parameters
109
110
private String debuggeeName =
111
"nsk.jdi.Locatable.location.location003a";
112
113
String mName = "nsk.jdi.Locatable.location";
114
115
//====================================================== test program
116
117
static ArgumentHandler argsHandler;
118
static int testExitCode = PASSED;
119
120
//------------------------------------------------------ common section
121
122
private int runThis (String argv[], PrintStream out) {
123
124
Debugee debuggee;
125
126
argsHandler = new ArgumentHandler(argv);
127
logHandler = new Log(out, argsHandler);
128
Binder binder = new Binder(argsHandler, logHandler);
129
130
131
if (argsHandler.verbose()) {
132
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
133
} else {
134
debuggee = binder.bindToDebugee(debuggeeName); // *** tp
135
}
136
137
IOPipe pipe = new IOPipe(debuggee);
138
139
debuggee.redirectStderr(out);
140
log2("location003a debuggee launched");
141
debuggee.resume();
142
143
String line = pipe.readln();
144
if ((line == null) || !line.equals("ready")) {
145
log3("signal received is not 'ready' but: " + line);
146
return FAILED;
147
} else {
148
log2("'ready' recieved");
149
}
150
151
VirtualMachine vm = debuggee.VM();
152
153
//------------------------------------------------------ testing section
154
log1(" TESTING BEGINS");
155
156
for (int i = 0; ; i++) {
157
pipe.println("newcheck");
158
line = pipe.readln();
159
160
if (line.equals("checkend")) {
161
log2(" : returned string is 'checkend'");
162
break ;
163
} else if (!line.equals("checkready")) {
164
log3("ERROR: returned string is not 'checkready'");
165
testExitCode = FAILED;
166
break ;
167
}
168
169
log1("new check: #" + i);
170
171
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
172
173
List listOfDebuggeeClasses = vm.classesByName(mName + ".location003aTestClass");
174
if (listOfDebuggeeClasses.size() != 1) {
175
testExitCode = FAILED;
176
log3("ERROR: listOfDebuggeeClasses.size() != 1");
177
break ;
178
}
179
180
List methods = null;
181
Method m = null;
182
Location mLocation = null;
183
184
int i2;
185
186
for (i2 = 0; ; i2++) {
187
188
int expresult = 0;
189
190
log2("new check: #" + i2);
191
192
switch (i2) {
193
194
case 0: // ArrayType
195
196
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
197
methodsByName("arraymethod");
198
m = (Method) methods.get(0);
199
mLocation = m.location();
200
201
if (mLocation == null) {
202
log3("ERROR: mLocation == null for 'arraymethod'");
203
testExitCode = FAILED;
204
}
205
break;
206
207
case 1: // ClassType
208
209
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
210
methodsByName("classmethod");
211
m = (Method) methods.get(0);
212
mLocation = m.location();
213
214
if (mLocation == null) {
215
log3("ERROR: mLocation == null for 'classmethod'");
216
testExitCode = FAILED;
217
}
218
break;
219
220
case 2: // InterfaceType
221
222
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
223
methodsByName("ifacemethod");
224
m = (Method) methods.get(0);
225
mLocation = m.location();
226
227
if (mLocation == null) {
228
log3("ERROR: mLocation == null for 'ifacemethod'");
229
testExitCode = FAILED;
230
}
231
break;
232
233
234
default: expresult = 2;
235
break ;
236
}
237
238
if (expresult == 2) {
239
log2(" test cases finished");
240
break ;
241
} else if (expresult == 1) {
242
log3("ERROR: expresult != true; check # = " + i);
243
testExitCode = FAILED;
244
}
245
}
246
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
247
}
248
log1(" TESTING ENDS");
249
250
//-------------------------------------------------- test summary section
251
//------------------------------------------------- standard end section
252
253
pipe.println("quit");
254
log2("waiting for the debuggee to finish ...");
255
debuggee.waitFor();
256
257
int status = debuggee.getStatus();
258
if (status != PASSED + PASS_BASE) {
259
log3("debuggee returned UNEXPECTED exit status: " +
260
status + " != PASS_BASE");
261
testExitCode = FAILED;
262
} else {
263
log2("debuggee returned expected exit status: " +
264
status + " == PASS_BASE");
265
}
266
267
if (testExitCode != PASSED) {
268
logHandler.complain("TEST FAILED");
269
}
270
return testExitCode;
271
}
272
}
273
274