Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/jdi/DebuggerThreadTest.java
38855 views
1
/*
2
* Copyright (c) 2001, 2002, 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
/**
25
* @test
26
* @bug 4513488
27
* @summary Test for JDI: Internal JDI helper threads should setDaemon(true)
28
*
29
* @author Tim Bell
30
*
31
* @run build TestScaffold VMConnection TargetListener TargetAdapter
32
* @run compile -g DebuggerThreadTest.java
33
* @run main DebuggerThreadTest
34
*/
35
import com.sun.jdi.*;
36
import com.sun.jdi.event.*;
37
import com.sun.jdi.request.*;
38
39
import java.util.*;
40
41
/********** target program **********/
42
43
class DebuggerThreadTarg {
44
public void ready() {
45
}
46
public static void main(String[] args){
47
System.out.println("Howdy!");
48
DebuggerThreadTarg targ = new DebuggerThreadTarg();
49
targ.ready();
50
System.out.println("Goodbye from DebuggerThreadTarg!");
51
}
52
}
53
54
/********** test program **********/
55
56
public class DebuggerThreadTest extends TestScaffold {
57
58
DebuggerThreadTest (String args[]) {
59
super(args);
60
}
61
62
public static void main(String[] args) throws Exception {
63
new DebuggerThreadTest(args).startTests();
64
}
65
66
/*
67
* Move to top ThreadGroup and dump all threads.
68
*/
69
public void dumpThreads() {
70
ThreadGroup tg = Thread.currentThread().getThreadGroup();
71
ThreadGroup parent = tg.getParent();
72
while (parent != null) {
73
tg = parent;
74
parent = tg.getParent();
75
}
76
int listThreads = tg.activeCount();
77
Thread list[] = new Thread[listThreads * 2];
78
int gotThreads = tg.enumerate(list, true);
79
for (int i = 0; i < Math.min(gotThreads, list.length); i++){
80
Thread t = list[i];
81
String groupName = t.getThreadGroup().getName();
82
83
System.out.println("Thread [" + i + "] group = '" +
84
groupName +
85
"' name = '" + t.getName() +
86
"' daemon = " + t.isDaemon());
87
88
if (groupName.startsWith("JDI ") &&
89
(! t.isDaemon())) {
90
failure("FAIL: non-daemon thread '" + t.getName() +
91
"' found in ThreadGroup '" + groupName + "'");
92
}
93
94
}
95
}
96
97
protected void runTests() throws Exception {
98
try {
99
/*
100
* Get to the top of ready()
101
*/
102
startTo("DebuggerThreadTarg", "ready", "()V");
103
104
dumpThreads();
105
106
listenUntilVMDisconnect();
107
108
} finally {
109
/*
110
* deal with results of test
111
* if anything has called failure("foo") testFailed will be true
112
*/
113
if (!testFailed) {
114
println("DebuggerThreadTest: passed");
115
} else {
116
throw new Exception("DebuggerThreadTest: failed");
117
}
118
}
119
return;
120
}
121
}
122
123