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