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/isprivate002.java
41161 views
1
/*
2
* Copyright (c) 2003, 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
32
import java.io.*;
33
import java.util.*;
34
35
/**
36
* The debugger application of the test.
37
*/
38
public class isprivate002 {
39
40
//------------------------------------------------------- immutable common fields
41
42
final static String SIGNAL_READY = "ready";
43
final static String SIGNAL_GO = "go";
44
final static String SIGNAL_QUIT = "quit";
45
46
private static int waitTime;
47
private static int exitStatus;
48
private static ArgumentHandler argHandler;
49
private static Log log;
50
private static Debugee debuggee;
51
private static ReferenceType debuggeeClass;
52
53
//------------------------------------------------------- mutable common fields
54
55
private final static String prefix = "nsk.jdi.Accessible.isPrivate.";
56
private final static String className = "isprivate002";
57
private final static String debuggerName = prefix + className;
58
private final static String debuggeeName = debuggerName + "a";
59
60
//------------------------------------------------------- test specific fields
61
62
private final static String[] testedFieldNames = {"f1", "f2"};
63
64
//------------------------------------------------------- immutable common methods
65
66
public static void main(String argv[]) {
67
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
68
}
69
70
private static void display(String msg) {
71
log.display("debugger > " + msg);
72
}
73
74
private static void complain(String msg) {
75
log.complain("debugger FAILURE > " + msg);
76
}
77
78
public static int run(String argv[], PrintStream out) {
79
80
exitStatus = Consts.TEST_PASSED;
81
82
argHandler = new ArgumentHandler(argv);
83
log = new Log(out, argHandler);
84
waitTime = argHandler.getWaitTime() * 60000;
85
86
debuggee = Debugee.prepareDebugee(argHandler, log, debuggeeName);
87
88
debuggeeClass = debuggee.classByName(debuggeeName);
89
if ( debuggeeClass == null ) {
90
complain("Class '" + debuggeeName + "' not found.");
91
exitStatus = Consts.TEST_FAILED;
92
}
93
94
execTest();
95
96
debuggee.quit();
97
98
return exitStatus;
99
}
100
101
//------------------------------------------------------ mutable common method
102
103
private static void execTest() {
104
for (int i=0; i < testedFieldNames.length; i++) {
105
check(testedFieldNames[i]);
106
display("");
107
}
108
display("Checking completed!");
109
}
110
111
//--------------------------------------------------------- test specific methods
112
113
private static void check (String fieldName) {
114
try {
115
ClassType checkedClass = (ClassType)debuggeeClass.fieldByName(fieldName).type();
116
String className = checkedClass.name();
117
118
if (checkedClass.isPrivate()) {
119
display("Accessible.isPrivate() returned true for " + className);
120
} else {
121
complain("Accessible.isPrivate() returned false for " + className);
122
exitStatus = Consts.TEST_FAILED;
123
}
124
125
} catch (Exception e) {
126
complain("Unexpected exception while checking of " + className + ": " + e);
127
e.printStackTrace(System.out);
128
exitStatus = Consts.TEST_FAILED;
129
}
130
}
131
}
132
//--------------------------------------------------------- test specific classes
133
134