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 #if defined(ENABLE_JNI_HEADERS)
39 # include "native/include/gnu_classpath_VMSystemProperties.h"
42 #include "vm/exceptions.hpp"
43 #include "vm/properties.h"
47 // Native functions are exported as C functions.
51 * Class: gnu/classpath/VMSystemProperties
53 * Signature: (Ljava/util/Properties;)V
55 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, jobject properties)
59 p = (java_handle_t *) properties;
62 exceptions_throw_nullpointerexception();
66 /* fill the java.util.Properties object */
68 properties_system_add_all(p);
73 * Class: gnu/classpath/VMSystemProperties
75 * Signature: (Ljava/util/Properties;)V
77 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, jobject properties)
80 #if defined(ENABLE_JRE_LAYOUT)
81 const char *java_home;
86 p = (java_handle_t *) properties;
89 exceptions_throw_nullpointerexception();
93 /* post-set some properties */
95 #if defined(ENABLE_JRE_LAYOUT)
96 /* XXX when we do it that way, we can't set these properties on
99 java_home = properties_get("java.home");
101 properties_system_add(p, "gnu.classpath.home", java_home);
109 path = MNEW(char, len);
111 strcpy(path, "file://");
112 strcat(path, java_home);
113 strcat(path, "/lib");
115 properties_system_add(p, "gnu.classpath.home.url", path);
117 MFREE(path, char, len);
124 /* native methods implemented by this file ************************************/
126 static JNINativeMethod methods[] = {
127 { (char*) "preInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_preInit },
128 { (char*) "postInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_postInit },
132 /* _Jv_gnu_classpat_VMSystemProperties_init ************************************
134 Register native functions.
136 *******************************************************************************/
140 void _Jv_gnu_classpath_VMSystemProperties_init(void)
144 u = utf_new_char("gnu/classpath/VMSystemProperties");
146 native_method_register(u, methods, NATIVE_METHODS_COUNT);
152 * These are local overrides for various environment variables in Emacs.
153 * Please do not remove this and leave it at the end of the file, where
154 * Emacs will automagically detect them.
155 * ---------------------------------------------------------------------
158 * indent-tabs-mode: t