Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionEvent/exception/exception001a.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.exception;
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 class is the debugged application in the test
34
35
class exception001a {
36
static final int PASSED = 0;
37
static final int FAILED = 2;
38
static final int JCK_STATUS_BASE = 95;
39
40
// synchronization commands
41
static final String COMMAND_READY = "ready";
42
static final String COMMAND_QUIT = "quit";
43
static final String COMMAND_GO = "go";
44
static final String COMMAND_DONE = "done";
45
static final String COMMAND_ERROR = "error";
46
47
/*
48
// line numbers where checked exceptions thrown (for user exceptions only)
49
public static final int userExceptionLocation = 77;
50
public static final int userErrorLocation = 84;
51
public static final int userThrowableLocation = 91;
52
53
// line numbers where checked exceptions caught
54
public static final int userExceptionCatchLocation = 79;
55
public static final int userErrorCatchLocation = 86;
56
public static final int userThrowableCatchLocation = 93;
57
public static final int javaExceptionCatchLocation = 100;
58
public static final int javaErrorCatchLocation = 107;
59
*/
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
exception001a _exception001a = new exception001a();
71
System.exit(JCK_STATUS_BASE + _exception001a.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
exception001aException e1 = new exception001aException ();
82
exception001aError e2 = new exception001aError ();
83
exception001aThrowable e3 = new exception001aThrowable ();
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 exception001aException();
99
} catch (exception001aException e) {
100
log.display("exception001aException is thrown");
101
userExceptionThrown = true;
102
}
103
104
try {
105
throw new exception001aError();
106
} catch (exception001aError e) {
107
log.display("exception001aError is thrown");
108
userErrorThrown = true;
109
}
110
111
try {
112
throw new exception001aThrowable();
113
} catch (exception001aThrowable e) {
114
log.display("exception001aThrowable is thrown");
115
userThrowableThrown = true;
116
}
117
118
try {
119
int i = Integer.parseInt("foo");
120
} catch (NumberFormatException e) {
121
log.display("NumberFormatException is thrown");
122
javaExceptionThrown = true;
123
}
124
125
try {
126
raiseStackOverflow();
127
} catch (StackOverflowError e) {
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 exception001aException extends Exception {}
186
187
class exception001aError extends Error {}
188
189
class exception001aThrowable extends Throwable {}
190
191