1 /* src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.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
33 #include "mm/memory.hpp"
35 #include "native/jni.hpp"
36 #include "native/native.hpp"
38 #if defined(ENABLE_JNI_HEADERS)
39 # include "native/include/gnu_classpath_VMSystemProperties.h"
42 #include "toolbox/sequence.hpp"
44 #include "vm/exceptions.hpp"
45 #include "vm/properties.hpp"
49 // Native functions are exported as C functions.
53 * Class: gnu/classpath/VMSystemProperties
55 * Signature: (Ljava/util/Properties;)V
57 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, jobject properties)
61 p = (java_handle_t *) properties;
64 exceptions_throw_nullpointerexception();
68 // Fill the java.util.Properties object.
69 VM::get_current()->get_properties().fill(p);
74 * Class: gnu/classpath/VMSystemProperties
76 * Signature: (Ljava/util/Properties;)V
78 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, jobject properties)
81 #if defined(ENABLE_JRE_LAYOUT)
82 const char *java_home;
85 p = (java_handle_t *) properties;
88 exceptions_throw_nullpointerexception();
92 /* post-set some properties */
94 #if defined(ENABLE_JRE_LAYOUT)
95 /* XXX when we do it that way, we can't set these properties on
98 java_home = VM::get_current()->get_properties().get("java.home");
100 Properties::put(p, "gnu.classpath.home", java_home);
102 // Use sequence builder to assemble value.
109 Properties::put(p, "gnu.classpath.home.url", sb.c_str());
116 /* native methods implemented by this file ************************************/
118 static JNINativeMethod methods[] = {
119 { (char*) "preInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_preInit },
120 { (char*) "postInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_postInit },
124 /* _Jv_gnu_classpat_VMSystemProperties_init ************************************
126 Register native functions.
128 *******************************************************************************/
130 void _Jv_gnu_classpath_VMSystemProperties_init(void)
132 utf* u = utf_new_char("gnu/classpath/VMSystemProperties");
134 NativeMethods& nm = VM::get_current()->get_nativemethods();
135 nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
140 * These are local overrides for various environment variables in Emacs.
141 * Please do not remove this and leave it at the end of the file, where
142 * Emacs will automagically detect them.
143 * ---------------------------------------------------------------------
146 * indent-tabs-mode: t