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/crstepreq003a.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 crstepreq003a {
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
private static IOPipe pipe;
51
52
//------------------------------------------------------ mutable common fields
53
54
//------------------------------------------------------ test specific fields
55
56
static Object waitnotifyObj = new Object();
57
58
//------------------------------------------------------ mutable common method
59
60
public static void main (String argv[]) {
61
62
argHandler = new ArgumentHandler(argv);
63
log = new Log(System.out, argHandler);
64
pipe = argHandler.createDebugeeIOPipe(log);
65
66
display("debuggee started!");
67
68
label0:
69
for (int testCase = 0; instruction != quit; testCase++) {
70
71
switch (testCase) {
72
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test case section
73
case 0:
74
75
Thread thread0 = new Thread0crstepreq003a("thread0");
76
threadStart(thread0);
77
threadJoin (thread0, "0");
78
break;
79
80
case 1:
81
82
Thread thread1 = new Thread0crstepreq003a("thread1");
83
threadStart(thread1);
84
threadJoin (thread1, "1");
85
break;
86
87
case 2:
88
89
Thread thread2 = new Thread0crstepreq003a("thread2");
90
threadStart(thread2);
91
threadJoin (thread2, "2");
92
93
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end of section
94
95
default:
96
instruction = quit;
97
break;
98
}
99
100
// display("call methodForCommunication() #0");
101
// methodForCommunication();
102
if (instruction == quit)
103
break;
104
}
105
106
display("debuggee exits");
107
System.exit(PASSED + PASS_BASE);
108
}
109
110
//--------------------------------------------------------- test specific methodss
111
112
static void threadJoin (Thread t, String number) {
113
try {
114
t.join();
115
} catch ( InterruptedException e ) {
116
exitCode = FAILED;
117
complain("Case #" + number + ": caught unexpected InterruptedException while waiting for thread finish" );
118
}
119
}
120
121
static int threadStart (Thread t) {
122
synchronized (waitnotifyObj) {
123
t.start();
124
try {
125
waitnotifyObj.wait();
126
} catch (InterruptedException e) {
127
exitCode = FAILED;
128
complain("Caught unexpected InterruptedException while waiting for thread start" );
129
return FAILED;
130
}
131
}
132
return PASSED;
133
}
134
135
static void breakInThread() {
136
Object dummy = new Object();
137
synchronized(dummy) { // crstepreq003.lineForBreakInThread
138
int i = 1; // This is line of step event's location for STEP_OVER and STEP_INTO -- crstepreq003.checkedLines[0-1]
139
}
140
}
141
142
//---------------------------------------------------------- immutable common methods
143
144
static void display(String msg) {
145
log.display("debuggee > " + msg);
146
}
147
148
static void complain(String msg) {
149
log.complain("debuggee FAILURE > " + msg);
150
}
151
152
private static void methodForCommunication() {
153
int i = instruction;
154
int curInstruction = i;
155
}
156
}
157
158
//--------------------------------------------------------- test specific classes
159
160
/**
161
* This thread will be suspended on breakpoint. No locks are used.
162
*/
163
class Thread0crstepreq003a extends Thread {
164
public Thread0crstepreq003a (String name) {
165
super(name);
166
}
167
168
public void run() {
169
crstepreq003a.display("enter thread " + getName());
170
171
synchronized(crstepreq003a.waitnotifyObj) {
172
crstepreq003a.waitnotifyObj.notifyAll();
173
}
174
175
crstepreq003a.display("call breakInThread()");
176
crstepreq003a.breakInThread();
177
178
crstepreq003a.display("exit thread " + getName()); // This is line of step event's location for STEP_OUT -- crstepreq003.checkedLines[2]
179
}
180
}
181
182