Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharValue/equals/equals001.java
41161 views
1
/*
2
* Copyright (c) 2000, 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.CharValue.equals;
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
* CharValue. <BR>
37
* <BR>
38
* The test checks up that results of the method <BR>
39
* <code>com.sun.jdi.CharValue.equals()</code> <BR>
40
* complies with its spec. <BR>
41
* <BR>
42
* The cases for testing are as follows : <BR>
43
* <BR>
44
* when a gebuggee executes the following : <BR>
45
* public static char char_a_1 = 'a'; <BR>
46
* public static char char_a_2 = 'a'; <BR>
47
* public static char char_b = 'b'; <BR>
48
* public static short shortchar_a_3 = (short) 'a'; <BR>
49
* <BR>
50
* which a debugger mirros as : <BR>
51
* <BR>
52
* CharValue cvchar_a_1; <BR>
53
* CharValue cvchar_a_2; <BR>
54
* CharValue cvchar_b; <BR>
55
* ShortValue svchar_a_3; <BR>
56
* <BR>
57
* the following is true: <BR>
58
* <BR>
59
* cvchar_a_1 == cvchar_a_2 <BR>
60
* cvchar_a_1 != cvchar_b <BR>
61
* cvchar_a_1 != svchar_a_3 <BR>
62
* <BR>
63
*/
64
65
public class equals001 {
66
67
//----------------------------------------------------- templete section
68
static final int PASSED = 0;
69
static final int FAILED = 2;
70
static final int PASS_BASE = 95;
71
72
//----------------------------------------------------- templete parameters
73
static final String
74
sHeader1 = "\n==> nsk/jdi/CharValue/equals/equals001",
75
sHeader2 = "--> equals001: ",
76
sHeader3 = "##> equals001: ";
77
78
//----------------------------------------------------- main method
79
80
public static void main (String argv[]) {
81
int result = run(argv, System.out);
82
System.exit(result + PASS_BASE);
83
}
84
85
public static int run (String argv[], PrintStream out) {
86
return new equals001().runThis(argv, out);
87
}
88
89
//-------------------------------------------------- log procedures
90
91
private static boolean verbMode = false;
92
93
private static Log logHandler;
94
95
private static void log1(String message) {
96
logHandler.display(sHeader1 + message);
97
}
98
private static void log2(String message) {
99
logHandler.display(sHeader2 + message);
100
}
101
private static void log3(String message) {
102
logHandler.complain(sHeader3 + message);
103
}
104
105
// ************************************************ test parameters
106
107
private String debuggeeName =
108
"nsk.jdi.CharValue.equals.equals001a";
109
110
//====================================================== test program
111
112
static ArgumentHandler argsHandler;
113
static int testExitCode = PASSED;
114
115
//------------------------------------------------------ common section
116
117
private int runThis (String argv[], PrintStream out) {
118
119
Debugee debuggee;
120
121
argsHandler = new ArgumentHandler(argv);
122
logHandler = new Log(out, argsHandler);
123
Binder binder = new Binder(argsHandler, logHandler);
124
125
if (argsHandler.verbose()) {
126
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
127
} else {
128
debuggee = binder.bindToDebugee(debuggeeName); // *** tp
129
}
130
131
IOPipe pipe = new IOPipe(debuggee);
132
133
debuggee.redirectStderr(out);
134
log2("equals001a debuggee launched");
135
debuggee.resume();
136
137
String line = pipe.readln();
138
if ((line == null) || !line.equals("ready")) {
139
log3("signal received is not 'ready' but: " + line);
140
return FAILED;
141
} else {
142
log2("'ready' recieved");
143
}
144
145
VirtualMachine vm = debuggee.VM();
146
147
//------------------------------------------------------ testing section
148
log1(" TESTING BEGINS");
149
150
for (int i = 0; ; i++) {
151
pipe.println("newcheck");
152
line = pipe.readln();
153
154
if (line.equals("checkend")) {
155
log2(" : returned string is 'checkend'");
156
break ;
157
} else if (!line.equals("checkready")) {
158
log3("ERROR: returned string is not 'checkready'");
159
testExitCode = FAILED;
160
break ;
161
}
162
163
log1("new check: #" + i);
164
165
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
166
167
List listOfDebuggeeExecClasses = vm.classesByName(debuggeeName);
168
if (listOfDebuggeeExecClasses.size() != 1) {
169
testExitCode = FAILED;
170
log3("ERROR: listOfDebuggeeExecClasses.size() != 1");
171
break ;
172
}
173
ReferenceType execClass =
174
(ReferenceType) listOfDebuggeeExecClasses.get(0);
175
176
Field fcchar_a_1 = execClass.fieldByName("char_a_1");
177
Field fcchar_a_2 = execClass.fieldByName("char_a_2");
178
Field fcchar_b = execClass.fieldByName("char_b");
179
Field fschar_a_3 = execClass.fieldByName("shortchar_a_3");
180
181
CharValue cvchar_a_1 = (CharValue) execClass.getValue(fcchar_a_1);
182
CharValue cvchar_a_2 = (CharValue) execClass.getValue(fcchar_a_2);
183
CharValue cvchar_b = (CharValue) execClass.getValue(fcchar_b);
184
ShortValue svchar_a_3 = (ShortValue) execClass.getValue(fschar_a_3);
185
186
187
int i2;
188
189
for (i2 = 0; ; i2++) {
190
191
int expresult = 0;
192
193
log2("new check: #" + i2);
194
195
switch (i2) {
196
197
case 0: if (!cvchar_a_1.equals(cvchar_a_2))
198
expresult = 1;
199
break;
200
201
case 1: if (cvchar_a_1.equals(cvchar_b))
202
expresult = 1;
203
break;
204
205
case 2: if (cvchar_a_1.equals(svchar_a_3))
206
expresult = 1;
207
break;
208
209
210
default: expresult = 2;
211
break ;
212
}
213
214
if (expresult == 2) {
215
log2(" test cases finished");
216
break ;
217
} else if (expresult == 1) {
218
log3("ERROR: expresult != true; check # = " + i);
219
testExitCode = FAILED;
220
}
221
}
222
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223
}
224
log1(" TESTING ENDS");
225
226
//-------------------------------------------------- test summary section
227
//------------------------------------------------- standard end section
228
229
pipe.println("quit");
230
log2("waiting for the debuggee finish ...");
231
debuggee.waitFor();
232
233
int status = debuggee.getStatus();
234
if (status != PASSED + PASS_BASE) {
235
log3("debuggee returned UNEXPECTED exit status: " +
236
status + " != PASS_BASE");
237
testExitCode = FAILED;
238
} else {
239
log2("debuggee returned expected exit status: " +
240
status + " == PASS_BASE");
241
}
242
243
if (testExitCode != PASSED) {
244
logHandler.complain("TEST FAILED");
245
}
246
return testExitCode;
247
}
248
}
249
250