Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Locatable/location/location005a.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.Locatable.location;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
31
/**
32
* This class is used as debuggee application for the location005 JDI test.
33
*/
34
35
public class location005a {
36
37
//----------------------------------------------------- templete section
38
39
static final int PASSED = 0;
40
static final int FAILED = 2;
41
static final int PASS_BASE = 95;
42
43
//-------------------------------------------------- log procedures
44
45
static boolean verbMode = false;
46
47
public static void log1(String message) {
48
if (verbMode)
49
System.err.println("**> mainThread: " + message);
50
}
51
public static void log2(String message) {
52
if (verbMode)
53
System.err.println("**> " + message);
54
}
55
56
private static void logErr(String message) {
57
if (verbMode)
58
System.err.println("!!**> mainThread: " + message);
59
}
60
61
//====================================================== test program
62
//---------------------------------------------------- main method
63
64
public static void main (String argv[]) {
65
66
for (int i=0; i<argv.length; i++) {
67
if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) {
68
verbMode = true;
69
break;
70
}
71
}
72
log1("debuggee started!");
73
74
// informing a debugger of readyness
75
ArgumentHandler argHandler = new ArgumentHandler(argv);
76
IOPipe pipe = argHandler.createDebugeeIOPipe();
77
pipe.println("ready");
78
79
80
int exitCode = PASSED;
81
for (int i = 0; ; i++) {
82
83
String instruction;
84
85
log1("waiting for an instruction from the debugger ...");
86
instruction = pipe.readln();
87
if (instruction.equals("quit")) {
88
log1("'quit' recieved");
89
break ;
90
91
} else if (instruction.equals("newcheck")) {
92
switch (i) {
93
94
//------------------------------------------------------ section tested
95
96
case 0:
97
Threadlocation005a thread2 =
98
new Threadlocation005a("Thread2");
99
log1(" thread2 is created");
100
101
label:
102
synchronized (Threadlocation005a.lockingObject) {
103
synchronized (Threadlocation005a.waitnotifyObj) {
104
log1(" synchronized (waitnotifyObj) { enter");
105
log1(" before: thread2.start()");
106
thread2.start();
107
108
try {
109
log1(" before: waitnotifyObj.wait();");
110
Threadlocation005a.waitnotifyObj.wait();
111
log1(" after: waitnotifyObj.wait();");
112
pipe.println("checkready");
113
instruction = pipe.readln();
114
if (!instruction.equals("continue")) {
115
logErr("ERROR: unexpected instruction: " + instruction);
116
exitCode = FAILED;
117
break label;
118
}
119
pipe.println("docontinue");
120
} catch ( Exception e2) {
121
log1(" Exception e2 exception: " + e2 );
122
pipe.println("waitnotifyerr");
123
}
124
}
125
}
126
log1("mainThread is out of: synchronized (lockingObject) {");
127
128
break ;
129
130
//------------------------------------------------- standard end section
131
132
default:
133
pipe.println("checkend");
134
break ;
135
}
136
137
} else {
138
logErr("ERRROR: unexpected instruction: " + instruction);
139
exitCode = FAILED;
140
break ;
141
}
142
}
143
144
System.exit(exitCode + PASS_BASE);
145
}
146
}
147
148
class Threadlocation005a extends Thread {
149
150
public Threadlocation005a(String threadName) {
151
super(threadName);
152
}
153
154
public static Object waitnotifyObj = new Object();
155
public static Object lockingObject = new Object();
156
157
private int i1 = 0, i2 = 10;
158
159
public void run() {
160
log("method 'run' enter");
161
synchronized (waitnotifyObj) {
162
log("entered into block: synchronized (waitnotifyObj)");
163
waitnotifyObj.notify(); }
164
log("exited from block: synchronized (waitnotifyObj)");
165
synchronized (lockingObject) {
166
log("entered into block: synchronized (lockingObject)"); }
167
log("exited from block: synchronized (lockingObject)");
168
i1++;
169
i2--;
170
log("call to 'runt1'");
171
runt1();
172
log("returned from 'runt1'");
173
log("method 'run' exit");
174
return;
175
}
176
177
public void runt1() {
178
179
log("method 'runt1' enter");
180
i1++;
181
i2--;
182
log("method 'runt1' exit");
183
184
return;
185
}
186
187
public static final int breakpointLineNumber1 = 3;
188
189
190
static void log(String str) {
191
location005a.log2("thread2: " + str);
192
}
193
194
}
195
196