Mercurial > hg > graal-compiler
comparison test/runtime/InternalApi/ThreadCpuTimesDeadlock.java @ 11990:fa57c8104b76
8009585: test/runtime/7196045 times out
Summary: test/runtime/7196045 times out
Reviewed-by: dholmes, mseledtsov
author | ctornqvi |
---|---|
date | Fri, 02 Aug 2013 18:12:10 +0200 |
parents | test/runtime/7196045/Test7196045.java@ac7193063af8 |
children |
comparison
equal
deleted
inserted
replaced
11987:81e0f17ade64 | 11990:fa57c8104b76 |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2013, 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 /* | |
26 * @test | |
27 * @bug 7196045 | |
28 * @bug 8014294 | |
29 * @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API. | |
30 * @run main/othervm -XX:+UsePerfData -Xmx32m ThreadCpuTimesDeadlock | |
31 */ | |
32 | |
33 import java.lang.management.ManagementFactory; | |
34 import javax.management.JMException; | |
35 import javax.management.MBeanServer; | |
36 import javax.management.MalformedObjectNameException; | |
37 import javax.management.ObjectName; | |
38 | |
39 public class ThreadCpuTimesDeadlock { | |
40 | |
41 public static byte[] dummy; | |
42 public static long duration = 10 * 1000; | |
43 private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal"; | |
44 | |
45 public static void main(String[] args) { | |
46 | |
47 MBeanServer server = ManagementFactory.getPlatformMBeanServer(); | |
48 ObjectName objName= null; | |
49 try { | |
50 ObjectName hotspotInternal = new ObjectName(HOTSPOT_INTERNAL); | |
51 try { | |
52 server.registerMBean(new sun.management.HotspotInternal(), hotspotInternal); | |
53 } catch (JMException e) { | |
54 throw new RuntimeException("HotSpotWatcher: Failed to register the HotspotInternal MBean" + e); | |
55 } | |
56 objName= new ObjectName("sun.management:type=HotspotThreading"); | |
57 | |
58 } catch (MalformedObjectNameException e1) { | |
59 throw new RuntimeException("Bad object name" + e1); | |
60 } | |
61 | |
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 | |
74 long endTime = System.currentTimeMillis() + duration; | |
75 long i = 0; | |
76 while (true) { | |
77 try { | |
78 server.getAttribute(objName, "InternalThreadCpuTimes"); | |
79 } catch (Exception ex) { | |
80 System.err.println("Exception while getting attribute: " + ex); | |
81 } | |
82 i++; | |
83 if (i % 10000 == 0) { | |
84 System.out.println("Successful iterations: " + i); | |
85 } | |
86 if (System.currentTimeMillis() > endTime) { | |
87 break; | |
88 } | |
89 } | |
90 System.out.println("PASSED."); | |
91 } | |
92 } |