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.h"
33 #include "native/native.h"
35 #if defined(ENABLE_JNI_HEADERS)
36 # include "native/vm/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
39 #include "vm/builtin.h"
40 #include "vm/global.h"
43 #include "vmcore/class.h"
44 #include "vmcore/loader.h" /* XXX only for load_class_bootstrap */
45 #include "vmcore/options.h"
48 // Native functions are exported as C functions.
52 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
53 * Method: getHeapMemoryUsage
54 * Signature: ()Ljava/lang/management/MemoryUsage;
56 JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
58 classinfo *class_java_lang_management_MemoryUsage;
67 /* XXX optimize me! sometime... */
69 if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage"))))
72 /* create the object */
74 o = builtin_new(class_java_lang_management_MemoryUsage);
79 /* find initializer */
81 m = class_findmethod(class_java_lang_management_MemoryUsage,
82 utf_init, utf_new_char("(JJJJ)V"));
84 /* initializer not found */
89 /* get values from the VM */
90 /* XXX if we ever support more than one VM, change this */
92 init = opt_heapstartsize;
93 used = gc_get_total_bytes();
94 commited = gc_get_heap_size();
95 maximum = gc_get_max_heap_size();
97 /* call initializer */
99 (void) vm_call_method(m, o, init, used, commited, maximum);
106 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
107 * Method: getNonHeapMemoryUsage
108 * Signature: ()Ljava/lang/management/MemoryUsage;
110 JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
112 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
119 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
120 * Method: getObjectPendingFinalizationCount
123 JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
125 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
132 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
136 JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
138 /* return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose; */
140 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose: MOVE TO C++!");
146 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
150 JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose)
152 /* _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose; */
154 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose: MOVE TO C++!");
160 /* native methods implemented by this file ************************************/
162 static JNINativeMethod methods[] = {
163 { (char*) "getHeapMemoryUsage", (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage },
164 { (char*) "getNonHeapMemoryUsage", (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage },
165 { (char*) "getObjectPendingFinalizationCount", (char*) "()I", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
166 { (char*) "isVerbose", (char*) "()Z", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose },
167 { (char*) "setVerbose", (char*) "(Z)V", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose },
171 /* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
173 Register native functions.
175 *******************************************************************************/
179 void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
183 u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl");
185 native_method_register(u, methods, NATIVE_METHODS_COUNT);
191 * These are local overrides for various environment variables in Emacs.
192 * Please do not remove this and leave it at the end of the file, where
193 * Emacs will automagically detect them.
194 * ---------------------------------------------------------------------
197 * indent-tabs-mode: t
201 * vim:noexpandtab:sw=4:ts=4: