Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ArrayReference/getValues/getvalues002.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
25
package nsk.jdi.ArrayReference.getValues;
26
27
import nsk.share.*;
28
import nsk.share.jpda.*;
29
import nsk.share.jdi.*;
30
31
import com.sun.jdi.*;
32
import java.io.*;
33
import java.util.*;
34
35
public class getvalues002 {
36
final static String FIELD_NAME[] = {"z1", "b1", "c1", "d1", "f1", "i1",
37
"l1", "r1", "lF1", "lP1", "lU1", "lR1",
38
"lT1", "lV1"};
39
private static Log log;
40
private final static String prefix = "nsk.jdi.ArrayReference.getValues.";
41
private final static String className = "getvalues002";
42
private final static String debugerName = prefix + className;
43
private final static String debugeeName = debugerName + "a";
44
private final static String classToCheckName = prefix + "getvalues002aClassToCheck";
45
46
public static void main(String argv[]) {
47
System.exit(95 + run(argv, System.out));
48
}
49
50
public static int run(String argv[], PrintStream out) {
51
ArgumentHandler argHandler = new ArgumentHandler(argv);
52
log = new Log(out, argHandler);
53
Binder binder = new Binder(argHandler, log);
54
Debugee debugee = binder.bindToDebugee(debugeeName
55
+ (argHandler.verbose() ? " -verbose" : ""));
56
IOPipe pipe = debugee.createIOPipe();
57
boolean testFailed = false;
58
59
// Connect with debugee and resume it
60
debugee.redirectStderr(out);
61
debugee.resume();
62
String line = pipe.readln();
63
if (line == null) {
64
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - null");
65
return 2;
66
}
67
if (!line.equals("ready")) {
68
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - "
69
+ line);
70
return 2;
71
}
72
else {
73
log.display("debuger> debugee's \"ready\" signal recieved.");
74
}
75
76
ReferenceType refType = debugee.classByName(classToCheckName);
77
if (refType == null) {
78
log.complain("debuger FAILURE> Class " + classToCheckName
79
+ " not found.");
80
return 2;
81
}
82
log.display("debuger> Total fields in debugee read: "
83
+ refType.allFields().size() + " total fields in debuger: "
84
+ FIELD_NAME.length + "\n");
85
86
// Check all array fields from debugee
87
for (int i = 0; i < FIELD_NAME.length; i++) {
88
Field field;
89
String name = FIELD_NAME[i];
90
Value value;
91
ArrayReference arrayRef;
92
List listOfValues;
93
94
// Get field from debuggee by name
95
try {
96
field = refType.fieldByName(name);
97
} catch (ClassNotPreparedException e) {
98
log.complain("debuger FAILURE 1> Can't get field by name "
99
+ name);
100
log.complain("debuger FAILURE 1> Exception: " + e);
101
testFailed = true;
102
continue;
103
} catch (ObjectCollectedException e) {
104
log.complain("debuger FAILURE 1> Can't get field by name "
105
+ name);
106
log.complain("debuger FAILURE 1> Exception: " + e);
107
testFailed = true;
108
continue;
109
}
110
log.display("debuger> " + i + " field " + field + " read.");
111
112
// Get field's value
113
try {
114
value = refType.getValue(field);
115
} catch (IllegalArgumentException e) {
116
log.complain("debuger FAILURE 2> Cannot get value for field "
117
+ name);
118
log.complain("debuger FAILURE 2> Exception: " + e);
119
testFailed = true;
120
continue;
121
} catch (ObjectCollectedException e) {
122
log.complain("debuger FAILURE 2> Cannot get value for field "
123
+ name);
124
log.complain("debuger FAILURE 2> Exception: " + e);
125
testFailed = true;
126
continue;
127
}
128
log.display("debuger> " + i + " field value is " + value);
129
130
// Cast to ArrayReference. All fields in debugee are
131
// arrays, so ClassCastException should not be thrown
132
try {
133
arrayRef = (ArrayReference)value;
134
} catch (ClassCastException e) {
135
log.complain("debuger FAILURE 3> Cannot cast value for field "
136
+ name + " to ArrayReference.");
137
log.complain("debuger FAILURE 3> Exception: " + e);
138
testFailed = true;
139
continue;
140
}
141
142
// Get all components from array
143
try {
144
listOfValues = arrayRef.getValues();
145
} catch (ObjectCollectedException e) {
146
log.complain("debuger FAILURE 4> Cannot get values from field "
147
+ name);
148
log.complain("debuger FAILURE 4> Exception: " + e);
149
testFailed = true;
150
} catch (IndexOutOfBoundsException e) {
151
log.complain("debuger FAILURE 4> Cannot get values from field "
152
+ name);
153
log.complain("debuger FAILURE 4> Exception: " + e);
154
testFailed = true;
155
}
156
log.display("debuger> " + i + " field checked.\n");
157
}
158
159
pipe.println("quit");
160
debugee.waitFor();
161
int status = debugee.getStatus();
162
if (testFailed) {
163
log.complain("debuger FAILURE> TEST FAILED");
164
return 2;
165
} else {
166
if (status == 95) {
167
log.display("debuger> expected Debugee's exit "
168
+ "status - " + status);
169
return 0;
170
} else {
171
log.complain("debuger FAILURE> UNEXPECTED Debugee's exit "
172
+ "status (not 95) - " + status);
173
return 2;
174
}
175
}
176
}
177
}
178
179