hotspot/test/runtime/7196045/Test7196045.java
author stefank
Tue, 09 Oct 2012 22:12:25 +0200
changeset 14075 53f86368a6a6
parent 13870 dd2c6a5a4722
child 13953 a96fb2fe0c08
permissions -rw-r--r--
8000659: NPG: ClassCastExceptions are unexpectedly thrown when testing nashorn Summary: Treat the oops in invoke_method_table() as strong roots when ClassUnloading is enabled. Reviewed-by: kamg, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13870
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
     1
/*
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
dd2c6a5a4722 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.
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
     4
 *
dd2c6a5a4722 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
dd2c6a5a4722 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
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
     8
 *
dd2c6a5a4722 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
dd2c6a5a4722 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
dd2c6a5a4722 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
dd2c6a5a4722 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
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    13
 * accompanied this code).
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    14
 *
dd2c6a5a4722 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
dd2c6a5a4722 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,
dd2c6a5a4722 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.
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    18
 *
dd2c6a5a4722 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
dd2c6a5a4722 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
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    21
 * questions.
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    22
 *
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    23
 */
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    24
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    25
/*
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    26
 * @test
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    27
 * @bug 7196045
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    28
 * @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    29
 * @run main/othervm
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    30
 */
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    31
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    32
import java.lang.management.ManagementFactory;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    33
import javax.management.JMException;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    34
import javax.management.MBeanServer;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    35
import javax.management.MalformedObjectNameException;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    36
import javax.management.ObjectName;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    37
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    38
public class Test7196045 {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    39
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    40
    public static long duration = 1000 * 60 * 2;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    41
    private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal";
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    42
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    43
    public static void main(String[] args) {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    44
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    45
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    46
        ObjectName objName= null;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    47
        try {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    48
            ObjectName hotspotInternal = new ObjectName(HOTSPOT_INTERNAL);
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    49
            try {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    50
                server.registerMBean(new sun.management.HotspotInternal(), hotspotInternal);
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    51
            } catch (JMException e) {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    52
                throw new RuntimeException("HotSpotWatcher: Failed to register the HotspotInternal MBean" + e);
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    53
            }
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    54
            objName= new ObjectName("sun.management:type=HotspotThreading");
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    55
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    56
        } catch (MalformedObjectNameException e1) {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    57
            throw new RuntimeException("Bad object name" + e1);
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    58
        }
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    59
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    60
        long endTime = System.currentTimeMillis() + duration;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    61
        long i = 0;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    62
        while (true) {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    63
            try {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    64
                server.getAttribute(objName, "InternalThreadCpuTimes");
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    65
            } catch (Exception ex) {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    66
                System.err.println("Exception while getting attribute: " + ex);
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    67
            }
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    68
            i++;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    69
            if (i % 10000 == 0) {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    70
                System.out.println("Successful iterations: " + i);
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    71
            }
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    72
            if (System.currentTimeMillis() > endTime) {
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    73
                break;
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    74
            }
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    75
        }
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    76
        System.out.println("PASSED.");
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    77
    }
dd2c6a5a4722 7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
kevinw
parents:
diff changeset
    78
}