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