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