Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Accessible/isPrivate/isPrivate001.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.isPrivate;
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>isPrivate()</code>
36
* of the JDI interface <code>Accessible</code> of com.sun.jdi package
37
* for ArrayType, ClassType, InterfaceType
38
*/
39
40
public class isPrivate001 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.isPrivate.",
47
// package_prefix = "", // for DEBUG without package
48
thisClassName = package_prefix + "isPrivate001",
49
debugeeName = thisClassName + "a";
50
51
52
static ArgumentHandler argsHandler;
53
private static Log logHandler;
54
55
/** Debugee's classes for check **/
56
private final static String classes_for_check[][] = {
57
{"boolean", "public", "primitive_type"},
58
{"byte" , "public", "primitive_type"},
59
{"char" , "public", "primitive_type"},
60
{"double" , "public", "primitive_type"},
61
{"float" , "public", "primitive_type"},
62
{"int" , "public", "primitive_type"},
63
{"long" , "public", "primitive_type"},
64
65
{"java.lang.Boolean" , "public", "reference_type"},
66
{"java.lang.Byte" , "public", "reference_type"},
67
{"java.lang.Character", "public", "reference_type"},
68
{"java.lang.Double" , "public", "reference_type"},
69
{"java.lang.Float" , "public", "reference_type"},
70
{"java.lang.Integer" , "public", "reference_type"},
71
{"java.lang.Long" , "public", "reference_type"},
72
{"java.lang.String" , "public", "reference_type"},
73
{"java.lang.Object" , "public", "reference_type"},
74
75
{thisClassName, "public", "reference_type" },
76
{thisClassName+"a", "public", "reference_type" },
77
{package_prefix + "pack_priv_cls", "package private", "reference_type"}, // class
78
{package_prefix + "pack_priv_interf", "package private", "reference_type"}, // interface
79
80
{debugeeName+"$s_interf", "private", "reference_type"}, // static interface
81
82
{debugeeName+"$U", "private", "reference_type" },
83
{debugeeName+"$V", "protected", "reference_type" },
84
{debugeeName+"$W", "public", "reference_type" },
85
{debugeeName+"$P", "package private", "reference_type"}
86
};
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 isPrivate001().runThis(argv,out_stream);
106
if ( v_test_result == 2/*STATUS_FAILED*/ ) {
107
logHandler.display("\n==> nsk/jdi/Accessible/isPrivate/isPrivate001 test FAILED");
108
}
109
else {
110
logHandler.display("\n==> nsk/jdi/Accessible/isPrivate/isPrivate001 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
124
if ( out_stream == null ) {
125
out_stream = out;
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/isPrivate/isPrivate001 test LOG:");
145
logHandler.display("==> test checks the isPrivate() method of Accessible interface");
146
logHandler.display(" of the com.sun.jdi package for ArrayType, ClassType, InterfaceType\n");
147
148
debugee.redirectStderr(out);
149
print_log_on_verbose("--> isPrivate001: isPrivate001a debugee launched");
150
debugee.resume();
151
152
String line = pipe.readln();
153
if (line == null) {
154
logHandler.complain("##> isPrivate001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
155
return 2/*STATUS_FAILED*/;
156
}
157
if (!line.equals("ready")) {
158
logHandler.display("##> isPrivate001: UNEXPECTED debugee's signal (not \"ready\") - " + line);
159
return 2/*STATUS_FAILED*/;
160
}
161
else {
162
print_log_on_verbose("--> isPrivate001: debugee's \"ready\" signal recieved!");
163
}
164
165
logHandler.display
166
("--> isPrivate001: checking debugee's classes by Accessible.isPrivate() method...");
167
int all_classes_count = 0;
168
int class_not_found_errors = 0;
169
int isPrivate_method_errors = 0;
170
171
172
for (int i=0; i<classes_for_check.length; i++) {
173
String basicName = classes_for_check[i][0];
174
for (int array_measure=0; array_measure<3; array_measure++) {
175
if ( array_measure == 0 ) { // not array type
176
if ( classes_for_check[i][2].equals("primitive_type") ) {
177
continue;
178
}
179
}
180
all_classes_count++;
181
String brackets[] = {"", "[]", "[][]"};
182
String className = basicName + brackets[array_measure];
183
ReferenceType refType = debugee.classByName(className);
184
if (refType == null) {
185
logHandler.complain("##> isPrivate001: Could NOT FIND class: " + className);
186
class_not_found_errors++;
187
continue;
188
}
189
boolean isPrivate = classes_for_check[i][1].equals("private");
190
if (refType.isPrivate() != isPrivate) {
191
logHandler.complain("##> isPrivate001: UNEXPECTED isPrivate() method result ("
192
+ !isPrivate + ") for class: " +
193
className + "(" + classes_for_check[i][1] + ")");
194
isPrivate_method_errors++;
195
}
196
else {
197
print_log_on_verbose("--> isPrivate001: expected isPrivate() method result ("
198
+ isPrivate + ") for class: "
199
+ className + "(" + classes_for_check[i][1] + ")");
200
}
201
}
202
}
203
logHandler.display("--> isPrivate001: checking debugee's classes completed!");
204
logHandler.display("--> isPrivate001: number of checked classes = " + all_classes_count);
205
if ( class_not_found_errors > 0 ) {
206
logHandler.complain("##> isPrivate001: \"class not found ERRORS\" counter = "
207
+ class_not_found_errors);
208
}
209
if ( isPrivate_method_errors > 0 ) {
210
logHandler.complain("##> isPrivate001: isPrivate() method ERRORS counter = "
211
+ isPrivate_method_errors);
212
}
213
int v_test_result = 0/*STATUS_PASSED*/;
214
if (class_not_found_errors + isPrivate_method_errors > 0) {
215
v_test_result = 2/*STATUS_FAILED*/;
216
}
217
218
print_log_on_verbose("--> isPrivate001: waiting for debugee finish...");
219
pipe.println("quit");
220
debugee.waitFor();
221
222
int status = debugee.getStatus();
223
if (status != 0/*STATUS_PASSED*/ + 95/*STATUS_TEMP*/) {
224
logHandler.complain("##> isPrivate001: UNEXPECTED Debugee's exit status (not 95) - " + status);
225
v_test_result = 2/*STATUS_FAILED*/;
226
}
227
else {
228
print_log_on_verbose("--> isPrivate001: expected Debugee's exit status - " + status);
229
}
230
231
return v_test_result;
232
}
233
}
234
235