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/resume008a.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 resume008 JDI test.
32
*/
33
34
public class resume008a {
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 Threadresume008a thread0 = null;
58
static Threadresume008a thread1 = null;
59
static Threadresume008a 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
// Debugger sets a breakpoint here to track debuggee
75
private static void methodForCommunication() {
76
int i1 = instruction;
77
int i2 = i1;
78
int i3 = i2;
79
}
80
//---------------------------------------------------- main method
81
82
public static void main (String argv[]) {
83
84
argHandler = new ArgumentHandler(argv);
85
log = argHandler.createDebugeeLog();
86
87
log1("debuggee started!");
88
89
label0:
90
for (int i = 0; ; i++) {
91
if (instruction > maxInstr) {
92
logErr("ERROR: unexpected instruction: " + instruction);
93
exitCode = FAILED;
94
break ;
95
}
96
switch (i) {
97
//------------------------------------------------------ section tested
98
case 0:
99
thread0 = new Threadresume008a("thread0");
100
methodForCommunication();
101
threadStart(thread0);
102
thread1 = new Threadresume008a("thread1");
103
// Wait for debugger to complete the first test case
104
// before advancing to the first breakpoint
105
waitForTestCase(0);
106
methodForCommunication();
107
break;
108
case 1:
109
threadStart(thread1);
110
thread2 = new Threadresume008a("thread2");
111
methodForCommunication();
112
break;
113
case 2:
114
threadStart(thread2);
115
//------------------------------------------------- standard end section
116
default:
117
instruction = end;
118
methodForCommunication();
119
break label0;
120
}
121
}
122
log1("debuggee exits");
123
System.exit(exitCode + PASS_BASE);
124
}
125
126
static Object waitnotifyObj = new Object();
127
128
static int threadStart(Thread t) {
129
synchronized (waitnotifyObj) {
130
t.start();
131
try {
132
waitnotifyObj.wait();
133
} catch ( Exception e) {
134
exitCode = FAILED;
135
logErr(" Exception : " + e );
136
return FAILED;
137
}
138
}
139
return PASSED;
140
}
141
// Synchronize with debugger progression.
142
static void waitForTestCase(int t) {
143
while (testCase < t) {
144
try {
145
Thread.sleep(100);
146
} catch (InterruptedException e) {
147
// ignored
148
}
149
}
150
}
151
static class Threadresume008a extends Thread {
152
String tName = null;
153
public Threadresume008a(String threadName) {
154
super(threadName);
155
tName = threadName;
156
}
157
public void run() {
158
log1(" 'run': enter :: threadName == " + tName);
159
synchronized (waitnotifyObj) {
160
waitnotifyObj.notify();
161
}
162
log1(" 'run': exit :: threadName == " + tName);
163
return;
164
}
165
}
166
}
167
168