Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/Name/name001a.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.jdwp.ThreadReference.Name;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdwp.*;
29
30
import java.io.*;
31
32
/**
33
* This class represents debuggee part in the test.
34
*/
35
public class name001a {
36
37
// name for the tested thread
38
public static final String THREAD_NAME = "TestedThreadName";
39
public static final String FIELD_NAME = "thread";
40
41
// notification object to notify debuggee that thread started
42
private static Object threadStarted = new Object();
43
// lock object to prevent thread from exit
44
private static Object threadLock = new Object();
45
46
// scaffold objects
47
private static volatile ArgumentHandler argumentHandler = null;
48
private static volatile Log log = null;
49
50
public static void main(String args[]) {
51
name001a _name001a = new name001a();
52
System.exit(name001.JCK_STATUS_BASE + _name001a.runIt(args, System.err));
53
}
54
55
public int runIt(String args[], PrintStream out) {
56
//make log for debugee messages
57
argumentHandler = new ArgumentHandler(args);
58
log = new Log(out, argumentHandler);
59
60
// make communication pipe to debugger
61
log.display("Creating pipe");
62
IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);
63
64
// lock the object to prevent thread from exit
65
synchronized (threadLock) {
66
67
// load tested class and create tested thread
68
log.display("Creating object of tested class");
69
TestedClass.thread = new TestedClass(THREAD_NAME);
70
71
// start the thread and wait for notification from it
72
synchronized (threadStarted) {
73
TestedClass.thread.start();
74
try {
75
threadStarted.wait();
76
// send debugger signal READY
77
log.display("Sending signal to debugger: " + name001.READY);
78
pipe.println(name001.READY);
79
} catch (InterruptedException e) {
80
log.complain("Interruption while waiting for thread started: " + e);
81
pipe.println(name001.ERROR);
82
}
83
}
84
85
// wait for signal QUIT from debugeer
86
log.display("Waiting for signal from debugger: " + name001.QUIT);
87
String signal = pipe.readln();
88
log.display("Received signal from debugger: " + signal);
89
90
// check received signal
91
if (signal == null || !signal.equals(name001.QUIT)) {
92
log.complain("Unexpected communication signal from debugee: " + signal
93
+ " (expected: " + name001.QUIT + ")");
94
log.display("Debugee FAILED");
95
return name001.FAILED;
96
}
97
98
// allow started thread to exit
99
}
100
101
// exit debugee
102
log.display("Debugee PASSED");
103
return name001.PASSED;
104
}
105
106
// tested thread class
107
public static class TestedClass extends Thread {
108
109
// field with the tested Thread value
110
public static volatile TestedClass thread = null;
111
112
TestedClass(String name) {
113
super(name);
114
}
115
116
public void run() {
117
log.display("Tested thread started");
118
119
// notify debuggee that thread really started
120
synchronized (threadStarted) {
121
threadStarted.notifyAll();
122
}
123
124
// wait for lock object released
125
synchronized (threadLock) {
126
log.display("Tested thread finished");
127
}
128
}
129
}
130
131
}
132
133