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/suspendpolicy008a.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 suspendpolicy008 JDI test.
32
*/
33
34
public class suspendpolicy008a {
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 Threadsuspendpolicy008a thread0 = null;
58
static Threadsuspendpolicy008a thread1 = null;
59
static Threadsuspendpolicy008a thread2 = null;
60
static Threadsuspendpolicy008a thread3 = null;
61
static Threadsuspendpolicy008a thread4 = null;
62
static Threadsuspendpolicy008a thread5 = null;
63
static Threadsuspendpolicy008a 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 Threadsuspendpolicy008a("thread0");
109
methodForCommunication();
110
111
threadStart(thread0);
112
113
thread1 = new Threadsuspendpolicy008a("thread1");
114
methodForCommunication();
115
break;
116
117
case 1:
118
threadStart(thread1);
119
120
thread2 = new Threadsuspendpolicy008a("thread2");
121
methodForCommunication();
122
break;
123
124
case 2:
125
threadStart(thread2);
126
127
thread3 = new Threadsuspendpolicy008a("thread3");
128
methodForCommunication();
129
break;
130
131
case 3:
132
threadStart(thread3);
133
134
thread4 = new Threadsuspendpolicy008a("thread4");
135
methodForCommunication();
136
break;
137
138
case 4:
139
threadStart(thread4);
140
141
thread5 = new Threadsuspendpolicy008a("thread5");
142
methodForCommunication();
143
break;
144
145
case 5:
146
threadStart(thread5);
147
148
thread6 = new Threadsuspendpolicy008a("thread6");
149
methodForCommunication();
150
break;
151
152
case 6:
153
threadStart(thread6);
154
155
//------------------------------------------------- standard end section
156
157
default:
158
instruction = end;
159
methodForCommunication();
160
break label0;
161
}
162
}
163
164
System.exit(exitCode + PASS_BASE);
165
}
166
167
static Object waitnotifyObj = new Object();
168
169
static int threadStart(Thread t) {
170
synchronized (waitnotifyObj) {
171
t.start();
172
try {
173
waitnotifyObj.wait();
174
} catch ( Exception e) {
175
exitCode = FAILED;
176
logErr(" Exception : " + e );
177
return FAILED;
178
}
179
}
180
return PASSED;
181
}
182
183
static class Threadsuspendpolicy008a extends Thread {
184
185
String tName = null;
186
187
public Threadsuspendpolicy008a(String threadName) {
188
super(threadName);
189
tName = threadName;
190
}
191
192
public void run() {
193
log1(" 'run': enter :: threadName == " + tName);
194
synchronized (waitnotifyObj) {
195
waitnotifyObj.notify();
196
}
197
log1(" 'run': exit :: threadName == " + tName);
198
return;
199
}
200
}
201
202
}
203
204