Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ArrayReference/SetValues/setvalues001a.java
41162 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.ArrayReference.SetValues;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdwp.*;
29
30
import java.io.*;
31
32
public class setvalues001a {
33
34
// name of the static field with the tested array object
35
public static final String ARRAY_FIELD_NAME = "array";
36
37
// length, first index and number of array components to get
38
public static final int ARRAY_LENGTH = 16;
39
public static final int ARRAY_FIRST_INDEX = 4;
40
public static final int ARRAY_ITEMS_COUNT = 10;
41
42
private static ArgumentHandler argumentHandler = null;
43
private static Log log = null;
44
45
public static void main(String args[]) {
46
setvalues001a _setvalues001a = new setvalues001a();
47
System.exit(setvalues001.JCK_STATUS_BASE + _setvalues001a.runIt(args, System.err));
48
}
49
50
public int runIt(String args[], PrintStream out) {
51
//make log for debugee messages
52
argumentHandler = new ArgumentHandler(args);
53
log = new Log(out, argumentHandler);
54
55
// meke communication pipe to debugger
56
log.display("Creating pipe");
57
IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);
58
59
// ensure tested class loaded
60
log.display("Creating and initializing tested array");
61
TestedClass.initArrayValues();
62
63
// send debugger signal READY
64
log.display("Sending signal to debugger: " + setvalues001.READY);
65
pipe.println(setvalues001.READY);
66
67
// wait for signal RUN from debugeer
68
log.display("Waiting for signal from debugger: " + setvalues001.RUN);
69
String signal = pipe.readln();
70
log.display("Received signal from debugger: " + signal);
71
// check received signal
72
if (signal == null || !signal.equals(setvalues001.RUN)) {
73
log.complain("Unexpected communication signal from debugee: " + signal
74
+ " (expected: " + setvalues001.RUN + ")");
75
log.display("Debugee FAILED");
76
return setvalues001.FAILED;
77
}
78
79
// check assigned values
80
log.display("Checking new array values");
81
if (TestedClass.checkArrayValues()) {
82
log.display("Sending signal to debugger: " + setvalues001.DONE);
83
pipe.println(setvalues001.DONE);
84
} else {
85
log.display("Sending signal to debugger: " + setvalues001.ERROR);
86
pipe.println(setvalues001.ERROR);
87
}
88
89
// wait for signal QUIT from debugeer
90
log.display("Waiting for signal from debugger: " + setvalues001.QUIT);
91
signal = pipe.readln();
92
log.display("Received signal from debugger: " + signal);
93
94
// check received signal
95
if (! signal.equals(setvalues001.QUIT)) {
96
log.complain("Unexpected communication signal from debugee: " + signal
97
+ " (expected: " + setvalues001.QUIT + ")");
98
log.display("Debugee FAILED");
99
return setvalues001.FAILED;
100
}
101
102
// exit debugee
103
log.display("Debugee PASSED");
104
return setvalues001.PASSED;
105
}
106
107
// tested class with own static fields values
108
public static class TestedClass {
109
110
// static field with tested array
111
public static int array[] = null;
112
113
public static void initArrayValues() {
114
array = new int[ARRAY_LENGTH];
115
for (int i = 0; i < ARRAY_LENGTH; i++) {
116
array[i] = i * 10;
117
}
118
}
119
120
public static boolean checkArrayValues() {
121
if (array == null) {
122
log.complain("Checked array == null after setting values: " + array);
123
return false;
124
}
125
126
boolean success = true;
127
if (array.length != ARRAY_LENGTH) {
128
log.complain("Unexpected array length after setting values: "
129
+ array.length + " (expected: " + ARRAY_LENGTH + ")");
130
success = false;
131
}
132
133
for (int i = 0; i < array.length; i++) {
134
int initial = i * 10;
135
int changed = i * 100 + 1;
136
if (i < ARRAY_FIRST_INDEX || i >= ARRAY_FIRST_INDEX + ARRAY_ITEMS_COUNT) {
137
log.display(" " + i + " (not changed): " + initial + " -> " + array[i]);
138
if (array[i] != initial) {
139
log.complain("Changed value of " + i + " component which is out of changed region: "
140
+ array[i] + "(initial: " + initial + ")");
141
success = false;
142
}
143
} else {
144
log.display(" " + i + " (changed): " + initial + " -> " + array[i]);
145
if (array[i] != changed) {
146
if (array[i] == initial) {
147
log.complain("Value of " + i + " component not changed: "
148
+ array[i] + "(expected: " + changed + ")");
149
success = false;
150
} else {
151
log.complain("Value of " + i + " component changed incorrectly: "
152
+ array[i] + "(expected: " + changed + ")");
153
success = false;
154
}
155
}
156
}
157
}
158
159
return success;
160
}
161
162
}
163
}
164
165