Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ObjectReference/SetValues/setvalues001a.java
41161 views
1
/*
2
* Copyright (c) 2001, 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.jdwp.ObjectReference.SetValues;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdwp.*;
29
30
import java.io.*;
31
32
/**
33
* This class represents debuggee part of the test.
34
*/
35
public class setvalues001a {
36
37
public static final String OBJECT_FIELD_NAME = "object";
38
39
static ArgumentHandler argumentHandler = null;
40
static Log log = null;
41
42
public static void main(String args[]) {
43
setvalues001a _setvalues001a = new setvalues001a();
44
System.exit(setvalues001.JCK_STATUS_BASE + _setvalues001a.runIt(args, System.err));
45
}
46
47
public int runIt(String args[], PrintStream out) {
48
// make log for debugee messages
49
ArgumentHandler argumentHandler = new ArgumentHandler(args);
50
log = new Log(out, argumentHandler);
51
52
// make communication pipe to debugger
53
log.display("Creating pipe");
54
IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);
55
56
// ensure tested class loaded
57
log.display("Creating object of all required classes");
58
OriginalValuesClass original = new OriginalValuesClass();
59
TargetValuesClass target = new TargetValuesClass();
60
ObjectClass.object = new TestedClass();
61
62
// send debugger signal READY
63
log.display("Sending signal to debugger: " + setvalues001.READY);
64
pipe.println(setvalues001.READY);
65
66
// wait for signal RUN from debugeer
67
log.display("Waiting for signal from debugger: " + setvalues001.RUN);
68
String signal = pipe.readln();
69
log.display("Received signal from debugger: " + signal);
70
// check received signal
71
if (signal == null || !signal.equals(setvalues001.RUN)) {
72
log.complain("Unexpected communication signal from debugee: " + signal
73
+ " (expected: " + setvalues001.RUN + ")");
74
log.display("Debugee FAILED");
75
return setvalues001.FAILED;
76
}
77
78
// check assigned values
79
if (checkValues(ObjectClass.object)) {
80
log.display("Sending signal to debugger: " + setvalues001.DONE);
81
pipe.println(setvalues001.DONE);
82
} else {
83
log.display("Sending signal to debugger: " + setvalues001.ERROR);
84
pipe.println(setvalues001.ERROR);
85
}
86
87
// wait for signal QUIT from debugeer
88
log.display("Waiting for signal from debugger: " + setvalues001.QUIT);
89
signal = pipe.readln();
90
log.display("Received signal from debugger: " + signal);
91
// check received signal
92
if (! signal.equals(setvalues001.QUIT)) {
93
log.complain("Unexpected communication signal from debugee: " + signal
94
+ " (expected: " + setvalues001.QUIT + ")");
95
log.display("Debugee FAILED");
96
return setvalues001.FAILED;
97
}
98
99
// exit debugee
100
log.display("Debugee PASSED");
101
return setvalues001.PASSED;
102
}
103
104
// check values of static fields for both classes
105
static boolean checkValues(TestedClass object) {
106
int different = 0;
107
log.display("Checking that values have been set correctly:");
108
109
// check value of the field
110
if (object.booleanValue != TargetValuesClass.booleanValue) {
111
different++;
112
log.complain(" booleanValue = " + object.booleanValue + "\n"
113
+ " setting: " + OriginalValuesClass.booleanValue
114
+ " -> " + TargetValuesClass.booleanValue);
115
if (object.booleanValue == OriginalValuesClass.booleanValue) {
116
log.complain(" not changed!");
117
} else {
118
log.complain(" changed incorrectly!");
119
}
120
} else {
121
log.display(" booleanValue: " + OriginalValuesClass.booleanValue
122
+ " -> " + TargetValuesClass.booleanValue);
123
}
124
125
// check value of the field
126
if (object.byteValue != TargetValuesClass.byteValue) {
127
different++;
128
log.complain(" byteValue = " + object.byteValue + "\n"
129
+ " setting: " + OriginalValuesClass.byteValue
130
+ " -> " + TargetValuesClass.byteValue);
131
if (object.byteValue == OriginalValuesClass.byteValue) {
132
log.complain(" not changed!");
133
} else {
134
log.complain(" changed incorrectly!");
135
}
136
} else {
137
log.display(" byteValue: " + OriginalValuesClass.byteValue
138
+ " -> " + TargetValuesClass.byteValue);
139
}
140
141
// check value of the field
142
if (object.charValue != TargetValuesClass.charValue) {
143
different++;
144
log.complain(" charValue = " + object.charValue + "\n"
145
+ " setting: " + OriginalValuesClass.charValue
146
+ " -> " + TargetValuesClass.charValue);
147
if (object.charValue == OriginalValuesClass.charValue) {
148
log.complain(" not changed!");
149
} else {
150
log.complain(" changed incorrectly!");
151
}
152
} else {
153
log.display(" charValue: " + OriginalValuesClass.charValue
154
+ " -> " + TargetValuesClass.charValue);
155
}
156
157
// check value of the field
158
if (object.intValue != TargetValuesClass.intValue) {
159
different++;
160
log.complain(" intValue = " + object.intValue + "\n"
161
+ " setting: " + OriginalValuesClass.intValue
162
+ " -> " + TargetValuesClass.intValue);
163
if (object.intValue == OriginalValuesClass.intValue) {
164
log.complain(" not changed!");
165
} else {
166
log.complain(" changed incorrectly!");
167
}
168
} else {
169
log.display(" intValue: " + OriginalValuesClass.intValue
170
+ " -> " + TargetValuesClass.intValue);
171
}
172
173
// check value of the field
174
if (object.shortValue != TargetValuesClass.shortValue) {
175
different++;
176
log.complain(" shortValue = " + object.shortValue + "\n"
177
+ " setting: " + OriginalValuesClass.shortValue
178
+ " -> " + TargetValuesClass.shortValue);
179
if (object.shortValue == OriginalValuesClass.shortValue) {
180
log.complain(" not changed!");
181
} else {
182
log.complain(" changed incorrectly!");
183
}
184
} else {
185
log.display(" shortValue: " + OriginalValuesClass.shortValue
186
+ " -> " + TargetValuesClass.shortValue);
187
}
188
189
// check value of the field
190
if (object.longValue != TargetValuesClass.longValue) {
191
different++;
192
log.complain(" longValue = " + object.longValue + "\n"
193
+ " setting: " + OriginalValuesClass.longValue
194
+ " -> " + TargetValuesClass.longValue);
195
if (object.longValue == OriginalValuesClass.longValue) {
196
log.complain(" not changed!");
197
} else {
198
log.complain(" changed incorrectly!");
199
}
200
} else {
201
log.display(" longValue: " + OriginalValuesClass.longValue
202
+ " -> " + TargetValuesClass.longValue);
203
}
204
205
// check value of the field
206
if (object.floatValue != TargetValuesClass.floatValue) {
207
different++;
208
log.complain(" floatValue = " + object.floatValue + "\n"
209
+ " setting: " + OriginalValuesClass.floatValue
210
+ " -> " + TargetValuesClass.floatValue);
211
if (object.floatValue == OriginalValuesClass.floatValue) {
212
log.complain(" not changed!");
213
} else {
214
log.complain(" changed incorrectly!");
215
}
216
} else {
217
log.display(" floatValue: " + OriginalValuesClass.floatValue
218
+ " -> " + TargetValuesClass.floatValue);
219
}
220
221
// check value of the field
222
if (object.doubleValue != TargetValuesClass.doubleValue) {
223
different++;
224
log.complain(" doubleValue = " + object.doubleValue + "\n"
225
+ " setting: " + OriginalValuesClass.doubleValue
226
+ " -> " + TargetValuesClass.doubleValue);
227
if (object.doubleValue == OriginalValuesClass.doubleValue) {
228
log.complain(" not changed!");
229
} else {
230
log.complain(" changed incorrectly!");
231
}
232
} else {
233
log.display(" doubleValue: " + OriginalValuesClass.doubleValue
234
+ " -> " + TargetValuesClass.doubleValue);
235
}
236
237
// check value of the field
238
if (object.stringValue != TargetValuesClass.stringValue) {
239
different++;
240
log.complain(" stringValue = " + object.stringValue + "\n"
241
+ " setting: " + OriginalValuesClass.stringValue
242
+ " -> " + TargetValuesClass.stringValue);
243
if (object.stringValue == OriginalValuesClass.stringValue) {
244
log.complain(" not changed!");
245
} else {
246
log.complain(" changed incorrectly!");
247
}
248
} else {
249
log.display(" stringValue: " + OriginalValuesClass.stringValue
250
+ " -> " + TargetValuesClass.stringValue);
251
}
252
253
// check value of the field
254
if (object.objectValue != TargetValuesClass.objectValue) {
255
different++;
256
log.complain(" objectValue = " + object.objectValue + "\n"
257
+ " setting: " + OriginalValuesClass.objectValue
258
+ " -> " + TargetValuesClass.objectValue);
259
if (object.objectValue == OriginalValuesClass.objectValue) {
260
log.complain(" not changed!");
261
} else {
262
log.complain(" changed incorrectly!");
263
}
264
} else {
265
log.display(" objectValue: " + OriginalValuesClass.objectValue
266
+ " -> " + TargetValuesClass.objectValue);
267
}
268
269
/*
270
// check value of the field
271
if (object.Value != TargetValuesClass.Value) {
272
different++;
273
log.complain(" Value = " + object.Value + "\n"
274
+ " setting: " + OriginalValuesClass.Value
275
+ " -> " + TargetValuesClass.Value);
276
if (object.Value == OriginalValuesClass.Value) {
277
log.complain(" not changed!");
278
} else {
279
log.complain(" changed incorrectly!");
280
}
281
} else {
282
log.display(" Value: " + OriginalValuesClass.Value
283
+ " -> " + TargetValuesClass.Value);
284
}
285
*/
286
287
// check taht no any changed value differs from target
288
if (different > 0) {
289
log.complain("Values of " + different + " fields have not been set correctly");
290
return false;
291
}
292
293
log.display("Values of all fields have been set correctly");
294
return true;
295
}
296
297
// class with the original values of static fields
298
public static class OriginalValuesClass {
299
static final boolean booleanValue = true;
300
static final byte byteValue = (byte)0x01;
301
static final char charValue = 'Z';
302
static final int intValue = 100;
303
static final short shortValue = (short)10;
304
static final long longValue = (long)1000000;
305
static final float floatValue = (float)3.14;
306
static final double doubleValue = (double)2.8e-12;
307
static final String stringValue = "text";
308
static final Object objectValue = new OriginalValuesClass();
309
}
310
311
// class with the original values of static fields
312
public static class TargetValuesClass {
313
static final boolean booleanValue = false;
314
static final byte byteValue = (byte)0x0F;
315
static final char charValue = 'A';
316
static final int intValue = 999;
317
static final short shortValue = (short)88;
318
static final long longValue = (long)11111111;
319
static final float floatValue = (float)7.19;
320
static final double doubleValue = (double)4.6e24;
321
static final String stringValue = "new text";
322
static final Object objectValue = new TargetValuesClass();
323
}
324
325
// tested class with own static fields values
326
public static class TestedClass {
327
private boolean booleanValue = OriginalValuesClass.booleanValue;
328
private byte byteValue = OriginalValuesClass.byteValue;
329
protected char charValue = OriginalValuesClass.charValue;
330
protected int intValue = OriginalValuesClass.intValue;
331
public short shortValue = OriginalValuesClass.shortValue;
332
public long longValue = OriginalValuesClass.longValue;
333
float floatValue = OriginalValuesClass.floatValue;
334
double doubleValue = OriginalValuesClass.doubleValue;
335
String stringValue = OriginalValuesClass.stringValue;
336
Object objectValue = OriginalValuesClass.objectValue;
337
}
338
339
// class with static field with the tested object
340
public static class ObjectClass {
341
// static field with the tested object
342
public static TestedClass object = null;
343
}
344
345
}
346
347