Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/Event/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
// THIS TEST IS LINE NUMBER SENSITIVE
25
26
package nsk.jdwp.Event.EXCEPTION;
27
28
import nsk.share.*;
29
import nsk.share.jpda.*;
30
import nsk.share.jdwp.*;
31
32
import java.io.*;
33
34
/**
35
* This class represents debuggee part in the test.
36
*/
37
public class exception001a {
38
39
static final int BREAKPOINT_LINE = 102;
40
static final int EXCEPTION_THROW_LINE = 114;
41
static final int EXCEPTION_CATCH_LINE = 121; // line number was changed due to 4740123
42
43
static ArgumentHandler argumentHandler = null;
44
static Log log = null;
45
46
public static void main(String args[]) {
47
exception001a _exception001a = new exception001a();
48
System.exit(exception001.JCK_STATUS_BASE + _exception001a.runIt(args, System.err));
49
}
50
51
public int runIt(String args[], PrintStream out) {
52
//make log for debugee messages
53
argumentHandler = new ArgumentHandler(args);
54
log = new Log(out, argumentHandler);
55
56
// create tested thread
57
log.display("Creating tested thread");
58
TestedThreadClass thread = new TestedThreadClass(exception001.TESTED_THREAD_NAME);
59
log.display(" ... thread created");
60
61
// create tested exception
62
log.display("Creating tested exception object");
63
TestedThreadClass.exception = new TestedExceptionClass("tested exception");
64
log.display(" ... exception object created");
65
66
// start tested thread
67
log.display("Starting tested thread");
68
thread.start();
69
log.display(" ... thread started");
70
71
// wait for thread finished
72
try {
73
log.display("Waiting for tested thread finished");
74
thread.join();
75
log.display(" ... thread finished");
76
} catch (InterruptedException e) {
77
log.complain("Interruption while waiting for tested thread finished");
78
return exception001.FAILED;
79
}
80
81
// exit debugee
82
log.display("Debugee PASSED");
83
return exception001.PASSED;
84
}
85
86
// tested class
87
public static class TestedThreadClass extends Thread {
88
89
// static field with tested exception object
90
public static volatile TestedExceptionClass exception = null;
91
92
public TestedThreadClass(String name) {
93
super(name);
94
}
95
96
// reach breakpoint before testing exception
97
public void run() {
98
log.display("Tested thread: started");
99
100
log.display("Breakpoint line reached");
101
// next line is for breakpoint
102
int foo = 0; // BREAKPOINT_LINE
103
log.display("Breakpoint line passed");
104
105
methodForCatch();
106
107
log.display("Tested thread: finished");
108
}
109
110
// throw tested exception
111
public void methodForThrow() throws TestedExceptionClass {
112
log.display("Throwing tested exception:\n\t" + exception);
113
// next line is location of exception throw
114
throw exception; // EXCEPTION_THROW_LINE
115
}
116
117
// catch tested exception
118
public void methodForCatch() {
119
try {
120
methodForThrow();
121
} catch (TestedExceptionClass e) { // EXCEPTION_CATCH_LINE
122
// due to evaluation of 4740123: "the first instruction at the target
123
// of the exception is code to assign to the formal parameter"
124
log.display("Caught tested exception:\n\t" + e);
125
}
126
}
127
128
}
129
130
// tested exception class
131
public static class TestedExceptionClass extends Exception {
132
public TestedExceptionClass(String message) {
133
super(message);
134
}
135
}
136
}
137
138