src/share/native/sun/management/VMManagementImpl.c

Print this page


   1 /*
   2  * Copyright (c) 2003, 2011, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include <jni.h>

  27 #include "jvm.h"
  28 #include "management.h"
  29 #include "sun_management_VMManagementImpl.h"
  30 
  31 #define MAX_VERSION_LEN   20
  32 
  33 JNIEXPORT jstring JNICALL
  34 Java_sun_management_VMManagementImpl_getVersion0
  35   (JNIEnv *env, jclass dummy)
  36 {
  37     char buf[MAX_VERSION_LEN];
  38     jstring version_string = NULL;
  39 
  40     unsigned int major = ((unsigned int) jmm_version & 0x0FFF0000) >> 16;
  41     unsigned int minor = ((unsigned int) jmm_version & 0xFF00) >> 8;
  42 
  43     // for internal use
  44     unsigned int micro = (unsigned int) jmm_version & 0xFF;
  45 
  46     sprintf(buf, "%d.%d", major, minor);


  79     value = mos.isOtherThreadCpuTimeSupported;
  80     setStaticBooleanField(env, cls, "otherThreadCpuTimeSupport", value);
  81 
  82     value = mos.isBootClassPathSupported;
  83     setStaticBooleanField(env, cls, "bootClassPathSupport", value);
  84 
  85     if (jmm_version >= JMM_VERSION_1_1) {
  86         value = mos.isObjectMonitorUsageSupported;
  87         setStaticBooleanField(env, cls, "objectMonitorUsageSupport", value);
  88 
  89         value = mos.isSynchronizerUsageSupported;
  90         setStaticBooleanField(env, cls, "synchronizerUsageSupport", value);
  91     } else {
  92         setStaticBooleanField(env, cls, "objectMonitorUsageSupport", JNI_FALSE);
  93         setStaticBooleanField(env, cls, "synchronizerUsageSupport", JNI_FALSE);
  94     }
  95 
  96     value = mos.isThreadAllocatedMemorySupported;
  97     setStaticBooleanField(env, cls, "threadAllocatedMemorySupport", value);
  98 



  99     if ((jmm_version > JMM_VERSION_1_2) ||
 100         (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF) >= 1))) {
 101         setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_TRUE);
 102     } else {
 103         setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_FALSE);
 104     }
 105 }
 106 
 107 JNIEXPORT jobjectArray JNICALL
 108 Java_sun_management_VMManagementImpl_getVmArguments0
 109   (JNIEnv *env, jobject dummy)
 110 {
 111     return jmm_interface->GetInputArgumentArray(env);
 112 }
 113 
 114 JNIEXPORT jlong JNICALL
 115 Java_sun_management_VMManagementImpl_getTotalClassCount
 116   (JNIEnv *env, jobject dummy)
 117 {
 118     /* JMM_CLASS_LOADED_COUNT is the total number of classes loaded */


   1 /*
   2  * Copyright (c) 2003, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include <jni.h>
  27 #include <stdlib.h>
  28 #include "jvm.h"
  29 #include "management.h"
  30 #include "sun_management_VMManagementImpl.h"
  31 
  32 #define MAX_VERSION_LEN   20
  33 
  34 JNIEXPORT jstring JNICALL
  35 Java_sun_management_VMManagementImpl_getVersion0
  36   (JNIEnv *env, jclass dummy)
  37 {
  38     char buf[MAX_VERSION_LEN];
  39     jstring version_string = NULL;
  40 
  41     unsigned int major = ((unsigned int) jmm_version & 0x0FFF0000) >> 16;
  42     unsigned int minor = ((unsigned int) jmm_version & 0xFF00) >> 8;
  43 
  44     // for internal use
  45     unsigned int micro = (unsigned int) jmm_version & 0xFF;
  46 
  47     sprintf(buf, "%d.%d", major, minor);


  80     value = mos.isOtherThreadCpuTimeSupported;
  81     setStaticBooleanField(env, cls, "otherThreadCpuTimeSupport", value);
  82 
  83     value = mos.isBootClassPathSupported;
  84     setStaticBooleanField(env, cls, "bootClassPathSupport", value);
  85 
  86     if (jmm_version >= JMM_VERSION_1_1) {
  87         value = mos.isObjectMonitorUsageSupported;
  88         setStaticBooleanField(env, cls, "objectMonitorUsageSupport", value);
  89 
  90         value = mos.isSynchronizerUsageSupported;
  91         setStaticBooleanField(env, cls, "synchronizerUsageSupport", value);
  92     } else {
  93         setStaticBooleanField(env, cls, "objectMonitorUsageSupport", JNI_FALSE);
  94         setStaticBooleanField(env, cls, "synchronizerUsageSupport", JNI_FALSE);
  95     }
  96 
  97     value = mos.isThreadAllocatedMemorySupported;
  98     setStaticBooleanField(env, cls, "threadAllocatedMemorySupport", value);
  99 
 100     value = mos.isRemoteDiagnosticCommandsSupported;
 101     setStaticBooleanField(env, cls, "remoteDiagnosticCommandsSupport", value);
 102 
 103     if ((jmm_version > JMM_VERSION_1_2) ||
 104         (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF) >= 1))) {
 105         setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_TRUE);
 106     } else {
 107         setStaticBooleanField(env, cls, "gcNotificationSupport", JNI_FALSE);
 108     }
 109 }
 110 
 111 JNIEXPORT jobjectArray JNICALL
 112 Java_sun_management_VMManagementImpl_getVmArguments0
 113   (JNIEnv *env, jobject dummy)
 114 {
 115     return jmm_interface->GetInputArgumentArray(env);
 116 }
 117 
 118 JNIEXPORT jlong JNICALL
 119 Java_sun_management_VMManagementImpl_getTotalClassCount
 120   (JNIEnv *env, jobject dummy)
 121 {
 122     /* JMM_CLASS_LOADED_COUNT is the total number of classes loaded */