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.h"
35 #include "native/jni.h"
36 #include "native/native.h"
38 #include "native/include/java_util_Properties.h"
42 #include "native/include/gnu_classpath_VMSystemProperties.h"
45 #include "vm/exceptions.hpp"
46 #include "vm/properties.h"
50 // Native functions are exported as C functions.
54 * Class: gnu/classpath/VMSystemProperties
56 * Signature: (Ljava/util/Properties;)V
58 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
62 p = (java_handle_t *) properties;
65 exceptions_throw_nullpointerexception();
69 /* fill the java.util.Properties object */
71 properties_system_add_all(p);
76 * Class: gnu/classpath/VMSystemProperties
78 * Signature: (Ljava/util/Properties;)V
80 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
83 #if defined(ENABLE_JRE_LAYOUT)
84 const char *java_home;
89 p = (java_handle_t *) properties;
92 exceptions_throw_nullpointerexception();
96 /* post-set some properties */
98 #if defined(ENABLE_JRE_LAYOUT)
99 /* XXX when we do it that way, we can't set these properties on
102 java_home = properties_get("java.home");
104 properties_system_add(p, "gnu.classpath.home", java_home);
112 path = MNEW(char, len);
114 strcpy(path, "file://");
115 strcat(path, java_home);
116 strcat(path, "/lib");
118 properties_system_add(p, "gnu.classpath.home.url", path);
120 MFREE(path, char, len);
127 /* native methods implemented by this file ************************************/
129 static JNINativeMethod methods[] = {
130 { (char*) "preInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_preInit },
131 { (char*) "postInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_postInit },
135 /* _Jv_gnu_classpat_VMSystemProperties_init ************************************
137 Register native functions.
139 *******************************************************************************/
143 void _Jv_gnu_classpath_VMSystemProperties_init(void)
147 u = utf_new_char("gnu/classpath/VMSystemProperties");
149 native_method_register(u, methods, NATIVE_METHODS_COUNT);
155 * These are local overrides for various environment variables in Emacs.
156 * Please do not remove this and leave it at the end of the file, where
157 * Emacs will automagically detect them.
158 * ---------------------------------------------------------------------
161 * indent-tabs-mode: t