Mercurial > hg > truffle
annotate test/runtime/InternalApi/ThreadCpuTimesDeadlock.java @ 19678:96ab2078eeaf
Merge
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Mon, 02 Mar 2015 19:11:22 +0100 |
parents | fa57c8104b76 |
children |
rev | line source |
---|---|
6779
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
1 /* |
11990 | 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
6779
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
4 * |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
8 * |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
13 * accompanied this code). |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
14 * |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
18 * |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
21 * questions. |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
22 * |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
23 */ |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
24 |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
25 /* |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
26 * @test |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
27 * @bug 7196045 |
11990 | 28 * @bug 8014294 |
6779
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
29 * @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API. |
11990 | 30 * @run main/othervm -XX:+UsePerfData -Xmx32m ThreadCpuTimesDeadlock |
6779
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
31 */ |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
32 |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
33 import java.lang.management.ManagementFactory; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
34 import javax.management.JMException; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
35 import javax.management.MBeanServer; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
36 import javax.management.MalformedObjectNameException; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
37 import javax.management.ObjectName; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
38 |
11990 | 39 public class ThreadCpuTimesDeadlock { |
6779
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
40 |
11990 | 41 public static byte[] dummy; |
42 public static long duration = 10 * 1000; | |
6779
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
43 private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal"; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
44 |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
45 public static void main(String[] args) { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
46 |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
47 MBeanServer server = ManagementFactory.getPlatformMBeanServer(); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
48 ObjectName objName= null; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
49 try { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
50 ObjectName hotspotInternal = new ObjectName(HOTSPOT_INTERNAL); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
51 try { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
52 server.registerMBean(new sun.management.HotspotInternal(), hotspotInternal); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
53 } catch (JMException e) { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
54 throw new RuntimeException("HotSpotWatcher: Failed to register the HotspotInternal MBean" + e); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
55 } |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
56 objName= new ObjectName("sun.management:type=HotspotThreading"); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
57 |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
58 } catch (MalformedObjectNameException e1) { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
59 throw new RuntimeException("Bad object name" + e1); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
60 } |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
61 |
11990 | 62 // Thread that allocs memory to generate GC's |
63 Thread allocThread = new Thread() { | |
64 public void run() { | |
65 while (true) { | |
66 dummy = new byte[4096]; | |
67 } | |
68 } | |
69 }; | |
70 | |
71 allocThread.setDaemon(true); | |
72 allocThread.start(); | |
73 | |
6779
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
74 long endTime = System.currentTimeMillis() + duration; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
75 long i = 0; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
76 while (true) { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
77 try { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
78 server.getAttribute(objName, "InternalThreadCpuTimes"); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
79 } catch (Exception ex) { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
80 System.err.println("Exception while getting attribute: " + ex); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
81 } |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
82 i++; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
83 if (i % 10000 == 0) { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
84 System.out.println("Successful iterations: " + i); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
85 } |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
86 if (System.currentTimeMillis() > endTime) { |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
87 break; |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
88 } |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
89 } |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
90 System.out.println("PASSED."); |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
91 } |
6af8f3562069
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff
changeset
|
92 } |