Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Accessible/isPublic/isPublic001.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
package nsk.jdi.Accessible.isPublic;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import java.util.*;
32
import java.io.*;
33
34
/**
35
* This test checks the method <code>isPublic()</code>
36
* of the JDI interface <code>Accessible</code> of com.sun.jdi package
37
* for ArrayType, ClassType, InterfaceType
38
*/
39
40
public class isPublic001 extends Log {
41
static java.io.PrintStream out_stream;
42
static boolean verbose_mode = false;
43
44
/** The main class names of the debugger & debugee applications. */
45
private final static String
46
package_prefix = "nsk.jdi.Accessible.isPublic.",
47
// package_prefix = "", // for DEBUG without package
48
thisClassName = package_prefix + "isPublic001",
49
debugeeName = thisClassName + "a";
50
51
52
static ArgumentHandler argsHandler;
53
private static Log logHandler;
54
55
56
/** Debugee's classes for check **/
57
private final static String classes_for_check[][] = {
58
{"boolean", "public", "primitive_type"},
59
{"byte" , "public", "primitive_type"},
60
{"char" , "public", "primitive_type"},
61
{"double" , "public", "primitive_type"},
62
{"float" , "public", "primitive_type"},
63
{"int" , "public", "primitive_type"},
64
{"long" , "public", "primitive_type"},
65
66
{"java.lang.Boolean" , "public", "reference_type"},
67
{"java.lang.Byte" , "public", "reference_type"},
68
{"java.lang.Character", "public", "reference_type"},
69
{"java.lang.Double" , "public", "reference_type"},
70
{"java.lang.Float" , "public", "reference_type"},
71
{"java.lang.Integer" , "public", "reference_type"},
72
{"java.lang.Long" , "public", "reference_type"},
73
{"java.lang.String" , "public", "reference_type"},
74
{"java.lang.Object" , "public", "reference_type"},
75
76
{thisClassName, "public", "reference_type" },
77
{thisClassName+"a", "public", "reference_type" },
78
{package_prefix + "pack_priv_cls", "package private", "reference_type"}, // class
79
{package_prefix + "pack_priv_interf", "package private", "reference_type"}, // interface
80
81
{debugeeName+"$s_interf", "public", "reference_type"}, // interface
82
83
{debugeeName+"$U", "private", "reference_type" },
84
{debugeeName+"$V", "protected", "reference_type" },
85
{debugeeName+"$W", "public", "reference_type" },
86
{debugeeName+"$P", "package private", "reference_type"}
87
};
88
89
/**
90
* Re-call to <code>run(args,out)</code>, and exit with
91
* either status 95 or 97 (JCK-like exit status).
92
*/
93
public static void main (String argv[]) {
94
int exitCode = run(argv,System.out);
95
System.exit(exitCode + 95/*STATUS_TEMP*/);
96
}
97
98
/**
99
* JCK-like entry point to the test: perform testing, and
100
* return exit code 0 (PASSED) or either 2 (FAILED).
101
*/
102
public static int run (String argv[], PrintStream out) {
103
out_stream = out;
104
105
int v_test_result = new isPublic001().runThis(argv,out_stream);
106
if ( v_test_result == 2/*STATUS_FAILED*/ ) {
107
logHandler.complain("\n==> nsk/jdi/Accessible/isPublic/isPublic001 test FAILED");
108
}
109
else {
110
logHandler.display("\n==> nsk/jdi/Accessible/isPublic/isPublic001 test PASSED");
111
}
112
return v_test_result;
113
}
114
115
private void print_log_on_verbose(String message) {
116
logHandler.display(message);
117
}
118
119
/**
120
* Non-static variant of the method <code>run(args,out)</code>
121
*/
122
private int runThis (String argv[], PrintStream out) {
123
if ( out_stream == null ) {
124
out_stream = out;
125
}
126
127
128
129
Debugee debugee;
130
131
argsHandler = new ArgumentHandler(argv);
132
logHandler = new Log(out, argsHandler);
133
Binder binder = new Binder(argsHandler, logHandler);
134
135
136
if (argsHandler.verbose()) {
137
debugee = binder.bindToDebugee(debugeeName + " -vbs");
138
} else {
139
debugee = binder.bindToDebugee(debugeeName);
140
}
141
142
IOPipe pipe = new IOPipe(debugee);
143
144
logHandler.display("==> nsk/jdi/Accessible/isPublic/isPublic001 test LOG:");
145
logHandler.display("==> test checks the isPublic() method of Accessible interface");
146
logHandler.display(" of the com.sun.jdi package for ArrayType, ClassType, InterfaceType\n");
147
148
149
debugee.redirectStderr(out);
150
print_log_on_verbose("--> isPublic001: isPublic001a debugee launched");
151
debugee.resume();
152
153
String line = pipe.readln();
154
if (line == null) {
155
logHandler.complain
156
("##> isPublic001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
157
return 2/*STATUS_FAILED*/;
158
}
159
if (!line.equals("ready")) {
160
logHandler.complain
161
("##> isPublic001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
162
return 2/*STATUS_FAILED*/;
163
}
164
else {
165
print_log_on_verbose("--> isPublic001: debugee's \"ready\" signal recieved!");
166
}
167
168
logHandler.display
169
("--> isPublic001: checking debugee's classes by Accessible.isPublic() method...");
170
int all_classes_count = 0;
171
int class_not_found_errors = 0;
172
int isPublic_method_errors = 0;
173
for (int i=0; i<classes_for_check.length; i++) {
174
String basicName = classes_for_check[i][0];
175
for (int array_measure=0; array_measure<3; array_measure++) {
176
if ( array_measure == 0 ) { // not array type
177
if ( classes_for_check[i][2].equals("primitive_type") ) {
178
continue;
179
}
180
}
181
all_classes_count++;
182
String brackets[] = {"", "[]", "[][]"};
183
String className = basicName + brackets[array_measure];
184
ReferenceType refType = debugee.classByName(className);
185
if (refType == null) {
186
logHandler.complain("##> isPublic001: Could NOT FIND class: " + className);
187
class_not_found_errors++;
188
continue;
189
}
190
boolean isPublic = classes_for_check[i][1].equals("public");
191
if (refType.isPublic() != isPublic) {
192
logHandler.complain
193
("##> isPublic001: UNEXPECTED isPublic() method result (" + !isPublic +
194
") for class: " + className + "(" + classes_for_check[i][1] + ")");
195
isPublic_method_errors++;
196
}
197
else {
198
print_log_on_verbose
199
("--> isPublic001: expected isPublic() method result (" + isPublic +
200
") for class: " + className + "(" + classes_for_check[i][1] + ")");
201
}
202
}
203
}
204
logHandler.display("--> isPublic001: checking debugee's classes completed!");
205
logHandler.display("--> isPublic001: number of checked classes = " + all_classes_count);
206
if ( class_not_found_errors > 0 ) {
207
logHandler.complain("##> isPublic001: \"class not found ERRORS\" counter = "
208
+ class_not_found_errors);
209
}
210
if ( isPublic_method_errors > 0 ) {
211
logHandler.complain("##> isPublic001: isPublic() method ERRORS counter = "
212
+ isPublic_method_errors);
213
}
214
int v_test_result = 0/*STATUS_PASSED*/;
215
if (class_not_found_errors + isPublic_method_errors > 0) {
216
v_test_result = 2/*STATUS_FAILED*/;
217
}
218
219
print_log_on_verbose("--> isPublic001: waiting for debugee finish...");
220
pipe.println("quit");
221
debugee.waitFor();
222
223
int status = debugee.getStatus();
224
if (status != 0/*STATUS_PASSED*/ + 95/*STATUS_TEMP*/) {
225
logHandler.complain
226
("##> isPublic001: UNEXPECTED Debugee's exit status (not 95) - " + status);
227
v_test_result = 2/*STATUS_FAILED*/;
228
}
229
else {
230
print_log_on_verbose
231
("--> isPublic001: expected Debugee's exit status - " + status);
232
}
233
234
return v_test_result;
235
}
236
}
237
238