* src/vm/class.h (vm/loader.h): Added.
authortwisti <none@none>
Mon, 18 Dec 2006 17:36:06 +0000 (17:36 +0000)
committertwisti <none@none>
Mon, 18 Dec 2006 17:36:06 +0000 (17:36 +0000)
(classinfo): Added enclosingclass and enclosingmethod.

* configure.ac (AC_CONFIG_FILES): Added src/native/vm/gnu/Makefile.

* src/native/native.c (native_class_getname): Removed.
* src/native/native.h: Likewise.

* src/native/vm/Makefile.am

* src/native/vm/java_lang_Class.c: New file, contains the
implementation for java.lang.Class functions.
* src/native/vm/java_lang_Class.h: Likewise.

* src/native/vm/java_security_VMAccessController.c,
src/native/vm/VMjdwp.c,
src/native/vm/java_lang_VMClass.c,
src/native/vm/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
src/native/vm/java_lang_VMThread.c,
src/native/vm/VMjdwp.h,
src/native/vm/gnu_classpath_jdwp_VMVirtualMachine.c,
src/native/vm/gnu_classpath_jdwp_VMMethod.c,
src/native/vm/java_lang_VMRuntime.c,
src/native/vm/java_lang_reflect_Field.c,
src/native/vm/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
src/native/vm/java_lang_VMThrowable.c,
src/native/vm/gnu_java_lang_management_VMThreadMXBeanImpl.c,
src/native/vm/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
src/native/vm/java_lang_VMClassLoader.c,
src/native/vm/java_lang_management_VMManagementFactory.c,
src/native/vm/java_lang_VMString.c,
src/native/vm/java_lang_VMObject.c,
src/native/vm/gnu_classpath_VMSystemProperties.c,
src/native/vm/sun_misc_Unsafe.c,
src/native/vm/java_lang_reflect_Method.c,
src/native/vm/gnu_classpath_VMStackWalker.c,
src/native/vm/java_lang_VMSystem.c,
src/native/vm/java_lang_reflect_VMProxy.c,
src/native/vm/java_lang_reflect_Constructor.c,
src/native/vm/gnu_classpath_jdwp_VMFrame.c: Moved to
src/native/vm/gnu.

* src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c,
src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c,
src/native/vm/gnu/java_security_VMAccessController.c,
src/native/vm/gnu/java_lang_VMClassLoader.c,
src/native/vm/gnu/java_lang_management_VMManagementFactory.c,
src/native/vm/gnu/VMjdwp.c,
src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c,
src/native/vm/gnu/java_lang_VMClass.c,
src/native/vm/gnu/java_lang_VMString.c,
src/native/vm/gnu/java_lang_VMObject.c,
src/native/vm/gnu/VMjdwp.h,
src/native/vm/gnu/java_lang_VMThread.c,
src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c,
src/native/vm/gnu/gnu_classpath_VMSystemProperties.c,
src/native/vm/gnu/sun_misc_Unsafe.c,
src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c,
src/native/vm/gnu/java_lang_reflect_Method.c,
src/native/vm/gnu/java_lang_VMRuntime.c,
src/native/vm/gnu/Makefile.am,
src/native/vm/gnu/java_lang_reflect_Field.c,
src/native/vm/gnu/gnu_classpath_VMStackWalker.c,
src/native/vm/gnu/java_lang_VMSystem.c,
src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c,
src/native/vm/gnu/java_lang_reflect_VMProxy.c,
src/native/vm/gnu/java_lang_reflect_Constructor.c,
src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c,
src/native/vm/gnu/java_lang_VMThrowable.c: Moved from src/native/vm.

--HG--
rename : src/native/vm/Makefile.am => src/native/vm/gnu/Makefile.am
rename : src/native/vm/VMjdwp.c => src/native/vm/gnu/VMjdwp.c
rename : src/native/vm/VMjdwp.h => src/native/vm/gnu/VMjdwp.h
rename : src/native/vm/gnu_classpath_VMStackWalker.c => src/native/vm/gnu/gnu_classpath_VMStackWalker.c
rename : src/native/vm/gnu_classpath_VMSystemProperties.c => src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
rename : src/native/vm/gnu_classpath_jdwp_VMFrame.c => src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c
rename : src/native/vm/gnu_classpath_jdwp_VMMethod.c => src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c
rename : src/native/vm/gnu_classpath_jdwp_VMVirtualMachine.c => src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c
rename : src/native/vm/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c => src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
rename : src/native/vm/gnu_java_lang_management_VMMemoryMXBeanImpl.c => src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
rename : src/native/vm/gnu_java_lang_management_VMRuntimeMXBeanImpl.c => src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
rename : src/native/vm/gnu_java_lang_management_VMThreadMXBeanImpl.c => src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c
rename : src/native/vm/java_lang_VMClass.c => src/native/vm/gnu/java_lang_VMClass.c
rename : src/native/vm/java_lang_VMClassLoader.c => src/native/vm/gnu/java_lang_VMClassLoader.c
rename : src/native/vm/java_lang_VMObject.c => src/native/vm/gnu/java_lang_VMObject.c
rename : src/native/vm/java_lang_VMRuntime.c => src/native/vm/gnu/java_lang_VMRuntime.c
rename : src/native/vm/java_lang_VMString.c => src/native/vm/gnu/java_lang_VMString.c
rename : src/native/vm/java_lang_VMSystem.c => src/native/vm/gnu/java_lang_VMSystem.c
rename : src/native/vm/java_lang_VMThread.c => src/native/vm/gnu/java_lang_VMThread.c
rename : src/native/vm/java_lang_VMThrowable.c => src/native/vm/gnu/java_lang_VMThrowable.c
rename : src/native/vm/java_lang_management_VMManagementFactory.c => src/native/vm/gnu/java_lang_management_VMManagementFactory.c
rename : src/native/vm/java_lang_reflect_Constructor.c => src/native/vm/gnu/java_lang_reflect_Constructor.c
rename : src/native/vm/java_lang_reflect_Field.c => src/native/vm/gnu/java_lang_reflect_Field.c
rename : src/native/vm/java_lang_reflect_Method.c => src/native/vm/gnu/java_lang_reflect_Method.c
rename : src/native/vm/java_lang_reflect_VMProxy.c => src/native/vm/gnu/java_lang_reflect_VMProxy.c
rename : src/native/vm/java_security_VMAccessController.c => src/native/vm/gnu/java_security_VMAccessController.c
rename : src/native/vm/sun_misc_Unsafe.c => src/native/vm/gnu/sun_misc_Unsafe.c

60 files changed:
configure.ac
src/native/native.c
src/native/native.h
src/native/vm/Makefile.am
src/native/vm/VMjdwp.c [deleted file]
src/native/vm/VMjdwp.h [deleted file]
src/native/vm/gnu/Makefile.am [new file with mode: 0644]
src/native/vm/gnu/VMjdwp.c [new file with mode: 0644]
src/native/vm/gnu/VMjdwp.h [new file with mode: 0644]
src/native/vm/gnu/gnu_classpath_VMStackWalker.c [new file with mode: 0644]
src/native/vm/gnu/gnu_classpath_VMSystemProperties.c [new file with mode: 0644]
src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c [new file with mode: 0644]
src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c [new file with mode: 0644]
src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c [new file with mode: 0644]
src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMClass.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMClassLoader.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMObject.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMRuntime.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMString.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMSystem.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMThread.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_VMThrowable.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_management_VMManagementFactory.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_reflect_Constructor.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_reflect_Field.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_reflect_Method.c [new file with mode: 0644]
src/native/vm/gnu/java_lang_reflect_VMProxy.c [new file with mode: 0644]
src/native/vm/gnu/java_security_VMAccessController.c [new file with mode: 0644]
src/native/vm/gnu/sun_misc_Unsafe.c [new file with mode: 0644]
src/native/vm/gnu_classpath_VMStackWalker.c [deleted file]
src/native/vm/gnu_classpath_VMSystemProperties.c [deleted file]
src/native/vm/gnu_classpath_jdwp_VMFrame.c [deleted file]
src/native/vm/gnu_classpath_jdwp_VMMethod.c [deleted file]
src/native/vm/gnu_classpath_jdwp_VMVirtualMachine.c [deleted file]
src/native/vm/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c [deleted file]
src/native/vm/gnu_java_lang_management_VMMemoryMXBeanImpl.c [deleted file]
src/native/vm/gnu_java_lang_management_VMRuntimeMXBeanImpl.c [deleted file]
src/native/vm/gnu_java_lang_management_VMThreadMXBeanImpl.c [deleted file]
src/native/vm/java_lang_Class.c [new file with mode: 0644]
src/native/vm/java_lang_Class.h [new file with mode: 0644]
src/native/vm/java_lang_VMClass.c [deleted file]
src/native/vm/java_lang_VMClassLoader.c [deleted file]
src/native/vm/java_lang_VMObject.c [deleted file]
src/native/vm/java_lang_VMRuntime.c [deleted file]
src/native/vm/java_lang_VMString.c [deleted file]
src/native/vm/java_lang_VMSystem.c [deleted file]
src/native/vm/java_lang_VMThread.c [deleted file]
src/native/vm/java_lang_VMThrowable.c [deleted file]
src/native/vm/java_lang_management_VMManagementFactory.c [deleted file]
src/native/vm/java_lang_reflect_Constructor.c [deleted file]
src/native/vm/java_lang_reflect_Field.c [deleted file]
src/native/vm/java_lang_reflect_Method.c [deleted file]
src/native/vm/java_lang_reflect_VMProxy.c [deleted file]
src/native/vm/java_security_VMAccessController.c [deleted file]
src/native/vm/sun_misc_Unsafe.c [deleted file]
src/vm/class.h

index e981fe516663e18252a72f93034a597b94ae51af..c60007485325d33dd0db8bcce82342080fc9d856 100644 (file)
@@ -941,6 +941,7 @@ AC_CONFIG_FILES([Makefile]
                [src/native/jvmti/Makefile]
                [src/native/tools/Makefile]
                [src/native/vm/Makefile]
+               [src/native/vm/gnu/Makefile]
                [src/scripts/Makefile]
                [src/scripts/java]
                [src/threads/Makefile]
index 8d90c43b7a64716cb81866bab2b5e3c19f1f9ab5..3ff96f2d842cc26eb2e1095f5b6ff96d3c4ea640 100644 (file)
@@ -29,7 +29,7 @@
             Andreas Krall
             Christian Thalinger
 
-   $Id: native.c 6035 2006-11-21 23:21:18Z twisti $
+   $Id: native.c 6213 2006-12-18 17:36:06Z twisti $
 
 */
 
@@ -1030,30 +1030,41 @@ java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwab
 }
 
 
-/* native_class_getname ********************************************************
+/* native_class_getdeclaredannotations *****************************************
 
-   Implementation for java.lang.Class.getName()Ljava/lang/String;
+   Implementation for
+   java.lang.Class.getDeclaredAnnotations(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
 
 *******************************************************************************/
 
-java_lang_String *native_class_getname(classinfo *c)
+java_objectarray *native_class_getdeclaredannotations(classinfo *c)
 {
-       java_lang_String *s;
-       u4                i;
+       java_objectarray *oa;
+       s4                count;
+       s4                i;
+
+       classinfo *class_java_lang_annotation_Annotation;
+
+       /* create Annotation-array */
 
-       s = (java_lang_String *) javastring_new(c->name);
+       /* XXX should we cache that class? */
+       if (!(class_java_lang_annotation_Annotation =
+                 load_class_bootstrap(utf_new_char("java/lang/annotation/Annotation"))))
+               return NULL;
+
+       count = c->runtimevisibleannotationscount;
 
-       if (s == NULL)
+       oa = builtin_anewarray(count, class_java_lang_annotation_Annotation);
+
+       if (oa == NULL)
                return NULL;
 
-       /* return string where '/' is replaced by '.' */
+       /* fill the annotations */
 
-       for (i = 0; i < s->value->header.size; i++) {
-               if (s->value->data[i] == '/')
-                       s->value->data[i] = '.';
+       for (i = 0; i < count; i++) {
        }
 
-       return s;
+       return oa;
 }
 
 
index 8e0e2968d3338705c78cefc4d89dc1682cb7b3f1..78b7d3980c3f7b1dd0a2fc71c147bedd686bfb48 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: native.h 6035 2006-11-21 23:21:18Z twisti $
+   $Id: native.h 6213 2006-12-18 17:36:06Z twisti $
 
 */
 
@@ -140,8 +140,6 @@ java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
    mainly used for exceptions with cause */
 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t);
 
-java_lang_String *native_class_getname(classinfo *c);
-
 java_objectarray *native_get_parametertypes(methodinfo *m);
 java_objectarray *native_get_exceptiontypes(methodinfo *m);
 classinfo *native_get_returntype(methodinfo *m);
index bdb8baf64e5bf30ae563b316a084c959be3218df..e146ce82e8c12222e79789568b3af83487901ca8 100644 (file)
@@ -26,9 +26,7 @@
 ##
 ## Authors: Christian Thalinger
 ##
-## Changes:
-##
-## $Id: Makefile.am 5558 2006-09-28 19:33:24Z edwin $
+## $Id$
 
 ## Process this file with automake to produce Makefile.in
 
@@ -36,45 +34,23 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top
 
 LIBS =
 
+DIST_SUBDIRS =
+       gnu
+
+SUBDIRS = \
+       gnu
+
+NATIVEVM_LIB = \
+       gnu/libnativevmgnu.la
+
 noinst_LTLIBRARIES = \
        libnativevm.la
 
-if ENABLE_JVMTI
-lib_LTLIBRARIES = \
-       libjdwp.la
-endif
-
 libnativevm_la_SOURCES = \
-       gnu_classpath_VMStackWalker.c \
-       gnu_classpath_VMSystemProperties.c \
-       gnu_java_lang_management_VMClassLoadingMXBeanImpl.c \
-       gnu_java_lang_management_VMMemoryMXBeanImpl.c \
-       gnu_java_lang_management_VMRuntimeMXBeanImpl.c \
-       gnu_java_lang_management_VMThreadMXBeanImpl.c \
-       java_lang_VMClass.c \
-       java_lang_VMClassLoader.c \
-       java_lang_VMObject.c \
-       java_lang_VMRuntime.c \
-       java_lang_VMString.c \
-       java_lang_VMSystem.c \
-       java_lang_VMThread.c \
-       java_lang_VMThrowable.c \
-       java_lang_management_VMManagementFactory.c \
-       java_lang_reflect_Constructor.c \
-       java_lang_reflect_Field.c \
-       java_lang_reflect_Method.c \
-       java_lang_reflect_VMProxy.c \
-       java_security_VMAccessController.c \
-       sun_misc_Unsafe.c
+       java_lang_Class.c
 
-if ENABLE_JVMTI
-libjdwp_la_SOURCES = \
-       gnu_classpath_jdwp_VMFrame.c \
-       gnu_classpath_jdwp_VMMethod.c \
-       gnu_classpath_jdwp_VMVirtualMachine.c \
-       VMjdwp.c \
-       VMjdwp.h
-endif
+libnativevm_la_LIBADD = \
+       $(NATIVEVM_LIB)
 
 
 ## Local variables:
