Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq001t.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.EventRequestManager.stepRequests;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
31
/**
32
* This is a debuggee class creating several dummy user and
33
* daemon threads with own names.
34
*/
35
public class stepreq001t {
36
private static ArgumentHandler argHandler;
37
38
public static void main(String args[]) {
39
System.exit(new stepreq001t().runThis(args));
40
}
41
42
private int runThis(String args[]) {
43
argHandler = new ArgumentHandler(args);
44
IOPipe pipe = argHandler.createDebugeeIOPipe();
45
Thread thrs[] = new Thread[stepreq001.THRDS_NUM];
46
Object lockObj = new Object();
47
Object readyObj = new Object();
48
String cmd;
49
50
// Create several dummy threads and give them new names
51
thrs[0] = Thread.currentThread();
52
try {
53
thrs[0].setName(stepreq001.DEBUGGEE_THRDS[0]);
54
} catch (SecurityException e) {
55
System.err.println("TEST FAILURE: setName: caught in debuggee "
56
+ e);
57
pipe.println("failed");
58
return stepreq001.JCK_STATUS_BASE +
59
stepreq001.FAILED;
60
}
61
// Get a monitor in order to prevent the threads from exiting
62
synchronized(lockObj) {
63
for (int i=1; i<stepreq001.THRDS_NUM; i++) {
64
thrs[i] = new stepreq001a(readyObj, lockObj,
65
stepreq001.DEBUGGEE_THRDS[i]);
66
thrs[i].setDaemon(stepreq001.DAEMON_THRDS[i]);
67
if (argHandler.verbose())
68
System.out.println("Debuggee: starting thread #"
69
+ i + " \"" + thrs[i].getName() + "\"");
70
synchronized(readyObj) {
71
thrs[i].start();
72
try {
73
readyObj.wait(); // wait for the thread's readiness
74
} catch (InterruptedException e) {
75
System.out.println("TEST FAILURE: Debuggee: waiting for the thread "
76
+ thrs[i].toString() + ": caught " + e);
77
pipe.println("failed");
78
return stepreq001.JCK_STATUS_BASE +
79
stepreq001.FAILED;
80
}
81
}
82
if (argHandler.verbose())
83
System.out.println("Debuggee: the thread #"
84
+ i + " \"" + thrs[i].getName() + "\" started");
85
}
86
// Now the debuggee is ready for testing
87
pipe.println(stepreq001.COMMAND_READY);
88
cmd = pipe.readln();
89
}
90
91
// The debuggee exits
92
for (int i=1; i<stepreq001.THRDS_NUM ; i++) {
93
try {
94
thrs[i].join(argHandler.getWaitTime()*60000);
95
if (argHandler.verbose())
96
System.out.println("Debuggee: thread #"
97
+ i + " \"" + thrs[i].getName() + "\" done");
98
} catch (InterruptedException e) {
99
System.err.println("Debuggee: joining the thread #"
100
+ i + " \"" + thrs[i].getName() + "\": " + e);
101
}
102
}
103
if (!cmd.equals(stepreq001.COMMAND_QUIT)) {
104
System.err.println("TEST BUG: unknown debugger command: "
105
+ cmd);
106
return stepreq001.JCK_STATUS_BASE +
107
stepreq001.FAILED;
108
}
109
return stepreq001.JCK_STATUS_BASE +
110
stepreq001.PASSED;
111
}
112
113
class stepreq001a extends Thread {
114
private Object readyObj;
115
private Object lockObj;
116
117
stepreq001a(Object readyObj, Object obj,
118
String name) {
119
super(name);
120
this.readyObj = readyObj;
121
lockObj = obj;
122
}
123
124
public void run() {
125
Thread thr = Thread.currentThread();
126
127
synchronized(readyObj) {
128
readyObj.notify(); // notify the main thread
129
}
130
if (argHandler.verbose())
131
System.out.println("Debuggee's thread \""
132
+ thr.getName() + "\": going to be blocked");
133
synchronized(lockObj) {
134
if (argHandler.verbose()) {
135
Thread.currentThread();
136
System.out.println("Debuggee's thread \""
137
+ thr.getName() + "\": unblocked, exiting...");
138
}
139
return;
140
}
141
}
142
}
143
}
144
145