[kaffe] CVS kaffe (robilad): merged in java/lang/System from GNU Classpath
Kaffe CVS
cvs-commits at kaffe.org
Tue May 17 03:25:08 PDT 2005
PatchSet 6538
Date: 2005/05/17 10:20:08
Author: robilad
Branch: HEAD
Tag: (none)
Log:
merged in java/lang/System from GNU Classpath
Members:
ChangeLog:1.4064->1.4065
include/Makefile.am:1.101->1.102
include/Makefile.in:1.230->1.231
kaffe/kaffevm/baseClasses.c:1.64->1.65
kaffe/kaffevm/baseClasses.h:INITIAL->1.21
kaffe/kaffevm/thread.c:1.98->1.99
libraries/clib/native/Class.c:1.82->1.83
libraries/clib/native/Field.c:1.19->1.20
libraries/clib/native/Makefile.am:1.44->1.45
libraries/clib/native/Makefile.in:1.183->1.184
libraries/clib/native/System.c:INITIAL->1.65
libraries/clib/native/java_lang_VMSystem.c:INITIAL->1.1
libraries/javalib/Makefile.am:1.350->1.351
libraries/javalib/Makefile.in:1.440->1.441
libraries/javalib/gnu/classpath/VMStackWalker.java:1.1->1.2
libraries/javalib/java/lang/Runtime.java:INITIAL->1.32
libraries/javalib/java/lang/System.java:INITIAL->1.47
libraries/javalib/java/lang/VMSystem.java:INITIAL->1.1
test/internal/Makefile.am:INITIAL->1.19
test/internal/Makefile.in:1.105->1.106
test/internal/java/lang/System.java:1.2->1.3
test/internal/java/lang/VMSystem.java:INITIAL->1.1
test/regression/Reflect.java:1.13->1.14
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4064 kaffe/ChangeLog:1.4065
--- kaffe/ChangeLog:1.4064 Mon May 16 12:13:41 2005
+++ kaffe/ChangeLog Tue May 17 10:20:08 2005
@@ -1,3 +1,57 @@
+2005-05-17 Dalibor Topic <robilad at kaffe.org>
+
+ * libraries/clib/native/java_lang_VMSystem.c,
+ libraries/javalib/java/lang/VMSystem.java,
+ test/internal/java/lang/VMSystem.java:
+ New files. Taken from GNU Classpath.
+
+ * include/Makefile.am (NOINSTALL_DERIVED_HDRS): Removed
+ java_lang_System.h. (NOINSTALL_JNI_DERIVED_HDRS) Added
+ java_lang_VMSystem.h.
+
+ * kaffe/kaffevm/baseClasses.c (RuntimeClass): New field.
+ (RUNTIMECLASS) New constant.
+ (initBaseClasses) Load Runtime class.
+
+ * kaffe/kaffevm/baseClasses.h (RuntimeClass): export field.
+
+ * kaffe/kaffevm/thread.c (runfinalizer): Call exitJavaCleanupHook
+ in Runtime class.
+
+ * libraries/clib/native/Class.c,
+ libraries/clib/native/Field.c: Removed unnecessary include of
+ java_lang_System.h.
+
+ * libraries/clib/native/Makefile.am (LANG_SRCS): Added
+ java_lang_VMSystem.c.
+
+ * libraries/clib/native/System.c (java_lang_System_getenv0,
+ java_lang_System_currentTimeMillis, Java_java_lang_System_setIn0,
+ Java_java_lang_System_setOut0, Java_java_lang_System_setErr0):
+ Removed.
+ (java_lang_System_identityHashCode, java_lang_System_arraycopy0)
+ Renamed into java_lang_VMSystem_identityHashCode and
+ java_lang_VMSystem_arraycopy0.
+
+ * libraries/javalib/gnu/classpath/VMStackWalker.java:
+ (MINIMAL_NUMBER_OF_FRAMES, CALLERS_CALLER_FRAME): New constants.
+ (getCallingClass, getCallingClassLoader): Use MINIMAL_NUMBER_OF_FRAMES
+ and CALLERS_CALLER_FRAME to return the class or the classloader of
+ the caller's caller.
+
+ * libraries/javalib/java/lang/Runtime.java (securityManager): Removed.
+ (exitJavaCleanupHook): New method.
+
+ * libraries/javalib/java/lang/System.java: Switched over to implementation
+ from GNU Classpath.
+
+ * test/internal/Makefile.am: Added java/lang/VMSystem.java into the build.
+
+ * test/internal/java/lang/System.java: Switched over to implementation
+ from GNU Classpath.
+
+ * test/regression/Reflect.java: Adapted expected output.
+
2005-05-16 Dalibor Topic <robilad at kaffe.org>
Resynced with GNU Classpath.
Index: kaffe/include/Makefile.am
diff -u kaffe/include/Makefile.am:1.101 kaffe/include/Makefile.am:1.102
--- kaffe/include/Makefile.am:1.101 Sun May 15 16:50:00 2005
+++ kaffe/include/Makefile.am Tue May 17 10:20:12 2005
@@ -61,7 +61,6 @@
java_lang_Math.h \
java_lang_Runtime.h \
java_lang_Short.h \
- java_lang_System.h \
java_lang_reflect_Array.h \
java_lang_reflect_Constructor.h \
java_lang_reflect_Field.h \
@@ -225,6 +224,7 @@
gnu_java_nio_charset_iconv_IconvEncoder.h \
gnu_java_nio_channels_FileChannelImpl.h \
gnu_java_nio_SelectorImpl.h \
+ java_lang_VMSystem.h \
java_io_VMObjectInputStream.h \
java_io_VMObjectStreamClass.h \
java_nio_VMDirectByteBuffer.h \
Index: kaffe/include/Makefile.in
diff -u kaffe/include/Makefile.in:1.230 kaffe/include/Makefile.in:1.231
--- kaffe/include/Makefile.in:1.230 Sun May 15 16:50:00 2005
+++ kaffe/include/Makefile.in Tue May 17 10:20:12 2005
@@ -424,7 +424,6 @@
java_lang_Math.h \
java_lang_Runtime.h \
java_lang_Short.h \
- java_lang_System.h \
java_lang_reflect_Array.h \
java_lang_reflect_Constructor.h \
java_lang_reflect_Field.h \
@@ -567,6 +566,7 @@
gnu_java_nio_charset_iconv_IconvEncoder.h \
gnu_java_nio_channels_FileChannelImpl.h \
gnu_java_nio_SelectorImpl.h \
+ java_lang_VMSystem.h \
java_io_VMObjectInputStream.h \
java_io_VMObjectStreamClass.h \
java_nio_VMDirectByteBuffer.h \
Index: kaffe/kaffe/kaffevm/baseClasses.c
diff -u kaffe/kaffe/kaffevm/baseClasses.c:1.64 kaffe/kaffe/kaffevm/baseClasses.c:1.65
--- kaffe/kaffe/kaffevm/baseClasses.c:1.64 Sat May 7 16:20:10 2005
+++ kaffe/kaffe/kaffevm/baseClasses.c Tue May 17 10:20:13 2005
@@ -63,6 +63,7 @@
Hjava_lang_Class* StringClass;
Hjava_lang_Class* ObjectClass;
Hjava_lang_Class* SystemClass;
+Hjava_lang_Class* RuntimeClass;
Hjava_lang_Class* SerialClass;
Hjava_lang_Class* CloneClass;
Hjava_lang_Class* PtrClass;
@@ -99,11 +100,12 @@
Hjava_lang_ClassLoader* appClassLoader;
-#define SYSTEMCLASS "java/lang/System"
-#define SERIALCLASS "java/io/Serializable"
-#define CLONECLASS "java/lang/Cloneable"
-#define LOADERCLASS "java/lang/ClassLoader"
-#define PTRCLASS "kaffe/util/Ptr"
+#define RUNTIMECLASS "java/lang/Runtime"
+#define SYSTEMCLASS "java/lang/System"
+#define SERIALCLASS "java/io/Serializable"
+#define CLONECLASS "java/lang/Cloneable"
+#define LOADERCLASS "java/lang/ClassLoader"
+#define PTRCLASS "kaffe/util/Ptr"
/* Initialisation prototypes */
@@ -316,6 +318,7 @@
loadStaticClass(&ClassClass, CLASSCLASS);
loadStaticClass(&StringClass, STRINGCLASS);
loadStaticClass(&SystemClass, SYSTEMCLASS);
+ loadStaticClass(&RuntimeClass, RUNTIMECLASS);
/* We must to a little cross tidying */
ObjectClass->head.vtable = ClassClass->vtable;
===================================================================
Checking out kaffe/kaffe/kaffevm/baseClasses.h
RCS: /home/cvs/kaffe/kaffe/kaffe/kaffevm/baseClasses.h,v
VERS: 1.21
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/baseClasses.h Tue May 17 10:25:07 2005
@@ -0,0 +1,72 @@
+/*
+ * baseClasses.h
+ * Handle base classes.
+ *
+ * Copyright (c) 1996, 1997
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#ifndef __baseclasses_h
+#define __baseclasses_h
+
+#include "object.h"
+#include "native.h"
+
+#define STRINGCLASS "java/lang/String"
+#define OBJECTCLASS "java/lang/Object"
+#define CLASSCLASS "java/lang/Class"
+#define APPCLASSLOADERCLASS "kaffe/lang/AppClassLoader"
+
+#define OBJECTCLASSSIG "Ljava/lang/Object;"
+
+#define PTRCLASS "kaffe/util/Ptr"
+#define PTRCLASSSIG "Lkaffe/util/Ptr;"
+
+void initBaseClasses(void);
+void initialiseKaffe(void);
+
+extern struct Hjava_lang_Class* ObjectClass;
+extern struct Hjava_lang_Class* StringClass;
+extern struct Hjava_lang_Class* RuntimeClass;
+extern struct Hjava_lang_Class* SystemClass;
+extern struct Hjava_lang_Class* SerialClass;
+extern struct Hjava_lang_Class* CloneClass;
+extern struct Hjava_lang_Class* PtrClass;
+extern struct Hjava_lang_Class* ClassLoaderClass;
+extern struct Hjava_lang_Class* kaffeLangAppClassLoaderClass;
+
+extern struct Hjava_lang_Class* javaLangRefReference;
+extern struct Hjava_lang_Class* javaLangRefSoftReference;
+extern struct Hjava_lang_Class* javaLangRefWeakReference;
+extern struct Hjava_lang_Class* javaLangRefPhantomReference;
+
+extern struct Hjava_lang_Class* javaLangVoidClass;
+extern struct Hjava_lang_Class* javaLangBooleanClass;
+extern struct Hjava_lang_Class* javaLangByteClass;
+extern struct Hjava_lang_Class* javaLangCharacterClass;
+extern struct Hjava_lang_Class* javaLangShortClass;
+extern struct Hjava_lang_Class* javaLangIntegerClass;
+extern struct Hjava_lang_Class* javaLangLongClass;
+extern struct Hjava_lang_Class* javaLangFloatClass;
+extern struct Hjava_lang_Class* javaLangDoubleClass;
+
+extern struct Hjava_lang_Class* javaLangThrowable;
+extern struct Hjava_lang_Class* javaLangVMThrowable;
+extern struct Hjava_lang_Class* javaLangStackTraceElement;
+extern struct Hjava_lang_Class* javaLangException;
+extern struct Hjava_lang_Class* javaLangNullPointerException;
+extern struct Hjava_lang_Class* javaLangArithmeticException;
+extern struct Hjava_lang_Class* javaLangArrayIndexOutOfBoundsException;
+extern struct Hjava_lang_Class* javaLangClassNotFoundException;
+extern struct Hjava_lang_Class* javaLangNoClassDefFoundError;
+extern struct Hjava_lang_Class* javaLangStackOverflowError;
+
+extern struct Hjava_lang_ClassLoader *appClassLoader;
+
+extern Hjava_lang_Class* getClassClass(void);
+extern Hjava_lang_Class* getStringClass(void);
+
+#endif
Index: kaffe/kaffe/kaffevm/thread.c
diff -u kaffe/kaffe/kaffevm/thread.c:1.98 kaffe/kaffe/kaffevm/thread.c:1.99
--- kaffe/kaffe/kaffevm/thread.c:1.98 Sat May 14 21:46:31 2005
+++ kaffe/kaffe/kaffevm/thread.c Tue May 17 10:20:13 2005
@@ -610,7 +610,7 @@
}
/* Do java-land cleanup */
- do_execute_java_method(NULL, SystemClass, "exitJavaCleanup",
+ do_execute_java_method(NULL, RuntimeClass, "exitJavaCleanupHook",
"()V", NULL, true);
if (runFinalizerOnExit) {
invokeFinalizer();
Index: kaffe/libraries/clib/native/Class.c
diff -u kaffe/libraries/clib/native/Class.c:1.82 kaffe/libraries/clib/native/Class.c:1.83
--- kaffe/libraries/clib/native/Class.c:1.82 Sat May 14 21:46:53 2005
+++ kaffe/libraries/clib/native/Class.c Tue May 17 10:20:13 2005
@@ -29,7 +29,6 @@
#include "java_io_InputStream.h"
#include "java_io_PrintStream.h"
-#include "java_lang_System.h"
#include "java_lang_reflect_Constructor.h"
#include "java_lang_reflect_Method.h"
#include "java_lang_reflect_Field.h"
Index: kaffe/libraries/clib/native/Field.c
diff -u kaffe/libraries/clib/native/Field.c:1.19 kaffe/libraries/clib/native/Field.c:1.20
--- kaffe/libraries/clib/native/Field.c:1.19 Fri Apr 22 21:20:47 2005
+++ kaffe/libraries/clib/native/Field.c Tue May 17 10:20:13 2005
@@ -24,7 +24,6 @@
#include "exception.h"
#include "java_io_InputStream.h"
#include "java_io_PrintStream.h"
-#include "java_lang_System.h"
#include "java_lang_reflect_Field.h"
#include <native.h>
#include "defs.h"
Index: kaffe/libraries/clib/native/Makefile.am
diff -u kaffe/libraries/clib/native/Makefile.am:1.44 kaffe/libraries/clib/native/Makefile.am:1.45
--- kaffe/libraries/clib/native/Makefile.am:1.44 Sun May 15 16:50:01 2005
+++ kaffe/libraries/clib/native/Makefile.am Tue May 17 10:20:13 2005
@@ -29,6 +29,7 @@
Runtime.c \
String.c \
System.c \
+ java_lang_VMSystem.c \
Thread.c \
ThreadStack.c \
Throwable.c \
Index: kaffe/libraries/clib/native/Makefile.in
diff -u kaffe/libraries/clib/native/Makefile.in:1.183 kaffe/libraries/clib/native/Makefile.in:1.184
--- kaffe/libraries/clib/native/Makefile.in:1.183 Sun May 15 16:50:01 2005
+++ kaffe/libraries/clib/native/Makefile.in Tue May 17 10:20:13 2005
@@ -97,8 +97,9 @@
libnative_la-MemoryAdvice.lo libnative_la-Object.lo \
libnative_la-PrimordialClassLoader.lo libnative_la-Runtime.lo \
libnative_la-String.lo libnative_la-System.lo \
- libnative_la-Thread.lo libnative_la-ThreadStack.lo \
- libnative_la-Throwable.lo libnative_la-UNIXProcess.lo \
+ libnative_la-java_lang_VMSystem.lo libnative_la-Thread.lo \
+ libnative_la-ThreadStack.lo libnative_la-Throwable.lo \
+ libnative_la-UNIXProcess.lo \
libnative_la-gnu_classpath_VMStackWalker.lo \
libnative_la-gnu_classpath_VMSystemProperties.lo \
libnative_la-ZipFile.lo
@@ -422,6 +423,7 @@
Runtime.c \
String.c \
System.c \
+ java_lang_VMSystem.c \
Thread.c \
ThreadStack.c \
Throwable.c \
@@ -571,6 +573,7 @@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-gnu_classpath_VMSystemProperties.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-java_lang_VMDouble.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-java_lang_VMFloat.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-java_lang_VMSystem.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-java_lang_ref_Reference.Plo at am__quote@
.c.o:
@@ -670,6 +673,13 @@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='System.c' object='libnative_la-System.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -c -o libnative_la-System.lo `test -f 'System.c' || echo '$(srcdir)/'`System.c
+
+libnative_la-java_lang_VMSystem.lo: java_lang_VMSystem.c
+ at am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -MT libnative_la-java_lang_VMSystem.lo -MD -MP -MF "$(DEPDIR)/libnative_la-java_lang_VMSystem.Tpo" -c -o libnative_la-java_lang_VMSystem.lo `test -f 'java_lang_VMSystem.c' || echo '$(srcdir)/'`java_lang_VMSystem.c; \
+ at am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnative_la-java_lang_VMSystem.Tpo" "$(DEPDIR)/libnative_la-java_lang_VMSystem.Plo"; else rm -f "$(DEPDIR)/libnative_la-java_lang_VMSystem.Tpo"; exit 1; fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='java_lang_VMSystem.c' object='libnative_la-java_lang_VMSystem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -c -o libnative_la-java_lang_VMSystem.lo `test -f 'java_lang_VMSystem.c' || echo '$(srcdir)/'`java_lang_VMSystem.c
libnative_la-Thread.lo: Thread.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -MT libnative_la-Thread.lo -MD -MP -MF "$(DEPDIR)/libnative_la-Thread.Tpo" -c -o libnative_la-Thread.lo `test -f 'Thread.c' || echo '$(srcdir)/'`Thread.c; \
===================================================================
Checking out kaffe/libraries/clib/native/System.c
RCS: /home/cvs/kaffe/kaffe/libraries/clib/native/System.c,v
VERS: 1.65
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/native/System.c Tue May 17 10:25:08 2005
@@ -0,0 +1,178 @@
+/*
+ * java.lang.System.c
+ *
+ * Copyright (c) 1996, 1997, 1998, 1999
+ * Transvirtual Technologies, Inc. All rights reserved.
+ * Copyright (c) 2003
+ * Mark J. Wielaard <mark at klomp.org>
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#include "config.h"
+#include "config-std.h"
+#include "config-io.h"
+#include "config-mem.h"
+#if defined(HAVE_SYS_UTSNAME_H)
+#include <sys/utsname.h>
+#endif
+#if defined(HAVE_PWD_H)
+#include <pwd.h>
+#endif
+#include <sys/time.h>
+#include <time.h>
+#include <ctype.h>
+#include "classMethod.h"
+#include "gtypes.h"
+#include "object.h"
+#include "constants.h"
+#include "access.h"
+#include "baseClasses.h"
+#include "stringSupport.h"
+#include "support.h"
+#include "external.h"
+#include "soft.h"
+#include "debug.h"
+#include "exception.h"
+#include "system.h"
+#include "defs.h"
+#include "java_io_InputStream.h"
+#include "java_io_PrintStream.h"
+#include "java_lang_VMSystem.h"
+#include "java_lang_Throwable.h"
+#include <native.h>
+#include <jni.h>
+
+#include <locale.h>
+
+extern void printStackTrace(struct Hjava_lang_Throwable*,
+ struct Hjava_lang_Object*, int);
+
+jint
+java_lang_VMSystem_identityHashCode(struct Hjava_lang_Object* o)
+{
+ /* Hash code is object's address */
+ return ((jint)(jword)o);
+}
+
+/*
+ * See java/lang/System.java for info on these two routines.
+ */
+void
+java_lang_System_debug(struct Hjava_lang_String *str)
+{
+ char *s;
+
+ s = checkPtr(stringJava2C(str));
+ dprintf("%s\n", s);
+ gc_free(s);
+}
+
+void
+java_lang_System_debugE(struct Hjava_lang_Throwable *t)
+{
+ Hjava_lang_String *msg;
+ const char *cname;
+ char *s;
+
+ cname = CLASS_CNAME(OBJECT_CLASS(&t->base));
+ msg = unhand(t)->detailMessage;
+
+ if (msg) {
+ s = checkPtr(stringJava2C(msg));
+ dprintf("%s: %s\n", cname, s);
+ gc_free(s);
+ } else {
+ dprintf("%s\n", cname);
+ }
+ printStackTrace(t, NULL, 1);
+}
+
+void
+java_lang_VMSystem_arraycopy0(struct Hjava_lang_Object* src,
+ jint srcpos,
+ struct Hjava_lang_Object* dst,
+ jint dstpos,
+ jint len)
+{
+ char* in;
+ char* out;
+ int elemsz;
+ Hjava_lang_Class* sclass;
+ Hjava_lang_Class* dclass;
+
+ sclass = OBJECT_CLASS(src);
+ dclass = OBJECT_CLASS(dst);
+
+ sclass = CLASS_ELEMENT_TYPE(sclass);
+ dclass = CLASS_ELEMENT_TYPE(dclass);
+ elemsz = TYPE_SIZE(sclass);
+
+ len *= elemsz;
+ srcpos *= elemsz;
+ dstpos *= elemsz;
+
+ in = &((char*)ARRAY_DATA(src))[srcpos];
+ out = &((char*)ARRAY_DATA(dst))[dstpos];
+
+ if (sclass == dclass) {
+#if defined(HAVE_MEMMOVE)
+ memmove((void*)out, (void*)in, (size_t)len);
+#else
+ /* Do it ourself */
+#if defined(HAVE_MEMCPY)
+ if (src != dst) {
+ memcpy((void*)out, (void*)in, (size_t)len);
+ } else
+#endif
+ if (out < in) {
+ /* Copy forwards */
+ for (; len > 0; len--) {
+ *out++ = *in++;
+ }
+ } else {
+ /* Copy backwards */
+ out += len;
+ in += len;
+ for (; len > 0; len--) {
+ *--out = *--in;
+ }
+ }
+#endif
+ } else {
+ if (CLASS_IS_PRIMITIVE(sclass) || CLASS_IS_PRIMITIVE(dclass)) {
+ Hjava_lang_Throwable* asexc;
+ const char *stype = CLASS_CNAME(sclass);
+ const char *dtype = CLASS_CNAME(dclass);
+ char *b;
+#define _FORMAT "incompatible array types `%s' and `%s'"
+ b = checkPtr(KMALLOC(strlen(stype)+strlen(dtype)+strlen(_FORMAT)));
+ sprintf(b, _FORMAT, stype, dtype);
+#undef _FORMAT
+ asexc = ArrayStoreException(b);
+ KFREE(b);
+ throwException(asexc);
+ }
+
+ for (; len > 0; len -= sizeof(Hjava_lang_Object*)) {
+ Hjava_lang_Object* val = *(Hjava_lang_Object**)in;
+ if (val != 0 && !instanceof(dclass, OBJECT_CLASS(val))) {
+ Hjava_lang_Throwable* asexc;
+ const char *vtype = CLASS_CNAME(OBJECT_CLASS(val));
+ const char *atype = CLASS_CNAME(dclass);
+ char *b;
+#define _FORMAT "can't store `%s' in array of type `%s'"
+ b = checkPtr(KMALLOC(strlen(vtype)+strlen(atype)+strlen(_FORMAT)));
+ sprintf(b, _FORMAT, vtype, atype);
+#undef _FORMAT
+ asexc = ArrayStoreException(b);
+ KFREE(b);
+ throwException(asexc);
+ }
+ *(Hjava_lang_Object**)out = val;
+ in += sizeof(Hjava_lang_Object*);
+ out += sizeof(Hjava_lang_Object*);
+ }
+ }
+}
===================================================================
Checking out kaffe/libraries/clib/native/java_lang_VMSystem.c
RCS: /home/cvs/kaffe/kaffe/libraries/clib/native/java_lang_VMSystem.c,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/native/java_lang_VMSystem.c Tue May 17 10:25:08 2005
@@ -0,0 +1,156 @@
+/* System.c -- native code for java.lang.System
+ Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include "java_lang_VMSystem.h"
+
+#include <jcl.h>
+
+#include <sys/time.h>
+#include <stdlib.h>
+
+/*
+ * Class: java_lang_VMSystem
+ * Method: setIn0
+ * Signature: (Ljava/io/InputStream;)V
+ */
+JNIEXPORT void JNICALL
+Java_java_lang_VMSystem_setIn (JNIEnv * env,
+ jclass thisClass __attribute__ ((__unused__)),
+ jobject obj)
+{
+ jclass cls;
+ jfieldID field;
+
+ cls = JCL_FindClass (env, "java/lang/System");
+ if (!cls)
+ return;
+
+ field = (*env)->GetStaticFieldID (env, cls, "in", "Ljava/io/InputStream;");
+ if (!field)
+ return;
+ (*env)->SetStaticObjectField (env, cls, field, obj);
+}
+
+/*
+ * Class: java_lang_VMSystem
+ * Method: setOut0
+ * Signature: (Ljava/io/PrintStream;)V
+ */
+JNIEXPORT void JNICALL
+Java_java_lang_VMSystem_setOut (JNIEnv * env,
+ jclass thisClass __attribute__ ((__unused__)),
+ jobject obj)
+{
+ jclass cls;
+ jfieldID field;
+
+ cls = JCL_FindClass (env, "java/lang/System");
+ if (!cls)
+ return;
+
+ field = (*env)->GetStaticFieldID (env, cls, "out", "Ljava/io/PrintStream;");
+ if (!field)
+ return;
+ (*env)->SetStaticObjectField (env, cls, field, obj);
+}
+
+/*
+ * Class: java_lang_VMSystem
+ * Method: setErr0
+ * Signature: (Ljava/io/PrintStream;)V
+ */
+JNIEXPORT void JNICALL
+Java_java_lang_VMSystem_setErr (JNIEnv * env,
+ jclass thisClass __attribute__ ((__unused__)),
+ jobject obj)
+{
+ jclass cls;
+ jfieldID field;
+
+ cls = JCL_FindClass (env, "java/lang/System");
+ if (!cls)
+ return;
+
+ field = (*env)->GetStaticFieldID (env, cls, "err", "Ljava/io/PrintStream;");
+ if (!field)
+ return;
+ (*env)->SetStaticObjectField (env, cls, field, obj);
+}
+
+/*
+ * Class: java_lang_VMSystem
+ * Method: currentTimeMillis
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL
+Java_java_lang_VMSystem_currentTimeMillis
+ (JNIEnv * env __attribute__ ((__unused__)),
+ jclass thisClass __attribute__ ((__unused__)))
+{
+ /* Note: this implementation copied directly from Japhar's, by Chris Toshok. */
+ jlong result;
+ struct timeval tp;
+
+ if (gettimeofday (&tp, NULL) == -1)
+ (*env)->FatalError (env, "gettimeofday call failed.");
+
+ result = (jlong) tp.tv_sec;
+ result *= 1000;
+ result += (tp.tv_usec / 1000);
+
+ return result;
+}
+
+JNIEXPORT jstring JNICALL
+Java_java_lang_VMSystem_getenv (JNIEnv * env,
+ jclass klass __attribute__ ((__unused__)),
+ jstring jname)
+{
+ const char *cname;
+ const char *envname;
+
+ cname = JCL_jstring_to_cstring (env, jname);
+ if (cname == NULL)
+ return NULL;
+
+ envname = getenv (cname);
+ if (envname == NULL)
+ return NULL;
+
+ JCL_free_cstring (env, jname, cname);
+ return (*env)->NewStringUTF (env, envname);
+}
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.350 kaffe/libraries/javalib/Makefile.am:1.351
--- kaffe/libraries/javalib/Makefile.am:1.350 Mon May 16 12:13:45 2005
+++ kaffe/libraries/javalib/Makefile.am Tue May 17 10:20:14 2005
@@ -2684,6 +2684,7 @@
java/lang/VMDouble.java \
java/lang/VMFloat.java \
java/lang/VMObject.java \
+ java/lang/VMSystem.java \
java/lang/VMThread.java \
java/lang/VMThrowable.java \
java/lang/VerifyError.java \
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.440 kaffe/libraries/javalib/Makefile.in:1.441
--- kaffe/libraries/javalib/Makefile.in:1.440 Mon May 16 12:13:46 2005
+++ kaffe/libraries/javalib/Makefile.in Tue May 17 10:20:15 2005
@@ -3186,6 +3186,7 @@
java/lang/VMDouble.java \
java/lang/VMFloat.java \
java/lang/VMObject.java \
+ java/lang/VMSystem.java \
java/lang/VMThread.java \
java/lang/VMThrowable.java \
java/lang/VerifyError.java \
Index: kaffe/libraries/javalib/gnu/classpath/VMStackWalker.java
diff -u kaffe/libraries/javalib/gnu/classpath/VMStackWalker.java:1.1 kaffe/libraries/javalib/gnu/classpath/VMStackWalker.java:1.2
--- kaffe/libraries/javalib/gnu/classpath/VMStackWalker.java:1.1 Sun May 15 16:50:06 2005
+++ kaffe/libraries/javalib/gnu/classpath/VMStackWalker.java Tue May 17 10:20:18 2005
@@ -52,6 +52,25 @@
public final class VMStackWalker
{
/**
+ * When calling <code>getCallingClass()</code> and
+ * <code>getCallingClassLoader()</code>, the minimal number of frames
+ * on the stack needs to be 4. The frames on the stack look like this:
+ *
+ * <ul>
+ * <li><code>getClassContext()</code>
+ * <li><code>getCallingClass()</code> | <code>getCallingClassLoader()</code>
+ * <li>method invoking it
+ * <li>method whose <code>Class</code> or <code>ClassLoader</code> we need
+ * </ul>
+ */
+ private static final int MINIMAL_NUMBER_OF_FRAMES = 4;
+
+ /**
+ * The frame of the caller's caller.
+ */
+ private static final int CALLERS_CALLER_FRAME = MINIMAL_NUMBER_OF_FRAMES - 1;
+
+ /**
* Get a list of all the classes currently executing methods on the
* Java stack. <code>getClassContext()[0]</code> is the class associated
* with the currently executing method, i.e., the method that called
@@ -81,9 +100,9 @@
public static Class getCallingClass()
{
Class[] ctx = getClassContext();
- if (ctx.length < 3)
+ if (ctx.length < MINIMAL_NUMBER_OF_FRAMES)
return null;
- return ctx[2];
+ return ctx[CALLERS_CALLER_FRAME];
}
/**
@@ -100,9 +119,9 @@
public static ClassLoader getCallingClassLoader()
{
Class[] ctx = getClassContext();
- if (ctx.length < 3)
+ if (ctx.length < MINIMAL_NUMBER_OF_FRAMES)
return null;
- return ctx[2].getClassLoader();
+ return ctx[CALLERS_CALLER_FRAME].getClassLoader();
}
}
===================================================================
Checking out kaffe/libraries/javalib/java/lang/Runtime.java
RCS: /home/cvs/kaffe/kaffe/libraries/javalib/java/lang/Runtime.java,v
VERS: 1.32
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/javalib/java/lang/Runtime.java Tue May 17 10:25:08 2005
@@ -0,0 +1,327 @@
+/*
+ * Java core library component.
+ *
+ * Copyright (c) 1997, 1998
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+package java.lang;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import kaffe.lang.ThreadStack;
+
+public class Runtime
+{
+/**
+ * XXX This is not part of the public interface.
+ */
+public interface MemoryAdvice {
+
+ // These should match those in kaffe.lang.MemoryAdvice
+ int GREEN = 0;
+ int YELLOW = 1;
+ int ORANGE = 2;
+ int RED = 3;
+}
+
+private static Runtime currentRuntime = new Runtime();
+private static kaffe.lang.MemoryAdvice advice
+ = kaffe.lang.MemoryAdvice.getInstance();
+private static final Vector shutdownHooks = new Vector(0);
+private static boolean VMShuttingDown = false;
+
+private static final RuntimePermission SHUTDOWN_HOOKS =
+ new RuntimePermission("shutdownHooks");
+
+private Runtime () {
+}
+
+public Process exec(String command) throws IOException {
+ return exec(command, null, null);
+}
+
+public Process exec(String command, String envp[]) throws IOException {
+ return exec(command, envp, null);
+}
+
+public Process exec(String command, String envp[], File dir)
+ throws IOException {
+ StringTokenizer tokenizer=new StringTokenizer(command);
+
+ int count=tokenizer.countTokens();
+ String cmdarray[]=new String[count];
+
+ for (int pos=0; pos<count; pos++) {
+ cmdarray[pos]=tokenizer.nextToken();
+ }
+
+ return exec(cmdarray, envp, dir);
+}
+
+public Process exec(String cmdarray[]) throws IOException {
+ return exec(cmdarray, null, null);
+}
+
+public Process exec(String cmdarray[], String envp[]) throws IOException {
+ return exec(cmdarray, envp, null);
+}
+
+public Process exec(String[] cmdarray, String[] envp, File dir)
+ throws IOException {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkExec(cmdarray[0]);
+ return execInternal(cmdarray, envp, dir);
+}
+
+private native Process execInternal(String cmdary[], String envp[], File dir)
+ throws IOException;
+
+/**
+ * Callback used to execute the shutdown hooks.
+ */
+boolean exitJavaCleanup() {
+ return runShutdownHooks();
+}
+
+public void exit(int status) throws SecurityException {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkExit(status);
+
+ /* First we cleanup the Virtual Machine */
+ if (!exitJavaCleanup())
+ /* Throw ThreadDeath to kill the currently running thread. */
+ throw new ThreadDeath();
+
+ /* Now we run the VM exit function */
+ exit0(status);
+}
+
+public void halt(int status) throws SecurityException {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkExit(status);
+
+ exit0(status);
+}
+
+native private void exit0(int status);
+
+native public long freeMemory();
+
+native public void gc();
+
+/**
+ * @deprecated
+ */
+public InputStream getLocalizedInputStream(InputStream in) {
+ return (in);
+}
+
+/**
+ * @deprecated
+ */
+public OutputStream getLocalizedOutputStream(OutputStream out) {
+ return (out);
+}
+
+public static Runtime getRuntime() {
+ return currentRuntime;
+}
+
+public void loadLibrary(String libname) {
+ loadLibrary(libname,
+ ThreadStack.getCallersClassLoader(false));
+}
+
+ /**
+ * Tries to load and link a native library.
+ *
+ * @return true if successfull
+ * @throws UnsatisfiedLinkError if the library was found but could not be linked.
+ */
+ private static native boolean linkLibrary(String name, ClassLoader loader)
+ throws UnsatisfiedLinkError;
+
+ private static native String getLibPrefix ();
+ private static native String getLibSuffix ();
+
+ static String mapLibraryName (String name)
+ {
+ return getLibPrefix() + name + getLibSuffix();
+ }
+
+void loadLibrary(String libname, ClassLoader loader) throws UnsatisfiedLinkError {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkLink(libname);
+ String errmsg = libname + ": not found";
+ String filename;
+ String[] names;
+
+ if (loader != null && (filename = loader.findLibrary(libname)) != null) {
+ if (linkLibrary(filename, loader))
+ return;
+ } else {
+ String libPath = System.getProperty("kaffe.library.path")
+ + File.pathSeparatorChar
+ + System.getProperty("java.library.path");
+
+ StringTokenizer t = new StringTokenizer(libPath,
+ new String(new char[] { File.pathSeparatorChar }));
+ while (t.hasMoreTokens ()) {
+ if (linkLibrary(t.nextToken() + File.separator + mapLibraryName(libname),
+ loader))
+ return;
+ }
+ }
+ throw new UnsatisfiedLinkError("Could not find library '" + libname +
+ "'\nAdding its directory to LD_LIBRARY_PATH may help.");
+}
+
+public void load(String filename) {
+ load(filename, ThreadStack.getCallersClassLoader(false));
+}
+
+void load(String filename, ClassLoader loader) {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkLink(filename);
+
+ if (!linkLibrary(filename, loader))
+ throw new UnsatisfiedLinkError(filename + ": not found");
+}
+
+native public long maxMemory();
+
+int getMemoryAdvice() {
+ return (advice.getColor());
+}
+
+int waitForMemoryAdvice(int level) throws InterruptedException {
+ return (advice.waitForOtherColor(level));
+}
+
*** Patch too long, truncated ***
More information about the kaffe
mailing list