diff --git a/src/native/vm/VMjdwp.c b/src/native/vm/VMjdwp.c
deleted file mode 100644 (file)
index d9dfa40..0000000
+++ /dev/null
@@ -1,533 +0,0 @@
-/* src/native/vm/VMjdwp.c - jvmti->jdwp interface
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Author: Martin Platter
-
-   Changes:             
-
-
-   $Id: VMjdwp.c 5157 2006-07-18 11:09:47Z twisti $
-
-*/
-
-#include "native/jvmti/jvmti.h"
-#include "native/jvmti/VMjdwp.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-void printjvmtierror(char *desc, jvmtiError err) {
-    char* errdesc;
-       
-       if (err == JVMTI_ERROR_NONE) return;
-       (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-       fprintf(stderr,"%s: jvmti error %s\n",desc, errdesc);
-       fflush(stderr);
-       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
-}
-
-
-/* class and method IDs */
-static jclass Jdwpclass, threadstartclass,threadendclass, classprepareclass,   vmmethodclass, locationclass, breakpointclass;
-static jmethodID notifymid, threadstartmid,threadendmid, classpreparemid, 
-       vmmethodmid, locationmid, breakpointmid;
-
-static void notify (JNIEnv* jni_env, jobject event){
-       fprintf(stderr,"VMjdwp notfiy called\n");
-
-       (*jni_env)->CallStaticVoidMethod(jni_env,Jdwpclass,notifymid,event);
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"Exception occourred in notify mehtod\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-       }
-
-}
-
-static void ThreadStart (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
-                         jthread thread){
-       jobject obj;
-
-       obj = (*jni_env)->
-               NewObject(jni_env, threadstartclass, threadstartmid, thread);
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling ThreadStartEvent constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               return;
-       }
-
-       fprintf(stderr,"VMjdwp:ThreadStart: thread %p\n",thread);
-       fflush(stderr);
-
-       notify (jni_env,obj);
-}
-
-
-static void ThreadEnd (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
-                         jthread thread){
-       jobject obj;
-
-
-       obj = (*jni_env)->NewObject(jni_env, threadendclass, threadendmid, thread);
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling ThreadEndEvent constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               return;
-       }
-
-       fprintf(stderr,"VMjdwp:ThreadEnd: thread %p\n",thread);
-       fflush(stderr);
-
-       notify (jni_env,obj);
-}
-
-
-static void ClassPrepare (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
-                                                 jthread thread, jclass klass) {
-       jobject obj;
-       int classstatus;
-       jvmtiError e;
-
-       if (JVMTI_ERROR_NONE != 
-               (e = (*jvmtienv)->GetClassStatus(jvmtienv, klass, &classstatus))) {
-               printjvmtierror("unable to get class status", e);
-               return;
-       }
-
-       obj = (*jni_env)->NewObject(jni_env, classprepareclass, classpreparemid, thread, klass, classstatus);
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling ClassPrepareEvent constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               return;
-       }
-
-       fprintf(stderr,"VMjdwp:ClassPrepareEvent: thread %p\n",thread);
-       fflush(stderr);
-
-       notify (jni_env,obj);
-}
-
-static void Exception (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
-                                          jmethodID method, jlocation location, jobject exception,
-                                          jmethodID catch_method, jlocation catch_location) {
-       /* gnu classpath jdwp has no ExceptionEvent yet */
-       fprintf(stderr,"VMjdwp:Exception: thread %p\n",thread);
-       fflush(stderr);
-       
-}
-
-static void Breakpoint (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
-                                               jmethodID method, jlocation location) {
-       jobject vmmethod, loc, ev;
-       jclass mcl;
-       jvmtiError e;
-
-       if (JVMTI_ERROR_NONE != 
-               (e = (*jvmtienv)->GetMethodDeclaringClass(jvmtienv,
-                                                                          method,
-                                                                          &mcl))){
-               printjvmtierror("unable to get declaring class", e);
-               return;
-       }
-
-       vmmethod = (*jni_env)->NewObject(jni_env, vmmethodclass, vmmethodmid, 
-                                                                        mcl, method);
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling VMMethod constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               return;
-       }
-
-       loc = (*jni_env)->NewObject(jni_env, locationclass, locationmid, 
-                                                                        vmmethod, location);
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling location constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               return;
-       }
-       
-       /* XXX todo: get object instance - needs jvmti local variable support */
-       ev = (*jni_env)->NewObject(jni_env, breakpointclass, breakpointmid, 
-                                                                        thread, loc,NULL);
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling breakpoint constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               return;
-       }
-
-       fprintf(stderr,"VMjdwp:Breakpoint: thread %p\n",thread);
-       fflush(stderr);
-
-       notify (jni_env,ev);    
-}
-
-
-static void MethodEntry (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
-                                                jthread thread, jmethodID method) {
-       /* do not report gnu/classpath/jdwp method entries */
-}
-
-
-static void VMDeath (jvmtiEnv *jvmti_env,
-                     JNIEnv* jni_env) {
-  fprintf(stderr,"JVMTI-Event: IMPLEMENT ME!!!");
-}
-
-
-/* setup_jdwp_thread **********************************************************
-
-   Helper function to start JDWP listening thread
-
-*******************************************************************************/
-
-static void setup_jdwp_thread(JNIEnv* jni_env) {
-       jobject o;
-       jmethodID m;
-       jstring  s;
-
-       /* new gnu.classpath.jdwp.Jdwp() */
-       m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"<init>","()V");
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"could not get Jdwp constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-       
-       o = (*jni_env)->NewObject(jni_env, Jdwpclass, m);
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling Jdwp constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-       jdwpthread = (jthread)o;
-       
-       
-       /* configure(jdwpoptions) */
-       m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"configure",
-                                                               "(Ljava/lang/String;)V");
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"could not get Jdwp configure method\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-       
-       s = (*jni_env)->NewStringUTF(jni_env,jdwpoptions);
-    if (s == NULL) {
-        fprintf(stderr,"could not get new java string from jdwp options\n");
-               exit(1); 
-       }
-
-       free(jdwpoptions);
-       
-       (*jni_env)->CallVoidMethod(jni_env,o,m,s);
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"Exception occourred in Jdwp configure\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-       m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"_doInitialization","()V");
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"could not get Jdwp _doInitialization method\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-
-       (*jni_env)->CallVoidMethod(jni_env,o,m);
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"Exception occourred in Jdwp _doInitialization\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-}
-
-#define FINDCLASSWITHEXCEPTION(CLASS,SIGNATURE) \
-       CLASS = (*jni_env)->FindClass(jni_env, SIGNATURE);     \
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {  \
-               fprintf(stderr,"could not find %s\n", SIGNATURE);  \
-               (*jni_env)->ExceptionDescribe(jni_env);            \
-               exit(1);                                           \
-       }
-#define GETMIDWITHEXCEPTION(CLASS, CLASSNAME, MID, METHODNAME, METHODSIG) \
-       FINDCLASSWITHEXCEPTION(CLASS, CLASSNAME);                             \
-       MID = (*jni_env)->GetMethodID(jni_env, CLASS, METHODNAME, METHODSIG); \
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {                 \
-        fprintf(stderr,"could not get %s %s\n",CLASSNAME, METHODNAME);    \
-               (*jni_env)->ExceptionDescribe(jni_env);                           \
-               exit(1);                                                          \
-       }
-
-
-static void fillidcache(JNIEnv* jni_env) {
-       FINDCLASSWITHEXCEPTION(Jdwpclass, "gnu/classpath/jdwp/Jdwp");
-       
-       notifymid = (*jni_env)->
-        GetStaticMethodID(jni_env,Jdwpclass,
-                                          "notify","(Lgnu/classpath/jdwp/event/Event;)V");
-       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-               fprintf(stderr,"could not get notify method\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-       GETMIDWITHEXCEPTION(threadstartclass, 
-                                               "gnu/classpath/jdwp/event/ThreadStartEvent", 
-                                               threadstartmid, "<init>", "(Ljava/lang/Thread;)V");
-
-
-       GETMIDWITHEXCEPTION(threadendclass, 
-                                               "gnu/classpath/jdwp/event/ThreadEndEvent", 
-                                               threadendmid, "<init>", "(Ljava/lang/Thread;)V");
-
-
-       GETMIDWITHEXCEPTION(classprepareclass, 
-                                               "gnu/classpath/jdwp/event/ClassPrepareEvent", 
-                                               classpreparemid, "<init>", 
-                                               "(Ljava/lang/Thread;Ljava/lang/Class;I)V");
-
-
-       GETMIDWITHEXCEPTION(vmmethodclass, "gnu/classpath/jdwp/VMMethod",
-                                               vmmethodmid, "<init>", "(Ljava/lang/Class;J)V");
-
-       GETMIDWITHEXCEPTION(locationclass, "gnu/classpath/jdwp/util/Location",
-                                               locationmid, "<init>", 
-                                               "(Lgnu/classpath/jdwp/VMMethod;J)V");
-
-
-       GETMIDWITHEXCEPTION(
-               breakpointclass, 
-               "gnu/classpath/jdwp/event/BreakpointEvent", 
-               breakpointmid, "<init>", 
-               "(Ljava/lang/Thread;Lgnu/classpath/jdwp/util/Location;Ljava/lang/Object;)V");
-
-}
-
-static void VMInit (jvmtiEnv *jvmti_env, 
-                    JNIEnv* jni_env,
-                    jthread thread) {
-       jclass cl;
-       jmethodID m;
-       jobject eventobj;
-       jvmtiError err;
-
-       fprintf(stderr,"JDWP VMInit\n");
-
-       /* get needed jmethodIDs and jclasses for callbacks */
-       fillidcache(jni_env);
-
-       /* startup gnu classpath jdwp thread */
-       setup_jdwp_thread(jni_env);
-
-       fprintf(stderr,"JDWP listening thread started\n");
-
-       /* send VmInitEvent */
-    cl = (*jni_env)->FindClass(jni_env, 
-                                                                         "gnu/classpath/jdwp/event/VmInitEvent");
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"could not find class VMInitEvent\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-       m = (*jni_env)->GetMethodID(jni_env,cl,"<init>",
-                                                               "(Ljava/lang/Thread;)V");
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"could not get VmInitEvent constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-       eventobj = (*jni_env)->NewObject(jni_env, cl, m, thread);
-    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
-        fprintf(stderr,"error calling VmInitEvent constructor\n");
-               (*jni_env)->ExceptionDescribe(jni_env);
-               exit(1); 
-       }
-
-
-       notify (jni_env,eventobj);
-
-       if (suspend) {
-               fprintf(stderr,"suspend initial thread\n");
-               err = (*jvmti_env)->SuspendThread(jvmti_env,thread);
-               printjvmtierror("error suspending initial thread",err);
-       }
-}
-
-static void usage() {  
-       puts("usage jdwp:[help]|(<option>=<value>),*");
-       puts("   transport=[dt_socket|...]");
-       puts("   address=<hostname:port>");
-       puts("   server=[y|n]");
-       puts("   suspend=[y|n]");
-}
-
-static bool processoptions(char *options) {
-       int i,len;
-       
-       if (strncmp(options,"help",4) == 0) {
-               usage();
-               return false;
-       }
-
-       suspend = true;         /* default value */
-
-
-       /* copy options for later use in java jdwp listen thread configure */
-       jdwpoptions = malloc(sizeof(char)*strlen(options));
-       strncpy(jdwpoptions, options, sizeof(char)*strlen(options));
-
-       len = strlen(options);
-       
-       i=0;
-       while (i<len) {
-               if (strncmp("suspend=",&options[i],8)==0) {
-                       if (8>=strlen(&options[i])) {
-                               if ((options[i+8]== 'y') || (options[i+8]== 'n')) {
-                                       suspend = options[i+8]== 'y';
-                               } else {
-                                       printf("jdwp error argument: %s\n",options);
-                                       usage();
-                                       return -1;
-                               }
-                       }
-               } else {
-                       /* these options will be handled by jdwp java configure */
-                       if ((strncmp("transport=",options,10)==0) ||
-                               (strncmp("server=",options,7)==0)) {
-                       } else {
-                               printf("jdwp unkown argument: %s\n",options);
-                               usage();
-                               return false;
-                       }
-               }
-               while ((options[i]!=',')&&(i<len)) i++;
-               i++;
-       }
-       return true;    
-}
-
-
-JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { 
-       jint rc;
-       jvmtiCapabilities cap;
-       jvmtiError e;
-
-
-       fprintf(stderr,"jdwp Agent_OnLoad options: %s\n",options);
-       if (!processoptions(options)) return -1;
-       
-       rc = (*vm)->GetEnv(vm, (void**)&jvmtienv, JVMTI_VERSION_1_0);
-       if (rc != JNI_OK) {         
-               fprintf(stderr, "jdwp: Unable to get jvmtiEnv error=%d\n", rc);
-               return -1;              
-       }
-       
-       /* set eventcallbacks */
-       if (JVMTI_ERROR_NONE != 
-               (e = (*jvmtienv)->SetEventCallbacks(jvmtienv,
-                                                                          &jvmti_jdwp_EventCallbacks,
-                                                                          sizeof(jvmtiEventCallbacks)))){
-               printjvmtierror("jdwp: unable to setup event callbacks", e);
-               return -1;
-       }
-
-       e = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &cap);
-       printjvmtierror("jdwp: unable to get potential capabilities", e);
-       if (e == JVMTI_ERROR_NONE) 
-               e = (*jvmtienv)->AddCapabilities(jvmtienv, &cap);
-       if (e != JVMTI_ERROR_NONE) {
-               printjvmtierror("jdwp: error adding jvmti capabilities", e);
-               return -1;
-       }
-       
-       /* only enable needed events. VMVirtualMachine.registerEvent will  
-          be used to enable other events by need */
-       if (JVMTI_ERROR_NONE != (e = (*jvmtienv)->
-                                                        SetEventNotificationMode(jvmtienv, JVMTI_ENABLE,
-                                                                                                         JVMTI_EVENT_VM_INIT, 
-                                                                                                         NULL))) {
-               printjvmtierror("jdwp unable to enable vm init callback",e);
-               return -1;
-       }
-
-       return 0;
-}
-       
-
-jvmtiEventCallbacks jvmti_jdwp_EventCallbacks = {
-    &VMInit,
-    &VMDeath,
-    &ThreadStart,
-    &ThreadEnd,
-    NULL, /* &ClassFileLoadHook, */
-    NULL, /* &ClassLoad, */
-    &ClassPrepare,
-    NULL, /* &VMStart */
-    &Exception,
-    NULL, /* &ExceptionCatch, */
-    NULL, /* &SingleStep, */
-    NULL, /* &FramePop, */
-    &Breakpoint,
-    NULL, /* &FieldAccess, */
-    NULL, /* &FieldModification, */
-    &MethodEntry,
-    NULL, /* &MethodExit, */
-    NULL, /* &NativeMethodBind, */
-    NULL, /* &CompiledMethodLoad, */
-    NULL, /* &CompiledMethodUnload, */
-    NULL, /* &DynamicCodeGenerated, */
-    NULL, /* &DataDumpRequest, */
-    NULL,
-    NULL, /* &MonitorWait, */
-    NULL, /* &MonitorWaited, */
-    NULL, /* &MonitorContendedEnter, */
-    NULL, /* &MonitorContendedEntered, */
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL, /* &GarbageCollectionStart, */
-    NULL, /* &GarbageCollectionFinish, */
-    NULL, /* &ObjectFree, */
-    NULL, /* &VMObjectAlloc, */
-};
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/VMjdwp.h b/src/native/vm/VMjdwp.h
deleted file mode 100644 (file)
index 5cb12e9..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* src/native/vm/VMjdwp.c - jvmti->jdwp interface
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Author: Martin Platter
-
-   Changes:             
-
-
-   $Id: VMjdwp.c 4661 2006-03-21 00:04:59Z motse $
-
-*/
-
-#ifndef _VMJDWP_H
-#define _VMJDWP_H
-
-#include "native/jvmti/jvmti.h"
-
-jvmtiEnv* jvmtienv;
-extern jvmtiEventCallbacks jvmti_jdwp_EventCallbacks;
-char* jdwpoptions;
-bool suspend;               /* should the virtual machine suspend on startup?  */
-jthread jdwpthread;
-
-void printjvmtierror(char *desc, jvmtiError err);
-#endif
diff --git a/src/native/vm/gnu/Makefile.am b/src/native/vm/gnu/Makefile.am
new file mode 100644 (file)
index 0000000..619bd68
--- /dev/null
@@ -0,0 +1,84 @@
+## src/native/vm/gnu/Makefile.am
+##
+## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+## J. Wenninger, Institut f. Computersprachen - TU Wien
+##
+## This file is part of CACAO.
+##
+## This program 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.
+##
+## This program 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 this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+##
+## Contact: cacao@cacaojvm.org
+##
+## Authors: Christian Thalinger
+##
+## $Id: Makefile.am 6213 2006-12-18 17:36:06Z twisti $
+
+## Process this file with automake to produce Makefile.in
+
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src
+
+LIBS =
+
+noinst_LTLIBRARIES = \
+       libnativevmgnu.la
+
+if ENABLE_JVMTI
+lib_LTLIBRARIES = \
+       libjdwp.la
+endif
+
+libnativevmgnu_la_SOURCES = \
+       gnu_classpath_VMStackWalker.c \
+       gnu_classpath_VMSystemProperties.c \
+       gnu_java_lang_management_VMClassLoadingMXBeanImpl.c \
+       gnu_java_lang_management_VMMemoryMXBeanImpl.c \
+       gnu_java_lang_management_VMRuntimeMXBeanImpl.c \
+       gnu_java_lang_management_VMThreadMXBeanImpl.c \
+       java_lang_VMClass.c \
+       java_lang_VMClassLoader.c \
+       java_lang_VMObject.c \
+       java_lang_VMRuntime.c \
+       java_lang_VMString.c \
+       java_lang_VMSystem.c \
+       java_lang_VMThread.c \
+       java_lang_VMThrowable.c \
+       java_lang_management_VMManagementFactory.c \
+       java_lang_reflect_Constructor.c \
+       java_lang_reflect_Field.c \
+       java_lang_reflect_Method.c \
+       java_lang_reflect_VMProxy.c \
+       java_security_VMAccessController.c \
+       sun_misc_Unsafe.c
+
+if ENABLE_JVMTI
+libjdwp_la_SOURCES = \
+       gnu_classpath_jdwp_VMFrame.c \
+       gnu_classpath_jdwp_VMMethod.c \
+       gnu_classpath_jdwp_VMVirtualMachine.c \
+       VMjdwp.c \
+       VMjdwp.h
+endif
+
+
+## Local variables:
+## mode: Makefile
+## indent-tabs-mode: t
+## c-basic-offset: 4
+## tab-width: 8
+## compile-command: "automake --add-missing"
+## End:
diff --git a/src/native/vm/gnu/VMjdwp.c b/src/native/vm/gnu/VMjdwp.c
new file mode 100644 (file)
index 0000000..5e4d746
--- /dev/null
@@ -0,0 +1,533 @@
+/* src/native/vm/VMjdwp.c - jvmti->jdwp interface
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Author: Martin Platter
+
+   Changes:             
+
+
+   $Id: VMjdwp.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+#include "native/jvmti/jvmti.h"
+#include "native/jvmti/VMjdwp.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+void printjvmtierror(char *desc, jvmtiError err) {
+    char* errdesc;
+       
+       if (err == JVMTI_ERROR_NONE) return;
+       (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
+       fprintf(stderr,"%s: jvmti error %s\n",desc, errdesc);
+       fflush(stderr);
+       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+}
+
+
+/* class and method IDs */
+static jclass Jdwpclass, threadstartclass,threadendclass, classprepareclass,   vmmethodclass, locationclass, breakpointclass;
+static jmethodID notifymid, threadstartmid,threadendmid, classpreparemid, 
+       vmmethodmid, locationmid, breakpointmid;
+
+static void notify (JNIEnv* jni_env, jobject event){
+       fprintf(stderr,"VMjdwp notfiy called\n");
+
+       (*jni_env)->CallStaticVoidMethod(jni_env,Jdwpclass,notifymid,event);
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"Exception occourred in notify mehtod\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+       }
+
+}
+
+static void ThreadStart (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                         jthread thread){
+       jobject obj;
+
+       obj = (*jni_env)->
+               NewObject(jni_env, threadstartclass, threadstartmid, thread);
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling ThreadStartEvent constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               return;
+       }
+
+       fprintf(stderr,"VMjdwp:ThreadStart: thread %p\n",thread);
+       fflush(stderr);
+
+       notify (jni_env,obj);
+}
+
+
+static void ThreadEnd (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                         jthread thread){
+       jobject obj;
+
+
+       obj = (*jni_env)->NewObject(jni_env, threadendclass, threadendmid, thread);
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling ThreadEndEvent constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               return;
+       }
+
+       fprintf(stderr,"VMjdwp:ThreadEnd: thread %p\n",thread);
+       fflush(stderr);
+
+       notify (jni_env,obj);
+}
+
+
+static void ClassPrepare (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                                                 jthread thread, jclass klass) {
+       jobject obj;
+       int classstatus;
+       jvmtiError e;
+
+       if (JVMTI_ERROR_NONE != 
+               (e = (*jvmtienv)->GetClassStatus(jvmtienv, klass, &classstatus))) {
+               printjvmtierror("unable to get class status", e);
+               return;
+       }
+
+       obj = (*jni_env)->NewObject(jni_env, classprepareclass, classpreparemid, thread, klass, classstatus);
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling ClassPrepareEvent constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               return;
+       }
+
+       fprintf(stderr,"VMjdwp:ClassPrepareEvent: thread %p\n",thread);
+       fflush(stderr);
+
+       notify (jni_env,obj);
+}
+
+static void Exception (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
+                                          jmethodID method, jlocation location, jobject exception,
+                                          jmethodID catch_method, jlocation catch_location) {
+       /* gnu classpath jdwp has no ExceptionEvent yet */
+       fprintf(stderr,"VMjdwp:Exception: thread %p\n",thread);
+       fflush(stderr);
+       
+}
+
+static void Breakpoint (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
+                                               jmethodID method, jlocation location) {
+       jobject vmmethod, loc, ev;
+       jclass mcl;
+       jvmtiError e;
+
+       if (JVMTI_ERROR_NONE != 
+               (e = (*jvmtienv)->GetMethodDeclaringClass(jvmtienv,
+                                                                          method,
+                                                                          &mcl))){
+               printjvmtierror("unable to get declaring class", e);
+               return;
+       }
+
+       vmmethod = (*jni_env)->NewObject(jni_env, vmmethodclass, vmmethodmid, 
+                                                                        mcl, method);
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling VMMethod constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               return;
+       }
+
+       loc = (*jni_env)->NewObject(jni_env, locationclass, locationmid, 
+                                                                        vmmethod, location);
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling location constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               return;
+       }
+       
+       /* XXX todo: get object instance - needs jvmti local variable support */
+       ev = (*jni_env)->NewObject(jni_env, breakpointclass, breakpointmid, 
+                                                                        thread, loc,NULL);
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling breakpoint constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               return;
+       }
+
+       fprintf(stderr,"VMjdwp:Breakpoint: thread %p\n",thread);
+       fflush(stderr);
+
+       notify (jni_env,ev);    
+}
+
+
+static void MethodEntry (jvmtiEnv *jvmti_env, JNIEnv* jni_env,
+                                                jthread thread, jmethodID method) {
+       /* do not report gnu/classpath/jdwp method entries */
+}
+
+
+static void VMDeath (jvmtiEnv *jvmti_env,
+                     JNIEnv* jni_env) {
+  fprintf(stderr,"JVMTI-Event: IMPLEMENT ME!!!");
+}
+
+
+/* setup_jdwp_thread **********************************************************
+
+   Helper function to start JDWP listening thread
+
+*******************************************************************************/
+
+static void setup_jdwp_thread(JNIEnv* jni_env) {
+       jobject o;
+       jmethodID m;
+       jstring  s;
+
+       /* new gnu.classpath.jdwp.Jdwp() */
+       m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"<init>","()V");
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"could not get Jdwp constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+       
+       o = (*jni_env)->NewObject(jni_env, Jdwpclass, m);
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling Jdwp constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+       jdwpthread = (jthread)o;
+       
+       
+       /* configure(jdwpoptions) */
+       m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"configure",
+                                                               "(Ljava/lang/String;)V");
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"could not get Jdwp configure method\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+       
+       s = (*jni_env)->NewStringUTF(jni_env,jdwpoptions);
+    if (s == NULL) {
+        fprintf(stderr,"could not get new java string from jdwp options\n");
+               exit(1); 
+       }
+
+       free(jdwpoptions);
+       
+       (*jni_env)->CallVoidMethod(jni_env,o,m,s);
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"Exception occourred in Jdwp configure\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+       m = (*jni_env)->GetMethodID(jni_env,Jdwpclass,"_doInitialization","()V");
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"could not get Jdwp _doInitialization method\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+
+       (*jni_env)->CallVoidMethod(jni_env,o,m);
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"Exception occourred in Jdwp _doInitialization\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+}
+
+#define FINDCLASSWITHEXCEPTION(CLASS,SIGNATURE) \
+       CLASS = (*jni_env)->FindClass(jni_env, SIGNATURE);     \
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {  \
+               fprintf(stderr,"could not find %s\n", SIGNATURE);  \
+               (*jni_env)->ExceptionDescribe(jni_env);            \
+               exit(1);                                           \
+       }
+#define GETMIDWITHEXCEPTION(CLASS, CLASSNAME, MID, METHODNAME, METHODSIG) \
+       FINDCLASSWITHEXCEPTION(CLASS, CLASSNAME);                             \
+       MID = (*jni_env)->GetMethodID(jni_env, CLASS, METHODNAME, METHODSIG); \
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {                 \
+        fprintf(stderr,"could not get %s %s\n",CLASSNAME, METHODNAME);    \
+               (*jni_env)->ExceptionDescribe(jni_env);                           \
+               exit(1);                                                          \
+       }
+
+
+static void fillidcache(JNIEnv* jni_env) {
+       FINDCLASSWITHEXCEPTION(Jdwpclass, "gnu/classpath/jdwp/Jdwp");
+       
+       notifymid = (*jni_env)->
+        GetStaticMethodID(jni_env,Jdwpclass,
+                                          "notify","(Lgnu/classpath/jdwp/event/Event;)V");
+       if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+               fprintf(stderr,"could not get notify method\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+       GETMIDWITHEXCEPTION(threadstartclass, 
+                                               "gnu/classpath/jdwp/event/ThreadStartEvent", 
+                                               threadstartmid, "<init>", "(Ljava/lang/Thread;)V");
+
+
+       GETMIDWITHEXCEPTION(threadendclass, 
+                                               "gnu/classpath/jdwp/event/ThreadEndEvent", 
+                                               threadendmid, "<init>", "(Ljava/lang/Thread;)V");
+
+
+       GETMIDWITHEXCEPTION(classprepareclass, 
+                                               "gnu/classpath/jdwp/event/ClassPrepareEvent", 
+                                               classpreparemid, "<init>", 
+                                               "(Ljava/lang/Thread;Ljava/lang/Class;I)V");
+
+
+       GETMIDWITHEXCEPTION(vmmethodclass, "gnu/classpath/jdwp/VMMethod",
+                                               vmmethodmid, "<init>", "(Ljava/lang/Class;J)V");
+
+       GETMIDWITHEXCEPTION(locationclass, "gnu/classpath/jdwp/util/Location",
+                                               locationmid, "<init>", 
+                                               "(Lgnu/classpath/jdwp/VMMethod;J)V");
+
+
+       GETMIDWITHEXCEPTION(
+               breakpointclass, 
+               "gnu/classpath/jdwp/event/BreakpointEvent", 
+               breakpointmid, "<init>", 
+               "(Ljava/lang/Thread;Lgnu/classpath/jdwp/util/Location;Ljava/lang/Object;)V");
+
+}
+
+static void VMInit (jvmtiEnv *jvmti_env, 
+                    JNIEnv* jni_env,
+                    jthread thread) {
+       jclass cl;
+       jmethodID m;
+       jobject eventobj;
+       jvmtiError err;
+
+       fprintf(stderr,"JDWP VMInit\n");
+
+       /* get needed jmethodIDs and jclasses for callbacks */
+       fillidcache(jni_env);
+
+       /* startup gnu classpath jdwp thread */
+       setup_jdwp_thread(jni_env);
+
+       fprintf(stderr,"JDWP listening thread started\n");
+
+       /* send VmInitEvent */
+    cl = (*jni_env)->FindClass(jni_env, 
+                                                                         "gnu/classpath/jdwp/event/VmInitEvent");
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"could not find class VMInitEvent\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+       m = (*jni_env)->GetMethodID(jni_env,cl,"<init>",
+                                                               "(Ljava/lang/Thread;)V");
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"could not get VmInitEvent constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+       eventobj = (*jni_env)->NewObject(jni_env, cl, m, thread);
+    if ((*jni_env)->ExceptionOccurred(jni_env) != NULL) {
+        fprintf(stderr,"error calling VmInitEvent constructor\n");
+               (*jni_env)->ExceptionDescribe(jni_env);
+               exit(1); 
+       }
+
+
+       notify (jni_env,eventobj);
+
+       if (suspend) {
+               fprintf(stderr,"suspend initial thread\n");
+               err = (*jvmti_env)->SuspendThread(jvmti_env,thread);
+               printjvmtierror("error suspending initial thread",err);
+       }
+}
+
+static void usage() {  
+       puts("usage jdwp:[help]|(<option>=<value>),*");
+       puts("   transport=[dt_socket|...]");
+       puts("   address=<hostname:port>");
+       puts("   server=[y|n]");
+       puts("   suspend=[y|n]");
+}
+
+static bool processoptions(char *options) {
+       int i,len;
+       
+       if (strncmp(options,"help",4) == 0) {
+               usage();
+               return false;
+       }
+
+       suspend = true;         /* default value */
+
+
+       /* copy options for later use in java jdwp listen thread configure */
+       jdwpoptions = malloc(sizeof(char)*strlen(options));
+       strncpy(jdwpoptions, options, sizeof(char)*strlen(options));
+
+       len = strlen(options);
+       
+       i=0;
+       while (i<len) {
+               if (strncmp("suspend=",&options[i],8)==0) {
+                       if (8>=strlen(&options[i])) {
+                               if ((options[i+8]== 'y') || (options[i+8]== 'n')) {
+                                       suspend = options[i+8]== 'y';
+                               } else {
+                                       printf("jdwp error argument: %s\n",options);
+                                       usage();
+                                       return -1;
+                               }
+                       }
+               } else {
+                       /* these options will be handled by jdwp java configure */
+                       if ((strncmp("transport=",options,10)==0) ||
+                               (strncmp("server=",options,7)==0)) {
+                       } else {
+                               printf("jdwp unkown argument: %s\n",options);
+                               usage();
+                               return false;
+                       }
+               }
+               while ((options[i]!=',')&&(i<len)) i++;
+               i++;
+       }
+       return true;    
+}
+
+
+JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { 
+       jint rc;
+       jvmtiCapabilities cap;
+       jvmtiError e;
+
+
+       fprintf(stderr,"jdwp Agent_OnLoad options: %s\n",options);
+       if (!processoptions(options)) return -1;
+       
+       rc = (*vm)->GetEnv(vm, (void**)&jvmtienv, JVMTI_VERSION_1_0);
+       if (rc != JNI_OK) {         
+               fprintf(stderr, "jdwp: Unable to get jvmtiEnv error=%d\n", rc);
+               return -1;              
+       }
+       
+       /* set eventcallbacks */
+       if (JVMTI_ERROR_NONE != 
+               (e = (*jvmtienv)->SetEventCallbacks(jvmtienv,
+                                                                          &jvmti_jdwp_EventCallbacks,
+                                                                          sizeof(jvmtiEventCallbacks)))){
+               printjvmtierror("jdwp: unable to setup event callbacks", e);
+               return -1;
+       }
+
+       e = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &cap);
+       printjvmtierror("jdwp: unable to get potential capabilities", e);
+       if (e == JVMTI_ERROR_NONE) 
+               e = (*jvmtienv)->AddCapabilities(jvmtienv, &cap);
+       if (e != JVMTI_ERROR_NONE) {
+               printjvmtierror("jdwp: error adding jvmti capabilities", e);
+               return -1;
+       }
+       
+       /* only enable needed events. VMVirtualMachine.registerEvent will  
+          be used to enable other events by need */
+       if (JVMTI_ERROR_NONE != (e = (*jvmtienv)->
+                                                        SetEventNotificationMode(jvmtienv, JVMTI_ENABLE,
+                                                                                                         JVMTI_EVENT_VM_INIT, 
+                                                                                                         NULL))) {
+               printjvmtierror("jdwp unable to enable vm init callback",e);
+               return -1;
+       }
+
+       return 0;
+}
+       
+
+jvmtiEventCallbacks jvmti_jdwp_EventCallbacks = {
+    &VMInit,
+    &VMDeath,
+    &ThreadStart,
+    &ThreadEnd,
+    NULL, /* &ClassFileLoadHook, */
+    NULL, /* &ClassLoad, */
+    &ClassPrepare,
+    NULL, /* &VMStart */
+    &Exception,
+    NULL, /* &ExceptionCatch, */
+    NULL, /* &SingleStep, */
+    NULL, /* &FramePop, */
+    &Breakpoint,
+    NULL, /* &FieldAccess, */
+    NULL, /* &FieldModification, */
+    &MethodEntry,
+    NULL, /* &MethodExit, */
+    NULL, /* &NativeMethodBind, */
+    NULL, /* &CompiledMethodLoad, */
+    NULL, /* &CompiledMethodUnload, */
+    NULL, /* &DynamicCodeGenerated, */
+    NULL, /* &DataDumpRequest, */
+    NULL,
+    NULL, /* &MonitorWait, */
+    NULL, /* &MonitorWaited, */
+    NULL, /* &MonitorContendedEnter, */
+    NULL, /* &MonitorContendedEntered, */
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL, /* &GarbageCollectionStart, */
+    NULL, /* &GarbageCollectionFinish, */
+    NULL, /* &ObjectFree, */
+    NULL, /* &VMObjectAlloc, */
+};
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/VMjdwp.h b/src/native/vm/gnu/VMjdwp.h
new file mode 100644 (file)
index 0000000..5cb12e9
--- /dev/null
@@ -0,0 +1,48 @@
+/* src/native/vm/VMjdwp.c - jvmti->jdwp interface
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Author: Martin Platter
+
+   Changes:             
+
+
+   $Id: VMjdwp.c 4661 2006-03-21 00:04:59Z motse $
+
+*/
+
+#ifndef _VMJDWP_H
+#define _VMJDWP_H
+
+#include "native/jvmti/jvmti.h"
+
+jvmtiEnv* jvmtienv;
+extern jvmtiEventCallbacks jvmti_jdwp_EventCallbacks;
+char* jdwpoptions;
+bool suspend;               /* should the virtual machine suspend on startup?  */
+jthread jdwpthread;
+
+void printjvmtierror(char *desc, jvmtiError err);
+#endif
diff --git a/src/native/vm/gnu/gnu_classpath_VMStackWalker.c b/src/native/vm/gnu/gnu_classpath_VMStackWalker.c
new file mode 100644 (file)
index 0000000..1e0c941
--- /dev/null
@@ -0,0 +1,151 @@
+/* src/native/vm/gnu_classpath_VMStackWalker.c - gnu/classpath/VMStackWalker
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes: Edwin Steiner
+
+   $Id: gnu_classpath_VMStackWalker.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/global.h"
+#include "vm/options.h"
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getClassContext
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
+{
+       java_objectarray *oa;
+
+       oa = stacktrace_getClassContext();
+
+       return oa;
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getCallingClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
+{
+       java_objectarray *oa;
+
+       oa = stacktrace_getClassContext();
+
+       if (oa == NULL)
+               return NULL;
+
+       if (oa->header.size < 2)
+               return NULL;
+
+       return (java_lang_Class *) oa->data[1];
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getCallingClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
+{
+       java_objectarray  *oa;
+       classinfo         *c;
+       java_objectheader *cl;
+
+       oa = stacktrace_getClassContext();
+
+       if (oa == NULL)
+               return NULL;
+
+       if (oa->header.size < 2)
+               return NULL;
+        
+       c  = (classinfo *) oa->data[1];
+       cl = c->classloader;
+
+       return (java_lang_ClassLoader *) cl;
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    firstNonNullClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
+{
+       java_objectarray  *oa;
+       classinfo         *c;
+       java_objectheader *cl;
+       s4                 i;
+
+       oa = stacktrace_getClassContext();
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0; i < oa->header.size; i++) {
+               c  = (classinfo *) oa->data[i];
+               cl = c->classloader;
+
+               if (cl != NULL)
+                       return (java_lang_ClassLoader *) cl;
+       }
+
+       return NULL;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/gnu_classpath_VMSystemProperties.c b/src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
new file mode 100644 (file)
index 0000000..01f9a44
--- /dev/null
@@ -0,0 +1,76 @@
+/* src/native/vm/VMSystemProperties.c - gnu/classpath/VMSystemProperties
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   $Id: gnu_classpath_VMSystemProperties.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_util_Properties.h"
+#include "vm/exceptions.h"
+#include "vm/properties.h"
+
+
+/*
+ * Class:     gnu/classpath/VMSystemProperties
+ * Method:    preInit
+ * Signature: (Ljava/util/Properties;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *p)
+{
+       if (p == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* add all properties */
+
+       properties_system_add_all(p);
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c b/src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c
new file mode 100644 (file)
index 0000000..69e5b91
--- /dev/null
@@ -0,0 +1,60 @@
+/* src/native/vm/VMFrame.c - jdwp->jvmti interface
+
+Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+J. Wenninger, Institut f. Computersprachen - TU Wien
+
+This file is part of CACAO.
+
+This program 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.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.
+
+Contact: cacao@cacaojvm.org
+
+Authors: Martin Platter
+
+Changes: 
+
+
+$Id: gnu_classpath_jdwp_VMFrame.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+#include "toolbox/logging.h"
+#include "native/jni.h"
+#include "native/include/gnu_classpath_jdwp_VMFrame.h"
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMFrame
+ * Method:    getValue
+ * Signature: (I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_gnu_classpath_jdwp_VMFrame_getValue(JNIEnv *env, struct gnu_classpath_jdwp_VMFrame* this, s4 par1) {
+    log_text ("JVMTI-Call: IMPLEMENT ME!!!");
+    return 0;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMFrame
+ * Method:    setValue
+ * Signature: (ILjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMFrame_setValue(JNIEnv *env, struct gnu_classpath_jdwp_VMFrame* this, s4 par1, struct java_lang_Object* par2) {
+    log_text ("JVMTI-Call: IMPLEMENT ME!!!");
+       return 0;
+}
diff --git a/src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c b/src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c
new file mode 100644 (file)
index 0000000..8dbbfac
--- /dev/null
@@ -0,0 +1,330 @@
+/* src/native/vm/VMMethod.c - jdwp->jvmti interface
+
+Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+J. Wenninger, Institut f. Computersprachen - TU Wien
+
+This file is part of CACAO.
+
+This program 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.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.
+
+Contact: cacao@cacaojvm.org
+
+Authors: Samuel Vinson
+         Martin Platter
+         
+
+Changes: 
+
+
+$Id: VMMethod.c $
+
+*/
+
+#include "native/jni.h"
+#include "native/include/gnu_classpath_jdwp_VMMethod.h"
+#include "native/jvmti/jvmti.h"
+#include "native/jvmti/VMjdwp.h"
+
+
+void printjvmtierror(char *desc, jvmtiError err) {
+    char* errdesc;
+       
+       if (err == JVMTI_ERROR_NONE) return;
+       (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
+       fprintf(stderr,"%s: jvmti error %s\n",desc, errdesc);
+       fflush(stderr);
+       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
+}
+
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMMethod
+ * Method:    getName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getName(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
+{
+    jvmtiError err;
+    char *name;
+    jstring stringname;
+    
+    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
+                             GetMethodName(jvmtienv, 
+                                                                                  (jmethodID)(long)this->_methodId,
+                                           &name,NULL, NULL))) {
+               printjvmtierror("VMMethod.getName GetMethodName",err);
+        return NULL;
+    }
+    
+    stringname = (*env)->NewStringUTF(env,name);
+    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)name);
+
+    return stringname;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMMethod
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getSignature(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
+{
+    jvmtiError err;
+    char *signature;
+    jstring stringsignature;
+    
+    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
+                             GetMethodName(jvmtienv, 
+                                                                                  (jmethodID)(long)this->_methodId,
+                                           NULL, &signature, NULL))) {
+               printjvmtierror("VMMethod.getSignature GetMethodName",err);
+        return NULL;
+    }
+    
+    stringsignature = (*env)->NewStringUTF(env,signature);
+    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)signature);
+    
+    return stringsignature;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMMethod
+ * Method:    getModifiers
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMMethod_getModifiers(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
+{
+    jvmtiError err;
+    jint modifiers;
+       
+    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
+                                                  GetMethodModifiers(jvmtienv, 
+                                                                                         (jmethodID)(long)this->_methodId,
+                                                                                         &modifiers))) {
+               printjvmtierror("VMMethod.getModifiers GetMethodModifiers",err);
+        return 0;
+    }
+    
+    return modifiers;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMMethod
+ * Method:    getLineTable
+ * Signature: ()Lgnu/classpath/jdwp/util/LineTable;
+ */
+JNIEXPORT struct gnu_classpath_jdwp_util_LineTable* JNICALL Java_gnu_classpath_jdwp_VMMethod_getLineTable(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
+{
+    jclass cl;
+    jmethodID m;
+    jobject ol;
+    jlongArray jlineCI;
+    jintArray jlineNum;
+    jint count = 0, i;
+    int *lineNum;
+    long *lineCI;
+    jvmtiLineNumberEntry *lne;
+    jlocation start,end;
+    
+    jvmtiError err;
+
+    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
+                                                  GetLineNumberTable(jvmtienv, 
+                                                                                         (jmethodID)(long)this->_methodId,
+                                                                                         &count, &lne))) {
+               printjvmtierror("VMMethod.getlinetable GetLineNumberTable",err);
+        return NULL;
+    }
+
+    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.util.LineTable");
+    if (!cl) return NULL;
+
+    m = (*env)->GetMethodID(env, cl, "<init>", "(JJ[I[J)V");
+    if (!m) return NULL;
+       
+    jlineNum = (*env)->NewIntArray(env, count);
+    if (!jlineNum) return NULL;
+    jlineCI = (*env)->NewLongArray(env, count);
+    if (!jlineCI) return NULL;
+    lineNum = (*env)->GetIntArrayElements(env, jlineNum, NULL);
+    lineCI = (*env)->GetLongArrayElements(env, jlineCI, NULL);
+    for (i = 0; i < count; ++i) {
+        lineNum[i] = lne[i].line_number;
+        lineCI[i] = lne[i].start_location;
+    }
+    (*env)->ReleaseLongArrayElements(env, jlineCI, lineCI, 0);
+    (*env)->ReleaseIntArrayElements(env, jlineNum, lineNum, 0);
+    (*jvmtienv)->Deallocate(jvmtienv, lne);
+
+    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
+                                                  GetMethodLocation(jvmtienv, 
+                                                                                        (jmethodID)(long)this->_methodId, 
+                                                                                        &start, &end))) {
+               printjvmtierror("VMMethod.getlinetable GetMethodLocation",err);
+        return NULL;
+    }
+
+    ol = (*env)->NewObject(env, cl, m, start, 
+                           end, jlineNum, jlineCI);
+
+    return (struct gnu_classpath_jdwp_util_LineTable*)ol;
+}
+
+static bool fillVariableTable(JNIEnv *env, jvmtiLocalVariableEntry* entries, 
+                                                         int count, jlongArray *jlineCI, 
+                                                         jobjectArray *names, jobjectArray *sigs, 
+                                                         jintArray *jlengths, jintArray *jslot) {
+       jint *lengths, *slot,i;
+       jclass cl;
+       jlong *lineCI;
+
+       *jlineCI = (*env)->NewLongArray(env, count);
+       if (!*jlineCI) return false;
+
+       cl=(*env)->FindClass(env,"java/lang/String");
+       if (!cl) return false;
+       
+       *names = (*env)->NewObjectArray(env, count, cl, NULL);
+       if (names) return false;
+       sigs = (*env)->NewObjectArray(env, count, cl, NULL);
+       if (sigs) return false;
+       
+       jlengths = (*env)->NewIntArray(env, count);
+       if (!lengths) return false;
+       
+       jslot = (*env)->NewIntArray(env, count);
+       if (!slot) return false;
+       
+       lineCI = (*env)->GetLongArrayElements(env, *jlineCI, NULL);
+       lengths = (*env)->GetIntArrayElements(env, *jlengths, NULL);
+       slot = (*env)->GetIntArrayElements(env, jslot, NULL);
+       
+       for (i=0; i<count; i++) {
+               (*env)->
+                       SetObjectArrayElement(env, *names, i, 
+                                                                 (*env)->NewStringUTF(env,entries[i].name));
+               (*env)->
+                       SetObjectArrayElement(env, *sigs, i, (*env)->NewStringUTF(
+                                                                         env,entries[i].signature));
+               lineCI[i]=entries[i].start_location;
+               lengths[i]=entries[i].length;
+               slot[i]=entries[i].slot;
+       }
+    (*env)->ReleaseLongArrayElements(env, jlineCI, lineCI, 0);
+    (*env)->ReleaseIntArrayElements(env, jlengths, lengths, 0);
+    (*env)->ReleaseIntArrayElements(env, jslot, slot, 0);
+       return true;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMMethod
+ * Method:    getVariableTable
+ * Signature: ()Lgnu/classpath/jdwp/util/VariableTable;
+ */
+JNIEXPORT struct gnu_classpath_jdwp_util_VariableTable* JNICALL Java_gnu_classpath_jdwp_VMMethod_getVariableTable(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
+{
+       jvmtiLocalVariableEntry* localvarentries;
+       jint entry_count, argCnt, slots; 
+       jclass cl;
+       jmethodID m, vmmethodid;
+    jobject o;
+       jobjectArray names, sigs;
+    jvmtiError err;
+    jlongArray jlineCI;
+       jintArray jlengths, jslot;
+
+       vmmethodid = (jmethodID)(long)this->_methodId;
+
+       err= (*jvmtienv)->GetLocalVariableTable(jvmtienv, 
+                                                                                       vmmethodid,
+                                                                                       &entry_count, 
+                                                                                       &localvarentries);
+    if (JVMTI_ERROR_NONE != err) { 
+               if (err == JVMTI_ERROR_ABSENT_INFORMATION) {
+                       /* no local variable table available for this method. 
+                          return an empty local variable table */
+                       argCnt = slots = 0;
+                       names = sigs = jlineCI = jlengths = jslot = NULL;
+               } else {
+                       printjvmtierror("VMMethod.getVariableTable GetLocalVariableTable",err);
+                       return NULL;
+               }
+       } else {
+               if (JVMTI_ERROR_NONE != (err= 
+                                                                (*jvmtienv)->GetArgumentsSize(jvmtienv, 
+                                                                                                                          vmmethodid, 
+                                                                                                                          &argCnt))) {
+                       printjvmtierror("VMMethod.getVariableTable GetArgumentsSize",err);
+                       return NULL;
+               }
+
+               if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->GetMaxLocals(jvmtienv, 
+                                                                                                                               vmmethodid,
+                                                                                                                               &slots))) {
+                       printjvmtierror("VMMethod.getVariableTable GetMaxLocals",err);
+                       return NULL;
+               }
+               
+               slots = slots - argCnt;
+               if (!fillVariableTable(env, localvarentries, entry_count, &jlineCI, 
+                                                          &names, &sigs, &jlengths, &jslot)) 
+                       return NULL;
+               (*jvmtienv)->
+                       Deallocate(jvmtienv, (unsigned char*)localvarentries->signature);
+               (*jvmtienv)->
+                       Deallocate(jvmtienv, (unsigned char*)localvarentries->name);
+               if (localvarentries->generic_signature != NULL)
+                       (*jvmtienv)-> Deallocate(jvmtienv, (unsigned char*)
+                                                                        localvarentries->generic_signature);
+
+
+               (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)localvarentries);
+       }
+       
+    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.util.VariableTable");
+    if (!cl) return NULL;
+
+    m = (*env)->
+               GetMethodID(env, cl,"<init>", 
+                                       "(II[J[Ljava/lang/String;[Ljava/lang/String;[I[I)V");
+    if (!m) return NULL;
+
+    o = (*env)->NewObject(env, cl, m, argCnt, slots, jlineCI, 
+                                                 names, sigs, jlengths, jslot);        
+
+    return (struct gnu_classpath_jdwp_util_VariableTable*) o;
+}
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c b/src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c
new file mode 100644 (file)
index 0000000..03323f2
--- /dev/null
@@ -0,0 +1,443 @@
+/* src/native/vm/VMVirtualMachine.c - jdwp->jvmti interface
+
+Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+J. Wenninger, Institut f. Computersprachen - TU Wien
+
+This file is part of CACAO.
+
+This program 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.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.
+
+Contact: cacao@cacaojvm.org
+
+Authors: Martin Platter
+
+Changes: Samuel Vinson
+
+
+$Id: gnu_classpath_jdwp_VMVirtualMachine.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+#include "toolbox/logging.h"
+#include "native/jni.h"
+#include "native/include/java_lang_Thread.h"
+#include "native/include/java_nio_ByteBuffer.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "native/include/java_lang_reflect_Method.h"
+#include "native/include/gnu_classpath_jdwp_event_EventRequest.h"
+#include "native/include/gnu_classpath_jdwp_VMVirtualMachine.h"
+#include "native/jvmti/jvmti.h"
+#include "native/jvmti/VMjdwp.h"
+#include <string.h>
+
+
+/*
+ * Class:     gnu_classpath_jdwp_VMVirtualMachine
+ * Method:    suspendThread
+ * Signature: (Ljava/lang/Thread;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1)
+{
+       jvmtiError err; 
+
+    err = (*jvmtienv)->SuspendThread(jvmtienv, (jthread) par1);
+       printjvmtierror("VMVirtualMachine.suspendThread SuspendThread", err);
+}
+
+/*
+ * Class:     gnu_classpath_jdwp_VMVirtualMachine
+ * Method:    resumeThread
+ * Signature: (Ljava/lang/Thread;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_resumeThread(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1)
+{
+       jvmtiError err; 
+
+    err = (*jvmtienv)->ResumeThread(jvmtienv, (jthread) par1);
+       printjvmtierror("VMVirtualMachine.resumethread ResumeThread", err);
+}
+
+
+/*
+ * Class:     gnu_classpath_jdwp_VMVirtualMachine
+ * Method:    getSuspendCount
+ * Signature: (Ljava/lang/Thread;)I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getSuspendCount(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
+    log_text ("VMVirtualMachine_getSuspendCount: not supported");
+       return 1;
+}
+
+/*
+ * Class:     gnu_classpath_jdwp_VMVirtualMachine
+ * Method:    getAllLoadedClassesCount
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClassesCount(JNIEnv *env, jclass clazz) {
+    jint count;
+    jclass* classes;
+       jvmtiError err;
+
+       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
+               GetLoadedClasses(jvmtienv, &count, &classes))) {
+               printjvmtierror("VMVirtualMachine_getAllLoadedClassCount GetLoadedClasses",err);
+               return 0;
+       }
+       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)classes);
+    return count;
+}
+
+/*
+ * Class:     gnu_classpath_jdwp_VMVirtualMachine
+ * Method:    getAllLoadedClasses
+ * Signature: ()Ljava/util/Iterator
+ */
+JNIEXPORT struct java_util_Iterator* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClasses(JNIEnv *env, jclass clazz) {
+       jclass *classes, *cl;
+       jint classcount;
+       jobjectArray joa;
+/*     jthrowable e;*/
+       jmethodID m;
+       jobject *ol,*oi;
+       int i;
+       jvmtiError err;
+
+       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
+               GetLoadedClasses(jvmtienv, &classcount, &classes))) {
+               printjvmtierror("VMVirtualMachine_getAllLoadedClasses GetLoadedClasses",err);
+               
+               /* we should throw JDWP Exception INTERNAL = 113;*/
+/*             env->ThrowNew(env,ec,"jvmti error occoured");  */
+               return NULL;
+       }
+       
+       cl = (*env)->FindClass(env,"java.lang.Class");
+       if (!cl) return NULL;
+
+       /* Arrays.asList(Object[] classes)->List.Iterator()->Iterator */
+       joa = (*env)->NewObjectArray(env, (jsize)classcount, cl , NULL);
+       if (!joa) return NULL;
+
+       for (i = 0; i < classcount; i++) 
+               (*env)->SetObjectArrayElement(env,joa,(jsize)i, (jobject)classes[i]);
+       (*jvmtienv)->Deallocate(jvmtienv, (unsigned char*)classes);
+       
+       cl = (*env)->FindClass(env,"java.util.Arrays");
+       if (!cl) return NULL;
+
+       m = (*env)->GetStaticMethodID(env, cl, "asList", "([Ljava/lang/Object;)Ljava/util/List;");
+       if (!m) return NULL;
+
+       ol = (*env)->CallStaticObjectMethod(env,(jclass)cl,m,joa);
+       if (!ol) return NULL;
+
+       cl = (*env)->FindClass(env,"java.util.List");
+       if (!cl) return NULL;
+       m = (*env)->GetMethodID(env,cl,"iterator","()Ljava/util/Iterator;");
+       if (!m) return NULL;
+       oi = (*env)->CallObjectMethod(env,ol,m);
+               
+       return (struct java_util_Iterator*)oi;
+}
+
+/* Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getClassStatus
+ * Signature: (Ljava/lang/Class;)I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
+       jint status;
+       jvmtiError err;
+
+       err = (*jvmtienv)->GetClassStatus(jvmtienv, (jclass) par1, &status);
+       printjvmtierror("VMVirtualMachine_getClassStatus GetClassStatus", err);
+
+       return status;
+}
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getAllClassMethods
+ * Signature: (Ljava/lang/Class;)[Lgnu/classpath/jdwp/VMMethod;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllClassMethods(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
+    jint count;
+    jmethodID* methodID, m;
+       jvmtiError err;
+       
+       jclass *cl;
+       jobject *ol;
+       jobjectArray joa;
+       int i;
+
+    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
+                                                        GetClassMethods(jvmtienv, (jclass) par1, 
+                                                                                        &count, &methodID))) {
+               printjvmtierror("VMVirtualMachine_getAllClassMethods GetClassMethods", err);
+               return NULL;
+       }
+       
+       m = (*env)->
+               GetStaticMethodID(env, clazz, "getClassMethod", 
+                                                 "(Ljava/lang/Class;J)Lgnu/classpath/jdwp/VMMethod;");
+       if (!m) return NULL;
+   
+    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.VMMethod");
+       if (!cl) return NULL;
+       
+       joa = (*env)->NewObjectArray(env, (jsize)count, cl , NULL);
+       if (!joa) return NULL;
+
+    for (i = 0; i < count; i++) {
+       ol = (*env)->
+                       CallStaticObjectMethod(env,clazz,m,(jobject)par1, methodID[i]);
+               if (!ol) return NULL;
+       (*env)->SetObjectArrayElement(env,joa,(jsize)i, ol);
+    }
+       return joa;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getClassMethod
+ * Signature: (Ljava/lang/Class;J)Lgnu/classpath/jdwp/VMMethod;
+ */
+JNIEXPORT struct gnu_classpath_jdwp_VMMethod* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getClassMethod(JNIEnv *env, jclass clazz, struct java_lang_Class* par1, s8 par2) {
+       jclass *cl;
+    jmethodID m;
+    jobject *ol;
+       
+    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.VMMethod");
+       if (!cl) return NULL;
+       
+       m = (*env)->GetMethodID(env, cl, "<init>", "(Ljava/lang/Class;J)V");
+       if (!m) return NULL;
+       
+    ol = (*env)->NewObject(env, cl, m, par1, par2);
+       
+       return (struct gnu_classpath_jdwp_VMMethod*)ol;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getFrames
+ * Signature: (Ljava/lang/Thread;II)Ljava/util/ArrayList;
+ */
+JNIEXPORT struct java_util_ArrayList* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrames(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1, s4 par2, s4 par3) {
+    log_text ("VMVirtualMachine_getFrames - IMPLEMENT ME!!!");
+/*     jclass ec = (*env)->FindClass(env,"gnu/classpath/jdwp/JdwpInternalErrorException");
+       if (JVMTI_ERROR_NONE != (*jvmtienv)->GetClassStatus(jvmtienv, par1, &status))
+       env->ThrowNew(env,ec,"jvmti error occoured");*/
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getFrame
+ * Signature: (Ljava/lang/Thread;Ljava/nio/ByteBuffer;)Lgnu/classpath/jdwp/VMFrame;
+ */
+JNIEXPORT struct gnu_classpath_jdwp_VMFrame* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrame(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1, struct java_nio_ByteBuffer* par2) {
+    log_text ("VMVirtualMachine_getFrame - IMPLEMENT ME!!!");
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getFrameCount
+ * Signature: (Ljava/lang/Thread;)I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
+       jint count;
+       jvmtiError err;
+       err = (*jvmtienv)->GetFrameCount(jvmtienv, (jthread)par1, &count);
+       printjvmtierror("VMVirtualMachine_getFrameCount GetFrameCount", err);
+       return count;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getThreadStatus
+ * Signature: (Ljava/lang/Thread;)I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getThreadStatus(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
+       jint status;
+       jvmtiError err; 
+       if (JVMTI_ERROR_NONE != (err = (*jvmtienv)->GetThreadState(jvmtienv, (jthread)par1, &status))) {
+               printjvmtierror("VMVirtualMachine_getThreadStatus GetThreadState", err);
+               return 0;
+       }
+       if (status && JVMTI_THREAD_STATE_ALIVE) {
+               if (status && JVMTI_THREAD_STATE_WAITING) {             
+                       return 4; /* WAIT - see JdwpConstants */
+               }
+               if (status && JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) { 
+                       return 3; /* MONITOR - see JdwpConstants */
+               }
+               if (status && JVMTI_THREAD_STATE_SLEEPING) { 
+                       return 2; /* SLEEPING - see JdwpConstants */
+               }
+               return 1; /* RUNNING - see JdwpConstants */
+       } else 
+               return 0; /* ZOMBIE - see JdwpConstants */
+       return -1; /* some error */
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getLoadRequests
+ * Signature: (Ljava/lang/ClassLoader;)Ljava/util/ArrayList;
+ */
+JNIEXPORT struct java_util_ArrayList* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getLoadRequests(JNIEnv *env, jclass clazz, struct java_lang_ClassLoader* par1) {
+    log_text ("VMVirtualMachine_getLoadRequests(");
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    executeMethod
+ * Signature: (Ljava/lang/Object;Ljava/lang/Thread;Ljava/lang/Class;Ljava/lang/reflect/Method;[Ljava/lang/Object;Z)Lgnu/classpath/jdwp/util/MethodResult;
+ */
+JNIEXPORT struct gnu_classpath_jdwp_util_MethodResult* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_executeMethod(JNIEnv *env, jclass clazz, struct java_lang_Object* par1, struct java_lang_Thread* par2, struct java_lang_Class* par3, struct java_lang_reflect_Method* par4, java_objectarray* par5, s4 par6) {
+    log_text ("VMVirtualMachine_executeMethod");
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    getSourceFile
+ * Signature: (Ljava/lang/Class;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getSourceFile(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
+       char* srcname;
+       jstring str;
+       jvmtiError err; 
+
+    if (JVMTI_ERROR_NONE !=(err=(*jvmtienv)->
+               GetSourceFileName(jvmtienv, (jclass)par1, &srcname))) {
+               printjvmtierror("VMVirtualMachine.getSourceFile GetSourceFileName", err);
+               return NULL;
+       }
+
+       str = (*env)->NewString(env,(jchar*)srcname,(jsize)strlen(srcname));
+
+       return (struct java_lang_String*)str;
+}
+
+/* match JdwpConstants.EventKind to jvmtiEvent constants */
+static jvmtiEvent EventKind2jvmtiEvent(jbyte kind){
+       switch (kind) {
+       case /* SINGLE_STEP */ 1: return JVMTI_EVENT_SINGLE_STEP;
+       case /* BREAKPOINT */ 2: return JVMTI_EVENT_BREAKPOINT;
+    case /*  FRAME_POP */ 3: return JVMTI_EVENT_FRAME_POP;
+    case /*  EXCEPTION */ 4: return JVMTI_EVENT_EXCEPTION;
+    case /*  USER_DEFINED */ 5: return -1; /* can this be matched ? */
+    case /*  THREAD_START */ 6: return JVMTI_EVENT_THREAD_START;
+    case /*  THREAD_END */ 7: return JVMTI_EVENT_THREAD_END;
+    case /*  CLASS_PREPARE */ 8: return JVMTI_EVENT_CLASS_PREPARE;
+    case /*  CLASS_UNLOAD */ 9: return -1; /* can this be matched ? */
+    case /*  CLASS_LOAD */ 10: return JVMTI_EVENT_CLASS_LOAD;
+    case /*  FIELD_ACCESS */ 20: return JVMTI_EVENT_FIELD_ACCESS;
+    case /*  FIELD_MODIFICATION */ 21: return JVMTI_EVENT_FIELD_MODIFICATION;
+    case /*  EXCEPTION_CATCH */ 30: return JVMTI_EVENT_EXCEPTION_CATCH;
+    case /*  METHOD_ENTRY */ 40: return JVMTI_EVENT_METHOD_ENTRY;
+    case /*  METHOD_EXIT */ 41: return JVMTI_EVENT_METHOD_EXIT;
+    case /*  VM_INIT */ 90: return JVMTI_EVENT_VM_INIT;
+    case /*  VM_DEATH */ 99: return JVMTI_EVENT_VM_DEATH;    
+    case /*  VM_DISCONNECTED */ 100: return -1; /* can this be matched ? */
+       default: return -1;
+       }
+}
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    registerEvent
+ * Signature: (Lgnu/classpath/jdwp/event/EventRequest;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_registerEvent(JNIEnv *env, jclass clazz, struct gnu_classpath_jdwp_event_EventRequest* par1) {
+       jbyte kind;
+       jfieldID kindid;
+       jclass erc;
+       jvmtiError err;
+
+       erc = (*env)->FindClass(env,"gnu.classpath.jdwp.event.EventRequest");
+       
+       kindid = (*env)->GetFieldID(env, erc, "_kind", "B");
+       kind = (*env)->GetByteField(env, (jobject)par1, kindid);
+
+       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
+               SetEventNotificationMode(jvmtienv, JVMTI_ENABLE, 
+                                                                EventKind2jvmtiEvent(kind), NULL)))
+               printjvmtierror("VMVirtualMachine_registerEvent SetEventNotificationMode",err);
+
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    unregisterEvent
+ * Signature: (Lgnu/classpath/jdwp/event/EventRequest;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_unregisterEvent(JNIEnv *env, jclass clazz, struct gnu_classpath_jdwp_event_EventRequest* par1) {
+       jbyte kind;
+       jfieldID kindid;
+       jclass erc;
+       jvmtiError err;
+
+       erc = (*env)->FindClass(env,"gnu.classpath.jdwp.event.EventRequest");
+       
+       kindid = (*env)->GetFieldID(env, erc, "_kind", "B");
+       kind = (*env)->GetByteField(env, (jobject)par1, kindid);
+
+       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
+               SetEventNotificationMode(jvmtienv, JVMTI_DISABLE, 
+                                                                EventKind2jvmtiEvent(kind), NULL)))
+               printjvmtierror("VMVirtualMachine_registerEvent SetEventNotificationMode",err);
+
+}
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMVirtualMachine
+ * Method:    clearEvents
+ * Signature: (B)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_clearEvents(JNIEnv *env, jclass clazz, s4 par1) {
+       /* jvmti events are not saved - there is nothing to clear */
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c b/src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
new file mode 100644 (file)
index 0000000..7ee69bf
--- /dev/null
@@ -0,0 +1,110 @@
+/* src/native/vm/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+
+#include "toolbox/logging.h"
+#include "vm/classcache.h"
+#include "vm/vm.h"
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    getLoadedClassCount
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
+{
+       s4 count;
+
+       count = classcache_get_loaded_class_count();
+
+       return count;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    getUnloadedClassCount
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    isVerbose
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
+{
+       return _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    setVerbose
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, s4 verbose)
+{
+       _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose = verbose;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c b/src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
new file mode 100644 (file)
index 0000000..4dc96e5
--- /dev/null
@@ -0,0 +1,171 @@
+/* src/native/vm/gnu_java_lang_management_VMMemoryMXBeanImpl.c
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+#include "native/include/java_lang_management_MemoryUsage.h"
+
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/global.h"
+#include "vm/loader.h"                   /* XXX only for load_class_bootstrap */
+#include "vm/options.h"
+#include "vm/vm.h"
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    getHeapMemoryUsage
+ * Signature: ()Ljava/lang/management/MemoryUsage;
+ */
+JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
+{
+       classinfo                        *class_java_lang_management_MemoryUsage;
+       java_objectheader                *o;
+       java_lang_management_MemoryUsage *mu;
+       methodinfo                       *m;
+       s8                                init;
+       s8                                used;
+       s8                                commited;
+       s8                                maximum;
+
+       /* get the class */
+       /* XXX optimize me! sometime... */
+
+       if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage"))))
+               return false;
+
+       /* create the object */
+
+       o = builtin_new(class_java_lang_management_MemoryUsage);
+       
+       if (o == NULL)
+               return NULL;
+
+       /* cast the object to a MemoryUsage object (for debugability) */
+
+       mu = (java_lang_management_MemoryUsage *) o;
+
+       /* find initializer */
+
+       m = class_findmethod(class_java_lang_management_MemoryUsage,
+                                                utf_init, utf_new_char("(JJJJ)V"));
+                                                     
+       /* initializer not found */
+
+       if (m == NULL)
+               return NULL;
+
+       /* get values from the VM */
+       /* XXX if we ever support more than one VM, change this */
+
+       init     = opt_heapstartsize;
+       used     = gc_get_total_bytes();
+       commited = gc_get_heap_size();
+       maximum  = gc_get_max_heap_size();
+
+       /* call initializer */
+
+       (void) vm_call_method(m, o, init, used, commited, maximum);
+
+       return mu;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    getNonHeapMemoryUsage
+ * Signature: ()Ljava/lang/management/MemoryUsage;
+ */
+JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    getObjectPendingFinalizationCount
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    isVerbose
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
+{
+       return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
+ * Method:    setVerbose
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, s4 verbose)
+{
+       _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c b/src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
new file mode 100644 (file)
index 0000000..68e8784
--- /dev/null
@@ -0,0 +1,81 @@
+/* src/native/vm/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/global.h"
+#include "vm/vm.h"
+
+
+/*
+ * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
+ * Method:    getInputArguments
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments: IMPLEMENT ME!");
+
+       return builtin_anewarray(0, class_java_lang_String);
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
+ * Method:    getStartTime
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime(JNIEnv *env, jclass clazz)
+{
+       return _Jv_jvm->starttime;
+}
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c b/src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c
new file mode 100644 (file)
index 0000000..8bde343
--- /dev/null
@@ -0,0 +1,173 @@
+/* src/native/vm/gnu_java_lang_management_VMThreadMXBeanImpl.c
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+#include "native/include/java_lang_management_ThreadInfo.h"
+
+#include "toolbox/logging.h"
+#include "vm/classcache.h"
+#include "vm/vm.h"
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    findMonitorDeadlockedThreads
+ * Signature: ()[J
+ */
+JNIEXPORT java_longarray* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getCurrentThreadCpuTime
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getCurrentThreadUserTime
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getPeakThreadCount
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz)
+{
+       return _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getThreadCpuTime
+ * Signature: (J)J
+ */
+JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, s8 id)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getThreadInfoForId
+ * Signature: (JI)Ljava/lang/management/ThreadInfo;
+ */
+JNIEXPORT java_lang_management_ThreadInfo* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, s8 id, s4 maxDepth)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getThreadUserTime
+ * Signature: (J)J
+ */
+JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, s8 par1)
+{
+       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    getTotalStartedThreadCount
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz)
+{
+       return _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    resetPeakThreadCount
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount(JNIEnv *env, jclass clazz)
+{
+       _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
+               _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMClass.c b/src/native/vm/gnu/java_lang_VMClass.c
new file mode 100644 (file)
index 0000000..2066079
--- /dev/null
@@ -0,0 +1,339 @@
+/* src/native/vm/java_lang_VMClass.c - java/lang/VMClass
+
+   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+   Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   $Id: java_lang_VMClass.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_VMClass.h"
+#include "native/include/java_lang_reflect_Constructor.h"
+#include "native/include/java_lang_reflect_Method.h"
+#include "native/vm/java_lang_Class.h"
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isInstance
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o)
+{
+       return _Jv_java_lang_Class_isInstance(klass, o);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isAssignableFrom
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
+{
+       return _Jv_java_lang_Class_isAssignableFrom(klass, c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isInterface
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_isInterface(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isPrimitive
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return  _Jv_java_lang_Class_isPrimitive(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getName(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getSuperclass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getSuperclass(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getInterfaces
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getInterfaces(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getComponentType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getComponentType(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getModifiers
+ * Signature: (Z)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 ignoreInnerClassesAttrib)
+{
+       return _Jv_java_lang_Class_getModifiers(klass, ignoreInnerClassesAttrib);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaringClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getDeclaringClass(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredClasses
+ * Signature: (Z)[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
+{
+       return _Jv_java_lang_Class_getDeclaredClasses(klass, publicOnly);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredFields
+ * Signature: (Z)[Ljava/lang/reflect/Field;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
+{
+       return _Jv_java_lang_Class_getDeclaredFields(klass, publicOnly);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredMethods
+ * Signature: (Z)[Ljava/lang/reflect/Method;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
+{
+       return _Jv_java_lang_Class_getDeclaredMethods(klass, publicOnly);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredConstructors
+ * Signature: (Z)[Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
+{
+       return _Jv_java_lang_Class_getDeclaredConstructors(klass, publicOnly);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getClassLoader(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    forName
+ * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader)
+{
+       return _Jv_java_lang_Class_forName(name, initialize, loader);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isArray
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_isArray(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    throwException
+ * Signature: (Ljava/lang/Throwable;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
+{
+       _Jv_java_lang_Class_throwException(t);
+}
+
+
+#if 0
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredAnnotations
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass)
+{
+}
+#endif
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getEnclosingClass
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getEnclosingClass(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getEnclosingConstructor
+ * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT java_lang_reflect_Constructor* JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getEnclosingConstructor(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getEnclosingMethod
+ * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method;
+ */
+JNIEXPORT java_lang_reflect_Method* JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return _Jv_java_lang_Class_getEnclosingMethod(klass);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getClassSignature
+ * Signature: (Ljava/lang/Class;)Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, java_lang_Class* klass)
+{
+       return _Jv_java_lang_Class_getClassSignature(klass);
+}
+
+
+#if 0
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isAnonymousClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isLocalClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isMemberClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+#endif
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMClassLoader.c b/src/native/vm/gnu/java_lang_VMClassLoader.c
new file mode 100644 (file)
index 0000000..282414a
--- /dev/null
@@ -0,0 +1,524 @@
+/* src/native/vm/VMClassLoader.c - java/lang/VMClassLoader
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+
+   Changes: Joseph Wenninger
+            Christian Thalinger
+            Edwin Steiner
+
+   $Id: java_lang_VMClassLoader.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <sys/stat.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_String.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "native/include/java_security_ProtectionDomain.h"
+#include "native/include/java_util_Vector.h"
+#include "toolbox/logging.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/classcache.h"
+#include "vm/exceptions.h"
+#include "vm/initialize.h"
+#include "vm/linker.h"
+#include "vm/loader.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
+#include "vm/stringlocal.h"
+#include "vm/suck.h"
+#include "vm/vm.h"
+#include "vm/zip.h"
+#include "vm/jit/asmpart.h"
+
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    defineClass
+ * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name, java_bytearray *data, s4 offset, s4 len, java_security_ProtectionDomain *pd)
+{
+       classinfo   *c;
+       classinfo   *r;
+       classbuffer *cb;
+       utf         *utfname;
+#if defined(ENABLE_JVMTI)
+       jint new_class_data_len = 0;
+       unsigned char* new_class_data = NULL;
+#endif
+
+       /* check if data was passed */
+
+       if (data == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* check the indexes passed */
+
+       if ((offset < 0) || (len < 0) || ((offset + len) > data->header.size)) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       if (name) {
+               /* convert '.' to '/' in java string */
+
+               utfname = javastring_toutf(name, true);
+               
+               /* check if this class has already been defined */
+
+               c = classcache_lookup_defined_or_initiated((java_objectheader *) cl, utfname);
+               if (c) {
+                       *exceptionptr =
+                               exceptions_new_linkageerror("duplicate class definition: ",c);
+                       return NULL;
+               }
+       } 
+       else {
+               utfname = NULL;
+       }
+
+
+#if defined(ENABLE_JVMTI)
+       /* fire Class File Load Hook JVMTI event */
+       if (jvmti) jvmti_ClassFileLoadHook(utfname, len, (unsigned char*)data->data, 
+                                                       (java_objectheader *)cl, (java_objectheader *)pd, 
+                                                       &new_class_data_len, &new_class_data);
+#endif
+
+
+       /* create a new classinfo struct */
+
+       c = class_create_classinfo(utfname);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_start();
+#endif
+
+       /* build a classbuffer with the given data */
+
+       cb = NEW(classbuffer);
+       cb->class = c;
+#if defined(ENABLE_JVMTI)
+       /* check if the JVMTI wants to modify the class */
+       if (new_class_data == NULL) {
+#endif
+       cb->size  = len;
+       cb->data  = (u1 *) &data->data[offset];
+#if defined(ENABLE_JVMTI)
+       } else {
+               cb->size  = new_class_data_len;
+               cb->data  = (u1 *) new_class_data;
+       }
+#endif
+       cb->pos   = cb->data;
+
+       /* preset the defining classloader */
+
+       c->classloader = (java_objectheader *) cl;
+
+       /* load the class from this buffer */
+
+       r = load_class_from_classbuffer(cb);
+
+       /* free memory */
+
+       FREE(cb, classbuffer);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_stop();
+#endif
+
+       if (!r) {
+               /* If return value is NULL, we had a problem and the class is not   */
+               /* loaded. */
+               /* now free the allocated memory, otherwise we could run into a DOS */
+
+               class_free(c);
+
+               return NULL;
+       }
+
+       /* set ProtectionDomain */
+
+       c->object.pd = pd;
+
+       /* Store the newly defined class in the class cache. This call also       */
+       /* checks whether a class of the same name has already been defined by    */
+       /* the same defining loader, and if so, replaces the newly created class  */
+       /* by the one defined earlier.                                            */
+       /* Important: The classinfo given to classcache_store must be             */
+       /*            fully prepared because another thread may return this       */
+       /*            pointer after the lookup at to top of this function         */
+       /*            directly after the class cache lock has been released.      */
+
+       c = classcache_store((java_objectheader *)cl,c,true);
+
+       return (java_lang_Class *) c;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    getPrimitiveClass
+ * Signature: (C)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, s4 type)
+{
+       classinfo *c;
+
+       /* get primitive class */
+
+       switch (type) {
+       case 'I':
+               c = primitivetype_table[PRIMITIVETYPE_INT].class_primitive;
+               break;
+       case 'J':
+               c = primitivetype_table[PRIMITIVETYPE_LONG].class_primitive;
+               break;
+       case 'F':
+               c = primitivetype_table[PRIMITIVETYPE_FLOAT].class_primitive;
+               break;
+       case 'D':
+               c = primitivetype_table[PRIMITIVETYPE_DOUBLE].class_primitive;
+               break;
+       case 'B':
+               c = primitivetype_table[PRIMITIVETYPE_BYTE].class_primitive;
+               break;
+       case 'C':
+               c = primitivetype_table[PRIMITIVETYPE_CHAR].class_primitive;
+               break;
+       case 'S':
+               c = primitivetype_table[PRIMITIVETYPE_SHORT].class_primitive;
+               break;
+       case 'Z':
+               c = primitivetype_table[PRIMITIVETYPE_BOOLEAN].class_primitive;
+               break;
+       case 'V':
+               c = primitivetype_table[PRIMITIVETYPE_VOID].class_primitive;
+               break;
+       default:
+               *exceptionptr = new_exception(string_java_lang_ClassNotFoundException);
+               c = NULL;
+       }
+
+       return (java_lang_Class *) c;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    resolveClass
+ * Signature: (Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, java_lang_Class *c)
+{
+       classinfo *ci;
+
+       ci = (classinfo *) c;
+
+       if (!ci) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* link the class */
+
+       if (!(ci->state & CLASS_LINKED))
+               (void) link_class(ci);
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    loadClass
+ * Signature: (Ljava/lang/String;Z)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, java_lang_String *name, jboolean resolve)
+{
+       classinfo *c;
+       utf *u;
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       u = javastring_toutf(name, true);
+
+       /* load class */
+
+       if (!(c = load_class_bootstrap(u)))
+               goto exception;
+
+       /* resolve class -- if requested */
+
+/*     if (resolve) */
+               if (!link_class(c))
+                       goto exception;
+
+       return (java_lang_Class *) c;
+
+ exception:
+       c = (*exceptionptr)->vftbl->class;
+       
+       /* if the exception is a NoClassDefFoundError, we replace it with a
+          ClassNotFoundException, otherwise return the exception */
+
+       if (c == class_java_lang_NoClassDefFoundError) {
+               /* clear exceptionptr, because builtin_new checks for 
+                  ExceptionInInitializerError */
+               *exceptionptr = NULL;
+
+               *exceptionptr =
+                       new_exception_javastring(string_java_lang_ClassNotFoundException, name);
+       }
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    nativeGetResources
+ * Signature: (Ljava/lang/String;)Ljava/util/Vector;
+ */
+JNIEXPORT java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, java_lang_String *name)
+{
+       jobject               o;         /* vector being created     */
+       methodinfo           *m;         /* "add" method of vector   */
+       java_lang_String     *path;      /* path to be added         */
+       list_classpath_entry *lce;       /* classpath entry          */
+       utf                  *utfname;   /* utf to look for          */
+       char                 *buffer;    /* char buffer              */
+       char                 *namestart; /* start of name to use     */
+       char                 *tmppath;   /* temporary buffer         */
+       s4                    namelen;   /* length of name to use    */
+       s4                    searchlen; /* length of name to search */
+       s4                    bufsize;   /* size of buffer allocated */
+       s4                    pathlen;   /* name of path to assemble */
+       struct stat           buf;       /* buffer for stat          */
+       jboolean              ret;       /* return value of "add"    */
+
+       /* get the resource name as utf string */
+
+       utfname = javastring_toutf(name, false);
+       if (!utfname)
+               return NULL;
+
+       /* copy it to a char buffer */
+
+       namelen = utf_bytes(utfname);
+       searchlen = namelen;
+       bufsize = namelen + strlen("0");
+       buffer = MNEW(char, bufsize);
+
+       utf_copy(buffer, utfname);
+       namestart = buffer;
+
+       /* skip leading '/' */
+
+       if (namestart[0] == '/') {
+               namestart++;
+               namelen--;
+               searchlen--;
+       }
+
+       /* remove trailing `.class' */
+
+       if (namelen >= 6 && strcmp(namestart + (namelen - 6), ".class") == 0) {
+               searchlen -= 6;
+       }
+
+       /* create a new needle to look for, if necessary */
+
+       if (searchlen != bufsize-1) {
+               utfname = utf_new(namestart, searchlen);
+               if (utfname == NULL)
+                       goto return_NULL;
+       }
+                       
+       /* new Vector() */
+
+       o = native_new_and_init(class_java_util_Vector);
+
+       if (!o)
+               goto return_NULL;
+
+       /* get Vector.add() method */
+
+       m = class_resolveclassmethod(class_java_util_Vector,
+                                                                utf_add,
+                                                                utf_new_char("(Ljava/lang/Object;)Z"),
+                                                                NULL,
+                                                                true);
+
+       if (!m)
+               goto return_NULL;
+
+       /* iterate over all classpath entries */
+
+       for (lce = list_first(list_classpath_entries); lce != NULL;
+                lce = list_next(list_classpath_entries, lce)) {
+               /* clear path pointer */
+               path = NULL;
+
+#if defined(ENABLE_ZLIB)
+               if (lce->type == CLASSPATH_ARCHIVE) {
+
+                       if (zip_find(lce, utfname)) {
+                               pathlen = strlen("jar:file://") + lce->pathlen + strlen("!/") +
+                                       namelen + strlen("0");
+
+                               tmppath = MNEW(char, pathlen);
+
+                               sprintf(tmppath, "jar:file://%s!/%s", lce->path, namestart);
+                               path = javastring_new_from_utf_string(tmppath),
+
+                               MFREE(tmppath, char, pathlen);
+                       }
+
+               } else {
+#endif /* defined(ENABLE_ZLIB) */
+                       pathlen = strlen("file://") + lce->pathlen + namelen + strlen("0");
+
+                       tmppath = MNEW(char, pathlen);
+
+                       sprintf(tmppath, "file://%s%s", lce->path, namestart);
+
+                       /* Does this file exist? */
+
+                       if (stat(tmppath + strlen("file://") - 1, &buf) == 0)
+                               if (!S_ISDIR(buf.st_mode))
+                                       path = javastring_new_from_utf_string(tmppath);
+
+                       MFREE(tmppath, char, pathlen);
+#if defined(ENABLE_ZLIB)
+               }
+#endif
+
+               /* if a resource was found, add it to the vector */
+
+               if (path) {
+                       ret = vm_call_method_int(m, o, path);
+
+                       if (*exceptionptr)
+                               goto return_NULL;
+
+                       if (ret == 0) 
+                               goto return_NULL;
+               }
+       }
+
+       MFREE(buffer, char, bufsize);
+
+       return (java_util_Vector *) o;
+
+return_NULL:
+       MFREE(buffer, char, bufsize);
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    defaultAssertionStatus
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
+{
+       return _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus;
+}
+
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    findLoadedClass
+ * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name)
+{
+       classinfo *c;
+       utf       *u;
+
+       /* replace `.' by `/', this is required by the classcache */
+
+       u = javastring_toutf(name, true);
+
+       /* lookup for defining classloader */
+
+       c = classcache_lookup_defined((classloader *) cl, u);
+
+       /* if not found, lookup for initiating classloader */
+
+       if (c == NULL)
+               c = classcache_lookup((classloader *) cl, u);
+
+       return (java_lang_Class *) c;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMObject.c b/src/native/vm/gnu/java_lang_VMObject.c
new file mode 100644 (file)
index 0000000..dbdbd75
--- /dev/null
@@ -0,0 +1,165 @@
+/* src/native/vm/VMObject.c - java/lang/VMObject
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+
+   Changes: Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_VMObject.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "mm/gc-common.h"
+#include "mm/memory.h"
+#include "toolbox/logging.h"
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_Cloneable.h"
+#include "native/include/java_lang_Object.h"
+
+#if defined(ENABLE_THREADS)
+# include "threads/native/threads.h"
+#endif
+
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/loader.h"
+#include "vm/options.h"
+#include "vm/stringlocal.h"
+
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    getClass
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, java_lang_Object *obj)
+{
+       classinfo *c;
+
+       if (!obj)
+               return NULL;
+
+       c = ((java_objectheader *) obj)->vftbl->class;
+
+       return (java_lang_Class *) c;
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    clone
+ * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, java_lang_Cloneable *this)
+{
+       java_objectheader *o;
+       java_objectheader *co;
+
+       o = (java_objectheader *) this;
+
+       co = builtin_clone(env, o);
+
+       return (java_lang_Object *) co;
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    notify
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this)
+{
+#if defined(ENABLE_THREADS)
+       lock_notify_object(&this->header);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    notifyAll
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *this)
+{
+#if defined(ENABLE_THREADS)
+       lock_notify_all_object(&this->header);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    wait
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, java_lang_Object *o, s8 ms, s4 ns)
+{
+#if defined(ENABLE_JVMTI)
+       /* Monitor Wait */
+       if (jvmti) jvmti_MonitorWaiting(true, o, ms);
+#endif
+
+#if defined(ENABLE_THREADS)
+       lock_wait_for_object(&o->header, ms, ns);
+#endif
+
+#if defined(ENABLE_JVMTI)
+       /* Monitor Waited */
+       /* XXX: How do you know if wait timed out ?*/
+       if (jvmti) jvmti_MonitorWaiting(false, o, 0);
+#endif
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMRuntime.c b/src/native/vm/gnu/java_lang_VMRuntime.c
new file mode 100644 (file)
index 0000000..c553b35
--- /dev/null
@@ -0,0 +1,394 @@
+/* src/native/vm/VMRuntime.c - java/lang/VMRuntime
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+
+   Changes: Joseph Wenninger
+            Christian Thalinger
+                       Edwin Steiner
+
+   $Id: java_lang_VMRuntime.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/utsname.h>
+
+#if !defined(WITH_STATIC_CLASSPATH)
+# include <ltdl.h>
+#endif
+
+#if defined(__DARWIN__)
+# define OS_INLINE    /* required for <libkern/ppc/OSByteOrder.h> */
+# include <mach/mach.h>
+#endif
+
+#include "vm/types.h"
+
+#include "mm/gc-common.h"
+#include "mm/memory.h"
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_io_File.h"
+#include "native/include/java_lang_String.h"
+#include "native/include/java_lang_Process.h"
+#include "toolbox/logging.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/loader.h"
+#include "vm/options.h"
+#include "vm/stringlocal.h"
+#include "vm/vm.h"
+
+
+/* this should work on BSD */
+/*
+#if defined(__DARWIN__)
+#include <sys/sysctl.h>
+#endif
+*/
+
+
+/* should we run all finalizers on exit? */
+static bool finalizeOnExit = false;
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    exitInternal
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, s4 par1)
+{
+       if (finalizeOnExit)
+               gc_finalize_all();
+
+       vm_shutdown(par1);
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    freeMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_free_bytes();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_heap_size();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    maxMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_max_heap_size();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    gc
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_gc(JNIEnv *env, jclass clazz)
+{
+       gc_call();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    runFinalization
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(JNIEnv *env, jclass clazz)
+{
+       gc_invoke_finalizers();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    runFinalizersOnExit
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, s4 value)
+{
+       /* XXX threading */
+
+       finalizeOnExit = value;
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    runFinalizationsForExit
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizationForExit(JNIEnv *env, jclass clazz)
+{
+/*     if (finalizeOnExit) { */
+/*             gc_call(); */
+       /* gc_finalize_all(); */
+/*     } */
+/*     log_text("Java_java_lang_VMRuntime_runFinalizationForExit called"); */
+       /*gc_finalize_all();*/
+       /*gc_invoke_finalizers();*/
+       /*gc_call();*/
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    traceInstructions
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, s4 par1)
+{
+       /* not supported */
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    traceMethodCalls
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, s4 par1)
+{
+       /* not supported */
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    availableProcessors
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
+{
+#if defined(_SC_NPROC_ONLN)
+       return (s4) sysconf(_SC_NPROC_ONLN);
+
+#elif defined(_SC_NPROCESSORS_ONLN)
+       return (s4) sysconf(_SC_NPROCESSORS_ONLN);
+
+#elif defined(__DARWIN__)
+       /* this should work in BSD */
+       /*
+       int ncpu, mib[2], rc;
+       size_t len;
+
+       mib[0] = CTL_HW;
+       mib[1] = HW_NCPU;
+       len = sizeof(ncpu);
+       rc = sysctl(mib, 2, &ncpu, &len, NULL, 0);
+
+       return (s4) ncpu;
+       */
+
+       host_basic_info_data_t hinfo;
+       mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
+       kern_return_t rc;
+
+       rc = host_info(mach_host_self(), HOST_BASIC_INFO,
+                                  (host_info_t) &hinfo, &hinfo_count);
+       if (rc != KERN_SUCCESS) {
+               return -1;
+       }
+
+    return (s4) hinfo.avail_cpus;
+
+#else
+       return 1;
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    nativeLoad
+ * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *filename, java_lang_ClassLoader *loader)
+{
+#if !defined(WITH_STATIC_CLASSPATH)
+       utf         *name;
+       lt_dlhandle  handle;
+       lt_ptr       onload;
+       s4           version;
+#endif
+
+       if (filename == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+#if defined(WITH_STATIC_CLASSPATH)
+       return 1;
+#else /* defined(WITH_STATIC_CLASSPATH) */
+       name = javastring_toutf(filename, 0);
+
+       /* is the library already loaded? */
+
+       if (native_hashtable_library_find(name, (java_objectheader *) loader))
+               return 1;
+
+       /* try to open the library */
+
+       if (!(handle = lt_dlopen(name->text))) {
+               if (opt_verbose) {
+                       log_start();
+                       log_print("Java_java_lang_VMRuntime_nativeLoad: ");
+                       log_print(lt_dlerror());
+                       log_finish();
+               }
+
+               return 0;
+       }
+
+       /* resolve JNI_OnLoad function */
+
+       if ((onload = lt_dlsym(handle, "JNI_OnLoad"))) {
+               JNIEXPORT s4 (JNICALL *JNI_OnLoad) (JavaVM *, void *);
+               JavaVM *vm;
+
+               JNI_OnLoad = (JNIEXPORT s4 (JNICALL *)(JavaVM *, void *)) (ptrint) onload;
+
+               (*env)->GetJavaVM(env, &vm);
+
+               version = JNI_OnLoad(vm, NULL);
+
+               /* if the version is not 1.2 and not 1.4 the library cannot be loaded */
+
+               if ((version != JNI_VERSION_1_2) && (version != JNI_VERSION_1_4)) {
+                       lt_dlclose(handle);
+
+                       return 0;
+               }
+       }
+
+       /* insert the library name into the library hash */
+
+       native_hashtable_library_add(name, (java_objectheader *) loader, handle);
+
+       return 1;
+#endif /* defined(WITH_STATIC_CLASSPATH) */
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    mapLibraryName
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, java_lang_String *libname)
+{
+       utf              *u;
+       char             *buffer;
+       s4                buffer_len;
+       s4                dumpsize;
+       java_lang_String *s;
+
+       if (!libname) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       u = javastring_toutf(libname, 0);
+
+       /* calculate length of library name */
+
+       buffer_len = strlen("lib");
+
+       buffer_len += utf_bytes(u);
+
+#if defined(__DARWIN__)
+       buffer_len += strlen(".dylib");
+#else
+       buffer_len += strlen(".so");
+#endif
+
+       buffer_len += strlen("0");
+
+       dumpsize = dump_size();
+       buffer = DMNEW(char, buffer_len);
+
+       /* generate library name */
+
+       strcpy(buffer, "lib");
+       utf_cat(buffer, u);
+
+#if defined(__DARWIN__)
+       strcat(buffer, ".dylib");
+#else
+       strcat(buffer, ".so");
+#endif
+
+       s = javastring_new_from_utf_string(buffer);
+
+       /* release memory */
+
+       dump_release(dumpsize);
+
+       return s;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMString.c b/src/native/vm/gnu/java_lang_VMString.c
new file mode 100644 (file)
index 0000000..93804a9
--- /dev/null
@@ -0,0 +1,75 @@
+/* native/vm/VMString.c - java/lang/VMString
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+
+   Changes: Christian Thalinger
+
+   $Id: java_lang_VMString.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include <stdlib.h>
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_String.h"
+#include "vm/stringlocal.h"
+
+
+/*
+ * Class:     java/lang/VMString
+ * Method:    intern
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, java_lang_String *str)
+{
+       java_objectheader *o;
+
+       if (!str)
+               return NULL;
+
+       /* search table so identical strings will get identical pointers */
+
+       o = literalstring_u2(str->value, str->count, str->offset, true);
+
+       return (java_lang_String *) o;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMSystem.c b/src/native/vm/gnu/java_lang_VMSystem.c
new file mode 100644 (file)
index 0000000..600c713
--- /dev/null
@@ -0,0 +1,83 @@
+/* src/native/vm/VMSystem.c - java/lang/VMSystem
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+
+   Changes: Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_VMSystem.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/include/java_lang_Object.h"
+
+#include "vm/builtin.h"
+
+
+/*
+ * Class:     java/lang/VMSystem
+ * Method:    arraycopy
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, s4 srcStart, java_lang_Object *dest, s4 destStart, s4 len)
+{
+       (void) builtin_arraycopy((java_arrayheader *) src, srcStart,
+                                                        (java_arrayheader *) dest, destStart, len);
+}
+
+
+/*
+ * Class:     java/lang/VMSystem
+ * Method:    identityHashCode
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, java_lang_Object *o)
+{
+       return (s4) ((ptrint) o);
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMThread.c b/src/native/vm/gnu/java_lang_VMThread.c
new file mode 100644 (file)
index 0000000..6edcf39
--- /dev/null
@@ -0,0 +1,248 @@
+/* src/native/vm/VMThread.c - java/lang/VMThread
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+
+   Changes: Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_VMThread.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_ThreadGroup.h"
+#include "native/include/java_lang_Object.h"            /* java_lang_Thread.h */
+#include "native/include/java_lang_Throwable.h"         /* java_lang_Thread.h */
+#include "native/include/java_lang_VMThread.h"
+#include "native/include/java_lang_Thread.h"
+
+#if defined(ENABLE_THREADS)
+# include "threads/native/threads.h"
+#endif
+
+#include "toolbox/logging.h"
+#include "vm/exceptions.h"
+#include "vm/options.h"
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    countStackFrames
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
+{
+    log_text("java_lang_VMThread_countStackFrames called");
+
+    return 0;
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    start
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, s8 stacksize)
+{
+#if defined(ENABLE_THREADS)
+       this->thread->vmThread = this;
+
+       /* don't pass a function pointer (NULL) since we want Thread.run()V here */
+
+       threads_start_thread((java_lang_Thread *) this->thread, NULL);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    interrupt
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this)
+{
+#if defined(ENABLE_THREADS)
+       threads_thread_interrupt(this);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    isInterrupted
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
+{
+#if defined(ENABLE_THREADS)
+       return threads_thread_has_been_interrupted(this);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    suspend
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this)
+{
+#if defined(ENABLE_THREADS)
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    resume
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this)
+{
+#if defined(ENABLE_THREADS)
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    nativeSetPriority
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, s4 priority)
+{
+#if defined(ENABLE_THREADS)
+       threads_java_lang_Thread_set_priority((java_lang_Thread *) this->thread,
+                                                                                 priority);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    nativeStop
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
+{
+#if defined(ENABLE_THREADS)
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    currentThread
+ * Signature: ()Ljava/lang/Thread;
+ */
+JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
+{
+       java_lang_Thread *t;
+
+#if defined(ENABLE_THREADS)
+       t = ((threadobject*) THREADOBJECT)->o.thread;
+
+       if (t == NULL)
+               log_text("t ptr is NULL\n");
+  
+       if (!t->group) {
+               /* ThreadGroup of currentThread is not initialized */
+
+               t->group = (java_lang_ThreadGroup *)
+                       native_new_and_init(class_java_lang_ThreadGroup);
+
+               if (t->group == NULL)
+                       log_text("unable to create ThreadGroup");
+       }
+#else
+       /* we just return a fake java.lang.Thread object, otherwise we get
+       NullPointerException's in GNU classpath */
+
+       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
+#endif
+
+       return t;
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    yield
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_THREADS)
+       threads_yield();
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    interrupted
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_THREADS)
+       return threads_check_if_interrupted_and_reset();
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    holdsLock
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
+{
+#if defined(ENABLE_THREADS)
+       return lock_is_held_by_current_thread((java_objectheader *) o);
+#endif
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_VMThrowable.c b/src/native/vm/gnu/java_lang_VMThrowable.c
new file mode 100644 (file)
index 0000000..47ceaaa
--- /dev/null
@@ -0,0 +1,256 @@
+/* src/native/vm/java_lang_VMThrowable.c - java/lang/VMThrowable
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_VMThrowable.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/gnu_classpath_Pointer.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_StackTraceElement.h"
+#include "native/include/java_lang_Throwable.h"
+#include "native/include/java_lang_VMThrowable.h"
+#include "native/vm/java_lang_Class.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/exceptions.h"
+#include "vm/loader.h"
+#include "vm/stringlocal.h"
+#include "vm/jit/stacktrace.h"
+
+
+/*
+ * Class:     java/lang/VMThrowable
+ * Method:    fillInStackTrace
+ * Signature: (Ljava/lang/Throwable;)Ljava/lang/VMThrowable;
+ */
+JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
+{
+       java_lang_VMThrowable *o;
+       stacktracecontainer   *stc;
+
+       o = (java_lang_VMThrowable *)
+               native_new_and_init(class_java_lang_VMThrowable);
+
+       if (o == NULL)
+               return NULL;
+
+       stc = stacktrace_fillInStackTrace();
+
+       if (stc == NULL)
+               return NULL;
+
+       o->vmData = (gnu_classpath_Pointer *) stc;
+
+       return o;
+}
+
+
+/*
+ * Class:     java/lang/VMThrowable
+ * Method:    getStackTrace
+ * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *this, java_lang_Throwable *t)
+{
+       stacktracecontainer         *stc;
+       stacktracebuffer            *stb;
+       stacktrace_entry            *ste;
+       stacktrace_entry            *tmpste;
+       s4                           size;
+       s4                           i;
+       classinfo                   *c;
+       bool                         inexceptionclass;
+       bool                         leftexceptionclass;
+
+       methodinfo                  *m;
+       java_objectarray            *oa;
+       s4                           oalength;
+       java_lang_StackTraceElement *o;
+       java_lang_String            *filename;
+       s4                           linenumber;
+       java_lang_String            *declaringclass;
+
+       /* get the stacktrace buffer from the VMThrowable object */
+
+       stc = (stacktracecontainer *) this->vmData;
+       stb = &(stc->stb);
+
+       /* get the class of the Throwable object */
+
+       c = t->header.vftbl->class;
+
+       assert(stb != NULL);
+
+       size = stb->used;
+
+       assert(size >= 2);
+
+       /* skip first 2 elements in stacktrace buffer:                            */
+       /*   0: VMThrowable.fillInStackTrace                                      */
+       /*   1: Throwable.fillInStackTrace                                        */
+
+       ste = &(stb->entries[2]);
+       size -= 2;
+
+       if ((size > 0) && (ste->method != 0)) {
+               /* not a builtin native wrapper*/
+
+               if ((ste->method->class->name == utf_java_lang_Throwable) &&
+                       (ste->method->name == utf_init)) {
+                       /* We assume that we are within the initializer of the
+                          exception object, the exception object itself should
+                          not appear in the stack trace, so we skip till we reach
+                          the first function, which is not an init function. */
+
+                       inexceptionclass = false;
+                       leftexceptionclass = false;
+
+                       while (size > 0) {
+                               /* check if we are in the exception class */
+
+                               if (ste->method->class == c)
+                                       inexceptionclass = true;
+
+                               /* check if we left the exception class */
+
+                               if (inexceptionclass && (ste->method->class != c))
+                                       leftexceptionclass = true;
+
+                               /* Found exception start point if we left the
+                                  initalizers or we left the exception class. */
+
+                               if ((ste->method->name != utf_init) || leftexceptionclass)
+                                       break;
+
+                               /* go to next stacktrace element */
+
+                               ste++;
+                               size--;
+                       }
+               }
+       }
+
+
+       /* now fill the stacktrace into java objects */
+
+       m = class_findmethod(class_java_lang_StackTraceElement,
+                                                utf_init,
+                                                utf_new_char("(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Z)V"));
+
+       if (m == NULL)
+               return NULL;
+
+       /* count entries with a method name */
+
+       for (oalength = 0, i = size, tmpste = ste; i > 0; i--, tmpste++)
+               if (tmpste->method)
+                       oalength++;
+
+       /* create the stacktrace element array */
+
+       oa = builtin_anewarray(oalength, class_java_lang_StackTraceElement);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0; size > 0; size--, ste++, i++) {
+               /* skip entries without a method name */
+
+               if (ste->method == NULL) {
+                       i--;
+                       continue;
+               }
+
+               /* allocate a new stacktrace element */
+
+               o = (java_lang_StackTraceElement *)
+                       builtin_new(class_java_lang_StackTraceElement);
+
+               if (o == NULL)
+                       return NULL;
+
+               /* get filename */
+
+               if (!(ste->method->flags & ACC_NATIVE)) {
+                       if (ste->method->class->sourcefile)
+                               filename = javastring_new(ste->method->class->sourcefile);
+                       else
+                               filename = NULL;
+               }
+               else
+                       filename = NULL;
+
+               /* get line number */
+
+               if (ste->method->flags & ACC_NATIVE)
+                       linenumber = -1;
+               else
+                       linenumber = (ste->linenumber == 0) ? -1 : ste->linenumber;
+
+               /* get declaring class name */
+
+               declaringclass = _Jv_java_lang_Class_getName(ste->method->class);
+
+               /* fill the java.lang.StackTraceElement element */
+
+               o->fileName       = filename;
+               o->lineNumber     = linenumber;
+               o->declaringClass = declaringclass;
+               o->methodName     = javastring_new(ste->method->name);
+               o->isNative       = (ste->method->flags & ACC_NATIVE) ? 1 : 0;
+
+               oa->data[i] = (java_objectheader *) o;
+       }
+
+       return oa;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_management_VMManagementFactory.c b/src/native/vm/gnu/java_lang_management_VMManagementFactory.c
new file mode 100644 (file)
index 0000000..8abcd62
--- /dev/null
@@ -0,0 +1,112 @@
+/* src/native/vm/java_lang_management_VMManagementFactory.c
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
+
+*/
+
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+
+#include "toolbox/logging.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+
+
+/*
+ * Class:     java/lang/management/VMManagementFactory
+ * Method:    getMemoryPoolNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
+{
+       java_objectarray *oa;
+
+       log_println("Java_java_lang_management_VMManagementFactory_getMemoryPoolNames: IMPLEMENT ME!");
+
+       oa = builtin_anewarray(0, class_java_lang_String);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/management/VMManagementFactory
+ * Method:    getMemoryManagerNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
+{
+       java_objectarray *oa;
+
+       log_println("Java_java_lang_management_VMManagementFactory_getMemoryManagerNames: IMPLEMENT ME!");
+
+       oa = builtin_anewarray(0, class_java_lang_String);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/management/VMManagementFactory
+ * Method:    getGarbageCollectorNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
+{
+       java_objectarray *oa;
+
+       log_println("Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames: IMPLEMENT ME!");
+
+       oa = builtin_anewarray(0, class_java_lang_String);
+
+       return oa;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnu/java_lang_reflect_Constructor.c b/src/native/vm/gnu/java_lang_reflect_Constructor.c
new file mode 100644 (file)
index 0000000..e507a1f
--- /dev/null
@@ -0,0 +1,214 @@
+/* src/native/vm/java_lang_reflect_Constructor.c
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+            Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_reflect_Constructor.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_String.h"
+#include "native/include/java_lang_reflect_Constructor.h"
+#include "toolbox/logging.h"
+#include "vm/class.h"
+#include "vm/exceptions.h"
+#include "vm/method.h"
+#include "vm/access.h"
+#include "vm/stringlocal.h"
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Constructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_Constructor *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+
+       c = (classinfo *) (this->clazz);
+       m = &(c->methods[this->slot]);
+
+       return m->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    getParameterTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+
+       c = (classinfo *) this->clazz;
+       m = &(c->methods[this->slot]);
+
+       return native_get_parametertypes(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    getExceptionTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+
+       c = (classinfo *) this->clazz;
+       m = &(c->methods[this->slot]);
+
+       return native_get_exceptiontypes(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    constructNative
+ * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_constructNative(JNIEnv *env, java_lang_reflect_Constructor *this, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
+{
+       classinfo         *c;
+       methodinfo        *m;
+       java_objectheader *o;
+
+       c = (classinfo *) declaringClass;
+
+#if 0
+       /* find initializer */
+
+       if (!args) {
+               if (this->parameterTypes->header.size != 0) {
+                       *exceptionptr =
+                               new_exception_message(string_java_lang_IllegalArgumentException,
+                                                                         "wrong number of arguments");
+                       return NULL;
+               }
+
+       } else {
+               if (this->parameterTypes->header.size != args->header.size) {
+                       *exceptionptr =
+                               new_exception_message(string_java_lang_IllegalArgumentException,
+                                                                         "wrong number of arguments");
+                       return NULL;
+               }
+       }
+#endif
+
+       if (this->slot >= c->methodscount) {
+               log_text("illegal index in methods table");
+               return NULL;
+       }
+
+       m = &(c->methods[this->slot]);
+
+       if (m->name != utf_init) {
+               /* XXX throw an exception here, although this should never happen */
+
+               assert(0);
+       }
+
+       /* check method access */
+       /* check if we should bypass security checks (AccessibleObject) */
+
+       if (this->flag == false) {
+               if (!access_check_caller(c, m->flags, 1))
+                       return NULL;
+       }
+
+       /* create object */
+
+       o = builtin_new(c);
+
+       if (!o)
+               return NULL;
+        
+       /* call initializer */
+
+       (void) _Jv_jni_invokeNative(m, o, args);
+
+       return (java_lang_Object *) o;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Constructor_getSignature(JNIEnv *env, java_lang_reflect_Constructor *this)
+{
+       classinfo        *c;
+       methodinfo       *m;
+       java_lang_String *s;
+
+       c = (classinfo *) this->clazz;
+       m = &(c->methods[this->slot]);
+
+       if (m->signature == NULL)
+               return NULL;
+
+       s = javastring_new(m->signature);
+
+       /* in error case, s == NULL */
+
+       return s;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_reflect_Field.c b/src/native/vm/gnu/java_lang_reflect_Field.c
new file mode 100644 (file)
index 0000000..dd60bfc
--- /dev/null
@@ -0,0 +1,1237 @@
+/* src/native/vm/java_lang_reflect_Field.c - java/lang/reflect/Field
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+            Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_reflect_Field.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Boolean.h"
+#include "native/include/java_lang_Byte.h"
+#include "native/include/java_lang_Character.h"
+#include "native/include/java_lang_Short.h"
+#include "native/include/java_lang_Integer.h"
+#include "native/include/java_lang_Long.h"
+#include "native/include/java_lang_Float.h"
+#include "native/include/java_lang_Double.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_reflect_Field.h"
+#include "vm/access.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/global.h"
+#include "vm/initialize.h"
+#include "vm/loader.h"
+#include "vm/resolve.h"
+#include "vm/stringlocal.h"
+#include "vm/utf8.h"
+#include "vm/jit/stacktrace.h"
+
+
+#define CHECKFIELDACCESS(this,fi,c,doret)
+
+
+/* cacao_get_field_address *****************************************************
+
+   Return the address of a field of an object.
+
+   IN:
+      this.........the field (a java.lang.reflect.Field object)
+         o............the object of which to get the field
+
+   RETURN VALUE:
+      a pointer to the field, or
+         NULL if an exception has been thrown
+
+*******************************************************************************/
+
+static void *cacao_get_field_address(java_lang_reflect_Field *this,
+                                                                        java_lang_Object *o)
+{
+       classinfo        *c;
+       fieldinfo        *f;
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* check field access */
+       /* check if we should bypass security checks (AccessibleObject) */
+
+       if (this->flag == false) {
+               /* this function is always called like this:
+
+                          java.lang.reflect.Field.xxx (Native Method)
+                  [0] <caller>
+               */
+               if (!access_check_caller(c, f->flags, 0))
+                       return NULL;
+       }
+
+       /* get the address of the field */
+
+       if (f->flags & ACC_STATIC) {
+               /* initialize class if required */
+
+               if (!(c->state & CLASS_INITIALIZED))
+                       if (!initialize_class(c))
+                               return NULL;
+
+               /* return value address */
+
+               return &(f->value);
+
+       } else {
+               /* obj is required for not-static fields */
+
+               if (o == NULL) {
+                       exceptions_throw_nullpointerexception();
+                       return NULL;
+               }
+       
+               if (builtin_instanceof((java_objectheader *) o, c))
+                       return (void *) ((ptrint) o + f->offset);
+       }
+
+       /* exception path */
+
+       exceptions_throw_illegalargumentexception();
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getModifiersInternal(JNIEnv *env, java_lang_reflect_Field *this)
+{
+       classinfo *c;
+       fieldinfo *f;
+
+       c = (classinfo *) this->declaringClass;
+       f = &(c->fields[this->slot]);
+
+       return f->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Field_getType(JNIEnv *env, java_lang_reflect_Field *this)
+{
+       classinfo *c;
+       typedesc  *desc;
+       classinfo *ret;
+
+       c    = (classinfo *) this->declaringClass;
+       desc = c->fields[this->slot].parseddesc;
+
+       if (desc == NULL)
+               return NULL;
+
+       if (!resolve_class_from_typedesc(desc, true, false, &ret))
+               return NULL;
+       
+       return (java_lang_Class *) ret;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    get
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Field_get(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get address of the source field value */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return NULL;
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BOOLEAN: {
+               java_lang_Boolean *bo;
+
+               /* create wrapping class */
+
+               if (!(bo = (java_lang_Boolean *) builtin_new(class_java_lang_Boolean)))
+                       return NULL;
+
+               /* set the object value */
+
+               bo->value = *((s4 *) addr);
+
+               /* return the wrapped object */
+
+               return (java_lang_Object *) bo;
+       }
+
+       case PRIMITIVETYPE_BYTE: {
+               java_lang_Byte *bo;
+
+               if (!(bo = (java_lang_Byte *) builtin_new(class_java_lang_Byte)))
+                       return NULL;
+
+               bo->value = *((s4 *) addr);
+
+               return (java_lang_Object *) bo;
+       }
+
+       case PRIMITIVETYPE_CHAR: {
+               java_lang_Character *co;
+
+               if (!(co = (java_lang_Character *) builtin_new(class_java_lang_Character)))
+                       return NULL;
+
+               co->value = *((s4 *) addr);
+
+               return (java_lang_Object *) co;
+       }
+
+       case PRIMITIVETYPE_SHORT: {
+               java_lang_Short *so;
+
+               if (!(so = (java_lang_Short *) builtin_new(class_java_lang_Short)))
+                       return NULL;
+
+               so->value = (s4) *((s4 *) addr);
+
+               return (java_lang_Object *) so;
+       }
+
+       case PRIMITIVETYPE_INT: {
+               java_lang_Integer *io;
+
+               if (!(io = (java_lang_Integer *) builtin_new(class_java_lang_Integer)))
+                       return NULL;
+
+               io->value = *((s4 *) addr);
+
+               return (java_lang_Object *) io;
+       }
+
+       case PRIMITIVETYPE_LONG: {
+               java_lang_Long *lo;
+
+               if (!(lo = (java_lang_Long *) builtin_new(class_java_lang_Long)))
+                       return NULL;
+
+               lo->value = *((s8 *) addr);
+
+               return (java_lang_Object *) lo;
+       }
+
+       case PRIMITIVETYPE_FLOAT: {
+               java_lang_Float *fo;
+
+               if (!(fo = (java_lang_Float *) builtin_new(class_java_lang_Float)))
+                       return NULL;
+
+               fo->value = *((float *) addr);
+
+               return (java_lang_Object *) fo;
+       }
+
+       case PRIMITIVETYPE_DOUBLE: {
+               java_lang_Double *_do;
+
+               if (!(_do = (java_lang_Double *) builtin_new(class_java_lang_Double)))
+                       return NULL;
+
+               _do->value = *((double *) addr);
+
+               return (java_lang_Object *) _do;
+       }
+
+       case TYPE_ADR:
+               return (java_lang_Object *) *((java_objectheader **) addr);
+       }
+
+       /* this must not happen */
+
+       assert(0);
+
+       /* keep compiler happy */
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getBoolean(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BOOLEAN:
+               return (s4) *((s4 *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;)B
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getByte(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+               return (s4) *((s4 *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;)C
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getChar(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_CHAR:
+               return (s4) *((s4 *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;)S
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getShort(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_SHORT:
+               return (s4) *((s4 *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getInt(JNIEnv *env , java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (s4) *((s4 *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_reflect_Field_getLong(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (s8) *((s4 *) addr);
+       case PRIMITIVETYPE_LONG:
+               return (s8) *((s8 *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (float) *((s4 *) addr);
+       case PRIMITIVETYPE_LONG:
+               return (float) *((s8 *) addr);
+       case PRIMITIVETYPE_FLOAT:
+               return (float) *((float *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble(JNIEnv *env , java_lang_reflect_Field *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               return (double) *((s4 *) addr);
+       case PRIMITIVETYPE_LONG:
+               return (double) *((s8 *) addr);
+       case PRIMITIVETYPE_FLOAT:
+               return (double) *((float *) addr);
+       case PRIMITIVETYPE_DOUBLE:
+               return (double) *((double *) addr);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    set
+ * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, java_lang_Object *value)
+{
+       classinfo *sc;
+       classinfo *dc;
+       fieldinfo *sf;
+       fieldinfo *df;
+       void      *faddr;
+
+       /* get the class and the field */
+
+       dc = (classinfo *) this->declaringClass;
+       df = &dc->fields[this->slot];
+
+       /* get the address of the destination field */
+
+       if ((faddr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* get the source classinfo from the object */
+
+       if (value == NULL)
+               sc = NULL;
+       else
+               sc = value->header.vftbl->class;
+
+       /* The fieldid is used to set the new value, for primitive
+          types the value has to be retrieved from the wrapping
+          object */
+
+       switch (df->parseddesc->decltype) {
+       case PRIMITIVETYPE_BOOLEAN: {
+               s4 val;
+
+               /* determine the field to read the value */
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_Z)))
+                       break;
+
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BOOLEAN:
+                       val = ((java_lang_Boolean *) value)->value;
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((s4 *) faddr) = val;
+               return;
+       }
+
+       case PRIMITIVETYPE_BYTE: {
+               s4 val;
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B)))
+                       break;
+
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = ((java_lang_Byte *) value)->value;
+                       break;
+               default:        
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((s4 *) faddr) = val;
+               return;
+       }
+
+       case PRIMITIVETYPE_CHAR: {
+               s4 val;
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C)))
+                       break;
+                                  
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_CHAR:
+                       val = ((java_lang_Character *) value)->value;
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((s4 *) faddr) = val;
+               return;
+       }
+
+       case PRIMITIVETYPE_SHORT: {
+               s4 val;
+
+               /* get field only by name, it can be one of B, S */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+                                  
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = ((java_lang_Byte *) value)->value;
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = ((java_lang_Short *) value)->value;
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((s4 *) faddr) = val;
+               return;
+       }
+
+       case PRIMITIVETYPE_INT: {
+               s4 val;
+
+               /* get field only by name, it can be one of B, S, C, I */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = ((java_lang_Byte *) value)->value;
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = ((java_lang_Character *) value)->value;
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = ((java_lang_Short *) value)->value;
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = ((java_lang_Integer *) value)->value;
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((s4 *) faddr) = val;
+               return;
+       }
+
+       case PRIMITIVETYPE_LONG: {
+               s8 val;
+
+               /* get field only by name, it can be one of B, S, C, I, J */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = ((java_lang_Byte *) value)->value;
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = ((java_lang_Character *) value)->value;
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = ((java_lang_Short *) value)->value;
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = ((java_lang_Integer *) value)->value;
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       val = ((java_lang_Long *) value)->value;
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((s8 *) faddr) = val;
+               return;
+       }
+
+       case PRIMITIVETYPE_FLOAT: {
+               float val;
+
+               /* get field only by name, it can be one of B, S, C, I, J, F */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = ((java_lang_Byte *) value)->value;
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = ((java_lang_Character *) value)->value;
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = ((java_lang_Short *) value)->value;
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = ((java_lang_Integer *) value)->value;
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       val = ((java_lang_Long *) value)->value;
+                       break;
+               case PRIMITIVETYPE_FLOAT:
+                       val = ((java_lang_Float *) value)->value;
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((float *) faddr) = val;
+               return;
+       }
+
+       case PRIMITIVETYPE_DOUBLE: {
+               double val;
+
+               /* get field only by name, it can be one of B, S, C, I, J, F, D */
+
+               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
+                       break;
+
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BYTE:
+                       val = ((java_lang_Byte *) value)->value;
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       val = ((java_lang_Character *) value)->value;
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       val = ((java_lang_Short *) value)->value;
+                       break;
+               case PRIMITIVETYPE_INT:
+                       val = ((java_lang_Integer *) value)->value;
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       val = ((java_lang_Long *) value)->value;
+                       break;
+               case PRIMITIVETYPE_FLOAT:
+                       val = ((java_lang_Float *) value)->value;
+                       break;
+               case PRIMITIVETYPE_DOUBLE:
+                       val = ((java_lang_Double *) value)->value;
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               *((double *) faddr) = val;
+               return;
+       }
+
+       case TYPE_ADR:
+               /* check if value is an instance of the destination class */
+
+               /* XXX TODO */
+               /*                      if (!builtin_instanceof((java_objectheader *) value, df->class)) */
+               /*                              break; */
+
+               *((java_lang_Object **) faddr) = value;
+               return;
+       }
+
+       /* raise exception */
+
+       exceptions_throw_illegalargumentexception();
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BOOLEAN:
+               *((s4 *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;B)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               *((s4 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_LONG:
+               *((s8 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               *((float *) addr) = value;
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               *((double *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;C)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_INT:
+               *((s4 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_LONG:
+               *((s8 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               *((float *) addr) = value;
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               *((double *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;S)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               *((s4 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_LONG:
+               *((s8 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               *((float *) addr) = value;
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               *((double *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_INT:
+               *((s4 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_LONG:
+               *((s8 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               *((float *) addr) = value;
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               *((double *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s8 value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_LONG:
+               *((s8 *) addr) = value;
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               *((float *) addr) = value;
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               *((double *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;F)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, float value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_FLOAT:
+               *((float *) addr) = value;
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               *((double *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;D)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, double value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       void      *addr;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       /* get the address of the field with an internal helper */
+
+       if ((addr = cacao_get_field_address(this, o)) == NULL)
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_DOUBLE:
+               *((double *) addr) = value;
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Field_getSignature(JNIEnv *env, java_lang_reflect_Field* this)
+{
+       classinfo        *c;
+       fieldinfo        *f;
+       java_lang_String *s;
+
+       /* get the class and the field */
+
+       c = (classinfo *) this->declaringClass;
+       f = &c->fields[this->slot];
+
+       if (f->signature == NULL)
+               return NULL;
+
+       s = javastring_new(f->signature);
+
+       /* in error case, s == NULL */
+
+       return s;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_reflect_Method.c b/src/native/vm/gnu/java_lang_reflect_Method.c
new file mode 100644 (file)
index 0000000..d7560e6
--- /dev/null
@@ -0,0 +1,192 @@
+/* src/native/vm/Method.c - java/lang/reflect/Method
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+            Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_reflect_Method.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_reflect_Method.h"
+#include "vm/access.h"
+#include "vm/global.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/initialize.h"
+#include "vm/stringlocal.h"
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+
+       c = (classinfo *) this->declaringClass;
+       m = &(c->methods[this->slot]);
+
+       return m->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    getReturnType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+
+       c = (classinfo *) this->declaringClass;
+       m = &(c->methods[this->slot]);
+
+       return (java_lang_Class *) native_get_returntype(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    getParameterTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+
+       c = (classinfo *) this->declaringClass;
+       m = &(c->methods[this->slot]);
+
+       return native_get_parametertypes(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    getExceptionTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+
+       c = (classinfo *) this->declaringClass;
+       m = &(c->methods[this->slot]);
+
+       return native_get_exceptiontypes(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    invokeNative
+ * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(JNIEnv *env, java_lang_reflect_Method *this, java_lang_Object *o, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
+{
+       classinfo        *c;
+       methodinfo       *m;
+
+       c = (classinfo *) declaringClass;
+       m = &(c->methods[slot]);
+
+       /* check method access */
+       /* check if we should bypass security checks (AccessibleObject) */
+
+       if (this->flag == false) {
+               if (!access_check_caller(c, m->flags, 1))
+                       return NULL;
+       }
+
+       /* check if method class is initialized */
+
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
+                       return NULL;
+
+       /* call the Java method via a helper function */
+
+       return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this)
+{
+       classinfo        *c;
+       methodinfo       *m;
+       java_lang_String *s;
+
+       c = (classinfo *) this->declaringClass;
+       m = &(c->methods[this->slot]);
+
+       if (m->signature == NULL)
+               return NULL;
+
+       s = javastring_new(m->signature);
+
+       /* in error case, s == NULL */
+
+       return s;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_lang_reflect_VMProxy.c b/src/native/vm/gnu/java_lang_reflect_VMProxy.c
new file mode 100644 (file)
index 0000000..2f96606
--- /dev/null
@@ -0,0 +1,95 @@
+/* src/native/vm/VMProxy.c - java/lang/reflect/VMProxy
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+
+   Changes: Joseph Wenninger
+            Christian Thalinger
+
+   $Id: java_lang_reflect_VMProxy.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include <stdlib.h>
+
+#include "native/jni.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "toolbox/logging.h"
+
+
+/*
+ * Class:     java/lang/reflect/VMProxy
+ * Method:    getProxyClass
+ * Signature: (Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMProxy_getProxyClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, java_objectarray *par2)
+{
+       log_text("Java_java_lang_reflect_Proxy_getProxyClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMProxy
+ * Method:    getProxyData
+ * Signature: (Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/reflect/Proxy$ProxyData;
+ */
+JNIEXPORT struct java_lang_reflect_Proxy_ProxyData* JNICALL Java_java_lang_reflect_VMProxy_getProxyData(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, java_objectarray *par2)
+{
+       log_text("Java_java_lang_reflect_Proxy_getProxyData: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMProxy
+ * Method:    generateProxyClass
+ * Signature: (Ljava/lang/ClassLoader;Ljava/lang/reflect/Proxy$ProxyData;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMProxy_generateProxyClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, struct java_lang_reflect_Proxy_ProxyData *par2)
+{
+       log_text("Java_java_lang_reflect_Proxy_generateProxyClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/java_security_VMAccessController.c b/src/native/vm/gnu/java_security_VMAccessController.c
new file mode 100644 (file)
index 0000000..36d1d1e
--- /dev/null
@@ -0,0 +1,100 @@
+/* src/native/vm/VMAccessController.c - java/security/VMAccessController
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Joseph Wenninger
+
+   Changes: Christian Thalinger
+
+   $Id: java_security_VMAccessController.c 6213 2006-12-18 17:36:06Z twisti $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/options.h"
+#include "vm/jit/stacktrace.h"
+
+
+/*
+ * Class:     java/security/VMAccessController
+ * Method:    getStack
+ * Signature: ()[[Ljava/lang/Object;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz) {
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined (__X86_64__)
+       /* these JITs support stacktraces */
+
+       return stacktrace_getStack();
+
+#else
+# if defined(ENABLE_INTRP)
+       /* the interpreter supports stacktraces, even if the JIT does not */
+
+       if (opt_intrp) {
+               return stacktrace_getStack();
+
+       } else
+# endif
+               {
+                       java_objectarray *result;
+                       java_objectarray *classes;
+                       java_objectarray *methodnames;
+
+                       if (!(result = builtin_anewarray(2, arrayclass_java_lang_Object)))
+                               return NULL;
+
+                       if (!(classes = builtin_anewarray(0, class_java_lang_Class)))
+                               return NULL;
+
+                       if (!(methodnames = builtin_anewarray(0, class_java_lang_String)))
+                               return NULL;
+
+                       result->data[0] = (java_objectheader *) classes;
+                       result->data[1] = (java_objectheader *) methodnames;
+
+                       return result;
+               }
+#endif
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu/sun_misc_Unsafe.c b/src/native/vm/gnu/sun_misc_Unsafe.c
new file mode 100644 (file)
index 0000000..a916513
--- /dev/null
@@ -0,0 +1,282 @@
+/* src/native/vm/sun_misc_Unsafe.c - sun/misc/Unsafe
+
+   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+   Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: java_lang_VMObject.c 5153 2006-07-18 08:19:24Z twisti $
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_reflect_Field.h"
+#include "native/include/java_lang_Thread.h" /* required by sun_misc_Unsafe.h */
+#include "native/include/sun_misc_Unsafe.h"
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    objectFieldOffset
+ * Signature: (Ljava/lang/reflect/Field;)J
+ */
+JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe* this, java_lang_reflect_Field* field)
+{
+       classinfo *c;
+       fieldinfo *f;
+
+       c = (classinfo *) field->declaringClass;
+       f = &c->fields[field->slot];
+
+       return (s8) f->offset;
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    compareAndSwapInt
+ * Signature: (Ljava/lang/Object;JII)Z
+ */
+JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, sun_misc_Unsafe* this, java_lang_Object* obj, s8 offset, s4 expect, s4 update)
+{
+       s4 *p;
+       s4  value;
+
+       p = (s4 *) (((u1 *) obj) + offset);
+
+       /* XXX this should be atomic */
+
+       value = *p;
+
+       if (value == expect) {
+               *p = update;
+
+               return true;
+       }
+
+       return false;
+}
+
+
+#if 0
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    compareAndSwapLong
+ * Signature: (Ljava/lang/Object;JJJ)Z
+ */
+JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3, s8 par4)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    compareAndSwapObject
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3, struct java_lang_Object* par4)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putOrderedInt
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s4 par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putOrderedLong
+ * Signature: (Ljava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putOrderedObject
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putIntVolatile
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s4 par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getIntVolatile
+ * Signature: (Ljava/lang/Object;J)I
+ */
+JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putLongVolatile
+ * Signature: (Ljava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putLong
+ * Signature: (Ljava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getLongVolatile
+ * Signature: (Ljava/lang/Object;J)J
+ */
+JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;J)J
+ */
+JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putObjectVolatile
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    putObject
+ * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    getObjectVolatile
+ * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    arrayBaseOffset
+ * Signature: (Ljava/lang/Class;)I
+ */
+JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    arrayIndexScale
+ * Signature: (Ljava/lang/Class;)I
+ */
+JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    unpark
+ * Signature: (Ljava/lang/Thread;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Thread* par1)
+{
+}
+
+
+/*
+ * Class:     sun/misc/Unsafe
+ * Method:    park
+ * Signature: (ZJ)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, struct sun_misc_Unsafe* this, s4 par1, s8 par2)
+{
+}
+#endif
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/native/vm/gnu_classpath_VMStackWalker.c b/src/native/vm/gnu_classpath_VMStackWalker.c
deleted file mode 100644 (file)
index fb43789..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/* src/native/vm/gnu_classpath_VMStackWalker.c - gnu/classpath/VMStackWalker
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes: Edwin Steiner
-
-   $Id: gnu_classpath_VMStackWalker.c 5257 2006-08-21 17:37:01Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "vm/builtin.h"
-#include "vm/class.h"
-#include "vm/global.h"
-#include "vm/options.h"
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getClassContext
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
-{
-       java_objectarray *oa;
-
-       oa = stacktrace_getClassContext();
-
-       return oa;
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getCallingClass
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
-{
-       java_objectarray *oa;
-
-       oa = stacktrace_getClassContext();
-
-       if (oa == NULL)
-               return NULL;
-
-       if (oa->header.size < 2)
-               return NULL;
-
-       return (java_lang_Class *) oa->data[1];
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getCallingClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
-{
-       java_objectarray  *oa;
-       classinfo         *c;
-       java_objectheader *cl;
-
-       oa = stacktrace_getClassContext();
-
-       if (oa == NULL)
-               return NULL;
-
-       if (oa->header.size < 2)
-               return NULL;
-        
-       c  = (classinfo *) oa->data[1];
-       cl = c->classloader;
-
-       return (java_lang_ClassLoader *) cl;
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    firstNonNullClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
-{
-       java_objectarray  *oa;
-       classinfo         *c;
-       java_objectheader *cl;
-       s4                 i;
-
-       oa = stacktrace_getClassContext();
-
-       if (oa == NULL)
-               return NULL;
-
-       for (i = 0; i < oa->header.size; i++) {
-               c  = (classinfo *) oa->data[i];
-               cl = c->classloader;
-
-               if (cl != NULL)
-                       return (java_lang_ClassLoader *) cl;
-       }
-
-       return NULL;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/gnu_classpath_VMSystemProperties.c b/src/native/vm/gnu_classpath_VMSystemProperties.c
deleted file mode 100644 (file)
index 876ccf0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* src/native/vm/VMSystemProperties.c - gnu/classpath/VMSystemProperties
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   $Id: gnu_classpath_VMSystemProperties.c 5988 2006-11-15 17:58:25Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <stdlib.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_util_Properties.h"
-#include "vm/exceptions.h"
-#include "vm/properties.h"
-
-
-/*
- * Class:     gnu/classpath/VMSystemProperties
- * Method:    preInit
- * Signature: (Ljava/util/Properties;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *p)
-{
-       if (p == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* add all properties */
-
-       properties_system_add_all(p);
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/gnu_classpath_jdwp_VMFrame.c b/src/native/vm/gnu_classpath_jdwp_VMFrame.c
deleted file mode 100644 (file)
index 1091241..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* src/native/vm/VMFrame.c - jdwp->jvmti interface
-
-Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-J. Wenninger, Institut f. Computersprachen - TU Wien
-
-This file is part of CACAO.
-
-This program 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.
-
-This program 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 this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.
-
-Contact: cacao@cacaojvm.org
-
-Authors: Martin Platter
-
-Changes: 
-
-
-$Id: gnu_classpath_jdwp_VMFrame.c 5157 2006-07-18 11:09:47Z twisti $
-
-*/
-
-#include "toolbox/logging.h"
-#include "native/jni.h"
-#include "native/include/gnu_classpath_jdwp_VMFrame.h"
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMFrame
- * Method:    getValue
- * Signature: (I)Ljava/lang/Object;
- */
-JNIEXPORT struct java_lang_Object* JNICALL Java_gnu_classpath_jdwp_VMFrame_getValue(JNIEnv *env, struct gnu_classpath_jdwp_VMFrame* this, s4 par1) {
-    log_text ("JVMTI-Call: IMPLEMENT ME!!!");
-    return 0;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMFrame
- * Method:    setValue
- * Signature: (ILjava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMFrame_setValue(JNIEnv *env, struct gnu_classpath_jdwp_VMFrame* this, s4 par1, struct java_lang_Object* par2) {
-    log_text ("JVMTI-Call: IMPLEMENT ME!!!");
-       return 0;
-}
diff --git a/src/native/vm/gnu_classpath_jdwp_VMMethod.c b/src/native/vm/gnu_classpath_jdwp_VMMethod.c
deleted file mode 100644 (file)
index 8dbbfac..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-/* src/native/vm/VMMethod.c - jdwp->jvmti interface
-
-Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-J. Wenninger, Institut f. Computersprachen - TU Wien
-
-This file is part of CACAO.
-
-This program 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.
-
-This program 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 this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.
-
-Contact: cacao@cacaojvm.org
-
-Authors: Samuel Vinson
-         Martin Platter
-         
-
-Changes: 
-
-
-$Id: VMMethod.c $
-
-*/
-
-#include "native/jni.h"
-#include "native/include/gnu_classpath_jdwp_VMMethod.h"
-#include "native/jvmti/jvmti.h"
-#include "native/jvmti/VMjdwp.h"
-
-
-void printjvmtierror(char *desc, jvmtiError err) {
-    char* errdesc;
-       
-       if (err == JVMTI_ERROR_NONE) return;
-       (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
-       fprintf(stderr,"%s: jvmti error %s\n",desc, errdesc);
-       fflush(stderr);
-       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
-}
-
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMMethod
- * Method:    getName
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getName(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
-{
-    jvmtiError err;
-    char *name;
-    jstring stringname;
-    
-    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                             GetMethodName(jvmtienv, 
-                                                                                  (jmethodID)(long)this->_methodId,
-                                           &name,NULL, NULL))) {
-               printjvmtierror("VMMethod.getName GetMethodName",err);
-        return NULL;
-    }
-    
-    stringname = (*env)->NewStringUTF(env,name);
-    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)name);
-
-    return stringname;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMMethod
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getSignature(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
-{
-    jvmtiError err;
-    char *signature;
-    jstring stringsignature;
-    
-    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                             GetMethodName(jvmtienv, 
-                                                                                  (jmethodID)(long)this->_methodId,
-                                           NULL, &signature, NULL))) {
-               printjvmtierror("VMMethod.getSignature GetMethodName",err);
-        return NULL;
-    }
-    
-    stringsignature = (*env)->NewStringUTF(env,signature);
-    (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)signature);
-    
-    return stringsignature;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMMethod
- * Method:    getModifiers
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMMethod_getModifiers(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
-{
-    jvmtiError err;
-    jint modifiers;
-       
-    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
-                                                  GetMethodModifiers(jvmtienv, 
-                                                                                         (jmethodID)(long)this->_methodId,
-                                                                                         &modifiers))) {
-               printjvmtierror("VMMethod.getModifiers GetMethodModifiers",err);
-        return 0;
-    }
-    
-    return modifiers;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMMethod
- * Method:    getLineTable
- * Signature: ()Lgnu/classpath/jdwp/util/LineTable;
- */
-JNIEXPORT struct gnu_classpath_jdwp_util_LineTable* JNICALL Java_gnu_classpath_jdwp_VMMethod_getLineTable(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this) 
-{
-    jclass cl;
-    jmethodID m;
-    jobject ol;
-    jlongArray jlineCI;
-    jintArray jlineNum;
-    jint count = 0, i;
-    int *lineNum;
-    long *lineCI;
-    jvmtiLineNumberEntry *lne;
-    jlocation start,end;
-    
-    jvmtiError err;
-
-    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
-                                                  GetLineNumberTable(jvmtienv, 
-                                                                                         (jmethodID)(long)this->_methodId,
-                                                                                         &count, &lne))) {
-               printjvmtierror("VMMethod.getlinetable GetLineNumberTable",err);
-        return NULL;
-    }
-
-    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.util.LineTable");
-    if (!cl) return NULL;
-
-    m = (*env)->GetMethodID(env, cl, "<init>", "(JJ[I[J)V");
-    if (!m) return NULL;
-       
-    jlineNum = (*env)->NewIntArray(env, count);
-    if (!jlineNum) return NULL;
-    jlineCI = (*env)->NewLongArray(env, count);
-    if (!jlineCI) return NULL;
-    lineNum = (*env)->GetIntArrayElements(env, jlineNum, NULL);
-    lineCI = (*env)->GetLongArrayElements(env, jlineCI, NULL);
-    for (i = 0; i < count; ++i) {
-        lineNum[i] = lne[i].line_number;
-        lineCI[i] = lne[i].start_location;
-    }
-    (*env)->ReleaseLongArrayElements(env, jlineCI, lineCI, 0);
-    (*env)->ReleaseIntArrayElements(env, jlineNum, lineNum, 0);
-    (*jvmtienv)->Deallocate(jvmtienv, lne);
-
-    if (JVMTI_ERROR_NONE!=(err= (*jvmtienv)->
-                                                  GetMethodLocation(jvmtienv, 
-                                                                                        (jmethodID)(long)this->_methodId, 
-                                                                                        &start, &end))) {
-               printjvmtierror("VMMethod.getlinetable GetMethodLocation",err);
-        return NULL;
-    }
-
-    ol = (*env)->NewObject(env, cl, m, start, 
-                           end, jlineNum, jlineCI);
-
-    return (struct gnu_classpath_jdwp_util_LineTable*)ol;
-}
-
-static bool fillVariableTable(JNIEnv *env, jvmtiLocalVariableEntry* entries, 
-                                                         int count, jlongArray *jlineCI, 
-                                                         jobjectArray *names, jobjectArray *sigs, 
-                                                         jintArray *jlengths, jintArray *jslot) {
-       jint *lengths, *slot,i;
-       jclass cl;
-       jlong *lineCI;
-
-       *jlineCI = (*env)->NewLongArray(env, count);
-       if (!*jlineCI) return false;
-
-       cl=(*env)->FindClass(env,"java/lang/String");
-       if (!cl) return false;
-       
-       *names = (*env)->NewObjectArray(env, count, cl, NULL);
-       if (names) return false;
-       sigs = (*env)->NewObjectArray(env, count, cl, NULL);
-       if (sigs) return false;
-       
-       jlengths = (*env)->NewIntArray(env, count);
-       if (!lengths) return false;
-       
-       jslot = (*env)->NewIntArray(env, count);
-       if (!slot) return false;
-       
-       lineCI = (*env)->GetLongArrayElements(env, *jlineCI, NULL);
-       lengths = (*env)->GetIntArrayElements(env, *jlengths, NULL);
-       slot = (*env)->GetIntArrayElements(env, jslot, NULL);
-       
-       for (i=0; i<count; i++) {
-               (*env)->
-                       SetObjectArrayElement(env, *names, i, 
-                                                                 (*env)->NewStringUTF(env,entries[i].name));
-               (*env)->
-                       SetObjectArrayElement(env, *sigs, i, (*env)->NewStringUTF(
-                                                                         env,entries[i].signature));
-               lineCI[i]=entries[i].start_location;
-               lengths[i]=entries[i].length;
-               slot[i]=entries[i].slot;
-       }
-    (*env)->ReleaseLongArrayElements(env, jlineCI, lineCI, 0);
-    (*env)->ReleaseIntArrayElements(env, jlengths, lengths, 0);
-    (*env)->ReleaseIntArrayElements(env, jslot, slot, 0);
-       return true;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMMethod
- * Method:    getVariableTable
- * Signature: ()Lgnu/classpath/jdwp/util/VariableTable;
- */
-JNIEXPORT struct gnu_classpath_jdwp_util_VariableTable* JNICALL Java_gnu_classpath_jdwp_VMMethod_getVariableTable(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
-{
-       jvmtiLocalVariableEntry* localvarentries;
-       jint entry_count, argCnt, slots; 
-       jclass cl;
-       jmethodID m, vmmethodid;
-    jobject o;
-       jobjectArray names, sigs;
-    jvmtiError err;
-    jlongArray jlineCI;
-       jintArray jlengths, jslot;
-
-       vmmethodid = (jmethodID)(long)this->_methodId;
-
-       err= (*jvmtienv)->GetLocalVariableTable(jvmtienv, 
-                                                                                       vmmethodid,
-                                                                                       &entry_count, 
-                                                                                       &localvarentries);
-    if (JVMTI_ERROR_NONE != err) { 
-               if (err == JVMTI_ERROR_ABSENT_INFORMATION) {
-                       /* no local variable table available for this method. 
-                          return an empty local variable table */
-                       argCnt = slots = 0;
-                       names = sigs = jlineCI = jlengths = jslot = NULL;
-               } else {
-                       printjvmtierror("VMMethod.getVariableTable GetLocalVariableTable",err);
-                       return NULL;
-               }
-       } else {
-               if (JVMTI_ERROR_NONE != (err= 
-                                                                (*jvmtienv)->GetArgumentsSize(jvmtienv, 
-                                                                                                                          vmmethodid, 
-                                                                                                                          &argCnt))) {
-                       printjvmtierror("VMMethod.getVariableTable GetArgumentsSize",err);
-                       return NULL;
-               }
-
-               if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->GetMaxLocals(jvmtienv, 
-                                                                                                                               vmmethodid,
-                                                                                                                               &slots))) {
-                       printjvmtierror("VMMethod.getVariableTable GetMaxLocals",err);
-                       return NULL;
-               }
-               
-               slots = slots - argCnt;
-               if (!fillVariableTable(env, localvarentries, entry_count, &jlineCI, 
-                                                          &names, &sigs, &jlengths, &jslot)) 
-                       return NULL;
-               (*jvmtienv)->
-                       Deallocate(jvmtienv, (unsigned char*)localvarentries->signature);
-               (*jvmtienv)->
-                       Deallocate(jvmtienv, (unsigned char*)localvarentries->name);
-               if (localvarentries->generic_signature != NULL)
-                       (*jvmtienv)-> Deallocate(jvmtienv, (unsigned char*)
-                                                                        localvarentries->generic_signature);
-
-
-               (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)localvarentries);
-       }
-       
-    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.util.VariableTable");
-    if (!cl) return NULL;
-
-    m = (*env)->
-               GetMethodID(env, cl,"<init>", 
-                                       "(II[J[Ljava/lang/String;[Ljava/lang/String;[I[I)V");
-    if (!m) return NULL;
-
-    o = (*env)->NewObject(env, cl, m, argCnt, slots, jlineCI, 
-                                                 names, sigs, jlengths, jslot);        
-
-    return (struct gnu_classpath_jdwp_util_VariableTable*) o;
-}
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/gnu_classpath_jdwp_VMVirtualMachine.c b/src/native/vm/gnu_classpath_jdwp_VMVirtualMachine.c
deleted file mode 100644 (file)
index 99ab8b9..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-/* src/native/vm/VMVirtualMachine.c - jdwp->jvmti interface
-
-Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-J. Wenninger, Institut f. Computersprachen - TU Wien
-
-This file is part of CACAO.
-
-This program 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.
-
-This program 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 this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.
-
-Contact: cacao@cacaojvm.org
-
-Authors: Martin Platter
-
-Changes: Samuel Vinson
-
-
-$Id: gnu_classpath_jdwp_VMVirtualMachine.c 5157 2006-07-18 11:09:47Z twisti $
-
-*/
-
-#include "toolbox/logging.h"
-#include "native/jni.h"
-#include "native/include/java_lang_Thread.h"
-#include "native/include/java_nio_ByteBuffer.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_reflect_Method.h"
-#include "native/include/gnu_classpath_jdwp_event_EventRequest.h"
-#include "native/include/gnu_classpath_jdwp_VMVirtualMachine.h"
-#include "native/jvmti/jvmti.h"
-#include "native/jvmti/VMjdwp.h"
-#include <string.h>
-
-
-/*
- * Class:     gnu_classpath_jdwp_VMVirtualMachine
- * Method:    suspendThread
- * Signature: (Ljava/lang/Thread;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1)
-{
-       jvmtiError err; 
-
-    err = (*jvmtienv)->SuspendThread(jvmtienv, (jthread) par1);
-       printjvmtierror("VMVirtualMachine.suspendThread SuspendThread", err);
-}
-
-/*
- * Class:     gnu_classpath_jdwp_VMVirtualMachine
- * Method:    resumeThread
- * Signature: (Ljava/lang/Thread;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_resumeThread(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1)
-{
-       jvmtiError err; 
-
-    err = (*jvmtienv)->ResumeThread(jvmtienv, (jthread) par1);
-       printjvmtierror("VMVirtualMachine.resumethread ResumeThread", err);
-}
-
-
-/*
- * Class:     gnu_classpath_jdwp_VMVirtualMachine
- * Method:    getSuspendCount
- * Signature: (Ljava/lang/Thread;)I
- */
-JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getSuspendCount(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
-    log_text ("VMVirtualMachine_getSuspendCount: not supported");
-       return 1;
-}
-
-/*
- * Class:     gnu_classpath_jdwp_VMVirtualMachine
- * Method:    getAllLoadedClassesCount
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClassesCount(JNIEnv *env, jclass clazz) {
-    jint count;
-    jclass* classes;
-       jvmtiError err;
-
-       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-               GetLoadedClasses(jvmtienv, &count, &classes))) {
-               printjvmtierror("VMVirtualMachine_getAllLoadedClassCount GetLoadedClasses",err);
-               return 0;
-       }
-       (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)classes);
-    return count;
-}
-
-/*
- * Class:     gnu_classpath_jdwp_VMVirtualMachine
- * Method:    getAllLoadedClasses
- * Signature: ()Ljava/util/Iterator
- */
-JNIEXPORT struct java_util_Iterator* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClasses(JNIEnv *env, jclass clazz) {
-       jclass *classes, *cl;
-       jint classcount;
-       jobjectArray joa;
-/*     jthrowable e;*/
-       jmethodID m;
-       jobject *ol,*oi;
-       int i;
-       jvmtiError err;
-
-       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-               GetLoadedClasses(jvmtienv, &classcount, &classes))) {
-               printjvmtierror("VMVirtualMachine_getAllLoadedClasses GetLoadedClasses",err);
-               
-               /* we should throw JDWP Exception INTERNAL = 113;*/
-/*             env->ThrowNew(env,ec,"jvmti error occoured");  */
-               return NULL;
-       }
-       
-       cl = (*env)->FindClass(env,"java.lang.Class");
-       if (!cl) return NULL;
-
-       /* Arrays.asList(Object[] classes)->List.Iterator()->Iterator */
-       joa = (*env)->NewObjectArray(env, (jsize)classcount, cl , NULL);
-       if (!joa) return NULL;
-
-       for (i = 0; i < classcount; i++) 
-               (*env)->SetObjectArrayElement(env,joa,(jsize)i, (jobject)classes[i]);
-       (*jvmtienv)->Deallocate(jvmtienv, (unsigned char*)classes);
-       
-       cl = (*env)->FindClass(env,"java.util.Arrays");
-       if (!cl) return NULL;
-
-       m = (*env)->GetStaticMethodID(env, cl, "asList", "([Ljava/lang/Object;)Ljava/util/List;");
-       if (!m) return NULL;
-
-       ol = (*env)->CallStaticObjectMethod(env,(jclass)cl,m,joa);
-       if (!ol) return NULL;
-
-       cl = (*env)->FindClass(env,"java.util.List");
-       if (!cl) return NULL;
-       m = (*env)->GetMethodID(env,cl,"iterator","()Ljava/util/Iterator;");
-       if (!m) return NULL;
-       oi = (*env)->CallObjectMethod(env,ol,m);
-               
-       return (struct java_util_Iterator*)oi;
-}
-
-/* Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getClassStatus
- * Signature: (Ljava/lang/Class;)I
- */
-JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
-       jint status;
-       jvmtiError err;
-
-       err = (*jvmtienv)->GetClassStatus(jvmtienv, (jclass) par1, &status);
-       printjvmtierror("VMVirtualMachine_getClassStatus GetClassStatus", err);
-
-       return status;
-}
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getAllClassMethods
- * Signature: (Ljava/lang/Class;)[Lgnu/classpath/jdwp/VMMethod;
- */
-JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getAllClassMethods(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
-    jint count;
-    jmethodID* methodID, m;
-       jvmtiError err;
-       
-       jclass *cl;
-       jobject *ol;
-       jobjectArray joa;
-       int i;
-
-    if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-                                                        GetClassMethods(jvmtienv, (jclass) par1, 
-                                                                                        &count, &methodID))) {
-               printjvmtierror("VMVirtualMachine_getAllClassMethods GetClassMethods", err);
-               return NULL;
-       }
-       
-       m = (*env)->
-               GetStaticMethodID(env, clazz, "getClassMethod", 
-                                                 "(Ljava/lang/Class;J)Lgnu/classpath/jdwp/VMMethod;");
-       if (!m) return NULL;
-   
-    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.VMMethod");
-       if (!cl) return NULL;
-       
-       joa = (*env)->NewObjectArray(env, (jsize)count, cl , NULL);
-       if (!joa) return NULL;
-
-    for (i = 0; i < count; i++) {
-       ol = (*env)->
-                       CallStaticObjectMethod(env,clazz,m,(jobject)par1, methodID[i]);
-               if (!ol) return NULL;
-       (*env)->SetObjectArrayElement(env,joa,(jsize)i, ol);
-    }
-       return joa;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getClassMethod
- * Signature: (Ljava/lang/Class;J)Lgnu/classpath/jdwp/VMMethod;
- */
-JNIEXPORT struct gnu_classpath_jdwp_VMMethod* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getClassMethod(JNIEnv *env, jclass clazz, struct java_lang_Class* par1, s8 par2) {
-       jclass *cl;
-    jmethodID m;
-    jobject *ol;
-       
-    cl = (*env)->FindClass(env,"gnu.classpath.jdwp.VMMethod");
-       if (!cl) return NULL;
-       
-       m = (*env)->GetMethodID(env, cl, "<init>", "(Ljava/lang/Class;J)V");
-       if (!m) return NULL;
-       
-    ol = (*env)->NewObject(env, cl, m, par1, par2);
-       
-       return (struct gnu_classpath_jdwp_VMMethod*)ol;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getFrames
- * Signature: (Ljava/lang/Thread;II)Ljava/util/ArrayList;
- */
-JNIEXPORT struct java_util_ArrayList* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrames(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1, s4 par2, s4 par3) {
-    log_text ("VMVirtualMachine_getFrames - IMPLEMENT ME!!!");
-/*     jclass ec = (*env)->FindClass(env,"gnu/classpath/jdwp/JdwpInternalErrorException");
-       if (JVMTI_ERROR_NONE != (*jvmtienv)->GetClassStatus(jvmtienv, par1, &status))
-       env->ThrowNew(env,ec,"jvmti error occoured");*/
-       return 0;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getFrame
- * Signature: (Ljava/lang/Thread;Ljava/nio/ByteBuffer;)Lgnu/classpath/jdwp/VMFrame;
- */
-JNIEXPORT struct gnu_classpath_jdwp_VMFrame* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrame(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1, struct java_nio_ByteBuffer* par2) {
-    log_text ("VMVirtualMachine_getFrame - IMPLEMENT ME!!!");
-       return 0;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getFrameCount
- * Signature: (Ljava/lang/Thread;)I
- */
-JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
-       jint count;
-       jvmtiError err;
-       err = (*jvmtienv)->GetFrameCount(jvmtienv, (jthread)par1, &count);
-       printjvmtierror("VMVirtualMachine_getFrameCount GetFrameCount", err);
-       return count;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getThreadStatus
- * Signature: (Ljava/lang/Thread;)I
- */
-JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getThreadStatus(JNIEnv *env, jclass clazz, struct java_lang_Thread* par1) {
-       jint status;
-       jvmtiError err; 
-       if (JVMTI_ERROR_NONE != (err = (*jvmtienv)->GetThreadState(jvmtienv, (jthread)par1, &status))) {
-               printjvmtierror("VMVirtualMachine_getThreadStatus GetThreadState", err);
-               return 0;
-       }
-       if (status && JVMTI_THREAD_STATE_ALIVE) {
-               if (status && JVMTI_THREAD_STATE_WAITING) {             
-                       return 4; /* WAIT - see JdwpConstants */
-               }
-               if (status && JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) { 
-                       return 3; /* MONITOR - see JdwpConstants */
-               }
-               if (status && JVMTI_THREAD_STATE_SLEEPING) { 
-                       return 2; /* SLEEPING - see JdwpConstants */
-               }
-               return 1; /* RUNNING - see JdwpConstants */
-       } else 
-               return 0; /* ZOMBIE - see JdwpConstants */
-       return -1; /* some error */
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getLoadRequests
- * Signature: (Ljava/lang/ClassLoader;)Ljava/util/ArrayList;
- */
-JNIEXPORT struct java_util_ArrayList* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getLoadRequests(JNIEnv *env, jclass clazz, struct java_lang_ClassLoader* par1) {
-    log_text ("VMVirtualMachine_getLoadRequests(");
-       return 0;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    executeMethod
- * Signature: (Ljava/lang/Object;Ljava/lang/Thread;Ljava/lang/Class;Ljava/lang/reflect/Method;[Ljava/lang/Object;Z)Lgnu/classpath/jdwp/util/MethodResult;
- */
-JNIEXPORT struct gnu_classpath_jdwp_util_MethodResult* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_executeMethod(JNIEnv *env, jclass clazz, struct java_lang_Object* par1, struct java_lang_Thread* par2, struct java_lang_Class* par3, struct java_lang_reflect_Method* par4, java_objectarray* par5, s4 par6) {
-    log_text ("VMVirtualMachine_executeMethod");
-       return 0;
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    getSourceFile
- * Signature: (Ljava/lang/Class;)Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_getSourceFile(JNIEnv *env, jclass clazz, struct java_lang_Class* par1) {
-       char* srcname;
-       jstring str;
-       jvmtiError err; 
-
-    if (JVMTI_ERROR_NONE !=(err=(*jvmtienv)->
-               GetSourceFileName(jvmtienv, (jclass)par1, &srcname))) {
-               printjvmtierror("VMVirtualMachine.getSourceFile GetSourceFileName", err);
-               return NULL;
-       }
-
-       str = (*env)->NewString(env,(jchar*)srcname,(jsize)strlen(srcname));
-
-       return (struct java_lang_String*)str;
-}
-
-/* match JdwpConstants.EventKind to jvmtiEvent constants */
-static jvmtiEvent EventKind2jvmtiEvent(jbyte kind){
-       switch (kind) {
-       case /* SINGLE_STEP */ 1: return JVMTI_EVENT_SINGLE_STEP;
-       case /* BREAKPOINT */ 2: return JVMTI_EVENT_BREAKPOINT;
-    case /*  FRAME_POP */ 3: return JVMTI_EVENT_FRAME_POP;
-    case /*  EXCEPTION */ 4: return JVMTI_EVENT_EXCEPTION;
-    case /*  USER_DEFINED */ 5: return -1; /* can this be matched ? */
-    case /*  THREAD_START */ 6: return JVMTI_EVENT_THREAD_START;
-    case /*  THREAD_END */ 7: return JVMTI_EVENT_THREAD_END;
-    case /*  CLASS_PREPARE */ 8: return JVMTI_EVENT_CLASS_PREPARE;
-    case /*  CLASS_UNLOAD */ 9: return -1; /* can this be matched ? */
-    case /*  CLASS_LOAD */ 10: return JVMTI_EVENT_CLASS_LOAD;
-    case /*  FIELD_ACCESS */ 20: return JVMTI_EVENT_FIELD_ACCESS;
-    case /*  FIELD_MODIFICATION */ 21: return JVMTI_EVENT_FIELD_MODIFICATION;
-    case /*  EXCEPTION_CATCH */ 30: return JVMTI_EVENT_EXCEPTION_CATCH;
-    case /*  METHOD_ENTRY */ 40: return JVMTI_EVENT_METHOD_ENTRY;
-    case /*  METHOD_EXIT */ 41: return JVMTI_EVENT_METHOD_EXIT;
-    case /*  VM_INIT */ 90: return JVMTI_EVENT_VM_INIT;
-    case /*  VM_DEATH */ 99: return JVMTI_EVENT_VM_DEATH;    
-    case /*  VM_DISCONNECTED */ 100: return -1; /* can this be matched ? */
-       default: return -1;
-       }
-}
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    registerEvent
- * Signature: (Lgnu/classpath/jdwp/event/EventRequest;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_registerEvent(JNIEnv *env, jclass clazz, struct gnu_classpath_jdwp_event_EventRequest* par1) {
-       jbyte kind;
-       jfieldID kindid;
-       jclass erc;
-       jvmtiError err;
-
-       erc = (*env)->FindClass(env,"gnu.classpath.jdwp.event.EventRequest");
-       
-       kindid = (*env)->GetFieldID(env, erc, "_kind", "B");
-       kind = (*env)->GetByteField(env, (jobject)par1, kindid);
-
-       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-               SetEventNotificationMode(jvmtienv, JVMTI_ENABLE, 
-                                                                EventKind2jvmtiEvent(kind), NULL)))
-               printjvmtierror("VMVirtualMachine_registerEvent SetEventNotificationMode",err);
-
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    unregisterEvent
- * Signature: (Lgnu/classpath/jdwp/event/EventRequest;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_unregisterEvent(JNIEnv *env, jclass clazz, struct gnu_classpath_jdwp_event_EventRequest* par1) {
-       jbyte kind;
-       jfieldID kindid;
-       jclass erc;
-       jvmtiError err;
-
-       erc = (*env)->FindClass(env,"gnu.classpath.jdwp.event.EventRequest");
-       
-       kindid = (*env)->GetFieldID(env, erc, "_kind", "B");
-       kind = (*env)->GetByteField(env, (jobject)par1, kindid);
-
-       if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
-               SetEventNotificationMode(jvmtienv, JVMTI_DISABLE, 
-                                                                EventKind2jvmtiEvent(kind), NULL)))
-               printjvmtierror("VMVirtualMachine_registerEvent SetEventNotificationMode",err);
-
-}
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMVirtualMachine
- * Method:    clearEvents
- * Signature: (B)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_jdwp_VMVirtualMachine_clearEvents(JNIEnv *env, jclass clazz, s4 par1) {
-       /* jvmti events are not saved - there is nothing to clear */
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c b/src/native/vm/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
deleted file mode 100644 (file)
index 7ee69bf..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* src/native/vm/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
-
-*/
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-
-#include "toolbox/logging.h"
-#include "vm/classcache.h"
-#include "vm/vm.h"
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    getLoadedClassCount
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
-{
-       s4 count;
-
-       count = classcache_get_loaded_class_count();
-
-       return count;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    getUnloadedClassCount
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    isVerbose
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    setVerbose
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, s4 verbose)
-{
-       _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose = verbose;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/gnu_java_lang_management_VMMemoryMXBeanImpl.c b/src/native/vm/gnu_java_lang_management_VMMemoryMXBeanImpl.c
deleted file mode 100644 (file)
index 4dc96e5..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/* src/native/vm/gnu_java_lang_management_VMMemoryMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
-
-*/
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/include/java_lang_management_MemoryUsage.h"
-
-#include "vm/builtin.h"
-#include "vm/class.h"
-#include "vm/global.h"
-#include "vm/loader.h"                   /* XXX only for load_class_bootstrap */
-#include "vm/options.h"
-#include "vm/vm.h"
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    getHeapMemoryUsage
- * Signature: ()Ljava/lang/management/MemoryUsage;
- */
-JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
-{
-       classinfo                        *class_java_lang_management_MemoryUsage;
-       java_objectheader                *o;
-       java_lang_management_MemoryUsage *mu;
-       methodinfo                       *m;
-       s8                                init;
-       s8                                used;
-       s8                                commited;
-       s8                                maximum;
-
-       /* get the class */
-       /* XXX optimize me! sometime... */
-
-       if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage"))))
-               return false;
-
-       /* create the object */
-
-       o = builtin_new(class_java_lang_management_MemoryUsage);
-       
-       if (o == NULL)
-               return NULL;
-
-       /* cast the object to a MemoryUsage object (for debugability) */
-
-       mu = (java_lang_management_MemoryUsage *) o;
-
-       /* find initializer */
-
-       m = class_findmethod(class_java_lang_management_MemoryUsage,
-                                                utf_init, utf_new_char("(JJJJ)V"));
-                                                     
-       /* initializer not found */
-
-       if (m == NULL)
-               return NULL;
-
-       /* get values from the VM */
-       /* XXX if we ever support more than one VM, change this */
-
-       init     = opt_heapstartsize;
-       used     = gc_get_total_bytes();
-       commited = gc_get_heap_size();
-       maximum  = gc_get_max_heap_size();
-
-       /* call initializer */
-
-       (void) vm_call_method(m, o, init, used, commited, maximum);
-
-       return mu;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    getNonHeapMemoryUsage
- * Signature: ()Ljava/lang/management/MemoryUsage;
- */
-JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    getObjectPendingFinalizationCount
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    isVerbose
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMMemoryMXBeanImpl
- * Method:    setVerbose
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, s4 verbose)
-{
-       _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/gnu_java_lang_management_VMRuntimeMXBeanImpl.c b/src/native/vm/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
deleted file mode 100644 (file)
index 68e8784..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* src/native/vm/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
-
-*/
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "vm/builtin.h"
-#include "vm/class.h"
-#include "vm/global.h"
-#include "vm/vm.h"
-
-
-/*
- * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
- * Method:    getInputArguments
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_objectarray* JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments: IMPLEMENT ME!");
-
-       return builtin_anewarray(0, class_java_lang_String);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
- * Method:    getStartTime
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->starttime;
-}
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/gnu_java_lang_management_VMThreadMXBeanImpl.c b/src/native/vm/gnu_java_lang_management_VMThreadMXBeanImpl.c
deleted file mode 100644 (file)
index 8bde343..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/* src/native/vm/gnu_java_lang_management_VMThreadMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
-
-*/
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/include/java_lang_management_ThreadInfo.h"
-
-#include "toolbox/logging.h"
-#include "vm/classcache.h"
-#include "vm/vm.h"
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    findMonitorDeadlockedThreads
- * Signature: ()[J
- */
-JNIEXPORT java_longarray* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getCurrentThreadCpuTime
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getCurrentThreadUserTime
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getPeakThreadCount
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getThreadCpuTime
- * Signature: (J)J
- */
-JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, s8 id)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getThreadInfoForId
- * Signature: (JI)Ljava/lang/management/ThreadInfo;
- */
-JNIEXPORT java_lang_management_ThreadInfo* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, s8 id, s4 maxDepth)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getThreadUserTime
- * Signature: (J)J
- */
-JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, s8 par1)
-{
-       log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    getTotalStartedThreadCount
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    resetPeakThreadCount
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount(JNIEnv *env, jclass clazz)
-{
-       _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
-               _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/java_lang_Class.c b/src/native/vm/java_lang_Class.c
new file mode 100644 (file)
index 0000000..e44694c
--- /dev/null
@@ -0,0 +1,1033 @@
+/* src/native/vm/java_lang_Class.c - java/lang/Class
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Roman Obermaiser
+            Joseph Wenninger
+            Christian Thalinger
+            Edwin Steiner
+
+   $Id: java_lang_VMClass.c 6131 2006-12-06 22:15:57Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_VMClass.h"
+#include "native/include/java_lang_reflect_Constructor.h"
+#include "native/include/java_lang_reflect_Field.h"
+#include "native/include/java_lang_reflect_Method.h"
+#include "native/include/java_security_ProtectionDomain.h"
+#include "native/vm/java_lang_Class.h"
+#include "toolbox/logging.h"
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/exceptions.h"
+#include "vm/global.h"
+#include "vm/initialize.h"
+#include "vm/loader.h"
+#include "vm/resolve.h"
+#include "vm/stringlocal.h"
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isInstance
+ * Signature: (Ljava/lang/Object;)Z
+ */
+s4 _Jv_java_lang_Class_isInstance(java_lang_Class *klass, java_lang_Object *o)
+{
+       classinfo         *c;
+       java_objectheader *ob;
+
+       c = (classinfo *) klass;
+       ob = (java_objectheader *) o;
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return 0;
+
+       return builtin_instanceof(ob, c);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isAssignableFrom
+ * Signature: (Ljava/lang/Class;)Z
+ */
+s4 _Jv_java_lang_Class_isAssignableFrom(java_lang_Class *klass, java_lang_Class *c)
+{
+       classinfo *kc;
+       classinfo *cc;
+
+       kc = (classinfo *) klass;
+       cc = (classinfo *) c;
+
+       if (cc == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       if (!(kc->state & CLASS_LINKED))
+               if (!link_class(kc))
+                       return 0;
+
+       if (!(cc->state & CLASS_LINKED))
+               if (!link_class(cc))
+                       return 0;
+
+       /* XXX this may be wrong for array classes */
+
+       return builtin_isanysubclass(cc, kc);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isInterface
+ * Signature: ()Z
+ */
+s4 _Jv_java_lang_Class_isInterface(java_lang_Class *klass)
+{
+       classinfo *c;
+
+       c = (classinfo *) klass;
+
+       if (c->flags & ACC_INTERFACE)
+               return true;
+
+       return false;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isPrimitive
+ * Signature: ()Z
+ */
+s4 _Jv_java_lang_Class_isPrimitive(java_lang_Class *klass)
+{
+       classinfo *c;
+       s4         i;
+
+       c = (classinfo *) klass;
+
+       /* search table of primitive classes */
+
+       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
+               if (primitivetype_table[i].class_primitive == c)
+                       return true;
+
+       return false;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getName
+ * Signature: ()Ljava/lang/String;
+ */
+java_lang_String *_Jv_java_lang_Class_getName(java_lang_Class *klass)
+{
+       classinfo        *c;
+       java_lang_String *s;
+       u4                i;
+
+       c = (classinfo *) klass;
+
+       /* create a java string */
+
+       s = (java_lang_String *) javastring_new(c->name);
+
+       if (s == NULL)
+               return NULL;
+
+       /* return string where '/' is replaced by '.' */
+
+       for (i = 0; i < s->value->header.size; i++) {
+               if (s->value->data[i] == '/')
+                       s->value->data[i] = '.';
+       }
+
+       return s;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getSuperclass
+ * Signature: ()Ljava/lang/Class;
+ */
+java_lang_Class *_Jv_java_lang_Class_getSuperclass(java_lang_Class *klass)
+{
+       classinfo *c;
+       classinfo *sc;
+
+       c = (classinfo *) klass;
+
+       /* for java.lang.Object, primitive and Void classes we return NULL */
+
+       if (!c->super.any)
+               return NULL;
+
+       /* for interfaces we also return NULL */
+
+       if (c->flags & ACC_INTERFACE)
+               return NULL;
+
+       /* we may have to resolve the super class reference */
+
+       if (!resolve_classref_or_classinfo(NULL, c->super, resolveEager, 
+                                                                          true, /* check access */
+                                                                          false,  /* don't link */
+                                                                          &sc))
+       {
+               return NULL;
+       }
+
+       /* store the resolution */
+
+       c->super.cls = sc;
+
+       return (java_lang_Class *) sc;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getInterfaces
+ * Signature: ()[Ljava/lang/Class;
+ */
+java_objectarray *_Jv_java_lang_Class_getInterfaces(java_lang_Class *klass)
+{
+       classinfo        *c;
+       classinfo        *ic;
+       java_objectarray *oa;
+       u4                i;
+
+       c = (classinfo *) klass;
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       oa = builtin_anewarray(c->interfacescount, class_java_lang_Class);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0; i < c->interfacescount; i++) {
+               ic = c->interfaces[i].cls;
+
+               oa->data[i] = (java_objectheader *) ic;
+       }
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getComponentType
+ * Signature: ()Ljava/lang/Class;
+ */
+java_lang_Class *_Jv_java_lang_Class_getComponentType(java_lang_Class *klass)
+{
+       classinfo       *c;
+       classinfo       *comp;
+       arraydescriptor *desc;
+       
+       c = (classinfo *) klass;
+       
+       /* XXX maybe we could find a way to do this without linking. */
+       /* This way should be safe and easy, however.                */
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       desc = c->vftbl->arraydesc;
+       
+       if (desc == NULL)
+               return NULL;
+       
+       if (desc->arraytype == ARRAYTYPE_OBJECT)
+               comp = desc->componentvftbl->class;
+       else
+               comp = primitivetype_table[desc->arraytype].class_primitive;
+               
+       return (java_lang_Class *) comp;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getModifiers
+ * Signature: (Z)I
+ */
+s4 _Jv_java_lang_Class_getModifiers(java_lang_Class *klass, s4 ignoreInnerClassesAttrib)
+{
+       classinfo             *c;
+       classref_or_classinfo  inner;
+       classref_or_classinfo  outer;
+       utf                   *innername;
+       s4                     i;
+
+       c = (classinfo *) klass;
+
+       if (!ignoreInnerClassesAttrib && (c->innerclasscount != 0)) {
+               /* search for passed class as inner class */
+
+               for (i = 0; i < c->innerclasscount; i++) {
+                       inner = c->innerclass[i].inner_class;
+                       outer = c->innerclass[i].outer_class;
+
+                       /* Check if inner is a classref or a real class and get
+               the name of the structure */
+
+                       innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name;
+
+                       /* innerclass is this class */
+
+                       if (innername == c->name) {
+                               /* has the class actually an outer class? */
+
+                               if (outer.any)
+                                       /* return flags got from the outer class file */
+                                       return c->innerclass[i].flags & ACC_CLASS_REFLECT_MASK;
+                               else
+                                       return c->flags & ACC_CLASS_REFLECT_MASK;
+                       }
+               }
+       }
+
+       /* passed class is no inner class or it was not requested */
+
+       return c->flags & ACC_CLASS_REFLECT_MASK;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaringClass
+ * Signature: ()Ljava/lang/Class;
+ */
+java_lang_Class *_Jv_java_lang_Class_getDeclaringClass(java_lang_Class *klass)
+{
+       classinfo             *c;
+       classref_or_classinfo  inner;
+       utf                   *innername;
+       classinfo             *outer;
+       s4                     i;
+
+       c = (classinfo *) klass;
+
+       if (!_Jv_java_lang_Class_isPrimitive(klass) && (c->name->text[0] != '[')) {
+               if (c->innerclasscount == 0)  /* no innerclasses exist */
+                       return NULL;
+    
+               for (i = 0; i < c->innerclasscount; i++) {
+                       inner = c->innerclass[i].inner_class;
+
+                       /* check if inner_class is a classref or a real class and
+               get the class name from the structure */
+
+                       innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name;
+
+                       /* innerclass is this class */
+
+                       if (innername == c->name) {
+                               /* maybe the outer class is not loaded yet */
+
+                               if (!resolve_classref_or_classinfo(NULL,
+                                                                                                  c->innerclass[i].outer_class,
+                                                                                                  resolveEager, false, false,
+                                                                                                  &outer))
+                                       return NULL;
+
+                               if (!(outer->state & CLASS_LINKED))
+                                       if (!link_class(outer))
+                                               return NULL;
+
+                               return (java_lang_Class *) outer;
+                       }
+               }
+       }
+
+       /* return NULL for arrayclasses and primitive classes */
+
+       return NULL;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaredClasses
+ * Signature: (Z)[Ljava/lang/Class;
+ */
+java_objectarray *_Jv_java_lang_Class_getDeclaredClasses(java_lang_Class *klass, s4 publicOnly)
+{
+       classinfo             *c;
+       classref_or_classinfo  outer;
+       utf                   *outername;
+       s4                     declaredclasscount;  /* number of declared classes */
+       s4                     pos;                     /* current declared class */
+       java_objectarray      *oa;                   /* array of declared classes */
+       s4                     i;
+
+       c = (classinfo *) klass;
+       declaredclasscount = 0;
+
+       if (!_Jv_java_lang_Class_isPrimitive(klass) && (c->name->text[0] != '[')) {
+               /* determine number of declared classes */
+
+               for (i = 0; i < c->innerclasscount; i++) {
+                       outer = c->innerclass[i].outer_class;
+
+                       /* check if outer_class is a classref or a real class and
+               get the class name from the structure */
+
+                       outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
+
+                       /* outer class is this class */
+
+                       if ((outername == c->name) &&
+                               ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC)))
+                               declaredclasscount++;
+               }
+       }
+
+       /* allocate Class[] and check for OOM */
+
+       oa = builtin_anewarray(declaredclasscount, class_java_lang_Class);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0, pos = 0; i < c->innerclasscount; i++) {
+               outer = c->innerclass[i].outer_class;
+
+               /* check if outer_class is a classref or a real class and
+                  get the class name from the structure */
+
+               outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
+
+               /* outer class is this class */
+
+               if ((outername == c->name) &&
+                       ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) {
+                       classinfo *inner;
+
+                       if (!resolve_classref_or_classinfo(NULL,
+                                                                                          c->innerclass[i].inner_class,
+                                                                                          resolveEager, false, false,
+                                                                                          &inner))
+                               return NULL;
+
+                       if (!(inner->state & CLASS_LINKED))
+                               if (!link_class(inner))
+                                       return NULL;
+
+                       oa->data[pos++] = (java_objectheader *) inner;
+               }
+       }
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaredFields
+ * Signature: (Z)[Ljava/lang/reflect/Field;
+ */
+java_objectarray *_Jv_java_lang_Class_getDeclaredFields(java_lang_Class *klass, s4 publicOnly)
+{
+       classinfo               *c;
+       java_objectarray        *oa;            /* result: array of field-objects */
+       fieldinfo               *f;
+       java_objectheader       *o;
+       java_lang_reflect_Field *rf;
+       s4 public_fields;                    /* number of elements in field-array */
+       s4 pos;
+       s4 i;
+
+       c = (classinfo *) klass;
+
+       /* determine number of fields */
+
+       for (i = 0, public_fields = 0; i < c->fieldscount; i++)
+               if ((c->fields[i].flags & ACC_PUBLIC) || (publicOnly == 0))
+                       public_fields++;
+
+       /* create array of fields */
+
+       oa = builtin_anewarray(public_fields, class_java_lang_reflect_Field);
+
+       if (oa == NULL)
+               return NULL;
+
+       /* get the fields and store in the array */
+
+       for (i = 0, pos = 0; i < c->fieldscount; i++) {
+               f = &(c->fields[i]);
+
+               if ((f->flags & ACC_PUBLIC) || (publicOnly == 0)) {
+                       /* create Field object */
+
+                       o = native_new_and_init(class_java_lang_reflect_Field);
+
+                       if (o == NULL)
+                               return NULL;
+
+                       /* initialize instance fields */
+
+                       rf = (java_lang_reflect_Field *) o;
+
+                       rf->declaringClass = (java_lang_Class *) c;
+                       rf->name           = javastring_new(f->name);
+                       rf->slot           = i;
+
+                       /* store object into array */
+
+                       oa->data[pos++] = o;
+               }
+       }
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaredMethods
+ * Signature: (Z)[Ljava/lang/reflect/Method;
+ */
+java_objectarray *_Jv_java_lang_Class_getDeclaredMethods(java_lang_Class *klass, s4 publicOnly)
+{
+       classinfo                *c;
+       java_objectheader        *o;
+       java_lang_reflect_Method *rm;
+       java_objectarray         *oa;          /* result: array of Method-objects */
+       methodinfo               *m;      /* the current method to be represented */
+       s4 public_methods;               /* number of public methods of the class */
+       s4 pos;
+       s4 i;
+
+       c = (classinfo *) klass;    
+       public_methods = 0;
+
+       /* JOWENN: array classes do not declare methods according to mauve
+          test.  It should be considered, if we should return to my old
+          clone method overriding instead of declaring it as a member
+          function. */
+
+       if (_Jv_java_lang_Class_isArray(klass))
+               return builtin_anewarray(0, class_java_lang_reflect_Method);
+
+       /* determine number of methods */
+
+       for (i = 0; i < c->methodscount; i++) {
+               m = &c->methods[i];
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) &&
+                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
+                       !(m->flags & ACC_MIRANDA))
+                       public_methods++;
+       }
+
+       oa = builtin_anewarray(public_methods, class_java_lang_reflect_Method);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0, pos = 0; i < c->methodscount; i++) {
+               m = &c->methods[i];
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && 
+                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
+                       !(m->flags & ACC_MIRANDA)) {
+
+                       o = native_new_and_init(class_java_lang_reflect_Method);
+
+                       if (o == NULL)
+                               return NULL;
+
+                       /* initialize instance fields */
+
+                       rm = (java_lang_reflect_Method *) o;
+
+                       rm->declaringClass = (java_lang_Class *) m->class;
+                       rm->name           = javastring_new(m->name);
+                       rm->slot           = i;
+
+                       /* store object into array */
+
+                       oa->data[pos++] = o;
+               }
+       }
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaredConstructors
+ * Signature: (Z)[Ljava/lang/reflect/Constructor;
+ */
+java_objectarray *_Jv_java_lang_Class_getDeclaredConstructors(java_lang_Class *klass, s4 publicOnly)
+{
+       classinfo                     *c;
+       methodinfo                    *m; /* the current method to be represented */
+       java_objectarray              *oa;     /* result: array of Method-objects */
+       java_objectheader             *o;
+       java_lang_reflect_Constructor *rc;
+       s4 public_methods;               /* number of public methods of the class */
+       s4 pos;
+       s4 i;
+
+       c = (classinfo *) klass;
+
+       /* determine number of constructors */
+
+       for (i = 0, public_methods = 0; i < c->methodscount; i++) {
+               m = &c->methods[i];
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
+                       (m->name == utf_init))
+                       public_methods++;
+       }
+
+       oa = builtin_anewarray(public_methods, class_java_lang_reflect_Constructor);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0, pos = 0; i < c->methodscount; i++) {
+               m = &c->methods[i];
+
+               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
+                       (m->name == utf_init)) {
+
+                       o = native_new_and_init(class_java_lang_reflect_Constructor);
+
+                       if (o == NULL)
+                               return NULL;
+
+                       /* initialize instance fields */
+
+                       rc = (java_lang_reflect_Constructor *) o;
+
+                       rc->clazz = (java_lang_Class *) c;
+                       rc->slot  = i;
+
+                       /* store object into array */
+
+                       oa->data[pos++] = o;
+               }
+       }
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+java_lang_ClassLoader *_Jv_java_lang_Class_getClassLoader(java_lang_Class *klass)
+{
+       classinfo *c;
+
+       c = (classinfo *) klass;
+
+       return (java_lang_ClassLoader *) c->classloader;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    forName
+ * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
+ */
+java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader)
+{
+       classinfo *c;
+       utf       *u;
+       u2        *pos;
+       s4         i;
+
+       /* illegal argument */
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* name must not contain '/' (mauve test) */
+
+       for (i = 0, pos = name->value->data + name->offset; i < name->count; i++, pos++) {
+               if (*pos == '/') {
+                       *exceptionptr =
+                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
+                       return NULL;
+               }
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       u = javastring_toutf(name, true);
+
+       /* try to load, ... */
+
+       if (!(c = load_class_from_classloader(u, (java_objectheader *) loader))) {
+               classinfo *xclass;
+
+               xclass = (*exceptionptr)->vftbl->class;
+
+               /* if the exception is a NoClassDefFoundError, we replace it with a
+                  ClassNotFoundException, otherwise return the exception */
+
+               if (xclass == class_java_lang_NoClassDefFoundError) {
+                       /* clear exceptionptr, because builtin_new checks for 
+                          ExceptionInInitializerError */
+                       *exceptionptr = NULL;
+
+                       *exceptionptr =
+                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
+               }
+
+           return NULL;
+       }
+
+       /* link, ... */
+
+       if (!link_class(c))
+               return NULL;
+       
+       /* ...and initialize it, if required */
+
+       if (initialize)
+               if (!initialize_class(c))
+                       return NULL;
+
+       return (java_lang_Class *) c;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isArray
+ * Signature: ()Z
+ */
+s4 _Jv_java_lang_Class_isArray(java_lang_Class *klass)
+{
+       classinfo *c;
+
+       c = (classinfo *) klass;
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return 0;
+
+       return (c->vftbl->arraydesc != NULL);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    throwException
+ * Signature: (Ljava/lang/Throwable;)V
+ */
+void _Jv_java_lang_Class_throwException(java_lang_Throwable *t)
+{
+       *exceptionptr = (java_objectheader *) t;
+}
+
+
+#if 0
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaredAnnotations
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
+ */
+java_objectarray *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass)
+{
+}
+#endif
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getEnclosingClass
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+java_lang_Class *_Jv_java_lang_Class_getEnclosingClass(java_lang_Class *klass)
+{
+       classinfo             *c;
+       classref_or_classinfo  cr;
+       classinfo             *ec;
+
+       c = (classinfo *) klass;
+
+       /* get enclosing class */
+
+       cr = c->enclosingclass;
+
+       if (cr.any == NULL)
+               return NULL;
+
+       /* resolve the class if necessary */
+
+       if (IS_CLASSREF(cr)) {
+               ec = resolve_classref_eager(cr.ref);
+
+               if (ec == NULL)
+                       return NULL;
+       }
+       else
+               ec = cr.cls;
+
+       return (java_lang_Class *) ec;
+}
+
+
+/* _Jv_java_lang_Class_getEnclosingMethod_intern *******************************
+
+   Helper function for _Jv_java_lang_Class_getEnclosingConstructor and
+   _Jv_java_lang_Class_getEnclosingMethod.
+
+*******************************************************************************/
+
+static methodinfo *_Jv_java_lang_Class_getEnclosingMethod_intern(classinfo *c)
+{
+       classref_or_classinfo     cr;
+       constant_nameandtype     *cn;
+       classinfo                *ec;
+       methodinfo               *m;
+
+       /* get enclosing class and method */
+
+       cr = c->enclosingclass;
+       cn = c->enclosingmethod;
+
+       /* check for enclosing class and method */
+
+       if (cr.any == NULL)
+               return NULL;
+
+       if (cn == NULL)
+               return NULL;
+
+       /* resolve the class if necessary */
+
+       if (IS_CLASSREF(cr)) {
+               ec = resolve_classref_eager(cr.ref);
+
+               if (ec == NULL)
+                       return NULL;
+       }
+       else
+               ec = cr.cls;
+
+       /* find method in enclosing class */
+
+       m = class_findmethod(ec, cn->name, cn->descriptor);
+
+       if (m == NULL) {
+               exceptions_throw_internalerror("Enclosing method doesn't exist");
+               return NULL;
+       }
+
+       return m;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getEnclosingConstructor
+ * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
+ */
+java_lang_reflect_Constructor *_Jv_java_lang_Class_getEnclosingConstructor(java_lang_Class *klass)
+{
+       classinfo                     *c;
+       methodinfo                    *m;
+       java_objectheader             *o;
+       java_lang_reflect_Constructor *rc;
+
+       c = (classinfo *) klass;
+
+       /* get enclosing method */
+
+       m = _Jv_java_lang_Class_getEnclosingMethod_intern(c);
+
+       if (m == NULL)
+               return NULL;
+
+       /* check for <init> */
+
+       if (m->name != utf_init)
+               return NULL;
+
+       /* create java.lang.reflect.Constructor object */
+
+       o = native_new_and_init(class_java_lang_reflect_Constructor);
+
+       if (o == NULL)
+               return NULL;
+
+       /* initialize instance fields */
+
+       rc = (java_lang_reflect_Constructor *) o;
+
+       rc->clazz = (java_lang_Class *) m->class;
+       rc->slot  = m - m->class->methods;               /* calculate method slot */
+
+       return rc;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getEnclosingMethod
+ * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method;
+ */
+java_lang_reflect_Method *_Jv_java_lang_Class_getEnclosingMethod(java_lang_Class *klass)
+{
+       classinfo                *c;
+       methodinfo               *m;
+       java_objectheader        *o;
+       java_lang_reflect_Method *rm;
+
+       c = (classinfo *) klass;
+
+       /* get enclosing method */
+
+       m = _Jv_java_lang_Class_getEnclosingMethod_intern(c);
+
+       if (m == NULL)
+               return NULL;
+
+       /* check for <init> */
+
+       if (m->name == utf_init)
+               return NULL;
+
+       /* create java.lang.reflect.Method object */
+
+       o = native_new_and_init(class_java_lang_reflect_Method);
+
+       if (o == NULL)
+               return NULL;
+
+       /* initialize instance fields */
+
+       rm = (java_lang_reflect_Method *) o;
+
+       rm->declaringClass = (java_lang_Class *) m->class;
+       rm->name           = javastring_new(m->name);
+       rm->slot           = m - m->class->methods;      /* calculate method slot */
+
+       return rm;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getClassSignature
+ * Signature: (Ljava/lang/Class;)Ljava/lang/String;
+ */
+java_lang_String *_Jv_java_lang_Class_getClassSignature(java_lang_Class* klass)
+{
+       classinfo        *c;
+       java_lang_String *s;
+
+       c = (classinfo *) klass;
+
+       if (c->signature == NULL)
+               return NULL;
+
+       s = javastring_new(c->signature);
+
+       /* in error case, s == NULL */
+
+       return s;
+}
+
+
+#if 0
+/*
+ * Class:     java/lang/Class
+ * Method:    isAnonymousClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+s4 _Jv_java_lang_Class_isAnonymousClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isLocalClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isMemberClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+#endif
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/java_lang_Class.h b/src/native/vm/java_lang_Class.h
new file mode 100644 (file)
index 0000000..b224a5b
--- /dev/null
@@ -0,0 +1,106 @@
+/* src/native/vm/java_lang_Class.h - java/lang/Class functions
+
+   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+   Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   $Id: java_lang_VMClass.c 6131 2006-12-06 22:15:57Z twisti $
+
+*/
+
+
+#ifndef _JV_JAVA_LANG_CLASS_H
+#define _JV_JAVA_LANG_CLASS_H
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_String.h"
+#include "native/include/java_lang_Throwable.h"
+#include "native/include/java_lang_reflect_Constructor.h"
+#include "native/include/java_lang_reflect_Method.h"
+
+
+/* function prototypes ********************************************************/
+
+s4                             _Jv_java_lang_Class_isInstance(java_lang_Class *klass, java_lang_Object *o);
+s4                             _Jv_java_lang_Class_isAssignableFrom(java_lang_Class *klass, java_lang_Class *c);
+s4                             _Jv_java_lang_Class_isInterface(java_lang_Class *klass);
+s4                             _Jv_java_lang_Class_isPrimitive(java_lang_Class *klass);
+java_lang_String              *_Jv_java_lang_Class_getName(java_lang_Class *klass);
+java_lang_Class               *_Jv_java_lang_Class_getSuperclass(java_lang_Class *klass);
+java_objectarray              *_Jv_java_lang_Class_getInterfaces(java_lang_Class *klass);
+java_lang_Class               *_Jv_java_lang_Class_getComponentType(java_lang_Class *klass);
+s4                             _Jv_java_lang_Class_getModifiers(java_lang_Class *klass, s4 ignoreInnerClassesAttrib);
+java_lang_Class               *_Jv_java_lang_Class_getDeclaringClass(java_lang_Class *klass);
+java_objectarray              *_Jv_java_lang_Class_getDeclaredClasses(java_lang_Class *klass, s4 publicOnly);
+java_objectarray              *_Jv_java_lang_Class_getDeclaredFields(java_lang_Class *klass, s4 publicOnly);
+java_objectarray              *_Jv_java_lang_Class_getDeclaredMethods(java_lang_Class *klass, s4 publicOnly);
+java_objectarray              *_Jv_java_lang_Class_getDeclaredConstructors(java_lang_Class *klass, s4 publicOnly);
+java_lang_ClassLoader         *_Jv_java_lang_Class_getClassLoader(java_lang_Class *klass);
+java_lang_Class               *_Jv_java_lang_Class_forName(java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader);
+s4                             _Jv_java_lang_Class_isArray(java_lang_Class *klass);
+void                           _Jv_java_lang_Class_throwException(java_lang_Throwable *t);
+
+#if 0
+java_objectarray              *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass);
+#endif
+
+java_lang_Class               *_Jv_java_lang_Class_getEnclosingClass(java_lang_Class *klass);
+
+#if 0
+java_lang_reflect_Constructor *_Jv_java_lang_Class_getEnclosingConstructor(java_lang_Class *klass);
+#endif
+
+java_lang_reflect_Method      *_Jv_java_lang_Class_getEnclosingMethod(java_lang_Class *klass);
+
+java_lang_String              *_Jv_java_lang_Class_getClassSignature(java_lang_Class* klass);
+
+#if 0
+s4                             _Jv_java_lang_Class_isAnonymousClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+#endif
+
+#endif /* _JV_JAVA_LANG_CLASS_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/java_lang_VMClass.c b/src/native/vm/java_lang_VMClass.c
deleted file mode 100644 (file)
index 5a948e1..0000000
+++ /dev/null
@@ -1,858 +0,0 @@
-/* src/native/vm/VMClass.c - java/lang/VMClass
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-            Joseph Wenninger
-            Christian Thalinger
-            Edwin Steiner
-
-   $Id: java_lang_VMClass.c 6131 2006-12-06 22:15:57Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_VMClass.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_reflect_Method.h"
-#include "native/include/java_security_ProtectionDomain.h"
-#include "toolbox/logging.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/loader.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isInstance
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o)
-{
-       classinfo         *c;
-       java_objectheader *ob;
-
-       c = (classinfo *) klass;
-       ob = (java_objectheader *) o;
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return 0;
-
-       return builtin_instanceof(ob, c);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isAssignableFrom
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
-{
-       classinfo *kc;
-       classinfo *cc;
-
-       kc = (classinfo *) klass;
-       cc = (classinfo *) c;
-
-       if (cc == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       if (!(kc->state & CLASS_LINKED))
-               if (!link_class(kc))
-                       return 0;
-
-       if (!(cc->state & CLASS_LINKED))
-               if (!link_class(cc))
-                       return 0;
-
-       /* XXX this may be wrong for array classes */
-
-       return builtin_isanysubclass(cc, kc);
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isInterface
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = (classinfo *) klass;
-
-       if (c->flags & ACC_INTERFACE)
-               return true;
-
-       return false;
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isPrimitive
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       s4         i;
-
-       c = (classinfo *) klass;
-
-       /* search table of primitive classes */
-
-       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
-               if (primitivetype_table[i].class_primitive == c)
-                       return true;
-
-       return false;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getName
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo        *c;
-       java_lang_String *s;
-
-       c = (classinfo *) klass;
-
-       s = native_class_getname(c);
-
-       return s;
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    getSuperclass
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *sc;
-
-       c = (classinfo *) klass;
-
-       /* for java.lang.Object, primitive and Void classes we return NULL */
-       if (!c->super.any)
-               return NULL;
-
-       /* for interfaces we also return NULL */
-       if (c->flags & ACC_INTERFACE)
-               return NULL;
-
-       /* we may have to resolve the super class reference */
-       if (!resolve_classref_or_classinfo(NULL, c->super, resolveEager, 
-                                                                          true, /* check access */
-                                                                          false,  /* don't link */
-                                                                          &sc))
-       {
-               return NULL;
-       }
-
-       /* store the resolution */
-       c->super.cls = sc;
-
-       return (java_lang_Class *) sc;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getInterfaces
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo        *c;
-       classinfo        *ic;
-       java_objectarray *oa;
-       u4                i;
-
-       c = (classinfo *) klass;
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return NULL;
-
-       oa = builtin_anewarray(c->interfacescount, class_java_lang_Class);
-
-       if (!oa)
-               return NULL;
-
-       for (i = 0; i < c->interfacescount; i++) {
-               ic = c->interfaces[i].cls;
-
-               oa->data[i] = (java_objectheader *) ic;
-       }
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getComponentType
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo       *c;
-       classinfo       *comp;
-       arraydescriptor *desc;
-       
-       c = (classinfo *) klass;
-       
-       /* XXX maybe we could find a way to do this without linking. */
-       /* This way should be safe and easy, however.                */
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return NULL;
-
-       desc = c->vftbl->arraydesc;
-       
-       if (desc == NULL)
-               return NULL;
-       
-       if (desc->arraytype == ARRAYTYPE_OBJECT)
-               comp = desc->componentvftbl->class;
-       else
-               comp = primitivetype_table[desc->arraytype].class_primitive;
-               
-       return (java_lang_Class *) comp;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getModifiers
- * Signature: (Z)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 ignoreInnerClassesAttrib)
-{
-       classinfo             *c;
-       classref_or_classinfo  inner;
-       classref_or_classinfo  outer;
-       utf                   *innername;
-       s4                     i;
-
-       c = (classinfo *) klass;
-
-       if (!ignoreInnerClassesAttrib && (c->innerclasscount != 0)) {
-               /* search for passed class as inner class */
-
-               for (i = 0; i < c->innerclasscount; i++) {
-                       inner = c->innerclass[i].inner_class;
-                       outer = c->innerclass[i].outer_class;
-
-                       /* Check if inner is a classref or a real class and get
-               the name of the structure */
-
-                       innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name;
-
-                       /* innerclass is this class */
-
-                       if (innername == c->name) {
-                               /* has the class actually an outer class? */
-
-                               if (outer.any)
-                                       /* return flags got from the outer class file */
-                                       return c->innerclass[i].flags & ACC_CLASS_REFLECT_MASK;
-                               else
-                                       return c->flags & ACC_CLASS_REFLECT_MASK;
-                       }
-               }
-       }
-
-       /* passed class is no inner class or it was not requested */
-
-       return c->flags & ACC_CLASS_REFLECT_MASK;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaringClass
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo             *c;
-       classref_or_classinfo  inner;
-       utf                   *innername;
-       classinfo             *outer;
-       s4                     i;
-
-       c = (classinfo *) klass;
-
-       if (!Java_java_lang_VMClass_isPrimitive(env, clazz, klass) &&
-               (c->name->text[0] != '[')) {
-
-               if (c->innerclasscount == 0)  /* no innerclasses exist */
-                       return NULL;
-    
-               for (i = 0; i < c->innerclasscount; i++) {
-                       inner = c->innerclass[i].inner_class;
-
-                       /* check if inner_class is a classref or a real class and
-               get the class name from the structure */
-
-                       innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name;
-
-                       /* innerclass is this class */
-
-                       if (innername == c->name) {
-                               /* maybe the outer class is not loaded yet */
-
-                               if (!resolve_classref_or_classinfo(NULL,
-                                                                                                  c->innerclass[i].outer_class,
-                                                                                                  resolveEager, false, false,
-                                                                                                  &outer))
-                                       return NULL;
-
-                               if (!(outer->state & CLASS_LINKED))
-                                       if (!link_class(outer))
-                                               return NULL;
-
-                               return (java_lang_Class *) outer;
-                       }
-               }
-       }
-
-       /* return NULL for arrayclasses and primitive classes */
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredClasses
- * Signature: (Z)[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
-{
-       classinfo             *c;
-       classref_or_classinfo  outer;
-       utf                   *outername;
-       s4                     declaredclasscount;  /* number of declared classes */
-       s4                     pos;                     /* current declared class */
-       java_objectarray      *oa;                   /* array of declared classes */
-       s4                     i;
-
-       c = (classinfo *) klass;
-       declaredclasscount = 0;
-
-       if (!Java_java_lang_VMClass_isPrimitive(env, clazz, klass) &&
-               (c->name->text[0] != '[')) {
-               /* determine number of declared classes */
-
-               for (i = 0; i < c->innerclasscount; i++) {
-                       outer = c->innerclass[i].outer_class;
-
-                       /* check if outer_class is a classref or a real class and
-               get the class name from the structure */
-
-                       outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
-
-                       /* outer class is this class */
-
-                       if ((outername == c->name) &&
-                               ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC)))
-                               declaredclasscount++;
-               }
-       }
-
-       /* allocate Class[] and check for OOM */
-
-       oa = builtin_anewarray(declaredclasscount, class_java_lang_Class);
-
-       if (!oa)
-               return NULL;
-
-       for (i = 0, pos = 0; i < c->innerclasscount; i++) {
-               outer = c->innerclass[i].outer_class;
-
-               /* check if outer_class is a classref or a real class and
-                  get the class name from the structure */
-
-               outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
-
-               /* outer class is this class */
-
-               if ((outername == c->name) &&
-                       ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) {
-                       classinfo *inner;
-
-                       if (!resolve_classref_or_classinfo(NULL,
-                                                                                          c->innerclass[i].inner_class,
-                                                                                          resolveEager, false, false,
-                                                                                          &inner))
-                               return NULL;
-
-                       if (!(inner->state & CLASS_LINKED))
-                               if (!link_class(inner))
-                                       return NULL;
-
-                       oa->data[pos++] = (java_objectheader *) inner;
-               }
-       }
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredFields
- * Signature: (Z)[Ljava/lang/reflect/Field;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
-{
-       classinfo               *c;
-       java_objectarray        *oa;            /* result: array of field-objects */
-       fieldinfo               *f;
-       java_objectheader       *o;
-       java_lang_reflect_Field *rf;
-       s4 public_fields;                    /* number of elements in field-array */
-       s4 pos;
-       s4 i;
-
-       c = (classinfo *) klass;
-
-       /* determine number of fields */
-
-       for (i = 0, public_fields = 0; i < c->fieldscount; i++)
-               if ((c->fields[i].flags & ACC_PUBLIC) || (publicOnly == 0))
-                       public_fields++;
-
-       /* create array of fields */
-
-       oa = builtin_anewarray(public_fields, class_java_lang_reflect_Field);
-
-       if (!oa)
-               return NULL;
-
-       /* get the fields and store in the array */
-
-       for (i = 0, pos = 0; i < c->fieldscount; i++) {
-               f = &(c->fields[i]);
-
-               if ((f->flags & ACC_PUBLIC) || (publicOnly == 0)) {
-                       /* create Field object */
-
-                       if (!(o = native_new_and_init(class_java_lang_reflect_Field)))
-                               return NULL;
-
-                       /* initialize instance fields */
-
-                       rf = (java_lang_reflect_Field *) o;
-
-                       rf->declaringClass = (java_lang_Class *) c;
-                       rf->name           = javastring_new(f->name);
-                       rf->slot           = i;
-
-                       /* store object into array */
-
-                       oa->data[pos++] = o;
-               }
-       }
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredMethods
- * Signature: (Z)[Ljava/lang/reflect/Method;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
-{
-       classinfo                *c;
-       java_objectheader        *o;
-       java_lang_reflect_Method *rm;
-       java_objectarray         *oa;          /* result: array of Method-objects */
-       methodinfo               *m;      /* the current method to be represented */
-       s4 public_methods;               /* number of public methods of the class */
-       s4 pos;
-       s4 i;
-
-       c = (classinfo *) klass;    
-       public_methods = 0;
-
-       /* JOWENN: array classes do not declare methods according to mauve
-          test.  It should be considered, if we should return to my old
-          clone method overriding instead of declaring it as a member
-          function. */
-
-       if (Java_java_lang_VMClass_isArray(env, clazz, klass))
-               return builtin_anewarray(0, class_java_lang_reflect_Method);
-
-       /* determine number of methods */
-
-       for (i = 0; i < c->methodscount; i++) {
-               m = &c->methods[i];
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) &&
-                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
-                       !(m->flags & ACC_MIRANDA))
-                       public_methods++;
-       }
-
-       oa = builtin_anewarray(public_methods, class_java_lang_reflect_Method);
-
-       if (!oa) 
-               return NULL;
-
-       for (i = 0, pos = 0; i < c->methodscount; i++) {
-               m = &c->methods[i];
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && 
-                       ((m->name != utf_init) && (m->name != utf_clinit)) &&
-                       !(m->flags & ACC_MIRANDA)) {
-
-                       if (!(o = native_new_and_init(class_java_lang_reflect_Method)))
-                               return NULL;
-
-                       /* initialize instance fields */
-
-                       rm = (java_lang_reflect_Method *) o;
-
-                       rm->declaringClass = (java_lang_Class *) m->class;
-                       rm->name           = javastring_new(m->name);
-                       rm->slot           = i;
-
-                       /* store object into array */
-
-                       oa->data[pos++] = o;
-               }
-       }
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredConstructors
- * Signature: (Z)[Ljava/lang/reflect/Constructor;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
-{
-       classinfo                     *c;
-       methodinfo                    *m; /* the current method to be represented */
-       java_objectarray              *oa;     /* result: array of Method-objects */
-       java_objectheader             *o;
-       java_lang_reflect_Constructor *rc;
-       s4 public_methods;               /* number of public methods of the class */
-       s4 pos;
-       s4 i;
-
-       c = (classinfo *) klass;
-
-       /* determine number of constructors */
-
-       for (i = 0, public_methods = 0; i < c->methodscount; i++) {
-               m = &c->methods[i];
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
-                       (m->name == utf_init))
-                       public_methods++;
-       }
-
-       oa = builtin_anewarray(public_methods, class_java_lang_reflect_Constructor);
-
-       if (!oa) 
-               return NULL;
-
-       for (i = 0, pos = 0; i < c->methodscount; i++) {
-               m = &c->methods[i];
-
-               if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
-                       (m->name == utf_init)) {
-
-                       if (!(o = native_new_and_init(class_java_lang_reflect_Constructor)))
-                               return NULL;
-
-                       /* initialize instance fields */
-
-                       rc = (java_lang_reflect_Constructor *) o;
-
-                       rc->clazz = (java_lang_Class *) c;
-                       rc->slot  = i;
-
-                       /* store object into array */
-
-                       oa->data[pos++] = o;
-               }
-       }
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = (classinfo *) klass;
-
-       return (java_lang_ClassLoader *) c->classloader;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    forName
- * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, java_lang_String *name, s4 initialize, java_lang_ClassLoader *loader)
-{
-       classinfo *c;
-       utf       *u;
-       u2        *pos;
-       s4         i;
-
-       /* illegal argument */
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* name must not contain '/' (mauve test) */
-
-       for (i = 0, pos = name->value->data + name->offset; i < name->count; i++, pos++) {
-               if (*pos == '/') {
-                       *exceptionptr =
-                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
-                       return NULL;
-               }
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       u = javastring_toutf(name, true);
-
-       /* try to load, ... */
-
-       if (!(c = load_class_from_classloader(u, (java_objectheader *) loader))) {
-               classinfo *xclass;
-
-               xclass = (*exceptionptr)->vftbl->class;
-
-               /* if the exception is a NoClassDefFoundError, we replace it with a
-                  ClassNotFoundException, otherwise return the exception */
-
-               if (xclass == class_java_lang_NoClassDefFoundError) {
-                       /* clear exceptionptr, because builtin_new checks for 
-                          ExceptionInInitializerError */
-                       *exceptionptr = NULL;
-
-                       *exceptionptr =
-                               new_exception_javastring(string_java_lang_ClassNotFoundException, name);
-               }
-
-           return NULL;
-       }
-
-       /* link, ... */
-
-       if (!link_class(c))
-               return NULL;
-       
-       /* ...and initialize it, if required */
-
-       if (initialize)
-               if (!initialize_class(c))
-                       return NULL;
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isArray
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c = (classinfo *) klass;
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return 0;
-
-       return (c->vftbl->arraydesc != NULL);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    throwException
- * Signature: (Ljava/lang/Throwable;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
-{
-       *exceptionptr = (java_objectheader *) t;
-}
-
-
-#if 0
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredAnnotations
- * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass)
-{
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getEnclosingClass
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getEnclosingConstructor
- * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
- */
-JNIEXPORT struct java_lang_reflect_Constructor* JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getEnclosingMethod
- * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method;
- */
-JNIEXPORT struct java_lang_reflect_Method* JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-#endif
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getClassSignature
- * Signature: (Ljava/lang/Class;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, java_lang_Class* klass)
-{
-       classinfo        *c;
-       java_lang_String *s;
-
-       c = (classinfo *) klass;
-
-       if (c->signature == NULL)
-               return NULL;
-
-       s = javastring_new(c->signature);
-
-       /* in error case, s == NULL */
-
-       return s;
-}
-
-
-#if 0
-/*
- * Class:     java/lang/VMClass
- * Method:    isAnonymousClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isLocalClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isMemberClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-#endif
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/java_lang_VMClassLoader.c b/src/native/vm/java_lang_VMClassLoader.c
deleted file mode 100644 (file)
index dfa0517..0000000
+++ /dev/null
@@ -1,524 +0,0 @@
-/* src/native/vm/VMClassLoader.c - java/lang/VMClassLoader
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-            Edwin Steiner
-
-   $Id: java_lang_VMClassLoader.c 5153 2006-07-18 08:19:24Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <sys/stat.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_security_ProtectionDomain.h"
-#include "native/include/java_util_Vector.h"
-#include "toolbox/logging.h"
-#include "vm/builtin.h"
-#include "vm/class.h"
-#include "vm/classcache.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/linker.h"
-#include "vm/loader.h"
-#include "vm/options.h"
-#include "vm/statistics.h"
-#include "vm/stringlocal.h"
-#include "vm/suck.h"
-#include "vm/vm.h"
-#include "vm/zip.h"
-#include "vm/jit/asmpart.h"
-
-#if defined(ENABLE_JVMTI)
-#include "native/jvmti/cacaodbg.h"
-#endif
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    defineClass
- * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name, java_bytearray *data, s4 offset, s4 len, java_security_ProtectionDomain *pd)
-{
-       classinfo   *c;
-       classinfo   *r;
-       classbuffer *cb;
-       utf         *utfname;
-#if defined(ENABLE_JVMTI)
-       jint new_class_data_len = 0;
-       unsigned char* new_class_data = NULL;
-#endif
-
-       /* check if data was passed */
-
-       if (data == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* check the indexes passed */
-
-       if ((offset < 0) || (len < 0) || ((offset + len) > data->header.size)) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       if (name) {
-               /* convert '.' to '/' in java string */
-
-               utfname = javastring_toutf(name, true);
-               
-               /* check if this class has already been defined */
-
-               c = classcache_lookup_defined_or_initiated((java_objectheader *) cl, utfname);
-               if (c) {
-                       *exceptionptr =
-                               exceptions_new_linkageerror("duplicate class definition: ",c);
-                       return NULL;
-               }
-       } 
-       else {
-               utfname = NULL;
-       }
-
-
-#if defined(ENABLE_JVMTI)
-       /* fire Class File Load Hook JVMTI event */
-       if (jvmti) jvmti_ClassFileLoadHook(utfname, len, (unsigned char*)data->data, 
-                                                       (java_objectheader *)cl, (java_objectheader *)pd, 
-                                                       &new_class_data_len, &new_class_data);
-#endif
-
-
-       /* create a new classinfo struct */
-
-       c = class_create_classinfo(utfname);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_start();
-#endif
-
-       /* build a classbuffer with the given data */
-
-       cb = NEW(classbuffer);
-       cb->class = c;
-#if defined(ENABLE_JVMTI)
-       /* check if the JVMTI wants to modify the class */
-       if (new_class_data == NULL) {
-#endif
-       cb->size  = len;
-       cb->data  = (u1 *) &data->data[offset];
-#if defined(ENABLE_JVMTI)
-       } else {
-               cb->size  = new_class_data_len;
-               cb->data  = (u1 *) new_class_data;
-       }
-#endif
-       cb->pos   = cb->data;
-
-       /* preset the defining classloader */
-
-       c->classloader = (java_objectheader *) cl;
-
-       /* load the class from this buffer */
-
-       r = load_class_from_classbuffer(cb);
-
-       /* free memory */
-
-       FREE(cb, classbuffer);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_stop();
-#endif
-
-       if (!r) {
-               /* If return value is NULL, we had a problem and the class is not   */
-               /* loaded. */
-               /* now free the allocated memory, otherwise we could run into a DOS */
-
-               class_free(c);
-
-               return NULL;
-       }
-
-       /* set ProtectionDomain */
-
-       c->object.pd = pd;
-
-       /* Store the newly defined class in the class cache. This call also       */
-       /* checks whether a class of the same name has already been defined by    */
-       /* the same defining loader, and if so, replaces the newly created class  */
-       /* by the one defined earlier.                                            */
-       /* Important: The classinfo given to classcache_store must be             */
-       /*            fully prepared because another thread may return this       */
-       /*            pointer after the lookup at to top of this function         */
-       /*            directly after the class cache lock has been released.      */
-
-       c = classcache_store((java_objectheader *)cl,c,true);
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    getPrimitiveClass
- * Signature: (C)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, s4 type)
-{
-       classinfo *c;
-
-       /* get primitive class */
-
-       switch (type) {
-       case 'I':
-               c = primitivetype_table[PRIMITIVETYPE_INT].class_primitive;
-               break;
-       case 'J':
-               c = primitivetype_table[PRIMITIVETYPE_LONG].class_primitive;
-               break;
-       case 'F':
-               c = primitivetype_table[PRIMITIVETYPE_FLOAT].class_primitive;
-               break;
-       case 'D':
-               c = primitivetype_table[PRIMITIVETYPE_DOUBLE].class_primitive;
-               break;
-       case 'B':
-               c = primitivetype_table[PRIMITIVETYPE_BYTE].class_primitive;
-               break;
-       case 'C':
-               c = primitivetype_table[PRIMITIVETYPE_CHAR].class_primitive;
-               break;
-       case 'S':
-               c = primitivetype_table[PRIMITIVETYPE_SHORT].class_primitive;
-               break;
-       case 'Z':
-               c = primitivetype_table[PRIMITIVETYPE_BOOLEAN].class_primitive;
-               break;
-       case 'V':
-               c = primitivetype_table[PRIMITIVETYPE_VOID].class_primitive;
-               break;
-       default:
-               *exceptionptr = new_exception(string_java_lang_ClassNotFoundException);
-               c = NULL;
-       }
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    resolveClass
- * Signature: (Ljava/lang/Class;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, java_lang_Class *c)
-{
-       classinfo *ci;
-
-       ci = (classinfo *) c;
-
-       if (!ci) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* link the class */
-
-       if (!(ci->state & CLASS_LINKED))
-               (void) link_class(ci);
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    loadClass
- * Signature: (Ljava/lang/String;Z)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, java_lang_String *name, jboolean resolve)
-{
-       classinfo *c;
-       utf *u;
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       u = javastring_toutf(name, true);
-
-       /* load class */
-
-       if (!(c = load_class_bootstrap(u)))
-               goto exception;
-
-       /* resolve class -- if requested */
-
-/*     if (resolve) */
-               if (!link_class(c))
-                       goto exception;
-
-       return (java_lang_Class *) c;
-
- exception:
-       c = (*exceptionptr)->vftbl->class;
-       
-       /* if the exception is a NoClassDefFoundError, we replace it with a
-          ClassNotFoundException, otherwise return the exception */
-
-       if (c == class_java_lang_NoClassDefFoundError) {
-               /* clear exceptionptr, because builtin_new checks for 
-                  ExceptionInInitializerError */
-               *exceptionptr = NULL;
-
-               *exceptionptr =
-                       new_exception_javastring(string_java_lang_ClassNotFoundException, name);
-       }
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    nativeGetResources
- * Signature: (Ljava/lang/String;)Ljava/util/Vector;
- */
-JNIEXPORT java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, java_lang_String *name)
-{
-       jobject               o;         /* vector being created     */
-       methodinfo           *m;         /* "add" method of vector   */
-       java_lang_String     *path;      /* path to be added         */
-       list_classpath_entry *lce;       /* classpath entry          */
-       utf                  *utfname;   /* utf to look for          */
-       char                 *buffer;    /* char buffer              */
-       char                 *namestart; /* start of name to use     */
-       char                 *tmppath;   /* temporary buffer         */
-       s4                    namelen;   /* length of name to use    */
-       s4                    searchlen; /* length of name to search */
-       s4                    bufsize;   /* size of buffer allocated */
-       s4                    pathlen;   /* name of path to assemble */
-       struct stat           buf;       /* buffer for stat          */
-       jboolean              ret;       /* return value of "add"    */
-
-       /* get the resource name as utf string */
-
-       utfname = javastring_toutf(name, false);
-       if (!utfname)
-               return NULL;
-
-       /* copy it to a char buffer */
-
-       namelen = utf_bytes(utfname);
-       searchlen = namelen;
-       bufsize = namelen + strlen("0");
-       buffer = MNEW(char, bufsize);
-
-       utf_copy(buffer, utfname);
-       namestart = buffer;
-
-       /* skip leading '/' */
-
-       if (namestart[0] == '/') {
-               namestart++;
-               namelen--;
-               searchlen--;
-       }
-
-       /* remove trailing `.class' */
-
-       if (namelen >= 6 && strcmp(namestart + (namelen - 6), ".class") == 0) {
-               searchlen -= 6;
-       }
-
-       /* create a new needle to look for, if necessary */
-
-       if (searchlen != bufsize-1) {
-               utfname = utf_new(namestart, searchlen);
-               if (utfname == NULL)
-                       goto return_NULL;
-       }
-                       
-       /* new Vector() */
-
-       o = native_new_and_init(class_java_util_Vector);
-
-       if (!o)
-               goto return_NULL;
-
-       /* get Vector.add() method */
-
-       m = class_resolveclassmethod(class_java_util_Vector,
-                                                                utf_add,
-                                                                utf_new_char("(Ljava/lang/Object;)Z"),
-                                                                NULL,
-                                                                true);
-
-       if (!m)
-               goto return_NULL;
-
-       /* iterate over all classpath entries */
-
-       for (lce = list_first(list_classpath_entries); lce != NULL;
-                lce = list_next(list_classpath_entries, lce)) {
-               /* clear path pointer */
-               path = NULL;
-
-#if defined(ENABLE_ZLIB)
-               if (lce->type == CLASSPATH_ARCHIVE) {
-
-                       if (zip_find(lce, utfname)) {
-                               pathlen = strlen("jar:file://") + lce->pathlen + strlen("!/") +
-                                       namelen + strlen("0");
-
-                               tmppath = MNEW(char, pathlen);
-
-                               sprintf(tmppath, "jar:file://%s!/%s", lce->path, namestart);
-                               path = javastring_new_from_utf_string(tmppath),
-
-                               MFREE(tmppath, char, pathlen);
-                       }
-
-               } else {
-#endif /* defined(ENABLE_ZLIB) */
-                       pathlen = strlen("file://") + lce->pathlen + namelen + strlen("0");
-
-                       tmppath = MNEW(char, pathlen);
-
-                       sprintf(tmppath, "file://%s%s", lce->path, namestart);
-
-                       /* Does this file exist? */
-
-                       if (stat(tmppath + strlen("file://") - 1, &buf) == 0)
-                               if (!S_ISDIR(buf.st_mode))
-                                       path = javastring_new_from_utf_string(tmppath);
-
-                       MFREE(tmppath, char, pathlen);
-#if defined(ENABLE_ZLIB)
-               }
-#endif
-
-               /* if a resource was found, add it to the vector */
-
-               if (path) {
-                       ret = vm_call_method_int(m, o, path);
-
-                       if (*exceptionptr)
-                               goto return_NULL;
-
-                       if (ret == 0) 
-                               goto return_NULL;
-               }
-       }
-
-       MFREE(buffer, char, bufsize);
-
-       return (java_util_Vector *) o;
-
-return_NULL:
-       MFREE(buffer, char, bufsize);
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    defaultAssertionStatus
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
-{
-       return _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus;
-}
-
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    findLoadedClass
- * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name)
-{
-       classinfo *c;
-       utf       *u;
-
-       /* replace `.' by `/', this is required by the classcache */
-
-       u = javastring_toutf(name, true);
-
-       /* lookup for defining classloader */
-
-       c = classcache_lookup_defined((classloader *) cl, u);
-
-       /* if not found, lookup for initiating classloader */
-
-       if (c == NULL)
-               c = classcache_lookup((classloader *) cl, u);
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/java_lang_VMObject.c b/src/native/vm/java_lang_VMObject.c
deleted file mode 100644 (file)
index 5f50af0..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/* src/native/vm/VMObject.c - java/lang/VMObject
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_VMObject.c 6013 2006-11-16 22:14:10Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-#include "toolbox/logging.h"
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Cloneable.h"
-#include "native/include/java_lang_Object.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/loader.h"
-#include "vm/options.h"
-#include "vm/stringlocal.h"
-
-#if defined(ENABLE_JVMTI)
-#include "native/jvmti/cacaodbg.h"
-#endif
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    getClass
- * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, java_lang_Object *obj)
-{
-       classinfo *c;
-
-       if (!obj)
-               return NULL;
-
-       c = ((java_objectheader *) obj)->vftbl->class;
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    clone
- * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, java_lang_Cloneable *this)
-{
-       java_objectheader *o;
-       java_objectheader *co;
-
-       o = (java_objectheader *) this;
-
-       co = builtin_clone(env, o);
-
-       return (java_lang_Object *) co;
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    notify
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this)
-{
-#if defined(ENABLE_THREADS)
-       lock_notify_object(&this->header);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    notifyAll
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *this)
-{
-#if defined(ENABLE_THREADS)
-       lock_notify_all_object(&this->header);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    wait
- * Signature: (Ljava/lang/Object;JI)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, java_lang_Object *o, s8 ms, s4 ns)
-{
-#if defined(ENABLE_JVMTI)
-       /* Monitor Wait */
-       if (jvmti) jvmti_MonitorWaiting(true, o, ms);
-#endif
-
-#if defined(ENABLE_THREADS)
-       lock_wait_for_object(&o->header, ms, ns);
-#endif
-
-#if defined(ENABLE_JVMTI)
-       /* Monitor Waited */
-       /* XXX: How do you know if wait timed out ?*/
-       if (jvmti) jvmti_MonitorWaiting(false, o, 0);
-#endif
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_VMRuntime.c b/src/native/vm/java_lang_VMRuntime.c
deleted file mode 100644 (file)
index c7cac9e..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-/* src/native/vm/VMRuntime.c - java/lang/VMRuntime
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-                       Edwin Steiner
-
-   $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/utsname.h>
-
-#if !defined(WITH_STATIC_CLASSPATH)
-# include <ltdl.h>
-#endif
-
-#if defined(__DARWIN__)
-# define OS_INLINE    /* required for <libkern/ppc/OSByteOrder.h> */
-# include <mach/mach.h>
-#endif
-
-#include "vm/types.h"
-
-#include "mm/gc-common.h"
-#include "mm/memory.h"
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_io_File.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Process.h"
-#include "toolbox/logging.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/loader.h"
-#include "vm/options.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-
-/* this should work on BSD */
-/*
-#if defined(__DARWIN__)
-#include <sys/sysctl.h>
-#endif
-*/
-
-
-/* should we run all finalizers on exit? */
-static bool finalizeOnExit = false;
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    exitInternal
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, s4 par1)
-{
-       if (finalizeOnExit)
-               gc_finalize_all();
-
-       vm_shutdown(par1);
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    freeMemory
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_free_bytes();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    totalMemory
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_heap_size();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    maxMemory
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_max_heap_size();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    gc
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_gc(JNIEnv *env, jclass clazz)
-{
-       gc_call();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    runFinalization
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(JNIEnv *env, jclass clazz)
-{
-       gc_invoke_finalizers();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    runFinalizersOnExit
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, s4 value)
-{
-       /* XXX threading */
-
-       finalizeOnExit = value;
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    runFinalizationsForExit
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizationForExit(JNIEnv *env, jclass clazz)
-{
-/*     if (finalizeOnExit) { */
-/*             gc_call(); */
-       /* gc_finalize_all(); */
-/*     } */
-/*     log_text("Java_java_lang_VMRuntime_runFinalizationForExit called"); */
-       /*gc_finalize_all();*/
-       /*gc_invoke_finalizers();*/
-       /*gc_call();*/
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    traceInstructions
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, s4 par1)
-{
-       /* not supported */
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    traceMethodCalls
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, s4 par1)
-{
-       /* not supported */
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    availableProcessors
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
-{
-#if defined(_SC_NPROC_ONLN)
-       return (s4) sysconf(_SC_NPROC_ONLN);
-
-#elif defined(_SC_NPROCESSORS_ONLN)
-       return (s4) sysconf(_SC_NPROCESSORS_ONLN);
-
-#elif defined(__DARWIN__)
-       /* this should work in BSD */
-       /*
-       int ncpu, mib[2], rc;
-       size_t len;
-
-       mib[0] = CTL_HW;
-       mib[1] = HW_NCPU;
-       len = sizeof(ncpu);
-       rc = sysctl(mib, 2, &ncpu, &len, NULL, 0);
-
-       return (s4) ncpu;
-       */
-
-       host_basic_info_data_t hinfo;
-       mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
-       kern_return_t rc;
-
-       rc = host_info(mach_host_self(), HOST_BASIC_INFO,
-                                  (host_info_t) &hinfo, &hinfo_count);
-       if (rc != KERN_SUCCESS) {
-               return -1;
-       }
-
-    return (s4) hinfo.avail_cpus;
-
-#else
-       return 1;
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    nativeLoad
- * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *filename, java_lang_ClassLoader *loader)
-{
-#if !defined(WITH_STATIC_CLASSPATH)
-       utf         *name;
-       lt_dlhandle  handle;
-       lt_ptr       onload;
-       s4           version;
-#endif
-
-       if (filename == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-#if defined(WITH_STATIC_CLASSPATH)
-       return 1;
-#else /* defined(WITH_STATIC_CLASSPATH) */
-       name = javastring_toutf(filename, 0);
-
-       /* is the library already loaded? */
-
-       if (native_hashtable_library_find(name, (java_objectheader *) loader))
-               return 1;
-
-       /* try to open the library */
-
-       if (!(handle = lt_dlopen(name->text))) {
-               if (opt_verbose) {
-                       log_start();
-                       log_print("Java_java_lang_VMRuntime_nativeLoad: ");
-                       log_print(lt_dlerror());
-                       log_finish();
-               }
-
-               return 0;
-       }
-
-       /* resolve JNI_OnLoad function */
-
-       if ((onload = lt_dlsym(handle, "JNI_OnLoad"))) {
-               JNIEXPORT s4 (JNICALL *JNI_OnLoad) (JavaVM *, void *);
-               JavaVM *vm;
-
-               JNI_OnLoad = (JNIEXPORT s4 (JNICALL *)(JavaVM *, void *)) (ptrint) onload;
-
-               (*env)->GetJavaVM(env, &vm);
-
-               version = JNI_OnLoad(vm, NULL);
-
-               /* if the version is not 1.2 and not 1.4 the library cannot be loaded */
-
-               if ((version != JNI_VERSION_1_2) && (version != JNI_VERSION_1_4)) {
-                       lt_dlclose(handle);
-
-                       return 0;
-               }
-       }
-
-       /* insert the library name into the library hash */
-
-       native_hashtable_library_add(name, (java_objectheader *) loader, handle);
-
-       return 1;
-#endif /* defined(WITH_STATIC_CLASSPATH) */
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    mapLibraryName
- * Signature: (Ljava/lang/String;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, java_lang_String *libname)
-{
-       utf              *u;
-       char             *buffer;
-       s4                buffer_len;
-       s4                dumpsize;
-       java_lang_String *s;
-
-       if (!libname) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       u = javastring_toutf(libname, 0);
-
-       /* calculate length of library name */
-
-       buffer_len = strlen("lib");
-
-       buffer_len += utf_bytes(u);
-
-#if defined(__DARWIN__)
-       buffer_len += strlen(".dylib");
-#else
-       buffer_len += strlen(".so");
-#endif
-
-       buffer_len += strlen("0");
-
-       dumpsize = dump_size();
-       buffer = DMNEW(char, buffer_len);
-
-       /* generate library name */
-
-       strcpy(buffer, "lib");
-       utf_cat(buffer, u);
-
-#if defined(__DARWIN__)
-       strcat(buffer, ".dylib");
-#else
-       strcat(buffer, ".so");
-#endif
-
-       s = javastring_new_from_utf_string(buffer);
-
-       /* release memory */
-
-       dump_release(dumpsize);
-
-       return s;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/java_lang_VMString.c b/src/native/vm/java_lang_VMString.c
deleted file mode 100644 (file)
index 0e08980..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* native/vm/VMString.c - java/lang/VMString
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Christian Thalinger
-
-   $Id: java_lang_VMString.c 5153 2006-07-18 08:19:24Z twisti $
-
-*/
-
-
-#include <stdlib.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_String.h"
-#include "vm/stringlocal.h"
-
-
-/*
- * Class:     java/lang/VMString
- * Method:    intern
- * Signature: (Ljava/lang/String;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, java_lang_String *str)
-{
-       java_objectheader *o;
-
-       if (!str)
-               return NULL;
-
-       /* search table so identical strings will get identical pointers */
-
-       o = literalstring_u2(str->value, str->count, str->offset, true);
-
-       return (java_lang_String *) o;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_VMSystem.c b/src/native/vm/java_lang_VMSystem.c
deleted file mode 100644 (file)
index b15a930..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* src/native/vm/VMSystem.c - java/lang/VMSystem
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_VMSystem.c 5251 2006-08-18 13:01:00Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/include/java_lang_Object.h"
-
-#include "vm/builtin.h"
-
-
-/*
- * Class:     java/lang/VMSystem
- * Method:    arraycopy
- * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, s4 srcStart, java_lang_Object *dest, s4 destStart, s4 len)
-{
-       (void) builtin_arraycopy((java_arrayheader *) src, srcStart,
-                                                        (java_arrayheader *) dest, destStart, len);
-}
-
-
-/*
- * Class:     java/lang/VMSystem
- * Method:    identityHashCode
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, java_lang_Object *o)
-{
-       return (s4) ((ptrint) o);
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_VMThread.c b/src/native/vm/java_lang_VMThread.c
deleted file mode 100644 (file)
index 41c934c..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/* src/native/vm/VMThread.c - java/lang/VMThread
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_VMThread.c 5806 2006-10-19 10:10:23Z twisti $
-
-*/
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_ThreadGroup.h"
-#include "native/include/java_lang_Object.h"            /* java_lang_Thread.h */
-#include "native/include/java_lang_Throwable.h"         /* java_lang_Thread.h */
-#include "native/include/java_lang_VMThread.h"
-#include "native/include/java_lang_Thread.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
-
-#include "toolbox/logging.h"
-#include "vm/exceptions.h"
-#include "vm/options.h"
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    countStackFrames
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
-{
-    log_text("java_lang_VMThread_countStackFrames called");
-
-    return 0;
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    start
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, s8 stacksize)
-{
-#if defined(ENABLE_THREADS)
-       this->thread->vmThread = this;
-
-       /* don't pass a function pointer (NULL) since we want Thread.run()V here */
-
-       threads_start_thread((java_lang_Thread *) this->thread, NULL);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    interrupt
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       threads_thread_interrupt(this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    isInterrupted
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       return threads_thread_has_been_interrupted(this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    suspend
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    resume
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    nativeSetPriority
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, s4 priority)
-{
-#if defined(ENABLE_THREADS)
-       threads_java_lang_Thread_set_priority((java_lang_Thread *) this->thread,
-                                                                                 priority);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    nativeStop
- * Signature: (Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
-{
-#if defined(ENABLE_THREADS)
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    currentThread
- * Signature: ()Ljava/lang/Thread;
- */
-JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
-{
-       java_lang_Thread *t;
-
-#if defined(ENABLE_THREADS)
-       t = ((threadobject*) THREADOBJECT)->o.thread;
-
-       if (t == NULL)
-               log_text("t ptr is NULL\n");
-  
-       if (!t->group) {
-               /* ThreadGroup of currentThread is not initialized */
-
-               t->group = (java_lang_ThreadGroup *)
-                       native_new_and_init(class_java_lang_ThreadGroup);
-
-               if (t->group == NULL)
-                       log_text("unable to create ThreadGroup");
-       }
-#else
-       /* we just return a fake java.lang.Thread object, otherwise we get
-       NullPointerException's in GNU classpath */
-
-       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
-#endif
-
-       return t;
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    yield
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_THREADS)
-       threads_yield();
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    interrupted
- * Signature: ()Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_THREADS)
-       return threads_check_if_interrupted_and_reset();
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    holdsLock
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
-{
-#if defined(ENABLE_THREADS)
-       return lock_is_held_by_current_thread((java_objectheader *) o);
-#endif
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_VMThrowable.c b/src/native/vm/java_lang_VMThrowable.c
deleted file mode 100644 (file)
index c28a3d1..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-/* src/native/vm/java_lang_VMThrowable.c - java/lang/VMThrowable
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_VMThrowable.c 6071 2006-11-28 15:11:20Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/gnu_classpath_Pointer.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_StackTraceElement.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_VMThrowable.h"
-#include "vm/builtin.h"
-#include "vm/class.h"
-#include "vm/exceptions.h"
-#include "vm/loader.h"
-#include "vm/stringlocal.h"
-#include "vm/jit/stacktrace.h"
-
-
-/*
- * Class:     java/lang/VMThrowable
- * Method:    fillInStackTrace
- * Signature: (Ljava/lang/Throwable;)Ljava/lang/VMThrowable;
- */
-JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
-{
-       java_lang_VMThrowable *o;
-       stacktracecontainer   *stc;
-
-       o = (java_lang_VMThrowable *)
-               native_new_and_init(class_java_lang_VMThrowable);
-
-       if (o == NULL)
-               return NULL;
-
-       stc = stacktrace_fillInStackTrace();
-
-       if (stc == NULL)
-               return NULL;
-
-       o->vmData = (gnu_classpath_Pointer *) stc;
-
-       return o;
-}
-
-
-/*
- * Class:     java/lang/VMThrowable
- * Method:    getStackTrace
- * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *this, java_lang_Throwable *t)
-{
-       stacktracecontainer         *stc;
-       stacktracebuffer            *stb;
-       stacktrace_entry            *ste;
-       stacktrace_entry            *tmpste;
-       s4                           size;
-       s4                           i;
-       classinfo                   *c;
-       bool                         inexceptionclass;
-       bool                         leftexceptionclass;
-
-       methodinfo                  *m;
-       java_objectarray            *oa;
-       s4                           oalength;
-       java_lang_StackTraceElement *o;
-       java_lang_String            *filename;
-       s4                           linenumber;
-       java_lang_String            *declaringclass;
-
-       /* get the stacktrace buffer from the VMThrowable object */
-
-       stc = (stacktracecontainer *) this->vmData;
-       stb = &(stc->stb);
-
-       /* get the class of the Throwable object */
-
-       c = t->header.vftbl->class;
-
-       assert(stb != NULL);
-
-       size = stb->used;
-
-       assert(size >= 2);
-
-       /* skip first 2 elements in stacktrace buffer:                            */
-       /*   0: VMThrowable.fillInStackTrace                                      */
-       /*   1: Throwable.fillInStackTrace                                        */
-
-       ste = &(stb->entries[2]);
-       size -= 2;
-
-       if ((size > 0) && (ste->method != 0)) {
-               /* not a builtin native wrapper*/
-
-               if ((ste->method->class->name == utf_java_lang_Throwable) &&
-                       (ste->method->name == utf_init)) {
-                       /* We assume that we are within the initializer of the
-                          exception object, the exception object itself should
-                          not appear in the stack trace, so we skip till we reach
-                          the first function, which is not an init function. */
-
-                       inexceptionclass = false;
-                       leftexceptionclass = false;
-
-                       while (size > 0) {
-                               /* check if we are in the exception class */
-
-                               if (ste->method->class == c)
-                                       inexceptionclass = true;
-
-                               /* check if we left the exception class */
-
-                               if (inexceptionclass && (ste->method->class != c))
-                                       leftexceptionclass = true;
-
-                               /* Found exception start point if we left the
-                                  initalizers or we left the exception class. */
-
-                               if ((ste->method->name != utf_init) || leftexceptionclass)
-                                       break;
-
-                               /* go to next stacktrace element */
-
-                               ste++;
-                               size--;
-                       }
-               }
-       }
-
-
-       /* now fill the stacktrace into java objects */
-
-       m = class_findmethod(class_java_lang_StackTraceElement,
-                                                utf_init,
-                                                utf_new_char("(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Z)V"));
-
-       if (m == NULL)
-               return NULL;
-
-       /* count entries with a method name */
-
-       for (oalength = 0, i = size, tmpste = ste; i > 0; i--, tmpste++)
-               if (tmpste->method)
-                       oalength++;
-
-       /* create the stacktrace element array */
-
-       oa = builtin_anewarray(oalength, class_java_lang_StackTraceElement);
-
-       if (oa == NULL)
-               return NULL;
-
-       for (i = 0; size > 0; size--, ste++, i++) {
-               /* skip entries without a method name */
-
-               if (ste->method == NULL) {
-                       i--;
-                       continue;
-               }
-
-               /* allocate a new stacktrace element */
-
-               o = (java_lang_StackTraceElement *)
-                       builtin_new(class_java_lang_StackTraceElement);
-
-               if (o == NULL)
-                       return NULL;
-
-               /* get filename */
-
-               if (!(ste->method->flags & ACC_NATIVE)) {
-                       if (ste->method->class->sourcefile)
-                               filename = javastring_new(ste->method->class->sourcefile);
-                       else
-                               filename = NULL;
-               }
-               else
-                       filename = NULL;
-
-               /* get line number */
-
-               if (ste->method->flags & ACC_NATIVE)
-                       linenumber = -1;
-               else
-                       linenumber = (ste->linenumber == 0) ? -1 : ste->linenumber;
-
-               /* get declaring class name */
-
-               declaringclass = native_class_getname(ste->method->class);
-
-               /* fill the java.lang.StackTraceElement element */
-
-               o->fileName       = filename;
-               o->lineNumber     = linenumber;
-               o->declaringClass = declaringclass;
-               o->methodName     = javastring_new(ste->method->name);
-               o->isNative       = (ste->method->flags & ACC_NATIVE) ? 1 : 0;
-
-               oa->data[i] = (java_objectheader *) o;
-       }
-
-       return oa;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_management_VMManagementFactory.c b/src/native/vm/java_lang_management_VMManagementFactory.c
deleted file mode 100644 (file)
index 8abcd62..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* src/native/vm/java_lang_management_VMManagementFactory.c
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
-
-*/
-
-
-#include "config.h"
-
-#include <stdlib.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-
-#include "toolbox/logging.h"
-#include "vm/builtin.h"
-#include "vm/class.h"
-
-
-/*
- * Class:     java/lang/management/VMManagementFactory
- * Method:    getMemoryPoolNames
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
-{
-       java_objectarray *oa;
-
-       log_println("Java_java_lang_management_VMManagementFactory_getMemoryPoolNames: IMPLEMENT ME!");
-
-       oa = builtin_anewarray(0, class_java_lang_String);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/management/VMManagementFactory
- * Method:    getMemoryManagerNames
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
-{
-       java_objectarray *oa;
-
-       log_println("Java_java_lang_management_VMManagementFactory_getMemoryManagerNames: IMPLEMENT ME!");
-
-       oa = builtin_anewarray(0, class_java_lang_String);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/management/VMManagementFactory
- * Method:    getGarbageCollectorNames
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
-{
-       java_objectarray *oa;
-
-       log_println("Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames: IMPLEMENT ME!");
-
-       oa = builtin_anewarray(0, class_java_lang_String);
-
-       return oa;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/native/vm/java_lang_reflect_Constructor.c b/src/native/vm/java_lang_reflect_Constructor.c
deleted file mode 100644 (file)
index 0a8c94e..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-/* src/native/vm/java_lang_reflect_Constructor.c
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-            Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_reflect_Constructor.c 6171 2006-12-11 11:47:42Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "toolbox/logging.h"
-#include "vm/class.h"
-#include "vm/exceptions.h"
-#include "vm/method.h"
-#include "vm/access.h"
-#include "vm/stringlocal.h"
-
-
-/*
- * Class:     java/lang/reflect/Constructor
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Constructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_Constructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) (this->clazz);
-       m = &(c->methods[this->slot]);
-
-       return m->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/Constructor
- * Method:    getParameterTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->clazz;
-       m = &(c->methods[this->slot]);
-
-       return native_get_parametertypes(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Constructor
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->clazz;
-       m = &(c->methods[this->slot]);
-
-       return native_get_exceptiontypes(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Constructor
- * Method:    constructNative
- * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_constructNative(JNIEnv *env, java_lang_reflect_Constructor *this, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
-{
-       classinfo         *c;
-       methodinfo        *m;
-       java_objectheader *o;
-
-       c = (classinfo *) declaringClass;
-
-#if 0
-       /* find initializer */
-
-       if (!args) {
-               if (this->parameterTypes->header.size != 0) {
-                       *exceptionptr =
-                               new_exception_message(string_java_lang_IllegalArgumentException,
-                                                                         "wrong number of arguments");
-                       return NULL;
-               }
-
-       } else {
-               if (this->parameterTypes->header.size != args->header.size) {
-                       *exceptionptr =
-                               new_exception_message(string_java_lang_IllegalArgumentException,
-                                                                         "wrong number of arguments");
-                       return NULL;
-               }
-       }
-#endif
-
-       if (this->slot >= c->methodscount) {
-               log_text("illegal index in methods table");
-               return NULL;
-       }
-
-       m = &(c->methods[this->slot]);
-
-       if (m->name != utf_init) {
-               /* XXX throw an exception here, although this should never happen */
-
-               assert(0);
-       }
-
-       /* check method access */
-       /* check if we should bypass security checks (AccessibleObject) */
-
-       if (this->flag == false) {
-               if (!access_check_caller(c, m->flags, 1))
-                       return NULL;
-       }
-
-       /* create object */
-
-       o = builtin_new(c);
-
-       if (!o)
-               return NULL;
-        
-       /* call initializer */
-
-       (void) _Jv_jni_invokeNative(m, o, args);
-
-       return (java_lang_Object *) o;
-}
-
-
-/*
- * Class:     java/lang/reflect/Constructor
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Constructor_getSignature(JNIEnv *env, java_lang_reflect_Constructor *this)
-{
-       classinfo        *c;
-       methodinfo       *m;
-       java_lang_String *s;
-
-       c = (classinfo *) this->clazz;
-       m = &(c->methods[this->slot]);
-
-       if (m->signature == NULL)
-               return NULL;
-
-       s = javastring_new(m->signature);
-
-       /* in error case, s == NULL */
-
-       return s;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_reflect_Field.c b/src/native/vm/java_lang_reflect_Field.c
deleted file mode 100644 (file)
index 7a6ebe0..0000000
+++ /dev/null
@@ -1,1237 +0,0 @@
-/* src/native/vm/java_lang_reflect_Field.c - java/lang/reflect/Field
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-            Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_reflect_Field.c 5937 2006-11-08 22:00:57Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Boolean.h"
-#include "native/include/java_lang_Byte.h"
-#include "native/include/java_lang_Character.h"
-#include "native/include/java_lang_Short.h"
-#include "native/include/java_lang_Integer.h"
-#include "native/include/java_lang_Long.h"
-#include "native/include/java_lang_Float.h"
-#include "native/include/java_lang_Double.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "vm/access.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/loader.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-#include "vm/utf8.h"
-#include "vm/jit/stacktrace.h"
-
-
-#define CHECKFIELDACCESS(this,fi,c,doret)
-
-
-/* cacao_get_field_address *****************************************************
-
-   Return the address of a field of an object.
-
-   IN:
-      this.........the field (a java.lang.reflect.Field object)
-         o............the object of which to get the field
-
-   RETURN VALUE:
-      a pointer to the field, or
-         NULL if an exception has been thrown
-
-*******************************************************************************/
-
-static void *cacao_get_field_address(java_lang_reflect_Field *this,
-                                                                        java_lang_Object *o)
-{
-       classinfo        *c;
-       fieldinfo        *f;
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* check field access */
-       /* check if we should bypass security checks (AccessibleObject) */
-
-       if (this->flag == false) {
-               /* this function is always called like this:
-
-                          java.lang.reflect.Field.xxx (Native Method)
-                  [0] <caller>
-               */
-               if (!access_check_caller(c, f->flags, 0))
-                       return NULL;
-       }
-
-       /* get the address of the field */
-
-       if (f->flags & ACC_STATIC) {
-               /* initialize class if required */
-
-               if (!(c->state & CLASS_INITIALIZED))
-                       if (!initialize_class(c))
-                               return NULL;
-
-               /* return value address */
-
-               return &(f->value);
-
-       } else {
-               /* obj is required for not-static fields */
-
-               if (o == NULL) {
-                       exceptions_throw_nullpointerexception();
-                       return NULL;
-               }
-       
-               if (builtin_instanceof((java_objectheader *) o, c))
-                       return (void *) ((ptrint) o + f->offset);
-       }
-
-       /* exception path */
-
-       exceptions_throw_illegalargumentexception();
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getModifiersInternal(JNIEnv *env, java_lang_reflect_Field *this)
-{
-       classinfo *c;
-       fieldinfo *f;
-
-       c = (classinfo *) this->declaringClass;
-       f = &(c->fields[this->slot]);
-
-       return f->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getType
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Field_getType(JNIEnv *env, java_lang_reflect_Field *this)
-{
-       classinfo *c;
-       typedesc  *desc;
-       classinfo *ret;
-
-       c    = (classinfo *) this->declaringClass;
-       desc = c->fields[this->slot].parseddesc;
-
-       if (desc == NULL)
-               return NULL;
-
-       if (!resolve_class_from_typedesc(desc, true, false, &ret))
-               return NULL;
-       
-       return (java_lang_Class *) ret;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    get
- * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Field_get(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get address of the source field value */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return NULL;
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN: {
-               java_lang_Boolean *bo;
-
-               /* create wrapping class */
-
-               if (!(bo = (java_lang_Boolean *) builtin_new(class_java_lang_Boolean)))
-                       return NULL;
-
-               /* set the object value */
-
-               bo->value = *((s4 *) addr);
-
-               /* return the wrapped object */
-
-               return (java_lang_Object *) bo;
-       }
-
-       case PRIMITIVETYPE_BYTE: {
-               java_lang_Byte *bo;
-
-               if (!(bo = (java_lang_Byte *) builtin_new(class_java_lang_Byte)))
-                       return NULL;
-
-               bo->value = *((s4 *) addr);
-
-               return (java_lang_Object *) bo;
-       }
-
-       case PRIMITIVETYPE_CHAR: {
-               java_lang_Character *co;
-
-               if (!(co = (java_lang_Character *) builtin_new(class_java_lang_Character)))
-                       return NULL;
-
-               co->value = *((s4 *) addr);
-
-               return (java_lang_Object *) co;
-       }
-
-       case PRIMITIVETYPE_SHORT: {
-               java_lang_Short *so;
-
-               if (!(so = (java_lang_Short *) builtin_new(class_java_lang_Short)))
-                       return NULL;
-
-               so->value = (s4) *((s4 *) addr);
-
-               return (java_lang_Object *) so;
-       }
-
-       case PRIMITIVETYPE_INT: {
-               java_lang_Integer *io;
-
-               if (!(io = (java_lang_Integer *) builtin_new(class_java_lang_Integer)))
-                       return NULL;
-
-               io->value = *((s4 *) addr);
-
-               return (java_lang_Object *) io;
-       }
-
-       case PRIMITIVETYPE_LONG: {
-               java_lang_Long *lo;
-
-               if (!(lo = (java_lang_Long *) builtin_new(class_java_lang_Long)))
-                       return NULL;
-
-               lo->value = *((s8 *) addr);
-
-               return (java_lang_Object *) lo;
-       }
-
-       case PRIMITIVETYPE_FLOAT: {
-               java_lang_Float *fo;
-
-               if (!(fo = (java_lang_Float *) builtin_new(class_java_lang_Float)))
-                       return NULL;
-
-               fo->value = *((float *) addr);
-
-               return (java_lang_Object *) fo;
-       }
-
-       case PRIMITIVETYPE_DOUBLE: {
-               java_lang_Double *_do;
-
-               if (!(_do = (java_lang_Double *) builtin_new(class_java_lang_Double)))
-                       return NULL;
-
-               _do->value = *((double *) addr);
-
-               return (java_lang_Object *) _do;
-       }
-
-       case TYPE_ADR:
-               return (java_lang_Object *) *((java_objectheader **) addr);
-       }
-
-       /* this must not happen */
-
-       assert(0);
-
-       /* keep compiler happy */
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getBoolean
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getBoolean(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-               return (s4) *((s4 *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getByte
- * Signature: (Ljava/lang/Object;)B
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getByte(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-               return (s4) *((s4 *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getChar
- * Signature: (Ljava/lang/Object;)C
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getChar(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_CHAR:
-               return (s4) *((s4 *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getShort
- * Signature: (Ljava/lang/Object;)S
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getShort(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_SHORT:
-               return (s4) *((s4 *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getInt
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getInt(JNIEnv *env , java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (s4) *((s4 *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getLong
- * Signature: (Ljava/lang/Object;)J
- */
-JNIEXPORT s8 JNICALL Java_java_lang_reflect_Field_getLong(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (s8) *((s4 *) addr);
-       case PRIMITIVETYPE_LONG:
-               return (s8) *((s8 *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getFloat
- * Signature: (Ljava/lang/Object;)F
- */
-JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (float) *((s4 *) addr);
-       case PRIMITIVETYPE_LONG:
-               return (float) *((s8 *) addr);
-       case PRIMITIVETYPE_FLOAT:
-               return (float) *((float *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getDouble
- * Signature: (Ljava/lang/Object;)D
- */
-JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble(JNIEnv *env , java_lang_reflect_Field *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               return (double) *((s4 *) addr);
-       case PRIMITIVETYPE_LONG:
-               return (double) *((s8 *) addr);
-       case PRIMITIVETYPE_FLOAT:
-               return (double) *((float *) addr);
-       case PRIMITIVETYPE_DOUBLE:
-               return (double) *((double *) addr);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    set
- * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, java_lang_Object *value)
-{
-       classinfo *sc;
-       classinfo *dc;
-       fieldinfo *sf;
-       fieldinfo *df;
-       void      *faddr;
-
-       /* get the class and the field */
-
-       dc = (classinfo *) this->declaringClass;
-       df = &dc->fields[this->slot];
-
-       /* get the address of the destination field */
-
-       if ((faddr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* get the source classinfo from the object */
-
-       if (value == NULL)
-               sc = NULL;
-       else
-               sc = value->header.vftbl->class;
-
-       /* The fieldid is used to set the new value, for primitive
-          types the value has to be retrieved from the wrapping
-          object */
-
-       switch (df->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN: {
-               s4 val;
-
-               /* determine the field to read the value */
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_Z)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BOOLEAN:
-                       val = ((java_lang_Boolean *) value)->value;
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((s4 *) faddr) = val;
-               return;
-       }
-
-       case PRIMITIVETYPE_BYTE: {
-               s4 val;
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       val = ((java_lang_Byte *) value)->value;
-                       break;
-               default:        
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((s4 *) faddr) = val;
-               return;
-       }
-
-       case PRIMITIVETYPE_CHAR: {
-               s4 val;
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C)))
-                       break;
-                                  
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_CHAR:
-                       val = ((java_lang_Character *) value)->value;
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((s4 *) faddr) = val;
-               return;
-       }
-
-       case PRIMITIVETYPE_SHORT: {
-               s4 val;
-
-               /* get field only by name, it can be one of B, S */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-                                  
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       val = ((java_lang_Byte *) value)->value;
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       val = ((java_lang_Short *) value)->value;
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((s4 *) faddr) = val;
-               return;
-       }
-
-       case PRIMITIVETYPE_INT: {
-               s4 val;
-
-               /* get field only by name, it can be one of B, S, C, I */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       val = ((java_lang_Byte *) value)->value;
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       val = ((java_lang_Character *) value)->value;
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       val = ((java_lang_Short *) value)->value;
-                       break;
-               case PRIMITIVETYPE_INT:
-                       val = ((java_lang_Integer *) value)->value;
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((s4 *) faddr) = val;
-               return;
-       }
-
-       case PRIMITIVETYPE_LONG: {
-               s8 val;
-
-               /* get field only by name, it can be one of B, S, C, I, J */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       val = ((java_lang_Byte *) value)->value;
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       val = ((java_lang_Character *) value)->value;
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       val = ((java_lang_Short *) value)->value;
-                       break;
-               case PRIMITIVETYPE_INT:
-                       val = ((java_lang_Integer *) value)->value;
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       val = ((java_lang_Long *) value)->value;
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((s8 *) faddr) = val;
-               return;
-       }
-
-       case PRIMITIVETYPE_FLOAT: {
-               float val;
-
-               /* get field only by name, it can be one of B, S, C, I, J, F */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       val = ((java_lang_Byte *) value)->value;
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       val = ((java_lang_Character *) value)->value;
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       val = ((java_lang_Short *) value)->value;
-                       break;
-               case PRIMITIVETYPE_INT:
-                       val = ((java_lang_Integer *) value)->value;
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       val = ((java_lang_Long *) value)->value;
-                       break;
-               case PRIMITIVETYPE_FLOAT:
-                       val = ((java_lang_Float *) value)->value;
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((float *) faddr) = val;
-               return;
-       }
-
-       case PRIMITIVETYPE_DOUBLE: {
-               double val;
-
-               /* get field only by name, it can be one of B, S, C, I, J, F, D */
-
-               if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       val = ((java_lang_Byte *) value)->value;
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       val = ((java_lang_Character *) value)->value;
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       val = ((java_lang_Short *) value)->value;
-                       break;
-               case PRIMITIVETYPE_INT:
-                       val = ((java_lang_Integer *) value)->value;
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       val = ((java_lang_Long *) value)->value;
-                       break;
-               case PRIMITIVETYPE_FLOAT:
-                       val = ((java_lang_Float *) value)->value;
-                       break;
-               case PRIMITIVETYPE_DOUBLE:
-                       val = ((java_lang_Double *) value)->value;
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               *((double *) faddr) = val;
-               return;
-       }
-
-       case TYPE_ADR:
-               /* check if value is an instance of the destination class */
-
-               /* XXX TODO */
-               /*                      if (!builtin_instanceof((java_objectheader *) value, df->class)) */
-               /*                              break; */
-
-               *((java_lang_Object **) faddr) = value;
-               return;
-       }
-
-       /* raise exception */
-
-       exceptions_throw_illegalargumentexception();
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setBoolean
- * Signature: (Ljava/lang/Object;Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-               *((s4 *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setByte
- * Signature: (Ljava/lang/Object;B)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               *((s4 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_LONG:
-               *((s8 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               *((float *) addr) = value;
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               *((double *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setChar
- * Signature: (Ljava/lang/Object;C)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_INT:
-               *((s4 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_LONG:
-               *((s8 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               *((float *) addr) = value;
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               *((double *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setShort
- * Signature: (Ljava/lang/Object;S)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               *((s4 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_LONG:
-               *((s8 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               *((float *) addr) = value;
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               *((double *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setInt
- * Signature: (Ljava/lang/Object;I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_INT:
-               *((s4 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_LONG:
-               *((s8 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               *((float *) addr) = value;
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               *((double *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setLong
- * Signature: (Ljava/lang/Object;J)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s8 value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_LONG:
-               *((s8 *) addr) = value;
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               *((float *) addr) = value;
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               *((double *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setFloat
- * Signature: (Ljava/lang/Object;F)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, float value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_FLOAT:
-               *((float *) addr) = value;
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               *((double *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    setDouble
- * Signature: (Ljava/lang/Object;D)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, double value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       void      *addr;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       /* get the address of the field with an internal helper */
-
-       if ((addr = cacao_get_field_address(this, o)) == NULL)
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_DOUBLE:
-               *((double *) addr) = value;
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/Field
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Field_getSignature(JNIEnv *env, java_lang_reflect_Field* this)
-{
-       classinfo        *c;
-       fieldinfo        *f;
-       java_lang_String *s;
-
-       /* get the class and the field */
-
-       c = (classinfo *) this->declaringClass;
-       f = &c->fields[this->slot];
-
-       if (f->signature == NULL)
-               return NULL;
-
-       s = javastring_new(f->signature);
-
-       /* in error case, s == NULL */
-
-       return s;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_reflect_Method.c b/src/native/vm/java_lang_reflect_Method.c
deleted file mode 100644 (file)
index 919754e..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/* src/native/vm/Method.c - java/lang/reflect/Method
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-            Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_reflect_Method.c 5937 2006-11-08 22:00:57Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_reflect_Method.h"
-#include "vm/access.h"
-#include "vm/global.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/stringlocal.h"
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return m->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getReturnType
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return (java_lang_Class *) native_get_returntype(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getParameterTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return native_get_parametertypes(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return native_get_exceptiontypes(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    invokeNative
- * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(JNIEnv *env, java_lang_reflect_Method *this, java_lang_Object *o, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
-{
-       classinfo        *c;
-       methodinfo       *m;
-
-       c = (classinfo *) declaringClass;
-       m = &(c->methods[slot]);
-
-       /* check method access */
-       /* check if we should bypass security checks (AccessibleObject) */
-
-       if (this->flag == false) {
-               if (!access_check_caller(c, m->flags, 1))
-                       return NULL;
-       }
-
-       /* check if method class is initialized */
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return NULL;
-
-       /* call the Java method via a helper function */
-
-       return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this)
-{
-       classinfo        *c;
-       methodinfo       *m;
-       java_lang_String *s;
-
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       if (m->signature == NULL)
-               return NULL;
-
-       s = javastring_new(m->signature);
-
-       /* in error case, s == NULL */
-
-       return s;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_lang_reflect_VMProxy.c b/src/native/vm/java_lang_reflect_VMProxy.c
deleted file mode 100644 (file)
index dedb362..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* src/native/vm/VMProxy.c - java/lang/reflect/VMProxy
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_reflect_VMProxy.c 5153 2006-07-18 08:19:24Z twisti $
-
-*/
-
-
-#include <stdlib.h>
-
-#include "native/jni.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "toolbox/logging.h"
-
-
-/*
- * Class:     java/lang/reflect/VMProxy
- * Method:    getProxyClass
- * Signature: (Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMProxy_getProxyClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, java_objectarray *par2)
-{
-       log_text("Java_java_lang_reflect_Proxy_getProxyClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMProxy
- * Method:    getProxyData
- * Signature: (Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/reflect/Proxy$ProxyData;
- */
-JNIEXPORT struct java_lang_reflect_Proxy_ProxyData* JNICALL Java_java_lang_reflect_VMProxy_getProxyData(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, java_objectarray *par2)
-{
-       log_text("Java_java_lang_reflect_Proxy_getProxyData: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMProxy
- * Method:    generateProxyClass
- * Signature: (Ljava/lang/ClassLoader;Ljava/lang/reflect/Proxy$ProxyData;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMProxy_generateProxyClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, struct java_lang_reflect_Proxy_ProxyData *par2)
-{
-       log_text("Java_java_lang_reflect_Proxy_generateProxyClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/java_security_VMAccessController.c b/src/native/vm/java_security_VMAccessController.c
deleted file mode 100644 (file)
index 54e7f81..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* src/native/vm/VMAccessController.c - java/security/VMAccessController
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Joseph Wenninger
-
-   Changes: Christian Thalinger
-
-   $Id: java_security_VMAccessController.c 5153 2006-07-18 08:19:24Z twisti $
-
-*/
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "vm/builtin.h"
-#include "vm/class.h"
-#include "vm/options.h"
-#include "vm/jit/stacktrace.h"
-
-
-/*
- * Class:     java/security/VMAccessController
- * Method:    getStack
- * Signature: ()[[Ljava/lang/Object;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz) {
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined (__X86_64__)
-       /* these JITs support stacktraces */
-
-       return stacktrace_getStack();
-
-#else
-# if defined(ENABLE_INTRP)
-       /* the interpreter supports stacktraces, even if the JIT does not */
-
-       if (opt_intrp) {
-               return stacktrace_getStack();
-
-       } else
-# endif
-               {
-                       java_objectarray *result;
-                       java_objectarray *classes;
-                       java_objectarray *methodnames;
-
-                       if (!(result = builtin_anewarray(2, arrayclass_java_lang_Object)))
-                               return NULL;
-
-                       if (!(classes = builtin_anewarray(0, class_java_lang_Class)))
-                               return NULL;
-
-                       if (!(methodnames = builtin_anewarray(0, class_java_lang_String)))
-                               return NULL;
-
-                       result->data[0] = (java_objectheader *) classes;
-                       result->data[1] = (java_objectheader *) methodnames;
-
-                       return result;
-               }
-#endif
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/native/vm/sun_misc_Unsafe.c b/src/native/vm/sun_misc_Unsafe.c
deleted file mode 100644 (file)
index a916513..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/* src/native/vm/sun_misc_Unsafe.c - sun/misc/Unsafe
-
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program 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.
-
-   This program 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 this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: java_lang_VMObject.c 5153 2006-07-18 08:19:24Z twisti $
-
-*/
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_Thread.h" /* required by sun_misc_Unsafe.h */
-#include "native/include/sun_misc_Unsafe.h"
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    objectFieldOffset
- * Signature: (Ljava/lang/reflect/Field;)J
- */
-JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe* this, java_lang_reflect_Field* field)
-{
-       classinfo *c;
-       fieldinfo *f;
-
-       c = (classinfo *) field->declaringClass;
-       f = &c->fields[field->slot];
-
-       return (s8) f->offset;
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    compareAndSwapInt
- * Signature: (Ljava/lang/Object;JII)Z
- */
-JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, sun_misc_Unsafe* this, java_lang_Object* obj, s8 offset, s4 expect, s4 update)
-{
-       s4 *p;
-       s4  value;
-
-       p = (s4 *) (((u1 *) obj) + offset);
-
-       /* XXX this should be atomic */
-
-       value = *p;
-
-       if (value == expect) {
-               *p = update;
-
-               return true;
-       }
-
-       return false;
-}
-
-
-#if 0
-/*
- * Class:     sun/misc/Unsafe
- * Method:    compareAndSwapLong
- * Signature: (Ljava/lang/Object;JJJ)Z
- */
-JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3, s8 par4)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    compareAndSwapObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
- */
-JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3, struct java_lang_Object* par4)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putOrderedInt
- * Signature: (Ljava/lang/Object;JI)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s4 par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putOrderedLong
- * Signature: (Ljava/lang/Object;JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putOrderedObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putIntVolatile
- * Signature: (Ljava/lang/Object;JI)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s4 par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getIntVolatile
- * Signature: (Ljava/lang/Object;J)I
- */
-JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putLongVolatile
- * Signature: (Ljava/lang/Object;JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putLong
- * Signature: (Ljava/lang/Object;JJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, s8 par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getLongVolatile
- * Signature: (Ljava/lang/Object;J)J
- */
-JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getLong
- * Signature: (Ljava/lang/Object;J)J
- */
-JNIEXPORT s8 JNICALL Java_sun_misc_Unsafe_getLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putObjectVolatile
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    putObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2, struct java_lang_Object* par3)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    getObjectVolatile
- * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
- */
-JNIEXPORT struct java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, s8 par2)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    arrayBaseOffset
- * Signature: (Ljava/lang/Class;)I
- */
-JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    arrayIndexScale
- * Signature: (Ljava/lang/Class;)I
- */
-JNIEXPORT s4 JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    unpark
- * Signature: (Ljava/lang/Thread;)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Thread* par1)
-{
-}
-
-
-/*
- * Class:     sun/misc/Unsafe
- * Method:    park
- * Signature: (ZJ)V
- */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, struct sun_misc_Unsafe* this, s4 par1, s8 par2)
-{
-}
-#endif
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
index cf103a0f8a25d9d8d9a5cffcfa6280d874b039e1..f3265eaef879c63b268344be9c3b1019c4375604 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: class.h 6085 2006-11-29 17:08:27Z twisti $
+   $Id: class.h 6213 2006-12-18 17:36:06Z twisti $
 
 */
 
@@ -55,6 +55,7 @@ typedef struct extra_classref extra_classref;
 
 #include "vm/field.h"
 #include "vm/linker.h"
+#include "vm/loader.h"
 #include "vm/method.h"
 #include "vm/references.h"
 #include "vm/utf8.h"
@@ -122,6 +123,11 @@ struct classinfo {                /* class structure                          */
        u2          innerclasscount;  /* number of inner classes                  */
        innerclassinfo *innerclass;
 
+#if defined(ENABLE_JAVASE)
+       classref_or_classinfo  enclosingclass;  /* enclosing class                */
+       constant_nameandtype  *enclosingmethod; /* enclosing method               */
+#endif
+
        utf        *packagename;      /* full name of the package                 */
        utf        *sourcefile;       /* SourceFile attribute                     */
 #if defined(ENABLE_JAVASE)
@@ -263,6 +269,8 @@ void class_postset_header_vftbl(void);
 /* set the package name after the name has been set */
 void class_set_packagename(classinfo *c);
 
+bool class_load_attributes(classbuffer *cb);
+
 /* retrieve constantpool element */
 voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
 voidptr innerclass_getconstant(classinfo *c, u4 pos, u4 ctype);