author | gadams |
Thu, 21 Feb 2019 05:06:41 -0500 | |
changeset 53869 | 34906de6c017 |
parent 50018 | 3ba0d8631f24 |
permissions | -rw-r--r-- |
50018 | 1 |
/* |
53869
34906de6c017
8219388: Misleading log message "issuspended002a debuggee launched"
gadams
parents:
50018
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
50018 | 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.ClassType.setValue; |
|
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 |
* ClassType. <BR> |
|
37 |
* <BR> |
|
38 |
* The test checks up that results of the method <BR> |
|
39 |
* <code>com.sun.jdi.ClassType.setValue()</code> <BR> |
|
40 |
* complies with its spec. <BR> |
|
41 |
* The test checks up on throwing IllegalArgumentException and <BR> |
|
42 |
* InvalidTypeException. <BR> |
|
43 |
* <BR> |
|
44 |
* The cases for testing include the primitive types and the array type.<BR> |
|
45 |
* After being started up, <BR> |
|
46 |
* a debuggee creates a TestClass object containing fields of each of <BR> |
|
47 |
* the primitive types and the array type, <BR> |
|
48 |
* and informs a debugger of the object creation. <BR> |
|
49 |
* Upon the receiption a message from the debuggee, the debugger <BR> |
|
50 |
* gets the mirror of the object, ClassType tClass, <BR> |
|
51 |
* and performs the following checks: <BR> |
|
52 |
* - invoking the method <BR> |
|
53 |
* tClass.setValue(Field field1, BooleanValue blv2) <BR> |
|
54 |
* with non-static field1 throws IllegalArgumentException; <BR> <BR> |
|
55 |
* - invoking the method <BR> |
|
56 |
* tClass.setValue(Field field1, ByteValue btv2) <BR> |
|
57 |
* with final field1 throws IllegalArgumentException; <BR> |
|
58 |
* - invoking the method <BR> |
|
59 |
* tClass.setValue(Field field1, IntegerValue inv2) <BR> |
|
60 |
* with field1 mirroring an static field within another debuggee's <BR> |
|
61 |
* class throws IllegalArgumentException; <BR> |
|
62 |
* - invoking the method <BR> |
|
63 |
* tClass.setValue(Field field1, ByteValue btv2) <BR> |
|
64 |
* with field1 mirroring not a primitive but an array type <BR> |
|
65 |
* throws InvalidTypeException. <BR> |
|
66 |
* <BR> |
|
67 |
*/ |
|
68 |
||
69 |
public class setvalue002 { |
|
70 |
||
71 |
//----------------------------------------------------- templete section |
|
72 |
static final int PASSED = 0; |
|
73 |
static final int FAILED = 2; |
|
74 |
static final int PASS_BASE = 95; |
|
75 |
||
76 |
//----------------------------------------------------- templete parameters |
|
77 |
static final String |
|
78 |
sHeader1 = "\n==> nsk/jdi/ClassType/setValue/setvalue002 ", |
|
79 |
sHeader2 = "--> debugger: ", |
|
80 |
sHeader3 = "##> debugger: "; |
|
81 |
||
82 |
//----------------------------------------------------- main method |
|
83 |
||
84 |
public static void main (String argv[]) { |
|
85 |
int result = run(argv, System.out); |
|
86 |
System.exit(result + PASS_BASE); |
|
87 |
} |
|
88 |
||
89 |
public static int run (String argv[], PrintStream out) { |
|
90 |
return new setvalue002().runThis(argv, out); |
|
91 |
} |
|
92 |
||
93 |
//-------------------------------------------------- log procedures |
|
94 |
||
95 |
private static Log logHandler; |
|
96 |
||
97 |
private static void log1(String message) { |
|
98 |
logHandler.display(sHeader1 + message); |
|
99 |
} |
|
100 |
private static void log2(String message) { |
|
101 |
logHandler.display(sHeader2 + message); |
|
102 |
} |
|
103 |
private static void log3(String message) { |
|
104 |
logHandler.complain(sHeader3 + message); |
|
105 |
} |
|
106 |
||
107 |
// ************************************************ test parameters |
|
108 |
||
109 |
private String debuggeeName = |
|
110 |
"nsk.jdi.ClassType.setValue.setvalue002a"; |
|
111 |
||
112 |
String mName = "nsk.jdi.ClassType.setValue"; |
|
113 |
||
114 |
//====================================================== test program |
|
115 |
//------------------------------------------------------ common section |
|
116 |
||
117 |
static ArgumentHandler argsHandler; |
|
118 |
||
119 |
static int waitTime; |
|
120 |
||
121 |
static VirtualMachine vm = null; |
|
122 |
||
123 |
static int testExitCode = PASSED; |
|
124 |
||
125 |
static final int returnCode0 = 0; |
|
126 |
static final int returnCode1 = 1; |
|
127 |
static final int returnCode2 = 2; |
|
128 |
static final int returnCode3 = 3; |
|
129 |
static final int returnCode4 = 4; |
|
130 |
||
131 |
//------------------------------------------------------ methods |
|
132 |
||
133 |
private int runThis (String argv[], PrintStream out) { |
|
134 |
||
135 |
Debugee debuggee; |
|
136 |
||
137 |
argsHandler = new ArgumentHandler(argv); |
|
138 |
logHandler = new Log(out, argsHandler); |
|
139 |
Binder binder = new Binder(argsHandler, logHandler); |
|
140 |
||
141 |
if (argsHandler.verbose()) { |
|
142 |
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); |
|
143 |
} else { |
|
144 |
debuggee = binder.bindToDebugee(debuggeeName); |
|
145 |
} |
|
146 |
||
147 |
waitTime = argsHandler.getWaitTime(); |
|
148 |
||
149 |
||
150 |
IOPipe pipe = new IOPipe(debuggee); |
|
151 |
||
152 |
debuggee.redirectStderr(out); |
|
53869
34906de6c017
8219388: Misleading log message "issuspended002a debuggee launched"
gadams
parents:
50018
diff
changeset
|
153 |
log2(debuggeeName + " debuggee launched"); |
50018 | 154 |
debuggee.resume(); |
155 |
||
156 |
String line = pipe.readln(); |
|
157 |
if ((line == null) || !line.equals("ready")) { |
|
158 |
log3("signal received is not 'ready' but: " + line); |
|
159 |
return FAILED; |
|
160 |
} else { |
|
161 |
log2("'ready' recieved"); |
|
162 |
} |
|
163 |
||
164 |
vm = debuggee.VM(); |
|
165 |
||
166 |
//------------------------------------------------------ testing section |
|
167 |
log1(" TESTING BEGINS"); |
|
168 |
||
169 |
for (int i = 0; ; i++) { |
|
170 |
||
171 |
pipe.println("newcheck"); |
|
172 |
line = pipe.readln(); |
|
173 |
||
174 |
if (line.equals("checkend")) { |
|
175 |
log2(" : returned string is 'checkend'"); |
|
176 |
break ; |
|
177 |
} else if (!line.equals("checkready")) { |
|
178 |
log3("ERROR: returned string is not 'checkready'"); |
|
179 |
testExitCode = FAILED; |
|
180 |
break ; |
|
181 |
} |
|
182 |
||
183 |
log1("new checkready: #" + i); |
|
184 |
||
185 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part |
|
186 |
||
187 |
||
188 |
String testedclassName = mName + ".setvalue002aTestClass"; |
|
189 |
||
190 |
ReferenceType testedclass = null; |
|
191 |
||
192 |
log2(" getting: List classes = vm.classesByName(testedclassName); expected size == 1"); |
|
193 |
List classes = vm.classesByName(testedclassName); |
|
194 |
int size = classes.size(); |
|
195 |
if (size != 1) { |
|
196 |
log3("ERROR: classes.size() != 1 : " + size); |
|
197 |
testExitCode = FAILED; |
|
198 |
break ; |
|
199 |
} |
|
200 |
||
201 |
log2(" getting ReferenceType and ClassType objects for setvalue002aTestClass"); |
|
202 |
testedclass = (ReferenceType) classes.get(0); |
|
203 |
||
204 |
ClassType tClass = (ClassType) testedclass; |
|
205 |
||
206 |
||
207 |
ReferenceType debuggeeclass = null; |
|
208 |
||
209 |
log2(" getting: List classes = vm.classesByName(debuggeeName); expected size == 1"); |
|
210 |
classes = vm.classesByName(debuggeeName); |
|
211 |
size = classes.size(); |
|
212 |
if (size != 1) { |
|
213 |
log3("ERROR: classes.size() != 1 : " + size); |
|
214 |
testExitCode = FAILED; |
|
215 |
break ; |
|
216 |
} |
|
217 |
||
218 |
log2(" getting ReferenceType and ClassType objects for debuggeeClass"); |
|
219 |
debuggeeclass = (ReferenceType) classes.get(0); |
|
220 |
||
221 |
ClassType dClass = (ClassType) debuggeeclass; |
|
222 |
||
223 |
||
224 |
||
225 |
||
226 |
String bl1 = "bl1", bl2 = "bl2"; |
|
227 |
String bt1 = "bt1", bt2 = "bt2"; |
|
228 |
String ch1 = "ch1", ch2 = "ch2"; |
|
229 |
String db1 = "db1", db2 = "db2"; |
|
230 |
String fl1 = "fl1", fl2 = "fl2"; |
|
231 |
String in1 = "in1", in2 = "in2"; |
|
232 |
String ln1 = "ln1", ln2 = "ln2"; |
|
233 |
String sh1 = "sh1", sh2 = "sh2"; |
|
234 |
||
235 |
Field field1 = null; |
|
236 |
Field field2 = null; |
|
237 |
||
238 |
||
239 |
||
240 |
log2("...... checking up: not static field; IllegalArgumentException is expected"); |
|
241 |
try { |
|
242 |
BooleanValue blv1 = null; |
|
243 |
BooleanValue blv2 = null; |
|
244 |
||
245 |
field1 = testedclass.fieldByName(bl1); |
|
246 |
field2 = testedclass.fieldByName(bl2); |
|
247 |
if (field1 == null || field2 == null) { |
|
248 |
log3("ERROR: field1 == null || field2 == null"); |
|
249 |
testExitCode = FAILED; |
|
250 |
} else { |
|
251 |
blv2 = (BooleanValue) testedclass.getValue(field2); |
|
252 |
tClass.setValue(field1, blv2); |
|
253 |
log3("ERROR: no IllegalArgumentException"); |
|
254 |
testExitCode = FAILED; |
|
255 |
} |
|
256 |
} catch ( IllegalArgumentException e1 ) { |
|
257 |
log2(" IllegalArgumentException"); |
|
258 |
} catch ( Exception e2 ) { |
|
259 |
log3("ERROR: unexpected Exception: " + e2); |
|
260 |
testExitCode = FAILED; |
|
261 |
} |
|
262 |
||
263 |
log2("...... checking up: final field; IllegalArgumentException is expected"); |
|
264 |
try { |
|
265 |
ByteValue btv1 = null; |
|
266 |
ByteValue btv2 = null; |
|
267 |
||
268 |
field1 = testedclass.fieldByName(bt1); |
|
269 |
field2 = testedclass.fieldByName(bt2); |
|
270 |
if (field1 == null || field2 == null) { |
|
271 |
log3("ERROR: field1 == null || field2 == null"); |
|
272 |
testExitCode = FAILED; |
|
273 |
} else { |
|
274 |
btv2 = (ByteValue) testedclass.getValue(field2); |
|
275 |
tClass.setValue(field1, btv2); |
|
276 |
log3("ERROR: no IllegalArgumentException"); |
|
277 |
testExitCode = FAILED; |
|
278 |
} |
|
279 |
} catch ( IllegalArgumentException e1 ) { |
|
280 |
log2(" IllegalArgumentException"); |
|
281 |
} catch ( Exception e2 ) { |
|
282 |
log3("ERROR: unexpected Exception: " + e2); |
|
283 |
testExitCode = FAILED; |
|
284 |
} |
|
285 |
||
286 |
||
287 |
log2("...... checking up: field doesn't exist in this class; IllegalArgumentException is expected"); |
|
288 |
try { |
|
289 |
IntegerValue inv1 = null; |
|
290 |
IntegerValue inv2 = null; |
|
291 |
||
292 |
field1 = debuggeeclass.fieldByName(in1); |
|
293 |
field2 = testedclass.fieldByName(in2); |
|
294 |
if (field1 == null || field2 == null) { |
|
295 |
log3("ERROR: field1 == null || field2 == null"); |
|
296 |
testExitCode = FAILED; |
|
297 |
} else { |
|
298 |
inv2 = (IntegerValue) testedclass.getValue(field2); |
|
299 |
tClass.setValue(field1, inv2); |
|
300 |
log3("ERROR: no IllegalArgumentException"); |
|
301 |
testExitCode = FAILED; |
|
302 |
} |
|
303 |
} catch ( IllegalArgumentException e1 ) { |
|
304 |
log2(" IllegalArgumentException"); |
|
305 |
} catch ( Exception e2 ) { |
|
306 |
log3("ERROR: unexpected Exception: " + e2); |
|
307 |
testExitCode = FAILED; |
|
308 |
} |
|
309 |
||
310 |
||
311 |
log2("...... checking up: no match the field's declared type; InvalidTypeException is expected"); |
|
312 |
try { |
|
313 |
ByteValue btv2 = null; |
|
314 |
String bta = "bta"; |
|
315 |
||
316 |
field1 = testedclass.fieldByName(bta); |
|
317 |
field2 = testedclass.fieldByName(bt2); |
|
318 |
if (field1 == null || field2 == null) { |
|
319 |
log3("ERROR: field1 == null || field2 == null"); |
|
320 |
testExitCode = FAILED; |
|
321 |
} else { |
|
322 |
btv2 = (ByteValue) testedclass.getValue(field2); |
|
323 |
tClass.setValue(field1, btv2); |
|
324 |
log3("ERROR: no InvalidTypeException"); |
|
325 |
testExitCode = FAILED; |
|
326 |
} |
|
327 |
} catch ( InvalidTypeException e1 ) { |
|
328 |
log2(" InvalidTypeException"); |
|
329 |
} catch ( Exception e2 ) { |
|
330 |
log3("ERROR: unexpected Exception: " + e2); |
|
331 |
testExitCode = FAILED; |
|
332 |
} |
|
333 |
||
334 |
||
335 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
336 |
} |
|
337 |
log1(" TESTING ENDS"); |
|
338 |
||
339 |
//-------------------------------------------------- test summary section |
|
340 |
//------------------------------------------------- standard end section |
|
341 |
||
342 |
pipe.println("quit"); |
|
343 |
log2("waiting for the debuggee to finish ..."); |
|
344 |
debuggee.waitFor(); |
|
345 |
||
346 |
int status = debuggee.getStatus(); |
|
347 |
if (status != PASSED + PASS_BASE) { |
|
348 |
log3("debuggee returned UNEXPECTED exit status: " + |
|
349 |
status + " != PASS_BASE"); |
|
350 |
testExitCode = FAILED; |
|
351 |
} else { |
|
352 |
log2("debuggee returned expected exit status: " + |
|
353 |
status + " == PASS_BASE"); |
|
354 |
} |
|
355 |
||
356 |
if (testExitCode != PASSED) { |
|
357 |
logHandler.complain("TEST FAILED"); |
|
358 |
} |
|
359 |
return testExitCode; |
|
360 |
} |
|
361 |
} |