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/equals001.java
41161 views
1
/*
2
* Copyright (c) 2000, 2021, 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 equals001 {
36
private static Log log;
37
private final static String prefix = "nsk.jdi.Field.equals.";
38
private final static String className = "equals001";
39
private final static String debugerName = prefix + className;
40
private final static String debugeeName = debugerName + "a";
41
private final static String classToCheckName = prefix + "ClassToCheck";
42
43
public static void main(String argv[]) {
44
System.exit(95 + run(argv, System.out));
45
}
46
47
public static int run(String argv[], PrintStream out) {
48
ArgumentHandler argHandler = new ArgumentHandler(argv);
49
log = new Log(out, argHandler);
50
Binder binder = new Binder(argHandler, log);
51
Debugee debugee = binder.bindToDebugee(debugeeName
52
+ (argHandler.verbose() ? " -verbose" : ""));
53
IOPipe pipe = new IOPipe(debugee);
54
boolean testFailed = false;
55
List fieldsDebugee;
56
List methods;
57
Iterator methodsIterator;
58
java.lang.reflect.Field[] fieldsDebuger;
59
ClassOfFields classOfFields = new ClassOfFields();
60
61
// Connect with debugee and resume it
62
debugee.redirectStderr(out);
63
debugee.resume();
64
String line = pipe.readln();
65
if (line == null) {
66
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - null");
67
return 2;
68
}
69
if (!line.equals("ready")) {
70
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - "
71
+ line);
72
return 2;
73
}
74
else {
75
log.display("debuger> debugee's \"ready\" signal recieved.");
76
}
77
78
// Get all fields from debugee
79
ReferenceType refType = debugee.classByName(classToCheckName);
80
if (refType == null) {
81
log.complain("debuger FAILURE> Class " + classToCheckName
82
+ " not found.");
83
return 2;
84
}
85
try {
86
fieldsDebugee = refType.allFields();
87
} catch (Exception e) {
88
log.complain("debuger FAILURE> Can't get fields from class");
89
log.complain("debuger FAILURE> Exception: " + e);
90
return 2;
91
}
92
int totalFields = fieldsDebugee.size();
93
if (totalFields < 1) {
94
log.complain("debuger FAILURE> Total number of fields read "
95
+ totalFields);
96
return 2;
97
}
98
log.display("debuger> Total fields found: " + totalFields);
99
100
// Compare each Field and Method from debugee
101
try {
102
methods = refType.allMethods();
103
} catch (Exception e) {
104
log.complain("debuger FAILURE 1> Can't get methods from class");
105
log.complain("debuger FAILURE 1> Exception: " + e);
106
return 2;
107
}
108
log.display("debuger> Total methods found: " + methods.size());
109
Iterator fieldsIterator = fieldsDebugee.iterator();
110
for (int i = 0; fieldsIterator.hasNext(); i++) {
111
Field fieldDebugee = (Field)fieldsIterator.next();
112
String name = fieldDebugee.name();
113
methodsIterator = methods.iterator();
114
115
for (int j = 0; methodsIterator.hasNext(); j++) {
116
Method method = (Method)methodsIterator.next();
117
String methodName = method.name();
118
119
log.display("debuger> Field " + name + " and method "
120
+ methodName + " read from debugee.");
121
if (fieldDebugee.equals(method)) {
122
// Field is not equal to any Object which type is not Field
123
log.complain("debuger FAILURE 2> Field " + name
124
+ " and method " + methodName + " are equal. "
125
+ "Expected result: not equal.");
126
testFailed = true;
127
continue;
128
}
129
}
130
}
131
132
// Compare Field (com.sun.jdi.Field) from debugee and Field
133
// from debuger (java.lang.reflect.Field)
134
Class classDebuger = classOfFields.getClass();
135
try {
136
fieldsDebuger = classDebuger.getDeclaredFields();
137
} catch (SecurityException e) {
138
log.complain("debuger FAILURE 3> Can't get fields from debuger's"
139
+ " class");
140
log.complain("debuger FAILURE 3> Exception: " + e);
141
return 2;
142
}
143
int totalDebugerFields = fieldsDebuger.length;
144
log.display("debuger> Total fields in debuger found: "
145
+ totalDebugerFields);
146
fieldsIterator = fieldsDebugee.iterator();
147
for (int i = 0; fieldsIterator.hasNext(); i++) {
148
Field fieldDebugee = (Field)fieldsIterator.next();
149
String name = fieldDebugee.name();
150
151
for (int j = 1; j < totalDebugerFields; j++) {
152
java.lang.reflect.Field fieldDebuger = fieldsDebuger[j];
153
String nameDebuger = fieldDebuger.getName();
154
155
log.display("debuger> Field from debugee " + name + " and "
156
+ "field from debuger " + nameDebuger + " read.");
157
if (fieldDebugee.equals(fieldDebuger)) {
158
// Field is not equal to any Object which type
159
// is not not com.sun.jdi.Field
160
log.complain("debuger FAILURE 4> Field from debugee "
161
+ name + " and field from debuger "
162
+ nameDebuger + " are equal. Expected "
163
+ "result: not equal.");
164
testFailed = true;
165
continue;
166
}
167
}
168
}
169
pipe.println("quit");
170
debugee.waitFor();
171
int status = debugee.getStatus();
172
if (testFailed) {
173
log.complain("debuger FAILURE> TEST FAILED");
174
return 2;
175
} else {
176
if (status == 95) {
177
log.display("debuger> expected Debugee's exit "
178
+ "status - " + status);
179
return 0;
180
} else {
181
log.complain("debuger FAILURE> UNEXPECTED Debugee's exit "
182
+ "status (not 95) - " + status);
183
return 2;
184
}
185
}
186
}
187
}
188
189
class ClassOfFields {
190
boolean z0, z1[]={z0}, z2[][]={z1};
191
byte b0, b1[]={b0}, b2[][]={b1};
192
char c0, c1[]={c0}, c2[][]={c1};
193
double d0, d1[]={d0}, d2[][]={d1};
194
float f0, f1[]={f0}, f2[][]={f1};
195
int i0, i1[]={i0}, i2[][]={i1};
196
long l0, l1[]={l0}, l2[][]={l1};
197
198
static long lS0, lS1[]={lS0}, lS2[][]={lS1};
199
private long lP0, lP1[]={lP0}, lP2[][]={lP1};
200
public long lU0, lU1[]={lU0}, lU2[][]={lU1};
201
protected long lR0, lR1[]={lR0}, lR2[][]={lR1};
202
transient long lT0, lT1[]={lT0}, lT2[][]={lT1};
203
volatile long lV0, lV1[]={lV0}, lV2[][]={lV1};
204
final long lF0 = 999, lF1[]={lF0}, lF2[][]={lF1};
205
206
Boolean Z0, Z1[]={Z0}, Z2[][]={Z1};
207
Byte B0, B1[]={B0}, B2[][]={B1};
208
Character C0, C1[]={C0}, C2[][]={C1};
209
Double D0, D1[]={D0}, D2[][]={D1};
210
Float F0, F1[]={F0}, F2[][]={F1};
211
Integer I0, I1[]={I0}, I2[][]={I1};
212
Long L0, L1[]={L0}, L2[][]={L1};
213
String S0, S1[]={S0}, S2[][]={S1};
214
Object O0, O1[]={O0}, O2[][]={O1};
215
216
static Long LS0, LS1[]={LS0}, LS2[][]={LS1};
217
private Long LP0, LP1[]={LP0}, LP2[][]={LP1};
218
public Long LU0, LU1[]={LU0}, LU2[][]={LU1};
219
protected Long LR0, LR1[]={LR0}, LR2[][]={LR1};
220
transient Long LT0, LT1[]={LT0}, LT2[][]={LT1};
221
volatile Long LV0, LV1[]={LV0}, LV2[][]={LV1};
222
final Long LF0 = Long.valueOf(999), LF1[]={LF0}, LF2[][]={LF1};
223
224
interface Inter {}
225
Inter E0, E1[]={E0}, E2[][]={E1};
226
static Inter ES0, ES1[]={ES0}, ES2[][]={ES1};
227
private Inter EP0, EP1[]={EP0}, EP2[][]={EP1};
228
public Inter EU0, EU1[]={EU0}, EU2[][]={EU1};
229
protected Inter ER0, ER1[]={ER0}, ER2[][]={ER1};
230
transient Inter ET0, ET1[]={ET0}, ET2[][]={ET1};
231
volatile Inter EV0, EV1[]={EV0}, EV2[][]={EV1};
232
final Inter EF0 = null, EF1[]={EF0}, EF2[][]={EF1};
233
}
234
235