1 /* src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 #include "native/jni.hpp"
33 #include "native/native.hpp"
35 #if defined(ENABLE_JNI_HEADERS)
36 # include "native/vm/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
39 #include "vm/class.hpp"
40 #include "vm/global.h"
41 #include "vm/javaobjects.hpp"
42 #include "vm/options.h"
46 // Native functions are exported as C functions.
50 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
51 * Method: getHeapMemoryUsage
52 * Signature: ()Ljava/lang/management/MemoryUsage;
54 JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
56 // Get values from the VM.
57 // XXX If we ever support more than one VM, change this.
58 int64_t init = opt_heapstartsize;
59 int64_t used = gc_get_total_bytes();
60 int64_t commited = gc_get_heap_size();
61 int64_t maximum = gc_get_max_heap_size();
63 // Construct a new java.lang.management.MemoryUsage object.
64 java_lang_management_MemoryUsage jlmmu(init, used, commited, maximum);
66 return jlmmu.get_handle();
71 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
72 * Method: getNonHeapMemoryUsage
73 * Signature: ()Ljava/lang/management/MemoryUsage;
75 JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
77 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
84 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
85 * Method: getObjectPendingFinalizationCount
88 JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
90 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
97 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
101 JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
103 return opt_verbosegc;
108 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
112 JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose)
114 opt_verbosegc = verbose;
120 /* native methods implemented by this file ************************************/
122 static JNINativeMethod methods[] = {
123 { (char*) "getHeapMemoryUsage", (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage },
124 { (char*) "getNonHeapMemoryUsage", (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage },
125 { (char*) "getObjectPendingFinalizationCount", (char*) "()I", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
126 { (char*) "isVerbose", (char*) "()Z", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose },
127 { (char*) "setVerbose", (char*) "(Z)V", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose },
131 /* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
133 Register native functions.
135 *******************************************************************************/
137 void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
139 utf* u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl");
141 NativeMethods& nm = VM::get_current()->get_nativemethods();
142 nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
147 * These are local overrides for various environment variables in Emacs.
148 * Please do not remove this and leave it at the end of the file, where
149 * Emacs will automagically detect them.
150 * ---------------------------------------------------------------------
153 * indent-tabs-mode: t
157 * vim:noexpandtab:sw=4:ts=4: