Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.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.resume;
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 resume009 JDI test.
32
*/
33
34
public class resume009a {
35
36
//----------------------------------------------------- template 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 Threadresume009a thread0 = null;
58
static Threadresume009a thread1 = null;
59
static Threadresume009a thread2 = null;
60
61
//------------------------------------------------------ common section
62
63
static int exitCode = PASSED;
64
65
static int testCase = -1;
66
static int instruction = 1;
67
static int end = 0;
68
// static int quit = 0;
69
// static int continue = 2;
70
static int maxInstr = 1; // 2;
71
72
static int lineForComm = 2;
73
74
private static void methodForCommunication() {
75
int i1 = instruction;
76
int i2 = i1;
77
int i3 = i2;
78
}
79
//---------------------------------------------------- main method
80
81
public static void main (String argv[]) {
82
83
argHandler = new ArgumentHandler(argv);
84
log = argHandler.createDebugeeLog();
85
86
log1("debuggee started!");
87
88
label0:
89
for (int i = 0; ; i++) {
90
91
if (instruction > maxInstr) {
92
logErr("ERROR: unexpected instruction: " + instruction);
93
exitCode = FAILED;
94
break ;
95
}
96
97
switch (i) {
98
99
//------------------------------------------------------ section tested
100
101
case 0:
102
thread0 = new Threadresume009a("thread0");
103
methodForCommunication();
104
105
threadRun(thread0);
106
107
thread1 = new Threadresume009a("thread1");
108
// Wait for debugger to complete the first test case
109
// before advancing to the first breakpoint
110
waitForTestCase(0);
111
methodForCommunication();
112
break;
113
114
case 1:
115
threadRun(thread1);
116
117
thread2 = new Threadresume009a("thread2");
118
methodForCommunication();
119
break;
120
121
case 2:
122
threadRun(thread2);
123
124
//------------------------------------------------- standard end section
125
126
default:
127
instruction = end;
128
methodForCommunication();
129
break label0;
130
}
131
}
132
133
log1("debuggee exits");
134
System.exit(exitCode + PASS_BASE);
135
}
136
137
static Object waitnotifyObj = new Object();
138
139
static int threadRun(Thread t) {
140
synchronized (waitnotifyObj) {
141
t.start();
142
try {
143
waitnotifyObj.wait();
144
} catch ( Exception e) {
145
exitCode = FAILED;
146
logErr("Exception in threadRun : " + e );
147
return FAILED;
148
}
149
}
150
try {
151
t.join();
152
} catch ( InterruptedException e ) {
153
exitCode = FAILED;
154
logErr("InterruptedException in threadRun : " + e );
155
return FAILED;
156
}
157
return PASSED;
158
}
159
// Synchronize with debugger progression.
160
static void waitForTestCase(int t) {
161
while (testCase < t) {
162
try {
163
Thread.sleep(100);
164
} catch (InterruptedException e) {
165
// ignored
166
}
167
}
168
}
169
170
static class Threadresume009a extends Thread {
171
172
String tName = null;
173
174
public Threadresume009a(String threadName) {
175
super(threadName);
176
tName = threadName;
177
}
178
179
public void run() {
180
log1(" 'run': enter :: threadName == " + tName);
181
synchronized (waitnotifyObj) {
182
waitnotifyObj.notify();
183
}
184
log1(" 'run': exit :: threadName == " + tName);
185
return;
186
}
187
}
188
189
}
190
191