Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassObjectReference/toString/tostring001.java
41161 views
1
/*
2
* Copyright (c) 2002, 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.ClassObjectReference.toString;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import com.sun.jdi.request.*;
32
import com.sun.jdi.event.*;
33
import com.sun.jdi.connect.*;
34
import java.io.*;
35
import java.util.*;
36
37
/**
38
* The debugger application of the test.
39
*/
40
public class tostring001 {
41
42
//------------------------------------------------------- immutable common fields
43
44
final static String SIGNAL_READY = "ready";
45
final static String SIGNAL_GO = "go";
46
final static String SIGNAL_QUIT = "quit";
47
48
private static int waitTime;
49
private static int exitStatus;
50
private static ArgumentHandler argHandler;
51
private static Log log;
52
private static Debugee debuggee;
53
private static ReferenceType debuggeeClass;
54
55
//------------------------------------------------------- mutable common fields
56
57
private final static String prefix = "nsk.jdi.ClassObjectReference.toString.";
58
private final static String className = "tostring001";
59
private final static String debuggerName = prefix + className;
60
private final static String debuggeeName = debuggerName + "a";
61
62
//------------------------------------------------------- test specific fields
63
64
/** debuggee's methods for check **/
65
private final static String checkedClasses[] = {
66
"java.lang.Boolean" ,
67
"java.lang.Byte" ,
68
"java.lang.Character",
69
"java.lang.Double" ,
70
"java.lang.Float" ,
71
"java.lang.Integer" ,
72
"java.lang.Long" ,
73
"java.lang.Short" ,
74
"java.lang.String" ,
75
"java.lang.Object" ,
76
77
debuggeeName + "$innerClass",
78
debuggeeName + "$innerInterf",
79
prefix + "tostring001aClass",
80
prefix + "tostring001aInterf"
81
};
82
83
//------------------------------------------------------- immutable common methods
84
85
public static void main(String argv[]) {
86
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
87
}
88
89
private static void display(String msg) {
90
log.display("debugger > " + msg);
91
}
92
93
private static void complain(String msg) {
94
log.complain("debugger FAILURE > " + msg);
95
}
96
97
public static int run(String argv[], PrintStream out) {
98
99
exitStatus = Consts.TEST_PASSED;
100
101
argHandler = new ArgumentHandler(argv);
102
log = new Log(out, argHandler);
103
waitTime = argHandler.getWaitTime() * 60000;
104
105
debuggee = Debugee.prepareDebugee(argHandler, log, debuggeeName);
106
107
debuggeeClass = debuggee.classByName(debuggeeName);
108
if ( debuggeeClass == null ) {
109
complain("Class '" + debuggeeName + "' not found.");
110
exitStatus = Consts.TEST_FAILED;
111
}
112
113
execTest();
114
115
debuggee.quit();
116
117
return exitStatus;
118
}
119
120
//------------------------------------------------------ mutable common method
121
122
private static void execTest() {
123
124
BreakpointRequest brkp = debuggee.setBreakpoint(debuggeeClass,
125
tostring001a.brkpMethodName,
126
tostring001a.brkpLineNumber);
127
debuggee.resume();
128
129
debuggee.sendSignal(SIGNAL_GO);
130
Event event = null;
131
132
// waiting the breakpoint event
133
try {
134
event = debuggee.waitingEvent(brkp, waitTime);
135
} catch (InterruptedException e) {
136
throw new Failure("unexpected InterruptedException while waiting for Breakpoint event");
137
}
138
if (!(event instanceof BreakpointEvent)) {
139
debuggee.resume();
140
throw new Failure("BreakpointEvent didn't arrive");
141
}
142
143
ThreadReference thread = ((BreakpointEvent)event).thread();
144
List params = new Vector();
145
ClassType testedClass = (ClassType)debuggeeClass;
146
147
display("Checking toString() method for ClassObjectReferences of debuggee's fields...");
148
String brackets[] = {"", "[]", "[][]"};
149
150
for (int i=0; i < checkedClasses.length; i++) {
151
152
String basicName = checkedClasses[i];
153
154
for (int dim = 0; dim<3; dim++) {
155
156
String className = basicName + brackets[dim];
157
ReferenceType refType = debuggee.classByName(className);
158
if (refType == null) {
159
complain("Could NOT FIND class: " + className);
160
exitStatus = Consts.TEST_FAILED;
161
continue;
162
}
163
164
try {
165
ClassObjectReference classObjRef = refType.classObject();
166
String str = classObjRef.toString();
167
if (str == null) {
168
complain("toString() returns null for ClassObjectReferences of debugges's field: " + className);
169
exitStatus = Consts.TEST_FAILED;
170
} else if (str.length() == 0) {
171
complain("toString() returns empty string for ClassObjectReferences of debugges's field: " + className);
172
exitStatus = Consts.TEST_FAILED;
173
} else {
174
display("toString() method returns for " + className + " : " + str);
175
}
176
} catch(Exception e) {
177
complain("unexpected " + e + " while taking ClassObjectReferences of debugges's field: " + className);
178
exitStatus = Consts.TEST_FAILED;
179
}
180
}
181
}
182
183
display("Checking completed!");
184
debuggee.resume();
185
}
186
187
//--------------------------------------------------------- test specific methods
188
189
}
190
//--------------------------------------------------------- test specific classes
191
192