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