-/* native/vm/VMSystemProperties.c - gnu/classpath/VMSystemProperties
+/* src/native/vm/VMSystemProperties.c - gnu/classpath/VMSystemProperties
Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
Changes:
- $Id: VMSystemProperties.c 1870 2005-01-12 13:55:47Z twisti $
+ $Id: VMSystemProperties.c 3829 2005-12-01 19:47:56Z twisti $
*/
#include <string.h>
#include <sys/utsname.h>
#include <time.h>
-#include <unistd.h>
#include "config.h"
+#include "vm/types.h"
+
#include "cacao/cacao.h"
+#include "mm/memory.h"
#include "native/jni.h"
#include "native/native.h"
#include "native/include/java_util_Properties.h"
#include "toolbox/logging.h"
+#include "toolbox/util.h"
#include "vm/exceptions.h"
#include "vm/builtin.h"
#include "vm/loader.h"
-#include "vm/tables.h"
+#include "vm/options.h"
+#include "vm/stringlocal.h"
#include "vm/jit/asmpart.h"
static void insert_property(methodinfo *m, java_util_Properties *p, char *key,
char *value)
{
- asm_calljavafunction(m,
- p,
- javastring_new_char(key),
- javastring_new_char(value),
- NULL);
+ java_lang_String *k;
+ java_lang_String *v;
+
+ k = javastring_new_char(key);
+ v = javastring_new_char(value);
+
+ asm_calljavafunction(m, p, k, v, NULL);
}
*/
JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *p)
{
-
-#define BUFFERSIZE 200
methodinfo *m;
- char cwd[BUFFERSIZE];
- char *java_home;
- char *user;
- char *home;
- char *locale;
- char *lang;
- char *region;
+ char *cwd;
+ char *java_home;
+ char *user;
+ char *home;
+ char *locale;
+ char *lang;
+ char *region;
struct utsname utsnamebuf;
+ /* endianess union */
union {
u4 i;
u1 c[4];
} u;
-#if !defined(STATIC_CLASSPATH)
+#if !defined(ENABLE_STATICVM)
+ char *ld_library_path;
char *libpath;
s4 libpathlen;
#endif
/* get properties from system */
- (void) getcwd(cwd, BUFFERSIZE);
+ cwd = _Jv_getcwd();
java_home = getenv("JAVA_HOME");
user = getenv("USER");
home = getenv("HOME");
if (!m)
return;
- insert_property(m, p, "java.version", VERSION);
- insert_property(m, p, "java.vendor", "CACAO Team");
- insert_property(m, p, "java.vendor.url", "http://www.cacaojvm.org/");
+ insert_property(m, p, "java.version", JAVA_VERSION);
+ insert_property(m, p, "java.vendor", "GNU Classpath");
+ insert_property(m, p, "java.vendor.url", "http://www.gnu.org/software/classpath/");
insert_property(m, p, "java.home", java_home ? java_home : CACAO_INSTALL_PREFIX);
insert_property(m, p, "java.vm.specification.version", "1.0");
insert_property(m, p, "java.vm.specification.vendor", "Sun Microsystems Inc.");
insert_property(m, p, "java.specification.version", "1.4");
insert_property(m, p, "java.specification.vendor", "Sun Microsystems Inc.");
insert_property(m, p, "java.specification.name", "Java Platform API Specification");
- insert_property(m, p, "java.class.version", "48.0");
+ insert_property(m, p, "java.class.version", CLASS_VERSION);
insert_property(m, p, "java.class.path", classpath);
+ insert_property(m, p, "java.runtime.version", VERSION);
+ insert_property(m, p, "java.runtime.name", "CACAO");
+
/* Set bootclasspath properties. One for GNU classpath and the other for */
/* compatibility with Sun (required by most applications). */
insert_property(m, p, "java.boot.class.path", bootclasspath);
insert_property(m, p, "sun.boot.class.path", bootclasspath);
-#if defined(STATIC_CLASSPATH)
+#if defined(ENABLE_STATICVM)
+ insert_property(m, p, "gnu.classpath.boot.library.path", ".");
insert_property(m, p, "java.library.path" , ".");
-#else
- libpathlen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_LIBRARY_PATH) + 1;
-
- if (getenv("CACAO_LIB_OVERRIDE"))
- libpathlen += strlen(getenv("CACAO_LIB_OVERRIDE")) + 1;
+#else /* defined(ENABLE_STATICVM) */
+ /* fill gnu.classpath.boot.library.path with GNU classpath library path */
- if (getenv("LD_LIBRARY_PATH"))
- libpathlen += strlen(getenv("LD_LIBRARY_PATH")) + 1;
+ libpathlen = strlen(CLASSPATH_INSTALL_DIR) +
+ strlen(CLASSPATH_LIBRARY_PATH) + strlen("0");
libpath = MNEW(char, libpathlen);
- if (getenv("CACAO_LIB_OVERRIDE")) {
- strcat(libpath, getenv("CACAO_LIB_OVERRIDE"));
- strcat(libpath, ":");
- }
+ strcat(libpath, CLASSPATH_INSTALL_DIR);
+ strcat(libpath, CLASSPATH_LIBRARY_PATH);
+
+ insert_property(m, p, "gnu.classpath.boot.library.path", libpath);
+
+ MFREE(libpath, char, libpathlen);
+
+
+ /* now fill java.library.path */
+
+ ld_library_path = getenv("LD_LIBRARY_PATH");
+
+ if (ld_library_path) {
+ libpathlen = strlen(".:") + strlen(ld_library_path) + strlen("0");
+
+ libpath = MNEW(char, libpathlen);
+
+ strcpy(libpath, ".:");
+ strcat(libpath, ld_library_path);
- strcat(libpath, CACAO_INSTALL_PREFIX);
- strcat(libpath, CACAO_LIBRARY_PATH);
+ insert_property(m, p, "java.library.path", libpath);
- if (getenv("LD_LIBRARY_PATH")) {
- strcat(libpath, ":");
- strcat(libpath, getenv("LD_LIBRARY_PATH"));
+ MFREE(libpath, char, libpathlen);
+
+ } else {
+ insert_property(m, p, "java.library.path", "");
}
- insert_property(m, p, "java.library.path", libpath);
+#endif /* defined(ENABLE_STATICVM) */
- MFREE(libpath, char, libpathlen);
+ insert_property(m, p, "java.io.tmpdir", "/tmp");
+
+#if defined(ENABLE_INTRP)
+ if (opt_intrp) {
+ /* XXX We don't support java.lang.Compiler */
+/* insert_property(m, p, "java.compiler", "cacao.intrp"); */
+ insert_property(m, p, "java.vm.info", "interpreted mode");
+ } else
#endif
+ {
+ /* XXX We don't support java.lang.Compiler */
+/* insert_property(m, p, "java.compiler", "cacao.jit"); */
+ insert_property(m, p, "java.vm.info", "JIT mode");
+ }
- insert_property(m, p, "java.io.tmpdir", "/tmp");
+ insert_property(m, p, "java.ext.dirs", "");
- /* XXX We don't support java.lang.Compiler */
-/* insert_property(m, p, "java.compiler", "cacao.jit"); */
+#if defined(DISABLE_GC)
+ /* When we disable the GC, we mmap the whole heap to a specific
+ address, so we can compare call traces. For this reason we have
+ to add the same properties on different machines, otherwise
+ more memory may be allocated (e.g. strlen("i386")
+ vs. strlen("powerpc"). */
- insert_property(m, p, "java.ext.dirs", CACAO_INSTALL_PREFIX""CACAO_EXT_DIR);
+ insert_property(m, p, "os.name", "unknown");
+ insert_property(m, p, "os.arch", "unknown");
+ insert_property(m, p, "os.version", "unknown");
+#else
insert_property(m, p, "os.name", utsnamebuf.sysname);
insert_property(m, p, "os.arch", utsnamebuf.machine);
insert_property(m, p, "os.version", utsnamebuf.release);
+#endif
+
insert_property(m, p, "file.separator", "/");
/* insert_property(m, p, "file.encoding", "null"); -- this must be set properly */
insert_property(m, p, "path.separator", ":");
insert_property(m, p, "user.dir", cwd ? cwd : "null");
/* Are we little or big endian? */
+
u.i = 1;
insert_property(m, p, "gnu.cpu.endian", u.c[0] ? "little" : "big");
-#ifdef USE_GTK
- /* disable gthread-jni's portable native sync due to yet unresolved
- threading issues */
- insert_property(m, p, "gnu.classpath.awt.gtk.portable.native.sync", "false");
-#endif
-
-
/* get locales */
+
locale = getenv("LANG");
if (locale != NULL) { /* gnu classpath is going to set en as language */
if (strlen(locale) <= 2) {
FREE(tp, property);
}
+ /* clean up */
+
+ MFREE(cwd, char, 0);
+
return;
}