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.ObjectReference.referenceType; |
|
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 |
* ObjectReference. <BR> |
|
37 |
* <BR> |
|
38 |
* The test checks up that results of the method <BR> |
|
39 |
* <code>com.sun.jdi.ObjectReference.referenceType()</code> <BR> |
|
40 |
* complies with its spec when ObjectReference is ArrayReference<BR> |
|
41 |
* of ClassType. <BR> |
|
42 |
* <BR> |
|
43 |
* The test consequently checks up the following assersions: <BR> |
|
44 |
* - the type may be a subclass or implementor of the declared type<BR> |
|
45 |
* of any field or variable which currently holds it; <BR> |
|
46 |
* - the returned ReferenceType will be a ClassType or ArrayType<BR> |
|
47 |
* and never an InterfaceType; <BR> |
|
48 |
* - the type of an object never changes, so this method will <BR> |
|
49 |
* always return the same ReferenceType over the lifetime <BR> |
|
50 |
* of the mirrored object. <BR> |
|
51 |
*/ |
|
52 |
||
53 |
public class referencetype005 { |
|
54 |
||
55 |
//----------------------------------------------------- templete section |
|
56 |
static final int PASSED = 0; |
|
57 |
static final int FAILED = 2; |
|
58 |
static final int PASS_BASE = 95; |
|
59 |
||
60 |
//----------------------------------------------------- templete parameters |
|
61 |
static final String |
|
62 |
sHeader1 = "\n==> nsk/jdi/ObjectReference/referenceType/referencetype005 ", |
|
63 |
sHeader2 = "--> debugger: ", |
|
64 |
sHeader3 = "##> debugger: "; |
|
65 |
||
66 |
//----------------------------------------------------- main method |
|
67 |
||
68 |
public static void main (String argv[]) { |
|
69 |
int result = run(argv, System.out); |
|
70 |
System.exit(result + PASS_BASE); |
|
71 |
} |
|
72 |
||
73 |
public static int run (String argv[], PrintStream out) { |
|
74 |
return new referencetype005().runThis(argv, out); |
|
75 |
} |
|
76 |
||
77 |
//-------------------------------------------------- log procedures |
|
78 |
||
79 |
private static Log logHandler; |
|
80 |
||
81 |
private static void log1(String message) { |
|
82 |
logHandler.display(sHeader1 + message); |
|
83 |
} |
|
84 |
private static void log2(String message) { |
|
85 |
logHandler.display(sHeader2 + message); |
|
86 |
} |
|
87 |
private static void log3(String message) { |
|
88 |
logHandler.complain(sHeader3 + message); |
|
89 |
} |
|
90 |
||
91 |
// ************************************************ test parameters |
|
92 |
||
93 |
private String debuggeeName = |
|
94 |
"nsk.jdi.ObjectReference.referenceType.referencetype005a"; |
|
95 |
||
96 |
private String testedClassName = |
|
97 |
"nsk.jdi.ObjectReference.referenceType.referencetype005aClassForCheck[]"; |
|
98 |
||
99 |
String mName = "nsk.jdi.ObjectReference.referenceType"; |
|
100 |
||
101 |
//====================================================== test program |
|
102 |
//------------------------------------------------------ common section |
|
103 |
||
104 |
static ArgumentHandler argsHandler; |
|
105 |
||
106 |
static int waitTime; |
|
107 |
||
108 |
static VirtualMachine vm = null; |
|
109 |
||
110 |
ReferenceType testedClass = null; |
|
111 |
||
112 |
static int testExitCode = PASSED; |
|
113 |
||
114 |
static final int returnCode0 = 0; |
|
115 |
static final int returnCode1 = 1; |
|
116 |
static final int returnCode2 = 2; |
|
117 |
static final int returnCode3 = 3; |
|
118 |
static final int returnCode4 = 4; |
|
119 |
||
120 |
//------------------------------------------------------ methods |
|
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 |
if (argsHandler.verbose()) { |
|
131 |
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); |
|
132 |
} else { |
|
133 |
debuggee = binder.bindToDebugee(debuggeeName); |
|
134 |
} |
|
135 |
||
136 |
waitTime = argsHandler.getWaitTime(); |
|
137 |
||
138 |
||
139 |
IOPipe pipe = new IOPipe(debuggee); |
|
140 |
||
141 |
debuggee.redirectStderr(out); |
|
53869
34906de6c017
8219388: Misleading log message "issuspended002a debuggee launched"
gadams
parents:
50018
diff
changeset
|
142 |
log2(debuggeeName + " debuggee launched"); |
50018 | 143 |
debuggee.resume(); |
144 |
||
145 |
String line = pipe.readln(); |
|
146 |
if ((line == null) || !line.equals("ready")) { |
|
147 |
log3("signal received is not 'ready' but: " + line); |
|
148 |
return FAILED; |
|
149 |
} else { |
|
150 |
log2("'ready' recieved"); |
|
151 |
} |
|
152 |
||
153 |
vm = debuggee.VM(); |
|
154 |
||
155 |
//------------------------------------------------------ testing section |
|
156 |
log1(" TESTING BEGINS"); |
|
157 |
||
158 |
for (int i = 0; ; i++) { |
|
159 |
||
160 |
pipe.println("newcheck"); |
|
161 |
line = pipe.readln(); |
|
162 |
||
163 |
if (line.equals("checkend")) { |
|
164 |
log2(" : returned string is 'checkend'"); |
|
165 |
break ; |
|
166 |
} else if (!line.equals("checkready")) { |
|
167 |
log3("ERROR: returned string is not 'checkready'"); |
|
168 |
testExitCode = FAILED; |
|
169 |
break ; |
|
170 |
} |
|
171 |
||
172 |
log1("new checkready: #" + i); |
|
173 |
||
174 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part |
|
175 |
||
176 |
List listOftestedClasses = vm.classesByName(mName + ".referencetype005aTestClass"); |
|
177 |
if (listOftestedClasses.size() != 1) { |
|
178 |
log3("ERROR: listOftestedClasses.size() != 1"); |
|
179 |
testExitCode = FAILED; |
|
180 |
continue; |
|
181 |
} |
|
182 |
ReferenceType testedClass = |
|
183 |
(ReferenceType) listOftestedClasses.get(0); |
|
184 |
||
185 |
Field fieldArray = testedClass.fieldByName("cfc"); |
|
186 |
if (fieldArray == null) { |
|
187 |
log3("ERROR: fieldArray == null"); |
|
188 |
testExitCode = FAILED; |
|
189 |
continue; |
|
190 |
} |
|
191 |
||
192 |
ArrayReference arrayRef = (ArrayReference) testedClass.getValue(fieldArray); |
|
193 |
||
194 |
log2("......ReferenceType testedClass = arrayRef.referenceType();"); |
|
195 |
testedClass = arrayRef.referenceType(); |
|
196 |
||
197 |
log2("...... check up on equality testedClass.name() to String testedClassName"); |
|
198 |
if (!testedClass.name().equals(testedClassName)) { |
|
199 |
log3("ERROR: check that the type may be a subclass or implementor of the declared type FAILED"); |
|
200 |
log3("ERROR: String testedClassName : " + testedClassName); |
|
201 |
log3("ERROR: performing statement : !testedClass.name().equals(testedClassName)"); |
|
202 |
log3("ERROR: testedClass.name() : " + testedClass.name()); |
|
203 |
testExitCode = FAILED; |
|
204 |
} |
|
205 |
||
206 |
try { |
|
207 |
log2(".......check up on cast to ArrayType; no Exception expected"); |
|
208 |
ArrayType ct = (ArrayType) testedClass; |
|
209 |
} catch ( Exception e ) { |
|
210 |
log3("ERROR: check that ReferenceType will be a ArrayType FAILED"); |
|
211 |
log3("ERROR: ReferenceType testedClass is of the type : " + testedClass); |
|
212 |
log3("ERROR: performing statement: ArrayType ct = (ArrayType) testedClass;"); |
|
213 |
log3("ERROR: Exception : " + e); |
|
214 |
testExitCode = FAILED; |
|
215 |
} |
|
216 |
||
217 |
||
218 |
log2(".......check up on equality ReferenceType arrayRef.referenceType() to testedClass"); |
|
219 |
ReferenceType testedClass1 = arrayRef.referenceType(); |
|
220 |
if (!testedClass1.equals(testedClass)) { |
|
221 |
log3("ERROR: check that the method always return the same RefereneceType object FAILED"); |
|
222 |
log3("ERROR: ReferenceType testedClass is of the type : " + testedClass); |
|
223 |
log3("ERROR: performing statement: !arrayRef.referenceType().equals(testedClass)"); |
|
224 |
log3("ERROR: returned ReferenceType : " + testedClass1); |
|
225 |
testExitCode = FAILED; |
|
226 |
} |
|
227 |
||
228 |
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
229 |
} |
|
230 |
log1(" TESTING ENDS"); |
|
231 |
||
232 |
//-------------------------------------------------- test summary section |
|
233 |
//------------------------------------------------- standard end section |
|
234 |
||
235 |
pipe.println("quit"); |
|
236 |
log2("waiting for the debuggee to finish ..."); |
|
237 |
debuggee.waitFor(); |
|
238 |
||
239 |
int status = debuggee.getStatus(); |
|
240 |
if (status != PASSED + PASS_BASE) { |
|
241 |
log3("debuggee returned UNEXPECTED exit status: " + |
|
242 |
status + " != PASS_BASE"); |
|
243 |
testExitCode = FAILED; |
|
244 |
} else { |
|
245 |
log2("debuggee returned expected exit status: " + |
|
246 |
status + " == PASS_BASE"); |
|
247 |
} |
|
248 |
||
249 |
if (testExitCode != PASSED) { |
|
250 |
logHandler.complain("TEST FAILED"); |
|
251 |
} |
|
252 |
return testExitCode; |
|
253 |
} |
|
254 |
} |