LCOV - code coverage report
Current view: top level - native/vm/gnuclasspath - gnu_java_lang_management_VMMemoryMXBeanImpl.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 23 21.7 %
Date: 2015-06-10 18:10:59 Functions: 1 6 16.7 %

          Line data    Source code
       1             : /* src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp
       2             : 
       3             :    Copyright (C) 1996-2013
       4             :    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
       5             : 
       6             :    This file is part of CACAO.
       7             : 
       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.
      12             : 
      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.
      17             : 
      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
      21             :    02110-1301, USA.
      22             : 
      23             : */
      24             : 
      25             : 
      26             : #include "config.h"
      27             : 
      28             : #include <stdint.h>
      29             : 
      30             : #include "mm/gc.hpp"
      31             : 
      32             : #include "native/jni.hpp"
      33             : #include "native/native.hpp"
      34             : 
      35             : #include "toolbox/logging.hpp"
      36             : 
      37             : #if defined(ENABLE_JNI_HEADERS)
      38             : # include "native/vm/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
      39             : #endif
      40             : 
      41             : #include "vm/class.hpp"
      42             : #include "vm/global.hpp"
      43             : #include "vm/javaobjects.hpp"
      44             : #include "vm/options.hpp"
      45             : #include "vm/vm.hpp"
      46             : 
      47             : 
      48             : // Native functions are exported as C functions.
      49             : extern "C" {
      50             : 
      51             : /*
      52             :  * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
      53             :  * Method:    getHeapMemoryUsage
      54             :  * Signature: ()Ljava/lang/management/MemoryUsage;
      55             :  */
      56           0 : JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
      57             : {
      58             :         // Get values from the VM.
      59             :         // XXX If we ever support more than one VM, change this.
      60           0 :         int64_t init     = opt_heapstartsize;
      61           0 :         int64_t used     = gc_get_total_bytes();
      62           0 :         int64_t commited = gc_get_heap_size();
      63           0 :         int64_t maximum  = gc_get_max_heap_size();
      64             : 
      65             :         // Construct a new java.lang.management.MemoryUsage object.
      66           0 :         java_lang_management_MemoryUsage jlmmu(init, used, commited, maximum);
      67             : 
      68           0 :         return jlmmu.get_handle();
      69             : }
      70             : 
      71             : 
      72             : /*
      73             :  * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
      74             :  * Method:    getNonHeapMemoryUsage
      75             :  * Signature: ()Ljava/lang/management/MemoryUsage;
      76             :  */
      77           0 : JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
      78             : {
      79           0 :         log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
      80             : 
      81           0 :         return NULL;
      82             : }
      83             : 
      84             : 
      85             : /*
      86             :  * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
      87             :  * Method:    getObjectPendingFinalizationCount
      88             :  * Signature: ()I
      89             :  */
      90           0 : JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
      91             : {
      92           0 :         log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
      93             : 
      94           0 :         return 0;
      95             : }
      96             : 
      97             : 
      98             : /*
      99             :  * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
     100             :  * Method:    isVerbose
     101             :  * Signature: ()Z
     102             :  */
     103           0 : JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
     104             : {
     105           0 :         return opt_verbosegc;
     106             : }
     107             : 
     108             : 
     109             : /*
     110             :  * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
     111             :  * Method:    setVerbose
     112             :  * Signature: (Z)V
     113             :  */
     114           0 : JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose)
     115             : {
     116           0 :         opt_verbosegc = verbose;
     117           0 : }
     118             : 
     119             : } // extern "C"
     120             : 
     121             : 
     122             : /* native methods implemented by this file ************************************/
     123             : 
     124             : static JNINativeMethod methods[] = {
     125             :         { (char*) "getHeapMemoryUsage",                (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage                },
     126             :         { (char*) "getNonHeapMemoryUsage",             (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage             },
     127             :         { (char*) "getObjectPendingFinalizationCount", (char*) "()I",                                  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
     128             :         { (char*) "isVerbose",                         (char*) "()Z",                                  (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose                         },
     129             :         { (char*) "setVerbose",                        (char*) "(Z)V",                                 (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose                        },
     130             : };
     131             : 
     132             : 
     133             : /* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
     134             : 
     135             :    Register native functions.
     136             : 
     137             : *******************************************************************************/
     138             : 
     139         163 : void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
     140             : {
     141         163 :         Utf8String u = Utf8String::from_utf8("gnu/java/lang/management/VMMemoryMXBeanImpl");
     142             : 
     143         163 :         NativeMethods& nm = VM::get_current()->get_nativemethods();
     144         163 :         nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
     145         163 : }
     146             : 
     147             : 
     148             : /*
     149             :  * These are local overrides for various environment variables in Emacs.
     150             :  * Please do not remove this and leave it at the end of the file, where
     151             :  * Emacs will automagically detect them.
     152             :  * ---------------------------------------------------------------------
     153             :  * Local variables:
     154             :  * mode: c++
     155             :  * indent-tabs-mode: t
     156             :  * c-basic-offset: 4
     157             :  * tab-width: 4
     158             :  * End:
     159             :  * vim:noexpandtab:sw=4:ts=4:
     160             :  */

Generated by: LCOV version 1.11