Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/InternalApi/ThreadCpuTimesDeadlock.java
40942 views
1
/*
2
* Copyright (c) 2012, 2021, 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 7196045
27
* @bug 8014294
28
* @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
29
* @modules java.management/sun.management
30
* @run main/othervm -XX:+UsePerfData -Xmx128m ThreadCpuTimesDeadlock
31
*/
32
33
/*
34
* @test
35
* @bug 8264649
36
* @summary OSR compiled method crash when UseTLAB is off
37
* @requires vm.debug
38
* @modules java.management/sun.management
39
* @run main/othervm -XX:-UseTLAB -XX:+UsePerfData -Xmx128m ThreadCpuTimesDeadlock
40
*/
41
42
import java.lang.management.ManagementFactory;
43
import javax.management.JMException;
44
import javax.management.MBeanServer;
45
import javax.management.MalformedObjectNameException;
46
import javax.management.ObjectName;
47
48
public class ThreadCpuTimesDeadlock {
49
50
public static byte[] dummy;
51
public static long duration = 10 * 1000;
52
private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal";
53
54
public static void main(String[] args) {
55
56
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
57
ObjectName objName= null;
58
try {
59
ObjectName hotspotInternal = new ObjectName(HOTSPOT_INTERNAL);
60
try {
61
server.registerMBean(new sun.management.HotspotInternal(), hotspotInternal);
62
} catch (JMException e) {
63
throw new RuntimeException("HotSpotWatcher: Failed to register the HotspotInternal MBean" + e);
64
}
65
objName= new ObjectName("sun.management:type=HotspotThreading");
66
67
} catch (MalformedObjectNameException e1) {
68
throw new RuntimeException("Bad object name" + e1);
69
}
70
71
// Thread that allocs memory to generate GC's
72
Thread allocThread = new Thread() {
73
public void run() {
74
while (true) {
75
dummy = new byte[4096];
76
}
77
}
78
};
79
80
allocThread.setDaemon(true);
81
allocThread.start();
82
83
long endTime = System.currentTimeMillis() + duration;
84
long i = 0;
85
while (true) {
86
try {
87
server.getAttribute(objName, "InternalThreadCpuTimes");
88
} catch (Exception ex) {
89
System.err.println("Exception while getting attribute: " + ex);
90
}
91
i++;
92
if (i % 10000 == 0) {
93
System.out.println("Successful iterations: " + i);
94
}
95
if (System.currentTimeMillis() > endTime) {
96
break;
97
}
98
}
99
System.out.println("PASSED.");
100
}
101
}
102
103