Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Locatable/location/location006.java
41161 views
1
/*
2
* Copyright (c) 2001, 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.Locatable.location;
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
* The test for the implementation of an object of the type <BR>
36
* Locatable. <BR>
37
* <BR>
38
* The test checks up that results of the method <BR>
39
* <code>com.sun.jdi.Locatable.location()</code> <BR>
40
* complies with its spec when a tested method is native. <BR>
41
* <BR>
42
* The case for testing is as follows. <BR>
43
* <BR>
44
* When a gebuggee creates an object of <BR>
45
* the following class type: <BR>
46
* class TestClass { <BR>
47
* public native void nativeMethod (); <BR>
48
* } <BR>
49
* a debugger checks up that the invocation of <BR>
50
* the method Locatable.location() on the nativeMethod <BR>
51
* returns not the null. <BR>
52
* <BR>
53
*/
54
55
public class location006 {
56
57
//----------------------------------------------------- templete section
58
static final int PASSED = 0;
59
static final int FAILED = 2;
60
static final int PASS_BASE = 95;
61
62
//----------------------------------------------------- templete parameters
63
static final String
64
sHeader1 = "\n==> nsk/jdi/Locatable/location/location006 ",
65
sHeader2 = "--> location006: ",
66
sHeader3 = "##> location006: ";
67
68
//----------------------------------------------------- main method
69
70
public static void main (String argv[]) {
71
int result = run(argv, System.out);
72
System.exit(result + PASS_BASE);
73
}
74
75
public static int run (String argv[], PrintStream out) {
76
return new location006().runThis(argv, out);
77
}
78
79
//-------------------------------------------------- log procedures
80
81
//private static boolean verbMode = false;
82
83
private static Log logHandler;
84
85
private static void log1(String message) {
86
logHandler.display(sHeader1 + message);
87
}
88
private static void log2(String message) {
89
logHandler.display(sHeader2 + message);
90
}
91
private static void log3(String message) {
92
logHandler.complain(sHeader3 + message);
93
}
94
95
// ************************************************ test parameters
96
97
private String debuggeeName =
98
"nsk.jdi.Locatable.location.location006a";
99
100
String mName = "nsk.jdi.Locatable.location";
101
102
//====================================================== test program
103
104
static ArgumentHandler argsHandler;
105
static int testExitCode = PASSED;
106
107
//------------------------------------------------------ common section
108
109
private int runThis (String argv[], PrintStream out) {
110
111
Debugee debuggee;
112
113
argsHandler = new ArgumentHandler(argv);
114
logHandler = new Log(out, argsHandler);
115
Binder binder = new Binder(argsHandler, logHandler);
116
117
118
if (argsHandler.verbose()) {
119
debuggee = binder.bindToDebugee(debuggeeName + " -vbs"); // *** tp
120
} else {
121
debuggee = binder.bindToDebugee(debuggeeName); // *** tp
122
}
123
124
IOPipe pipe = new IOPipe(debuggee);
125
126
debuggee.redirectStderr(out);
127
log2("location006a debuggee launched");
128
debuggee.resume();
129
130
String line = pipe.readln();
131
if ((line == null) || !line.equals("ready")) {
132
log3("signal received is not 'ready' but: " + line);
133
return FAILED;
134
} else {
135
log2("'ready' recieved");
136
}
137
138
VirtualMachine vm = debuggee.VM();
139
140
//------------------------------------------------------ testing section
141
log1(" TESTING BEGINS");
142
143
for (int i = 0; ; i++) {
144
pipe.println("newcheck");
145
line = pipe.readln();
146
147
if (line.equals("checkend")) {
148
log2(" : returned string is 'checkend'");
149
break ;
150
} else if (!line.equals("checkready")) {
151
log3("ERROR: returned string is not 'checkready'");
152
testExitCode = FAILED;
153
break ;
154
}
155
156
log1("new check: #" + i);
157
158
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
159
160
List listOfDebuggeeClasses = vm.classesByName(mName + ".location006aTestClass");
161
if (listOfDebuggeeClasses.size() != 1) {
162
testExitCode = FAILED;
163
log3("ERROR: listOfDebuggeeClasses.size() != 1");
164
break ;
165
}
166
167
List methods = null;
168
Method m = null;
169
Location mLocation = null;
170
171
methods = ((ReferenceType) listOfDebuggeeClasses.get(0)).
172
methodsByName("nativeMethod");
173
m = (Method) methods.get(0);
174
mLocation = m.location();
175
176
if (mLocation == null) {
177
log3("ERROR: mLocation == null for a native method");
178
testExitCode = FAILED;
179
}
180
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181
}
182
log1(" TESTING ENDS");
183
184
//-------------------------------------------------- test summary section
185
//------------------------------------------------- standard end section
186
187
pipe.println("quit");
188
log2("waiting for the debuggee to finish ...");
189
debuggee.waitFor();
190
191
int status = debuggee.getStatus();
192
if (status != PASSED + PASS_BASE) {
193
log3("debuggee returned UNEXPECTED exit status: " +
194
status + " != PASS_BASE");
195
testExitCode = FAILED;
196
} else {
197
log2("debuggee returned expected exit status: " +
198
status + " == PASS_BASE");
199
}
200
201
if (testExitCode != PASSED) {
202
System.out.println("TEST FAILED");
203
}
204
return testExitCode;
205
}
206
}
207
208