jdk/src/share/classes/sun/management/VMManagementImpl.java
author mchung
Thu, 10 Apr 2008 10:47:13 -0700
changeset 401 ef01e0dccd63
parent 2 90ce3da70b43
child 715 f16baef3a20e
permissions -rw-r--r--
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031) Summary: Add new methods in ManagementFactory class to obtain platform MXBeans Reviewed-by: alanb, dfuchs, emcmanus
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.misc.Perf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.management.counter.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.management.counter.perf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.nio.ByteBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.net.InetAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.net.UnknownHostException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.security.action.GetPropertyAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Implementation of VMManagement interface that accesses the management
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * attributes and operations locally within the same Java virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
class VMManagementImpl implements VMManagement {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private static String version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static boolean compTimeMonitoringSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static boolean threadContentionMonitoringSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private static boolean currentThreadCpuTimeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static boolean otherThreadCpuTimeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static boolean bootClassPathSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static boolean objectMonitorUsageSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static boolean synchronizerUsageSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        version = getVersion0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        if (version == null) {
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
    62
            throw new AssertionError("Invalid Management Version");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        initOptionalSupportFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private native static String getVersion0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private native static void initOptionalSupportFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // Optional supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public boolean isCompilationTimeMonitoringSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        return compTimeMonitoringSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public boolean isThreadContentionMonitoringSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return threadContentionMonitoringSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public boolean isCurrentThreadCpuTimeSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return currentThreadCpuTimeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public boolean isOtherThreadCpuTimeSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        return otherThreadCpuTimeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public boolean isBootClassPathSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        return bootClassPathSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public boolean isObjectMonitorUsageSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return objectMonitorUsageSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public boolean isSynchronizerUsageSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        return synchronizerUsageSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public native boolean isThreadContentionMonitoringEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public native boolean isThreadCpuTimeEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    // Class Loading Subsystem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public int    getLoadedClassCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        long count = getTotalClassCount() - getUnloadedClassCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return (int) count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public native long getTotalClassCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public native long getUnloadedClassCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public native boolean getVerboseClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    // Memory Subsystem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public native boolean getVerboseGC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    // Runtime Subsystem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public String   getManagementVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        return version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public String getVmId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        int pid = getProcessId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        String hostname = "localhost";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            hostname = InetAddress.getLocalHost().getHostName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        } catch (UnknownHostException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            // ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        return pid + "@" + hostname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    private native int getProcessId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public String   getVmName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        return System.getProperty("java.vm.name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public String   getVmVendor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        return System.getProperty("java.vm.vendor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public String   getVmVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return System.getProperty("java.vm.version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public String   getVmSpecName()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        return System.getProperty("java.vm.specification.name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public String   getVmSpecVendor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        return System.getProperty("java.vm.specification.vendor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public String   getVmSpecVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        return System.getProperty("java.vm.specification.version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public String   getClassPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        return System.getProperty("java.class.path");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public String   getLibraryPath()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return System.getProperty("java.library.path");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public String   getBootClassPath( ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        PrivilegedAction<String> pa
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            = new GetPropertyAction("sun.boot.class.path");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        String result =  AccessController.doPrivileged(pa);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    private List<String> vmArgs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public synchronized List<String> getVmArguments() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (vmArgs == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            String[] args = getVmArguments0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            List<String> l = ((args != null && args.length != 0) ? Arrays.asList(args) :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                                        Collections.<String>emptyList());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            vmArgs = Collections.unmodifiableList(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        return vmArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public native String[] getVmArguments0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public native long getStartupTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public native int getAvailableProcessors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    // Compilation Subsystem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public String   getCompilerName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        String name =  AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            new PrivilegedAction<String>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                public String run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    return System.getProperty("sun.management.compiler");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public native long getTotalCompileTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    // Thread Subsystem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public native long getTotalThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public native int  getLiveThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public native int  getPeakThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public native int  getDaemonThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    // Operating System
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public String getOsName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        return System.getProperty("os.name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public String getOsArch() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return System.getProperty("os.arch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public String getOsVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        return System.getProperty("os.version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    // Hotspot-specific runtime support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public native long getSafepointCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public native long getTotalSafepointTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public native long getSafepointSyncTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public native long getTotalApplicationNonStoppedTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public native long getLoadedClassSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public native long getUnloadedClassSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public native long getClassLoadingTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public native long getMethodDataSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public native long getInitializedClassCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public native long getClassInitializationTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public native long getClassVerificationTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    // Performance Counter Support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    private PerfInstrumentation perfInstr = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    private boolean noPerfData = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    private synchronized PerfInstrumentation getPerfInstrumentation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (noPerfData || perfInstr != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
             return perfInstr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        // construct PerfInstrumentation object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        Perf perf =  AccessController.doPrivileged(new Perf.GetPerfAction());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            ByteBuffer bb = perf.attach(0, "r");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            if (bb.capacity() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                noPerfData = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            perfInstr = new PerfInstrumentation(bb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            // If the shared memory doesn't exist e.g. if -XX:-UsePerfData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            // was set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            noPerfData = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        } catch (IOException e) {
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   247
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return perfInstr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public List<Counter> getInternalCounters(String pattern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        PerfInstrumentation perf = getPerfInstrumentation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        if (perf != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            return perf.findByPattern(pattern);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            return Collections.emptyList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
}