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