Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionEvent/catchLocation/location001a.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.ExceptionEvent.catchLocation;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import java.lang.Integer.*;
31
import java.io.*;
32
33
// THIS TEST IS LINE NUMBER SENSITIVE
34
35
// This class is the debugged application in the test
36
37
class location001a {
38
static final int PASSED = 0;
39
static final int FAILED = 2;
40
static final int JCK_STATUS_BASE = 95;
41
42
// synchronization commands
43
static final String COMMAND_READY = "ready";
44
static final String COMMAND_QUIT = "quit";
45
static final String COMMAND_GO = "go";
46
static final String COMMAND_DONE = "done";
47
static final String COMMAND_ERROR = "error";
48
49
// line numbers where checked exceptions thrown (for user exceptions only)
50
public static final int userExceptionLocation = 98;
51
public static final int userErrorLocation = 105;
52
public static final int userThrowableLocation = 112;
53
54
// line numbers where checked exceptions caught. Numbers were changed due to 4740123
55
public static final int userExceptionCatchLocation = 99;
56
public static final int userErrorCatchLocation = 106;
57
public static final int userThrowableCatchLocation = 113;
58
public static final int javaExceptionCatchLocation = 120;
59
public static final int javaErrorCatchLocation = 127;
60
61
// flags marked all actually thrown exceptions
62
private static boolean userExceptionThrown = false;
63
private static boolean userErrorThrown = false;
64
private static boolean userThrowableThrown = false;
65
private static boolean javaExceptionThrown = false;
66
private static boolean javaErrorThrown = false;
67
68
// run debuggee from command line
69
public static void main(String args[]) throws Throwable {
70
location001a _location001a = new location001a();
71
System.exit(JCK_STATUS_BASE + _location001a.runIt(args, System.err));
72
}
73
74
// perform debuggee class execution
75
int runIt(String args[], PrintStream out) throws Throwable {
76
ArgumentHandler argHandler = new ArgumentHandler(args);
77
IOPipe pipe = argHandler.createDebugeeIOPipe();
78
Log log = new Log(out, argHandler);
79
80
// create checked exceptions
81
location001aException e1 = new location001aException ();
82
location001aError e2 = new location001aError ();
83
location001aThrowable e3 = new location001aThrowable ();
84
85
// notify debugger that debuggee started
86
pipe.println(COMMAND_READY);
87
88
// wait for command <GO> from debugger
89
String command = pipe.readln();
90
if (!command.equals(COMMAND_GO)) {
91
log.complain("TEST BUG: unknown command: " + command);
92
return FAILED;
93
}
94
95
// throw checked exceptions
96
try {
97
try {
98
throw new location001aException(); // userExceptionLocation
99
} catch (location001aException e) { // <= expected catch location due to evaluation of 4740123. // userExceptionLocation
100
log.display("location001aException is thrown");
101
userExceptionThrown = true;
102
}
103
104
try {
105
throw new location001aError(); // userErrorLocation
106
} catch (location001aError e) { // <= expected catch location due to evaluation of 4740123. // userErrorCatchLocation
107
log.display("location001aError is thrown");
108
userErrorThrown = true;
109
}
110
111
try {
112
throw new location001aThrowable(); // userThrowableLocation
113
} catch (location001aThrowable e) { // <= expected catch location due to evaluation of 4740123. // userThrowableCatchLocation
114
log.display("location001aThrowable is thrown");
115
userThrowableThrown = true;
116
}
117
118
try {
119
int i = Integer.parseInt("foo");
120
} catch (NumberFormatException e) { // <= expected catch location due to evaluation of 4740123. // userThrowableCatchLocation
121
log.display("NumberFormatException is thrown");
122
javaExceptionThrown = true;
123
}
124
125
try {
126
raiseStackOverflow();
127
} catch (StackOverflowError e) { // <= expected catch location due to evaluation of 4740123. // javaErrorCatchLocation
128
log.display("StackOverflowError is thrown");
129
javaErrorThrown = true;
130
}
131
132
} catch (Throwable e) {
133
log.complain("Unexpected Throwable: " + e.getMessage());
134
e.printStackTrace();
135
if (e instanceof ThreadDeath) {
136
throw e;
137
}
138
}
139
140
// check that all exceptions are thrown
141
boolean thrown = true;
142
if (!userExceptionThrown) {
143
log.complain("TEST BUG: user exception NOT thrown");
144
thrown = false;
145
}
146
if (!userErrorThrown) {
147
log.complain("TEST BUG: user error NOT thrown");
148
thrown = false;
149
}
150
if (!userThrowableThrown) {
151
log.complain("TEST BUG: user Throwable NOT thrown");
152
thrown = false;
153
}
154
if (!javaExceptionThrown) {
155
log.complain("TEST BUG: java exception NOT thrown");
156
thrown = false;
157
}
158
if (!javaErrorThrown) {
159
log.complain("TEST BUG: java error NOT thrown");
160
thrown = false;
161
}
162
163
// notify debugger whether all exceptions thrown or not
164
if (thrown) {
165
pipe.println(COMMAND_DONE);
166
} else {
167
pipe.println(COMMAND_ERROR);
168
}
169
170
// wait for command <QUIT> from debugger and exit
171
command = pipe.readln();
172
if (!command.equals(COMMAND_QUIT)) {
173
log.complain("TEST BUG: unknown command: " + command);
174
return FAILED;
175
}
176
177
return PASSED;
178
}
179
180
private void raiseStackOverflow () {
181
raiseStackOverflow();
182
}
183
}
184
185
class location001aException extends Exception {}
186
187
class location001aError extends Error {}
188
189
class location001aThrowable extends Throwable {}
190
191