* src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit):
[cacao.git] / src / native / vm / gnu / gnu_classpath_VMSystemProperties.c
1 /* src/native/vm/VMSystemProperties.c - gnu/classpath/VMSystemProperties
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    $Id: gnu_classpath_VMSystemProperties.c 7237 2007-01-22 20:16:22Z twisti $
30
31 */
32
33
34 #include "config.h"
35
36 #include <stdlib.h>
37
38 #include "vm/types.h"
39
40 #include "native/jni.h"
41 #include "native/include/java_util_Properties.h"
42
43 #include "vm/exceptions.h"
44 #include "vm/properties.h"
45 #include "vm/vm.h"
46
47
48 /*
49  * Class:     gnu/classpath/VMSystemProperties
50  * Method:    preInit
51  * Signature: (Ljava/util/Properties;)V
52  */
53 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
54 {
55         if (properties == NULL) {
56                 exceptions_throw_nullpointerexception();
57                 return;
58         }
59
60         /* fill the java.util.Properties object */
61
62         properties_system_add_all(properties);
63 }
64
65
66 /*
67  * Class:     gnu/classpath/VMSystemProperties
68  * Method:    postInit
69  * Signature: (Ljava/util/Properties;)V
70  */
71 JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
72 {
73         java_objectheader *p;
74 #if defined(WITH_JRE_LAYOUT)
75         char *path;
76         s4    len;
77 #endif
78
79         p = (java_objectheader *) properties;
80
81         if (p == NULL) {
82                 exceptions_throw_nullpointerexception();
83                 return;
84         }
85
86         /* post-set some properties */
87
88 #if defined(WITH_JRE_LAYOUT)
89         /* XXX when we do it that way, we can't set these properties on
90            commandline */
91
92         properties_system_add(p, "gnu.classpath.home", cacao_prefix);
93
94         len =
95                 strlen("file://") +
96                 strlen(cacao_prefix) +
97                 strlen("/lib") +
98                 strlen("0");
99
100         path = MNEW(char, len);
101
102         strcpy(path, "file://");
103         strcat(path, cacao_prefix);
104         strcat(path, "/lib");
105
106         properties_system_add(p, "gnu.classpath.home.url", path);
107
108         MFREE(path, char, len);
109 #endif
110 }
111
112
113 /*
114  * These are local overrides for various environment variables in Emacs.
115  * Please do not remove this and leave it at the end of the file, where
116  * Emacs will automagically detect them.
117  * ---------------------------------------------------------------------
118  * Local variables:
119  * mode: c
120  * indent-tabs-mode: t
121  * c-basic-offset: 4
122  * tab-width: 4
123  * End:
124  */