Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009a.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.EventSet.suspendPolicy;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
/**
31
* This class is used as debuggee application for the suspendpolicy009 JDI test.
32
*/
33
34
public class suspendpolicy009a {
35
36
//----------------------------------------------------- templete section
37
38
static final int PASSED = 0;
39
static final int FAILED = 2;
40
static final int PASS_BASE = 95;
41
42
static ArgumentHandler argHandler;
43
static Log log;
44
45
//-------------------------------------------------- log procedures
46
47
private static void log1(String message) {
48
log.display("**> debuggee: " + message);
49
}
50
51
private static void logErr(String message) {
52
log.complain("**> debuggee: " + message);
53
}
54
55
//====================================================== test program
56
57
static Threadsuspendpolicy009a thread0 = null;
58
static Threadsuspendpolicy009a thread1 = null;
59
static Threadsuspendpolicy009a thread2 = null;
60
static Threadsuspendpolicy009a thread3 = null;
61
static Threadsuspendpolicy009a thread4 = null;
62
static Threadsuspendpolicy009a thread5 = null;
63
static Threadsuspendpolicy009a thread6 = null;
64
65
//------------------------------------------------------ common section
66
67
static int exitCode = PASSED;
68
69
static int instruction = 1;
70
static int end = 0;
71
// static int quit = 0;
72
// static int continue = 2;
73
static int maxInstr = 1; // 2;
74
75
static int lineForComm = 2;
76
77
private static void methodForCommunication() {
78
int i1 = instruction;
79
int i2 = i1;
80
int i3 = i2;
81
}
82
//---------------------------------------------------- main method
83
84
public static void main (String argv[]) {
85
86
argHandler = new ArgumentHandler(argv);
87
log = argHandler.createDebugeeLog();
88
89
log1("debuggee started!");
90
91
int exitCode = PASSED;
92
93
94
label0:
95
for (int i = 0; ; i++) {
96
97
if (instruction > maxInstr) {
98
logErr("ERROR: unexpected instruction: " + instruction);
99
exitCode = FAILED;
100
break ;
101
}
102
103
switch (i) {
104
105
//------------------------------------------------------ section tested
106
107
case 0:
108
thread0 = new Threadsuspendpolicy009a("thread0");
109
methodForCommunication();
110
111
threadStart(thread0);
112
try {
113
thread0.join();
114
} catch (InterruptedException e) {
115
}
116
thread1 = new Threadsuspendpolicy009a("thread1");
117
methodForCommunication();
118
break;
119
120
case 1:
121
threadStart(thread1);
122
try {
123
thread1.join();
124
} catch (InterruptedException e) {
125
}
126
thread2 = new Threadsuspendpolicy009a("thread2");
127
methodForCommunication();
128
break;
129
130
case 2:
131
threadStart(thread2);
132
try {
133
thread2.join();
134
} catch (InterruptedException e) {
135
}
136
thread3 = new Threadsuspendpolicy009a("thread3");
137
methodForCommunication();
138
break;
139
140
case 3:
141
threadStart(thread3);
142
try {
143
thread3.join();
144
} catch (InterruptedException e) {
145
}
146
thread4 = new Threadsuspendpolicy009a("thread4");
147
methodForCommunication();
148
break;
149
150
case 4:
151
threadStart(thread4);
152
try {
153
thread4.join();
154
} catch (InterruptedException e) {
155
}
156
thread5 = new Threadsuspendpolicy009a("thread5");
157
methodForCommunication();
158
break;
159
160
case 5:
161
threadStart(thread5);
162
try {
163
thread5.join();
164
} catch (InterruptedException e) {
165
}
166
thread6 = new Threadsuspendpolicy009a("thread6");
167
methodForCommunication();
168
break;
169
170
case 6:
171
threadStart(thread6);
172
try {
173
thread6.join();
174
} catch (InterruptedException e) {
175
}
176
//------------------------------------------------- standard end section
177
178
default:
179
instruction = end;
180
methodForCommunication();
181
break label0;
182
}
183
}
184
185
System.exit(exitCode + PASS_BASE);
186
}
187
188
static Object waitnotifyObj = new Object();
189
190
static int threadStart(Thread t) {
191
synchronized (waitnotifyObj) {
192
t.start();
193
try {
194
waitnotifyObj.wait();
195
} catch ( Exception e) {
196
exitCode = FAILED;
197
logErr(" Exception : " + e );
198
return FAILED;
199
}
200
}
201
return PASSED;
202
}
203
204
static class Threadsuspendpolicy009a extends Thread {
205
206
String tName = null;
207
208
public Threadsuspendpolicy009a(String threadName) {
209
super(threadName);
210
tName = threadName;
211
}
212
213
public void run() {
214
log1(" 'run': enter :: threadName == " + tName);
215
synchronized (waitnotifyObj) {
216
waitnotifyObj.notify();
217
}
218
log1(" 'run': exit :: threadName == " + tName);
219
return;
220
}
221
}
222
223
}
224
225