jdk/src/share/native/sun/management/VMManagementImpl.c
author jbachorik
Sun, 10 Nov 2013 20:05:03 +0100
changeset 21640 6bbdcc430310
parent 17954 885a02686acb
permissions -rw-r--r--
6523160: RuntimeMXBean.getUptime() returns negative values Summary: RuntimeMXBean.getUptime() should be based on HR timers rather than on the OS time Reviewed-by: dholmes, sla
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
17954
885a02686acb 7150256: Add back Diagnostic Command JMX API
fparain
parents: 9698
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <jni.h>
17954
885a02686acb 7150256: Add back Diagnostic Command JMX API
fparain
parents: 9698
diff changeset
    27
#include <stdlib.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "jvm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "management.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "sun_management_VMManagementImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#define MAX_VERSION_LEN   20
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
Java_sun_management_VMManagementImpl_getVersion0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  (JNIEnv *env, jclass dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    char buf[MAX_VERSION_LEN];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    jstring version_string = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    unsigned int major = ((unsigned int) jmm_version & 0x0FFF0000) >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    unsigned int minor = ((unsigned int) jmm_version & 0xFF00) >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    // for internal use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    unsigned int micro = (unsigned int) jmm_version & 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    sprintf(buf, "%d.%d", major, minor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    version_string = (*env)->NewStringUTF(env, buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    return version_string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
static void setStaticBooleanField
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
   (JNIEnv* env, jclass cls, const char* name, jboolean value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    jfieldID fid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    fid = (*env)->GetStaticFieldID(env, cls, name, "Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    if (fid != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        (*env)->SetStaticBooleanField(env, cls, fid, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
Java_sun_management_VMManagementImpl_initOptionalSupportFields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    jmmOptionalSupport mos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    jint ret = jmm_interface->GetOptionalSupport(env, &mos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    jboolean value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    value = mos.isCompilationTimeMonitoringSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    setStaticBooleanField(env, cls, "compTimeMonitoringSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    value = mos.isThreadContentionMonitoringSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    setStaticBooleanField(env, cls, "threadContentionMonitoringSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    value = mos.isCurrentThreadCpuTimeSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    setStaticBooleanField(env, cls, "currentThreadCpuTimeSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    value = mos.isOtherThreadCpuTimeSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    setStaticBooleanField(env, cls, "otherThreadCpuTimeSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    value = mos.isBootClassPathSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    setStaticBooleanField(env, cls, "bootClassPathSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    if (jmm_version >= JMM_VERSION_1_1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        value = mos.isObjectMonitorUsageSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        setStaticBooleanField(env, cls, "objectMonitorUsageSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        value = mos.isSynchronizerUsageSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        setStaticBooleanField(env, cls, "synchronizerUsageSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        setStaticBooleanField(env, cls, "objectMonitorUsageSupport", JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        setStaticBooleanField(env, cls, "synchronizerUsageSupport", JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
    96
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
    97
    value = mos.isThreadAllocatedMemorySupported;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
    98
    setStaticBooleanField(env, cls, "threadAllocatedMemorySupport", value);
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8001
diff changeset
    99
17954
885a02686acb 7150256: Add back Diagnostic Command JMX API
fparain
parents: 9698
diff changeset
   100
    value = mos.isRemoteDiagnosticCommandsSupported;
885a02686acb 7150256: Add back Diagnostic Command JMX API
fparain
parents: 9698
diff changeset
   101
    setStaticBooleanField(env, cls, "remoteDiagnosticCommandsSupport", value);
885a02686acb 7150256: Add back Diagnostic Command JMX API
fparain
parents: 9698
diff changeset
   102
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8001
diff changeset
   103
    if ((jmm_version > JMM_VERSION_1_2) ||
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8001
diff changeset
   104
        (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF) >= 1))) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8001
diff changeset
   105
        setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_TRUE);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8001
diff changeset
   106
    } else {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8001
diff changeset
   107
        setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_FALSE);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8001
diff changeset
   108
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
JNIEXPORT jobjectArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
Java_sun_management_VMManagementImpl_getVmArguments0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    return jmm_interface->GetInputArgumentArray(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
Java_sun_management_VMManagementImpl_getTotalClassCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /* JMM_CLASS_LOADED_COUNT is the total number of classes loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                                                  JMM_CLASS_LOADED_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
Java_sun_management_VMManagementImpl_getUnloadedClassCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /* JMM_CLASS_UNLOADED_COUNT is the total number of classes unloaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                                  JMM_CLASS_UNLOADED_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
Java_sun_management_VMManagementImpl_getVerboseGC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    return jmm_interface->GetBoolAttribute(env, JMM_VERBOSE_GC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
Java_sun_management_VMManagementImpl_getVerboseClass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    return jmm_interface->GetBoolAttribute(env, JMM_VERBOSE_CLASS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
Java_sun_management_VMManagementImpl_getTotalThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                           JMM_THREAD_TOTAL_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
Java_sun_management_VMManagementImpl_getLiveThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                                                  JMM_THREAD_LIVE_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    return (jint) count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
Java_sun_management_VMManagementImpl_getPeakThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                                  JMM_THREAD_PEAK_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    return (jint) count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
Java_sun_management_VMManagementImpl_getDaemonThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                                                  JMM_THREAD_DAEMON_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    return (jint) count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
Java_sun_management_VMManagementImpl_getTotalCompileTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                                           JMM_COMPILE_TOTAL_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
Java_sun_management_VMManagementImpl_getStartupTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                                           JMM_JVM_INIT_DONE_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
21640
6bbdcc430310 6523160: RuntimeMXBean.getUptime() returns negative values
jbachorik
parents: 17954
diff changeset
   203
JNIEXPORT jlong JNICALL
6bbdcc430310 6523160: RuntimeMXBean.getUptime() returns negative values
jbachorik
parents: 17954
diff changeset
   204
Java_sun_management_VMManagementImpl_getUptime0
6bbdcc430310 6523160: RuntimeMXBean.getUptime() returns negative values
jbachorik
parents: 17954
diff changeset
   205
  (JNIEnv *env, jobject dummy)
6bbdcc430310 6523160: RuntimeMXBean.getUptime() returns negative values
jbachorik
parents: 17954
diff changeset
   206
{
6bbdcc430310 6523160: RuntimeMXBean.getUptime() returns negative values
jbachorik
parents: 17954
diff changeset
   207
    return jmm_interface->GetLongAttribute(env, NULL, JMM_JVM_UPTIME_MS);
6bbdcc430310 6523160: RuntimeMXBean.getUptime() returns negative values
jbachorik
parents: 17954
diff changeset
   208
}
6bbdcc430310 6523160: RuntimeMXBean.getUptime() returns negative values
jbachorik
parents: 17954
diff changeset
   209
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
Java_sun_management_VMManagementImpl_isThreadContentionMonitoringEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    return jmm_interface->GetBoolAttribute(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                                           JMM_THREAD_CONTENTION_MONITORING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
Java_sun_management_VMManagementImpl_isThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    return jmm_interface->GetBoolAttribute(env, JMM_THREAD_CPU_TIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   225
JNIEXPORT jboolean JNICALL
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   226
Java_sun_management_VMManagementImpl_isThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   227
  (JNIEnv *env, jobject dummy)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   228
{
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   229
    return jmm_interface->GetBoolAttribute(env, JMM_THREAD_ALLOCATED_MEMORY);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   230
}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   231
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
Java_sun_management_VMManagementImpl_getProcessId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    jlong pid = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                                                JMM_OS_PROCESS_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    return (jint) pid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
Java_sun_management_VMManagementImpl_getAvailableProcessors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    return JVM_ActiveProcessorCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
Java_sun_management_VMManagementImpl_getSafepointCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                                           JMM_SAFEPOINT_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
Java_sun_management_VMManagementImpl_getTotalSafepointTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                           JMM_TOTAL_STOPPED_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
Java_sun_management_VMManagementImpl_getSafepointSyncTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                           JMM_TOTAL_SAFEPOINTSYNC_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
Java_sun_management_VMManagementImpl_getTotalApplicationNonStoppedTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                                           JMM_TOTAL_APP_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
Java_sun_management_VMManagementImpl_getLoadedClassSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                                           JMM_CLASS_LOADED_BYTES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
Java_sun_management_VMManagementImpl_getUnloadedClassSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                                           JMM_CLASS_UNLOADED_BYTES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
Java_sun_management_VMManagementImpl_getClassLoadingTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                                           JMM_TOTAL_CLASSLOAD_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
Java_sun_management_VMManagementImpl_getMethodDataSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                                           JMM_METHOD_DATA_SIZE_BYTES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
Java_sun_management_VMManagementImpl_getInitializedClassCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                                           JMM_CLASS_INIT_TOTAL_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
Java_sun_management_VMManagementImpl_getClassInitializationTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                                           JMM_CLASS_INIT_TOTAL_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
Java_sun_management_VMManagementImpl_getClassVerificationTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                                           JMM_CLASS_VERIFY_TOTAL_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
}