Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Field/equals/equals002.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
25
package nsk.jdi.Field.equals;
26
27
import nsk.share.*;
28
import nsk.share.jpda.*;
29
import nsk.share.jdi.*;
30
31
import com.sun.jdi.*;
32
import java.util.*;
33
import java.io.*;
34
35
public class equals002 {
36
final static int TOTAL_FIELDS = 117;
37
final static String FIELDS_TYPE_NAME[][] = {
38
{"boolean", "z0"},
39
{"boolean", "z1"},
40
{"boolean", "z2"},
41
{"byte", "b0"},
42
{"byte", "b1"},
43
{"byte", "b2"},
44
{"char", "c0"},
45
{"char", "c1"},
46
{"char", "c2"},
47
{"double", "d0"},
48
{"double", "d1"},
49
{"double", "d2"},
50
{"float", "f0"},
51
{"float", "f1"},
52
{"float", "f2"},
53
{"int", "i0"},
54
{"int", "i1"},
55
{"int", "i2"},
56
{"long", "l0"},
57
{"long", "l1"},
58
{"long", "l2"},
59
60
{"long", "lS0"},
61
{"long", "lS1"},
62
{"long", "lS2"},
63
{"long", "lP0"},
64
{"long", "lP1"},
65
{"long", "lP2"},
66
{"long", "lU0"},
67
{"long", "lU1"},
68
{"long", "lU2"},
69
{"long", "lR0"},
70
{"long", "lR1"},
71
{"long", "lR2"},
72
{"long", "lT0"},
73
{"long", "lT1"},
74
{"long", "lT2"},
75
{"long", "lV0"},
76
{"long", "lV1"},
77
{"long", "lV2"},
78
{"long", "lF0"},
79
{"long", "lF1"},
80
{"long", "lF2"},
81
82
{"Class", "X0"},
83
{"Class", "X1"},
84
{"Class", "X2"},
85
{"Boolean", "Z0"},
86
{"Boolean", "Z1"},
87
{"Boolean", "Z2"},
88
{"Byte", "B0"},
89
{"Byte", "B1"},
90
{"Byte", "B2"},
91
{"Char", "C0"},
92
{"Char", "C1"},
93
{"Char", "C2"},
94
{"Double", "D0"},
95
{"Double", "D1"},
96
{"Double", "D2"},
97
{"Float", "F0"},
98
{"Float", "F1"},
99
{"Float", "F2"},
100
{"Int", "I0"},
101
{"Int", "I1"},
102
{"Int", "I2"},
103
{"Long", "L0"},
104
{"Long", "L1"},
105
{"Long", "L2"},
106
{"String", "S0"},
107
{"String", "S1"},
108
{"String", "S2"},
109
{"Object", "O0"},
110
{"Object", "O1"},
111
{"Object", "O2"},
112
113
{"Long", "LS0"},
114
{"Long", "LS1"},
115
{"Long", "LS2"},
116
{"Long", "LP0"},
117
{"Long", "LP1"},
118
{"Long", "LP2"},
119
{"Long", "LU0"},
120
{"Long", "LU1"},
121
{"Long", "LU2"},
122
{"Long", "LR0"},
123
{"Long", "LR1"},
124
{"Long", "LR2"},
125
{"Long", "LT0"},
126
{"Long", "LT1"},
127
{"Long", "LT2"},
128
{"Long", "LV0"},
129
{"Long", "LV1"},
130
{"Long", "LV2"},
131
{"Long", "LF0"},
132
{"Long", "LF1"},
133
{"Long", "LF2"},
134
135
{"Inter", "E0"},
136
{"Inter", "E1"},
137
{"Inter", "E2"},
138
{"Inter", "ES0"},
139
{"Inter", "ES1"},
140
{"Inter", "ES2"},
141
{"Inter", "EP0"},
142
{"Inter", "EP1"},
143
{"Inter", "EP2"},
144
{"Inter", "EU0"},
145
{"Inter", "EU1"},
146
{"Inter", "EU2"},
147
{"Inter", "ER0"},
148
{"Inter", "ER1"},
149
{"Inter", "ER2"},
150
{"Inter", "ET0"},
151
{"Inter", "ET1"},
152
{"Inter", "ET2"},
153
{"Inter", "EV0"},
154
{"Inter", "EV1"},
155
{"Inter", "EV2"},
156
{"Inter", "EF0"},
157
{"Inter", "EF1"},
158
{"Inter", "EF2"}
159
};
160
private static Log log;
161
private final static String prefix = "nsk.jdi.Field.equals.";
162
private final static String className = "equals002";
163
private final static String debugerName = prefix + className;
164
private final static String debugeeName = debugerName + "a";
165
166
public static void main(String argv[]) {
167
System.exit(95 + run(argv, System.out));
168
}
169
170
public static int run(String argv[], PrintStream out) {
171
ArgumentHandler argHandler = new ArgumentHandler(argv);
172
log = new Log(out, argHandler);
173
Binder binder = new Binder(argHandler, log);
174
Debugee debugee = binder.bindToDebugee(debugeeName
175
+ (argHandler.verbose() ? " -verbose" : ""));
176
IOPipe pipe = new IOPipe(debugee);
177
boolean testFailed = false;
178
List fields;
179
180
// Connect with debugee and resume it
181
debugee.redirectStderr(out);
182
debugee.resume();
183
String line = pipe.readln();
184
if (line == null) {
185
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - null");
186
return 2;
187
}
188
if (!line.equals("ready")) {
189
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - "
190
+ line);
191
return 2;
192
}
193
else {
194
log.display("debuger> debugee's \"ready\" signal recieved.");
195
}
196
197
// Get all fields from debugee
198
ReferenceType refType = debugee.classByName(debugeeName);
199
if (refType == null) {
200
log.complain("debuger FAILURE> Class " + debugeeName
201
+ " not found.");
202
return 2;
203
}
204
try {
205
fields = refType.allFields();
206
} catch (Exception e) {
207
log.complain("debuger FAILURE> Can't get fields from class");
208
log.complain("debuger FAILURE> Exception: " + e);
209
return 2;
210
}
211
int totalFields = fields.size();
212
if (totalFields < 1) {
213
log.complain("debuger FAILURE> Total number of fields read "
214
+ totalFields + ", should be " + TOTAL_FIELDS);
215
return 2;
216
}
217
log.display("debuger> Total fields found: " + totalFields);
218
Iterator fieldsIterator = fields.iterator();
219
for (int i = 0; fieldsIterator.hasNext(); i++) {
220
Field srcField = (Field)fieldsIterator.next();
221
String name = srcField.name();
222
223
// Compare all fields with each other but srcField
224
if (name == null) {
225
log.complain("debuger FAILURE 1> Name is null for " + i
226
+ " field");
227
testFailed = true;
228
continue;
229
}
230
for (int j = 0; j < TOTAL_FIELDS; j++) {
231
String checkFieldName = FIELDS_TYPE_NAME[j][1];
232
Field checkField;
233
234
if (!name.equals(checkFieldName)) {
235
try {
236
checkField = refType.fieldByName(checkFieldName);
237
} catch (Exception e) {
238
log.complain("debuger FAILURE 2> Can't get field "
239
+ "by name " + checkFieldName);
240
log.complain("debuger FAILURE 2> Exception: " + e);
241
testFailed = true;
242
continue;
243
}
244
245
// Compare two different Fields, result should be false
246
boolean fieldsEqual = srcField.equals(checkField);
247
log.display("debuger> Compared fields " + name + " and "
248
+ checkFieldName + ", result is " + fieldsEqual);
249
if (fieldsEqual) {
250
// Fields in the same class that mirror different
251
// fields are not equal
252
log.complain("debuger FAILURE 3> Different fields "
253
+ "(" + name + " and " + checkFieldName + ")"
254
+ " are equal. Expected result: not equal.");
255
testFailed = true;
256
continue;
257
}
258
}
259
}
260
}
261
pipe.println("quit");
262
debugee.waitFor();
263
int status = debugee.getStatus();
264
if (testFailed) {
265
log.complain("debuger FAILURE> TEST FAILED");
266
return 2;
267
} else {
268
if (status == 95) {
269
log.display("debuger> expected Debugee's exit "
270
+ "status - " + status);
271
return 0;
272
} else {
273
log.complain("debuger FAILURE> UNEXPECTED Debugee's exit "
274
+ "status (not 95) - " + status);
275
return 2;
276
}
277
}
278
}
279
}
280
281