Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq008a.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.EventRequestManager.createStepRequest;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
// THIS TEST IS LINE NUMBER SENSITIVE
31
32
/**
33
* The debugged application of the test.
34
*/
35
public class crstepreq008a {
36
37
//----------------------------------------------------- immutable common fields
38
39
static final int PASSED = 0;
40
static final int FAILED = 2;
41
static final int PASS_BASE = 95;
42
static final int quit = -1;
43
44
static int instruction = 1;
45
static int lineForComm = 2;
46
static int exitCode = PASSED;
47
48
private static ArgumentHandler argHandler;
49
private static Log log;
50
51
//---------------------------------------------------------- immutable common methods
52
53
static void display(String msg) {
54
log.display("debuggee > " + msg);
55
}
56
57
static void complain(String msg) {
58
log.complain("debuggee FAILURE > " + msg);
59
}
60
61
static void methodForCommunication() {
62
int i = instruction; // crstepreq008.lineForBreak
63
int curInstruction = i;
64
}
65
66
//------------------------------------------------------ mutable common fields
67
68
//------------------------------------------------------ test specific fields
69
70
static final int maxCase = 4;
71
static Object waitnotifyObj = new Object();
72
static Thread thread1;
73
74
//------------------------------------------------------ mutable common method
75
76
public static void main (String argv[]) {
77
78
argHandler = new ArgumentHandler(argv);
79
log = argHandler.createDebugeeLog();
80
81
display("debuggee started!");
82
83
label0:
84
for (int testCase = 0; testCase < maxCase && instruction != quit; testCase++) {
85
86
thread1 = new Thread0crstepreq008a(testCase);
87
threadStart(thread1);
88
threadJoin (thread1, testCase);
89
90
}
91
92
display("debuggee exits");
93
System.exit(PASSED + PASS_BASE);
94
}
95
96
//--------------------------------------------------------- test specific methodss
97
98
static void threadJoin (Thread t, int number) {
99
try {
100
t.join();
101
} catch ( InterruptedException e ) {
102
exitCode = FAILED;
103
complain("Case #" + number + ": caught unexpected InterruptedException while waiting for thread finish" );
104
}
105
}
106
107
static int threadStart (Thread t) {
108
synchronized (waitnotifyObj) {
109
t.start();
110
try {
111
waitnotifyObj.wait();
112
} catch (InterruptedException e) {
113
exitCode = FAILED;
114
complain("Caught unexpected InterruptedException while waiting for thread start" );
115
return FAILED;
116
}
117
}
118
return PASSED;
119
}
120
121
}
122
123
//--------------------------------------------------------- test specific classes
124
125
/**
126
* This thread will be suspended on breakpoint. No locks are used.
127
*/
128
class Thread0crstepreq008a extends Thread {
129
int testCase;
130
131
public Thread0crstepreq008a (int testCase) {
132
super("thread" + testCase);
133
this.testCase = testCase;
134
}
135
136
public void run() {
137
crstepreq008a.display("enter thread " + getName());
138
synchronized(crstepreq008a.waitnotifyObj) {
139
crstepreq008a.waitnotifyObj.notifyAll();
140
}
141
142
crstepreq008a.methodForCommunication();
143
caseRun();
144
crstepreq008a.display("exit thread " + getName());
145
}
146
147
void caseRun() {
148
int i;
149
try {
150
switch (testCase) {
151
case 0:
152
i = m00(1); // crstepreq008.checkedLines[0][0-2]
153
i = m00(2); i = m00(3);
154
break;
155
156
case 1:
157
i = m01(1); i = m01(2);
158
break;
159
160
case 2:
161
i = m02(-1);
162
break;
163
164
case 3:
165
i = m03(-1);
166
break;
167
}
168
} catch (DummyException e) {
169
crstepreq008a.display("DummyException was caught for testCase # " + testCase);
170
}
171
}
172
173
int m00 (int arg) {
174
return arg++; // crstepreq008.checkedLines[1][0-2]
175
}
176
177
int m01 (int arg) {
178
return m00(arg);
179
}
180
181
int m02 (int arg) throws DummyException {
182
if (arg < 0) { // crstepreq008.checkedLines[2][0-1]
183
throw new DummyException(); // crstepreq008.checkedLines[2][2]// crstepreq008.checkedLines[3][0-2]
184
}
185
return arg++;
186
}
187
188
int m03 (int arg) throws DummyException {
189
return m02(arg);
190
}
191
192
class DummyException extends Exception {}
193
}
194
195