Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Accessible/isPackagePrivate/accipp001.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.isPackagePrivate;
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 if the method <code>isPackagePrivate()</code>
36
* of the JDI interface <code>Accessible</code> works fine with
37
* the <code>ArrayType</code> sub-interface.
38
*/
39
public class accipp001 extends Log {
40
final static boolean MODE_VERBOSE = false;
41
42
/** The main class names of the debugger & debugee applications. */
43
private final static String
44
thisClassName = "nsk.jdi.Accessible.isPackagePrivate.accipp001",
45
debugeeName = thisClassName + "a";
46
47
48
static ArgumentHandler argsHandler;
49
private static Log logHandler;
50
51
52
/** Debugee's classes which status (private or public) is known. */
53
private final static String knownClasses[][] = {
54
{"boolean", "public"},
55
{"byte" , "public"},
56
{"char" , "public"},
57
{"double" , "public"},
58
{"float" , "public"},
59
{"int" , "public"},
60
{"long" , "public"},
61
{"short" , "public"},
62
63
{"java.lang.Boolean" , "public"},
64
{"java.lang.Byte" , "public"},
65
{"java.lang.Character", "public"},
66
{"java.lang.Double" , "public"},
67
{"java.lang.Float" , "public"},
68
{"java.lang.Integer" , "public"},
69
{"java.lang.Long" , "public"},
70
{"java.lang.Short" , "public"},
71
{"java.lang.String" , "public"},
72
{"java.lang.Object" , "public"},
73
74
{thisClassName+"a", "public" },
75
{thisClassName+"e", "package private"},
76
77
{debugeeName+"$U", "private" },
78
{debugeeName+"$V", "protected" },
79
{debugeeName+"$W", "public" },
80
{debugeeName+"$P", "package private"}
81
};
82
83
/**
84
* Re-call to <code>run(args,out)</code>, and exit with
85
* either status 95 or 97 (JCK-like exit status).
86
*/
87
public static void main (String args[]) {
88
int exitCode = run(args,System.out);
89
System.exit(exitCode + 95);
90
}
91
92
/**
93
* JCK-like entry point to the test: perform testing, and
94
* return exit code 0 (PASSED) or either 2 (FAILED).
95
*/
96
public static int run (String args[], PrintStream out) {
97
return new accipp001().runThis(args,out); // incarnate Log
98
}
99
100
/**
101
* Non-static variant of the method <code>run(args,out)</code>
102
* can use Log features.
103
*/
104
private int runThis (String argv[], PrintStream out) {
105
106
Debugee debugee;
107
108
argsHandler = new ArgumentHandler(argv);
109
logHandler = new Log(out, argsHandler);
110
Binder binder = new Binder(argsHandler, logHandler);
111
112
113
if (argsHandler.verbose()) {
114
debugee = binder.bindToDebugee(debugeeName + " -vbs");
115
} else {
116
debugee = binder.bindToDebugee(debugeeName);
117
}
118
119
IOPipe pipe = new IOPipe(debugee);
120
121
122
debugee.redirectStderr(out);
123
debugee.resume();
124
125
String line = pipe.readln();
126
if (!line.equals("ready")) {
127
logHandler.complain("# Cannot recognize debugee's signal: " + line);
128
return 2;
129
};
130
131
// ReferenceType classes[] = debugee.classes();
132
// for (int i=0; i<classes.length; i++) {
133
// ReferenceType t = classes[i];
134
// if (t.signature().startsWith("["))
135
// logHandler.display(t.name() + ": " + t.isPackagePrivate());
136
// };
137
138
int errors = 0;
139
for (int i=0; i<knownClasses.length; i++) {
140
String basicName = knownClasses[i][0];
141
for (int indirectionLevel=1; indirectionLevel<5; indirectionLevel++) {
142
String brackets[] = {"", "[]", "[][]", "[][][]", "[][][][]"};
143
String className = basicName + brackets[indirectionLevel];
144
ReferenceType refType = debugee.classByName(className);
145
if (refType == null) {
146
logHandler.complain("Could not find class: " + className);
147
errors++;
148
continue;
149
};
150
boolean isPackagePrivate =
151
!knownClasses[i][1].equals("private") &&
152
!knownClasses[i][1].equals("public") &&
153
!knownClasses[i][1].equals("protected");
154
if (refType.isPackagePrivate() != isPackagePrivate) {
155
logHandler.complain("Class is not treated package private: "
156
+ className);
157
errors++;
158
continue;
159
};
160
logHandler.display(className + ": " + knownClasses[i][1]);
161
};
162
};
163
if (errors > 0) {
164
logHandler.complain("Errors revealed: " + errors);
165
return 2;
166
};
167
168
pipe.println("quit");
169
debugee.waitFor();
170
171
int status = debugee.getStatus();
172
if (status != 95) {
173
logHandler.complain("Debugee's exit status=" + status);
174
return 2;
175
};
176
177
logHandler.display("Passed");
178
return 0;
179
}
180
}
181
182