* Merged with tip.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 19 May 2008 19:40:05 +0000 (21:40 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 19 May 2008 19:40:05 +0000 (21:40 +0200)
--HG--
rename : src/native/vm/sun/jvm.c => src/native/vm/openjdk/jvm.c

166 files changed:
configure.ac
contrib/setenvinstalled.in
contrib/setenvsource.in
m4/classpath.m4 [deleted file]
m4/hpi.m4
m4/java-runtime-library.m4 [new file with mode: 0644]
src/cacao/Makefile.am
src/cacaoh/cacaoh.c
src/classes/Makefile.am
src/classes/gnu/gnu/classpath/VMStackWalker.java [deleted file]
src/classes/gnu/gnu/classpath/VMSystemProperties.java [deleted file]
src/classes/gnu/gnu/java/lang/CPStringBuilder.java [deleted file]
src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java [deleted file]
src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java [deleted file]
src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java [deleted file]
src/classes/gnu/java/lang/VMClassLoader.java [deleted file]
src/classes/gnu/java/lang/VMString.java [deleted file]
src/classes/gnu/java/lang/VMThread.java [deleted file]
src/classes/gnu/java/lang/reflect/Constructor.java [deleted file]
src/classes/gnu/java/lang/reflect/Field.java [deleted file]
src/classes/gnu/java/lang/reflect/Method.java [deleted file]
src/classes/gnu/java/lang/reflect/Modifier.java [deleted file]
src/classes/gnu/java/lang/reflect/VMConstructor.java [deleted file]
src/classes/gnu/java/lang/reflect/VMField.java [deleted file]
src/classes/gnu/java/lang/reflect/VMMethod.java [deleted file]
src/classes/gnu/java/security/VMAccessController.java [deleted file]
src/classes/gnu/sun/misc/Unsafe.java [deleted file]
src/classes/gnu/sun/reflect/ConstantPool.java [deleted file]
src/classes/gnu/sun/reflect/annotation/AnnotationParser.java [deleted file]
src/classes/gnu/sun/reflect/annotation/AnnotationType.java [deleted file]
src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java [deleted file]
src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java [deleted file]
src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java [deleted file]
src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java [deleted file]
src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java [new file with mode: 0644]
src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/VMClassLoader.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/VMString.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/VMThread.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Constructor.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Field.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Method.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/Modifier.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/VMField.java [new file with mode: 0644]
src/classes/gnuclasspath/java/lang/reflect/VMMethod.java [new file with mode: 0644]
src/classes/gnuclasspath/java/security/VMAccessController.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/misc/Unsafe.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/ConstantPool.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java [new file with mode: 0644]
src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java [new file with mode: 0644]
src/mm/boehm-gc/pthread_stop_world.c
src/native/include/Makefile.am
src/native/jni.c
src/native/native.c
src/native/vm/Makefile.am
src/native/vm/gnu/Makefile.am [deleted file]
src/native/vm/gnu/VMjdwp.c [deleted file]
src/native/vm/gnu/VMjdwp.h [deleted file]
src/native/vm/gnu/gnu_classpath_VMStackWalker.c [deleted file]
src/native/vm/gnu/gnu_classpath_VMSystemProperties.c [deleted file]
src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c [deleted file]
src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c [deleted file]
src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c [deleted file]
src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c [deleted file]
src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c [deleted file]
src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c [deleted file]
src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c [deleted file]
src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c [deleted file]
src/native/vm/gnu/java_lang_VMClass.c [deleted file]
src/native/vm/gnu/java_lang_VMClassLoader.c [deleted file]
src/native/vm/gnu/java_lang_VMObject.c [deleted file]
src/native/vm/gnu/java_lang_VMRuntime.c [deleted file]
src/native/vm/gnu/java_lang_VMString.c [deleted file]
src/native/vm/gnu/java_lang_VMSystem.c [deleted file]
src/native/vm/gnu/java_lang_VMThread.c [deleted file]
src/native/vm/gnu/java_lang_VMThrowable.c [deleted file]
src/native/vm/gnu/java_lang_management_VMManagementFactory.c [deleted file]
src/native/vm/gnu/java_lang_reflect_VMConstructor.c [deleted file]
src/native/vm/gnu/java_lang_reflect_VMField.c [deleted file]
src/native/vm/gnu/java_lang_reflect_VMMethod.c [deleted file]
src/native/vm/gnu/java_lang_reflect_VMProxy.c [deleted file]
src/native/vm/gnu/java_security_VMAccessController.c [deleted file]
src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c [deleted file]
src/native/vm/gnu/sun_reflect_ConstantPool.c [deleted file]
src/native/vm/gnuclasspath/Makefile.am [new file with mode: 0644]
src/native/vm/gnuclasspath/VMjdwp.c [new file with mode: 0644]
src/native/vm/gnuclasspath/VMjdwp.h [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMClass.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMClassLoader.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMObject.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMRuntime.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMString.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMSystem.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMThread.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_VMThrowable.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMField.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_security_VMAccessController.c [new file with mode: 0644]
src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c [new file with mode: 0644]
src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c [new file with mode: 0644]
src/native/vm/nativevm.c
src/native/vm/nativevm.h
src/native/vm/openjdk/Makefile.am [new file with mode: 0644]
src/native/vm/openjdk/hpi.c [new file with mode: 0644]
src/native/vm/openjdk/hpi.h [new file with mode: 0644]
src/native/vm/openjdk/jvm.c [new file with mode: 0644]
src/native/vm/reflect.c
src/native/vm/reflect.h
src/native/vm/sun/Makefile.am [deleted file]
src/native/vm/sun/hpi.c [deleted file]
src/native/vm/sun/hpi.h [deleted file]
src/native/vm/sun/jvm.c [deleted file]
src/native/vm/sun_misc_Unsafe.c
src/threads/none/thread-none.h
src/threads/posix/lock.c
src/threads/posix/thread-posix.c
src/threads/posix/thread-posix.h
src/threads/thread.c
src/vm/access.c
src/vm/assertion.c
src/vm/initialize.c
src/vm/jit/allocator/simplereg.c
src/vm/jit/cfg.c
src/vm/jit/codegen-common.c
src/vm/jit/i386/codegen.c
src/vm/jit/icmdtable.inc
src/vm/jit/jit.c
src/vm/jit/jit.h
src/vm/jit/optimizing/ssa.c
src/vm/jit/optimizing/ssa3.c
src/vm/jit/s390/codegen.c
src/vm/jit/show.c
src/vm/jit/stacktrace.c
src/vm/jit/x86_64/asmpart.S
src/vm/properties.c
src/vm/signal.c
src/vm/vm.c
src/vm/vm.h
src/vmcore/class.c
src/vmcore/class.h
src/vmcore/linker.c
src/vmcore/loader.c
src/vmcore/utf8.c
src/vmcore/utf8.h

index 2aa52423d2eb7e7648753edaf7668872ce51239b..a1febed28ac4937bb4c4e152a6abc5544bab7336 100644 (file)
@@ -764,17 +764,17 @@ AC_SUBST(CACAO_VM_ZIP)
 
 
 AC_CHECK_WITH_CACAOH
-AC_CHECK_WITH_CLASSPATH
+AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY
 
 dnl Now we check for jre-layout so we can skip some checks that are
 dnl not required.
 AC_CHECK_ENABLE_JRE_LAYOUT
 
-AC_CHECK_WITH_CLASSPATH_PREFIX
-AC_CHECK_WITH_CLASSPATH_CLASSES
+AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_PREFIX
+AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_CLASSES
 
 if test x"${ENABLE_JRE_LAYOUT}" = "xno"; then
-   AC_CHECK_WITH_CLASSPATH_LIBDIR
+   AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_LIBDIR
 fi
 
 dnl The check for jni_md.h must be before jni.h.
@@ -782,8 +782,8 @@ AC_CHECK_WITH_JNI_MD_H
 AC_CHECK_WITH_JNI_H
 
 dnl HPI is only required for OpenJDK
-case "${WITH_CLASSPATH}" in
-    sun)
+case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+    openjdk)
         AC_CHECK_WITH_HPI_MD_H
         AC_CHECK_WITH_HPI_H
         ;;
@@ -793,15 +793,15 @@ esac
 
 dnl check for some programs we need
 
-case "${WITH_CLASSPATH}" in
-    cldc1.1 | gnu)
+case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+    cldc1.1 | gnuclasspath)
         AC_PROG_JAVAC
         AC_PROG_JAR
         ;;
-    sun)
+    openjdk)
         ;;
     *)
-        AC_MSG_ERROR(unknown classpath configuration ${WITH_CLASSPATH})
+        AC_MSG_ERROR(unknown classpath configuration ${WITH_JAVA_RUNTIME_LIBRARY})
         ;;
 esac
 
@@ -867,8 +867,8 @@ AC_CONFIG_FILES([Makefile]
                [src/native/jvmti/Makefile]
                [src/native/vm/Makefile]
                [src/native/vm/cldc1.1/Makefile]
-               [src/native/vm/gnu/Makefile]
-               [src/native/vm/sun/Makefile]
+               [src/native/vm/gnuclasspath/Makefile]
+               [src/native/vm/openjdk/Makefile]
                [src/scripts/Makefile]
                [src/scripts/java]
                [src/threads/Makefile]
index 580d7cf6f69cf10a9e4f443d4b958a883402725e..5f9eb541804c988686923dbdb6e00c3f1c305f79 100644 (file)
@@ -3,4 +3,4 @@
 
 export PATH=$PWD/src/cacao:$PATH
 export LD_LIBRARY_PATH=$PWD/src/cacao/.libs
-export BOOTCLASSPATH=$PWD/src/classes/vm.zip:@CLASSPATH_CLASSES@
+export BOOTCLASSPATH=$PWD/src/classes/vm.zip:@JAVA_RUNTIME_LIBRARY_CLASSES@
index b260cb655672936726530d3e97da7ea9907543cd..377599afef535bb0f33de7bea23f6ad0d2db964c 100644 (file)
@@ -5,13 +5,13 @@ export PATH=$PWD/src/cacao:$PATH
 
 export LD_LIBRARY_PATH=\
 $PWD/src/cacao/.libs:\
-@CLASSPATH_PREFIX@/native/jawt/.libs:\
-@CLASSPATH_PREFIX@/native/jni/gtk-peer/.libs:\
-@CLASSPATH_PREFIX@/native/jni/java-io/.libs:\
-@CLASSPATH_PREFIX@/native/jni/java-lang/.libs:\
-@CLASSPATH_PREFIX@/native/jni/java-net/.libs:\
-@CLASSPATH_PREFIX@/native/jni/java-nio/.libs:\
-@CLASSPATH_PREFIX@/native/jni/java-util/.libs:\
+@JAVA_RUNTIME_LIBRARY_PREFIX@/native/jawt/.libs:\
+@JAVA_RUNTIME_LIBRARY_PREFIX@/native/jni/gtk-peer/.libs:\
+@JAVA_RUNTIME_LIBRARY_PREFIX@/native/jni/java-io/.libs:\
+@JAVA_RUNTIME_LIBRARY_PREFIX@/native/jni/java-lang/.libs:\
+@JAVA_RUNTIME_LIBRARY_PREFIX@/native/jni/java-net/.libs:\
+@JAVA_RUNTIME_LIBRARY_PREFIX@/native/jni/java-nio/.libs:\
+@JAVA_RUNTIME_LIBRARY_PREFIX@/native/jni/java-util/.libs:\
 $LD_LIBRARY_PATH
 
-export BOOTCLASSPATH=$PWD/src/classes/vm.zip:@CLASSPATH_CLASSES@
+export BOOTCLASSPATH=$PWD/src/classes/vm.zip:@JAVA_RUNTIME_LIBRARY_CLASSES@
diff --git a/m4/classpath.m4 b/m4/classpath.m4
deleted file mode 100644 (file)
index 1a65af7..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-dnl m4/classpath.m4
-dnl
-dnl Copyright (C) 2007, 2008
-dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-dnl
-dnl This file is part of CACAO.
-dnl
-dnl This program is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU General Public License as
-dnl published by the Free Software Foundation; either version 2, or (at
-dnl your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-dnl 02110-1301, USA.
-
-
-dnl which Java core library should we use
-
-AC_DEFUN([AC_CHECK_WITH_CLASSPATH],[
-AC_MSG_CHECKING(which Java core library to use)
-AC_ARG_WITH([classpath],
-            [AS_HELP_STRING(--with-classpath=<type>,specifies which type of classpath to use as Java core library (cldc1.1,gnu,sun) [[default=gnu]])],
-            [case "${withval}" in
-                cldc1.1)
-                    WITH_CLASSPATH=cldc1.1
-                    AC_DEFINE([WITH_CLASSPATH_CLDC1_1], 1, [use Sun's CLDC1.1 classes])
-                    AC_SUBST(WITH_CLASSPATH_CLDC1_1)
-                    ;;
-                gnu)
-                    WITH_CLASSPATH=gnu
-                    AC_DEFINE([WITH_CLASSPATH_GNU], 1, [use GNU Classpath])
-                    AC_SUBST(WITH_CLASSPATH_GNU)
-                    ;;
-                sun)
-                    WITH_CLASSPATH=sun
-                    AC_DEFINE([WITH_CLASSPATH_SUN], 1, [use Sun's Java SE classes])
-                    AC_SUBST(WITH_CLASSPATH_SUN)
-                    ;;
-                *)
-                    AC_MSG_ERROR(unknown classpath ${withval})
-                    ;;
-             esac],
-            [WITH_CLASSPATH=gnu
-             AC_DEFINE([WITH_CLASSPATH_GNU], 1, [use GNU Classpath])
-             AC_SUBST(WITH_CLASSPATH_GNU)])
-AC_MSG_RESULT(${WITH_CLASSPATH})
-AM_CONDITIONAL([WITH_CLASSPATH_CLDC1_1], test x"${WITH_CLASSPATH}" = "xcldc1.1")
-AM_CONDITIONAL([WITH_CLASSPATH_GNU], test x"${WITH_CLASSPATH}" = "xgnu")
-AM_CONDITIONAL([WITH_CLASSPATH_SUN], test x"${WITH_CLASSPATH}" = "xsun")
-])
-
-
-dnl where is Java core library installed
-
-AC_DEFUN([AC_CHECK_WITH_CLASSPATH_PREFIX],[
-AC_MSG_CHECKING(where Java core library is installed)
-AC_ARG_WITH([classpath-prefix],
-            [AS_HELP_STRING(--with-classpath-prefix=<dir>,installation directory of Java core library [[default=/usr/local/classpath]])],
-            [CLASSPATH_PREFIX=${withval}],
-            [CLASSPATH_PREFIX=/usr/local/classpath])
-AC_MSG_RESULT(${CLASSPATH_PREFIX})
-AC_DEFINE_UNQUOTED([CLASSPATH_PREFIX], "${CLASSPATH_PREFIX}", [Java core library installation directory])
-AC_SUBST(CLASSPATH_PREFIX)
-])
-
-
-dnl where are Java core library classes installed
-
-AC_DEFUN([AC_CHECK_WITH_CLASSPATH_CLASSES],[
-AC_MSG_CHECKING(where Java core library classes are installed)
-AC_ARG_WITH([classpath-classes],
-            [AS_HELP_STRING(--with-classpath-classes=<path>,path to Java core library classes (includes the name of the file and may be flat) [[default=(gnu:${CLASSPATH_PREFIX}/share/classpath/glibj.zip,sun:${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/classes,*:${CLASSPATH_PREFIX})]])],
-            [CLASSPATH_CLASSES=${withval}],
-            [case "${WITH_CLASSPATH}" in
-                 gnu)
-                     CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/share/classpath/glibj.zip
-                     ;;
-                 sun)
-                     CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/classes
-                     ;;
-                 *)
-                     CLASSPATH_CLASSES=${CLASSPATH_PREFIX}
-                     ;;
-             esac])
-AC_MSG_RESULT(${CLASSPATH_CLASSES})
-AC_DEFINE_UNQUOTED([CLASSPATH_CLASSES], "${CLASSPATH_CLASSES}", [Java core library classes])
-AC_SUBST(CLASSPATH_CLASSES)
-
-dnl define BOOTCLASSPATH for Makefiles
-case "${WITH_CLASSPATH}" in
-    cldc1.1 | gnu)
-        BOOTCLASSPATH="\$(top_builddir)/src/classes/classes:\$(CLASSPATH_CLASSES)"
-        ;;
-    *)
-        BOOTCLASSPATH="\$(CLASSPATH_CLASSES)"
-        ;;
-esac
-AC_SUBST(BOOTCLASSPATH)
-])
-
-
-dnl where are Java core library native libraries installed
-
-AC_DEFUN([AC_CHECK_WITH_CLASSPATH_LIBDIR],[
-AC_MSG_CHECKING(where Java core library native libraries are installed)
-AC_ARG_WITH([classpath-libdir],
-            [AS_HELP_STRING(--with-classpath-libdir=<dir>,installation directory of Java core library native libraries [[default=(gnu:${CLASSPATH_PREFIX}/lib,sun:${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/lib/${JAVA_ARCH},*:${CLASSPATH_PREFIX})]])],
-            [CLASSPATH_LIBDIR=${withval}],
-            [case "${WITH_CLASSPATH}" in
-                 gnu)
-                     CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/lib
-                     ;;
-                 sun)
-                     CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/lib/${JAVA_ARCH}
-                     ;;
-                 *)
-                     CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}
-                     ;;
-             esac])
-AC_MSG_RESULT(${CLASSPATH_LIBDIR})
-
-dnl expand CLASSPATH_LIBDIR to something that is usable in C code
-AS_AC_EXPAND([CLASSPATH_LIBDIR], ${CLASSPATH_LIBDIR})
-AC_DEFINE_UNQUOTED([CLASSPATH_LIBDIR], "${CLASSPATH_LIBDIR}", [Java core library native libraries installation directory])
-AC_SUBST(CLASSPATH_LIBDIR)
-])
-
-
-dnl where jni_md.h is installed
-
-AC_DEFUN([AC_CHECK_WITH_JNI_MD_H],[
-AC_MSG_CHECKING(where jni_md.h is installed)
-AC_ARG_WITH([jni_md_h],
-            [AS_HELP_STRING(--with-jni_md_h=<dir>,path to jni_md.h [[default=(sun:${CLASSPATH_PREFIX}/jdk/src/solaris/javavm/export,*:${CLASSPATH_PREFIX}/include)]])],
-            [WITH_JNI_MD_H=${withval}],
-            [case "${WITH_CLASSPATH}" in
-                 sun)
-                     WITH_JNI_MD_H=${CLASSPATH_PREFIX}/jdk/src/solaris/javavm/export
-                     ;;
-                 *)
-                     WITH_JNI_MD_H=${CLASSPATH_PREFIX}/include
-                     ;;
-            esac])
-AC_MSG_RESULT(${WITH_JNI_MD_H})
-
-dnl We use CPPFLAGS so jni.h can find jni_md.h
-CPPFLAGS="${CPPFLAGS} -I${WITH_JNI_MD_H}"
-
-AC_CHECK_HEADER([${WITH_JNI_MD_H}/jni_md.h],
-                [AC_DEFINE_UNQUOTED([INCLUDE_JNI_MD_H], "${WITH_JNI_MD_H}/jni_md.h", [Java core library jni_md.h header])],
-                [AC_MSG_ERROR(cannot find jni_md.h)])
-])
-
-
-dnl where jni.h is installed
-
-AC_DEFUN([AC_CHECK_WITH_JNI_H],[
-AC_MSG_CHECKING(where jni.h is installed)
-AC_ARG_WITH([jni_h],
-            [AS_HELP_STRING(--with-jni_h=<dir>,path to jni.h [[default=(sun:${CLASSPATH_PREFIX}/jdk/src/share/javavm/export,*:${CLASSPATH_PREFIX}/include)]])],
-            [WITH_JNI_H=${withval}],
-            [case "${WITH_CLASSPATH}" in
-                 sun)
-                     WITH_JNI_H=${CLASSPATH_PREFIX}/jdk/src/share/javavm/export
-                     ;;
-                 *)
-                     WITH_JNI_H=${CLASSPATH_PREFIX}/include
-                     ;;
-            esac])
-AC_MSG_RESULT(${WITH_JNI_H})
-
-dnl We use CPPFLAGS so jni.h can find jni_md.h
-CPPFLAGS="${CPPFLAGS} -I${WITH_JNI_H}"
-
-AC_CHECK_HEADER([${WITH_JNI_H}/jni.h],
-                [AC_DEFINE_UNQUOTED([INCLUDE_JNI_H], "${WITH_JNI_H}/jni.h", [Java core library jni.h header])],
-                [AC_MSG_ERROR(cannot find jni.h)],
-                [#include INCLUDE_JNI_MD_H])
-])
index 9166e56c4aa69d7230231565fca7ef7a741e3ae0..441d8cae216efa08c7a5b3ee132271e848d44caf 100644 (file)
--- a/m4/hpi.m4
+++ b/m4/hpi.m4
@@ -26,11 +26,11 @@ dnl where hpi_md.h is installed
 AC_DEFUN([AC_CHECK_WITH_HPI_MD_H],[
 AC_MSG_CHECKING(where hpi_md.h is installed)
 AC_ARG_WITH([hpi_md_h],
-            [AS_HELP_STRING(--with-hpi_md_h=<dir>,path to hpi_md.h (only with --with-classpath=sun) [[default=${CLASSPATH_PREFIX}/jdk/src/solaris/hpi/export]])],
+            [AS_HELP_STRING(--with-hpi_md_h=<dir>,path to hpi_md.h (only with --with-java-runtime-library=openjdk) [[default=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/solaris/hpi/export]])],
             [WITH_HPI_MD_H=${withval}],
-            [case "${WITH_CLASSPATH}" in
-                 sun)
-                     WITH_HPI_MD_H=${CLASSPATH_PREFIX}/jdk/src/solaris/hpi/export
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 openjdk)
+                     WITH_HPI_MD_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/solaris/hpi/export
                      ;;
                  *)
                      ;;
@@ -51,9 +51,9 @@ dnl where hpi.h is installed
 AC_DEFUN([AC_CHECK_WITH_HPI_H],[
 AC_MSG_CHECKING(where hpi.h is installed)
 AC_ARG_WITH([hpi_h],
-            [AS_HELP_STRING(--with-hpi_h=<dir>,path to hpi.h (only with --with-classpath=sun) [[default=${CLASSPATH_PREFIX}/jdk/src/share/hpi/export]])],
+            [AS_HELP_STRING(--with-hpi_h=<dir>,path to hpi.h (only with --with-java-runtime-library=openjdk) [[default=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/hpi/export]])],
             [WITH_HPI_H=${withval}],
-            [WITH_HPI_H=${CLASSPATH_PREFIX}/jdk/src/share/hpi/export])
+            [WITH_HPI_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/hpi/export])
 AC_MSG_RESULT(${WITH_HPI_H})
 
 dnl We use CPPFLAGS so hpi.h can find hpi_md.h
diff --git a/m4/java-runtime-library.m4 b/m4/java-runtime-library.m4
new file mode 100644 (file)
index 0000000..d69cf7e
--- /dev/null
@@ -0,0 +1,186 @@
+dnl m4/java-runtime-library.m4
+dnl
+dnl Copyright (C) 2007, 2008
+dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+dnl
+dnl This file is part of CACAO.
+dnl
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2, or (at
+dnl your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+
+
+dnl which Java runtime library should we use
+
+AC_DEFUN([AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY],[
+AC_MSG_CHECKING(which Java runtime library to use)
+AC_ARG_WITH([java-runtime-library],
+            [AS_HELP_STRING(--with-java-runtime-library=<type>,specifies which type of classpath to use as Java runtime library (cldc1.1,gnuclasspath,openjdk) [[default=gnuclasspath]])],
+            [case "${withval}" in
+                cldc1.1)
+                    WITH_JAVA_RUNTIME_LIBRARY=cldc1.1
+                    AC_DEFINE([WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1], 1, [use Sun's CLDC1.1 classes])
+                    AC_SUBST(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+                    ;;
+                gnuclasspath)
+                    WITH_JAVA_RUNTIME_LIBRARY=gnuclasspath
+                    AC_DEFINE([WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH], 1, [use GNU Classpath])
+                    AC_SUBST(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+                    ;;
+                openjdk)
+                    WITH_JAVA_RUNTIME_LIBRARY=openjdk
+                    AC_DEFINE([WITH_JAVA_RUNTIME_LIBRARY_OPENJDK], 1, [use OpenJDK's Java SE classes])
+                    AC_SUBST(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+                    ;;
+                *)
+                    AC_MSG_ERROR(unknown classpath ${withval})
+                    ;;
+             esac],
+            [WITH_JAVA_RUNTIME_LIBRARY=gnuclasspath
+             AC_DEFINE([WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH], 1, [use GNU Classpath])
+             AC_SUBST(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)])
+AC_MSG_RESULT(${WITH_JAVA_RUNTIME_LIBRARY})
+AM_CONDITIONAL([WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1], test x"${WITH_JAVA_RUNTIME_LIBRARY}" = "xcldc1.1")
+AM_CONDITIONAL([WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH], test x"${WITH_JAVA_RUNTIME_LIBRARY}" = "xgnuclasspath")
+AM_CONDITIONAL([WITH_JAVA_RUNTIME_LIBRARY_OPENJDK], test x"${WITH_JAVA_RUNTIME_LIBRARY}" = "xopenjdk")
+])
+
+
+dnl where is Java runtime library installed
+
+AC_DEFUN([AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_PREFIX],[
+AC_MSG_CHECKING(where Java runtime library is installed)
+AC_ARG_WITH([java-runtime-library-prefix],
+            [AS_HELP_STRING(--with-java-runtime-library-prefix=<dir>,installation directory of Java runtime library [[default=/usr/local/classpath]])],
+            [JAVA_RUNTIME_LIBRARY_PREFIX=${withval}],
+            [JAVA_RUNTIME_LIBRARY_PREFIX=/usr/local/classpath])
+AC_MSG_RESULT(${JAVA_RUNTIME_LIBRARY_PREFIX})
+AC_DEFINE_UNQUOTED([JAVA_RUNTIME_LIBRARY_PREFIX], "${JAVA_RUNTIME_LIBRARY_PREFIX}", [Java runtime library installation directory])
+AC_SUBST(JAVA_RUNTIME_LIBRARY_PREFIX)
+])
+
+
+dnl where are Java runtime library classes installed
+
+AC_DEFUN([AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_CLASSES],[
+AC_MSG_CHECKING(where Java runtime library classes are installed)
+AC_ARG_WITH([java-runtime-library-classes],
+            [AS_HELP_STRING(--with-java-runtime-library-classes=<path>,path to Java runtime library classes (includes the name of the file and may be flat) [[default=(gnuclasspath:${JAVA_RUNTIME_LIBRARY_PREFIX}/share/classpath/glibj.zip,openjdk:${JAVA_RUNTIME_LIBRARY_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/classes,*:${JAVA_RUNTIME_LIBRARY_PREFIX})]])],
+            [JAVA_RUNTIME_LIBRARY_CLASSES=${withval}],
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 gnuclasspath)
+                     JAVA_RUNTIME_LIBRARY_CLASSES=${JAVA_RUNTIME_LIBRARY_PREFIX}/share/classpath/glibj.zip
+                     ;;
+                 openjdk)
+                     JAVA_RUNTIME_LIBRARY_CLASSES=${JAVA_RUNTIME_LIBRARY_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/classes
+                     ;;
+                 *)
+                     JAVA_RUNTIME_LIBRARY_CLASSES=${JAVA_RUNTIME_LIBRARY_PREFIX}
+                     ;;
+             esac])
+AC_MSG_RESULT(${JAVA_RUNTIME_LIBRARY_CLASSES})
+AC_DEFINE_UNQUOTED([JAVA_RUNTIME_LIBRARY_CLASSES], "${JAVA_RUNTIME_LIBRARY_CLASSES}", [Java runtime library classes])
+AC_SUBST(JAVA_RUNTIME_LIBRARY_CLASSES)
+
+dnl define BOOTCLASSPATH for Makefiles
+case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+    cldc1.1 | gnuclasspath)
+        BOOTCLASSPATH="\$(top_builddir)/src/classes/classes:\$(JAVA_RUNTIME_LIBRARY_CLASSES)"
+        ;;
+    *)
+        BOOTCLASSPATH="\$(JAVA_RUNTIME_LIBRARY_CLASSES)"
+        ;;
+esac
+AC_SUBST(BOOTCLASSPATH)
+])
+
+
+dnl where are Java runtime library native libraries installed
+
+AC_DEFUN([AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_LIBDIR],[
+AC_MSG_CHECKING(where Java runtime library native libraries are installed)
+AC_ARG_WITH([java-runtime-library-libdir],
+            [AS_HELP_STRING(--with-java-runtime-library-libdir=<dir>,installation directory of Java runtime library native libraries [[default=(gnuclasspath:${JAVA_RUNTIME_LIBRARY_PREFIX}/lib,openjdk:${JAVA_RUNTIME_LIBRARY_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/lib/${JAVA_ARCH},*:${JAVA_RUNTIME_LIBRARY_PREFIX})]])],
+            [JAVA_RUNTIME_LIBRARY_LIBDIR=${withval}],
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 gnuclasspath)
+                     JAVA_RUNTIME_LIBRARY_LIBDIR=${JAVA_RUNTIME_LIBRARY_PREFIX}/lib
+                     ;;
+                 openjdk)
+                     JAVA_RUNTIME_LIBRARY_LIBDIR=${JAVA_RUNTIME_LIBRARY_PREFIX}/control/build/${OS_DIR}-${JAVA_ARCH}/lib/${JAVA_ARCH}
+                     ;;
+                 *)
+                     JAVA_RUNTIME_LIBRARY_LIBDIR=${JAVA_RUNTIME_LIBRARY_PREFIX}
+                     ;;
+             esac])
+AC_MSG_RESULT(${JAVA_RUNTIME_LIBRARY_LIBDIR})
+
+dnl expand JAVA_RUNTIME_LIBRARY_LIBDIR to something that is usable in C code
+AS_AC_EXPAND([JAVA_RUNTIME_LIBRARY_LIBDIR], ${JAVA_RUNTIME_LIBRARY_LIBDIR})
+AC_DEFINE_UNQUOTED([JAVA_RUNTIME_LIBRARY_LIBDIR], "${JAVA_RUNTIME_LIBRARY_LIBDIR}", [Java runtime library native libraries installation directory])
+AC_SUBST(JAVA_RUNTIME_LIBRARY_LIBDIR)
+])
+
+
+dnl where jni_md.h is installed
+
+AC_DEFUN([AC_CHECK_WITH_JNI_MD_H],[
+AC_MSG_CHECKING(where jni_md.h is installed)
+AC_ARG_WITH([jni_md_h],
+            [AS_HELP_STRING(--with-jni_md_h=<dir>,path to jni_md.h [[default=(openjdk:${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/solaris/javavm/export,*:${JAVA_RUNTIME_LIBRARY_PREFIX}/include)]])],
+            [WITH_JNI_MD_H=${withval}],
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 openjdk)
+                     WITH_JNI_MD_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/solaris/javavm/export
+                     ;;
+                 *)
+                     WITH_JNI_MD_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/include
+                     ;;
+            esac])
+AC_MSG_RESULT(${WITH_JNI_MD_H})
+
+dnl We use CPPFLAGS so jni.h can find jni_md.h
+CPPFLAGS="${CPPFLAGS} -I${WITH_JNI_MD_H}"
+
+AC_CHECK_HEADER([${WITH_JNI_MD_H}/jni_md.h],
+                [AC_DEFINE_UNQUOTED([INCLUDE_JNI_MD_H], "${WITH_JNI_MD_H}/jni_md.h", [Java runtime library jni_md.h header])],
+                [AC_MSG_ERROR(cannot find jni_md.h)])
+])
+
+
+dnl where jni.h is installed
+
+AC_DEFUN([AC_CHECK_WITH_JNI_H],[
+AC_MSG_CHECKING(where jni.h is installed)
+AC_ARG_WITH([jni_h],
+            [AS_HELP_STRING(--with-jni_h=<dir>,path to jni.h [[default=(openjdk:${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/javavm/export,*:${JAVA_RUNTIME_LIBRARY_PREFIX}/include)]])],
+            [WITH_JNI_H=${withval}],
+            [case "${WITH_JAVA_RUNTIME_LIBRARY}" in
+                 openjdk)
+                     WITH_JNI_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/jdk/src/share/javavm/export
+                     ;;
+                 *)
+                     WITH_JNI_H=${JAVA_RUNTIME_LIBRARY_PREFIX}/include
+                     ;;
+            esac])
+AC_MSG_RESULT(${WITH_JNI_H})
+
+dnl We use CPPFLAGS so jni.h can find jni_md.h
+CPPFLAGS="${CPPFLAGS} -I${WITH_JNI_H}"
+
+AC_CHECK_HEADER([${WITH_JNI_H}/jni.h],
+                [AC_DEFINE_UNQUOTED([INCLUDE_JNI_H], "${WITH_JNI_H}/jni.h", [Java runtime library jni.h header])],
+                [AC_MSG_ERROR(cannot find jni.h)],
+                [#include INCLUDE_JNI_MD_H])
+])
index c823692e9e9f4242ab4b4055f5d65c79242005cd..2a5247afd4a716069e0ad0873e79e608858173be 100644 (file)
@@ -37,7 +37,7 @@ lib_LTLIBRARIES = \
 libjvm_la_LDFLAGS = \
        -version-info 1:0:0
 
-if WITH_CLASSPATH_SUN
+if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
 libjvm_la_LDFLAGS += \
        -Xlinker --version-script=$(top_srcdir)/contrib/mapfile-vers-product
 endif
index 09aab9cba11affc0b6b8edc50ab357a7a0145a33..0f1e8edfda615441df40336be626006b4e417fd8 100644 (file)
@@ -1,9 +1,7 @@
 /* src/cacaoh/cacaoh.c - main for header generation (cacaoh)
 
-   Copyright (C) 1996-2005, 2006, 2007 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
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -169,19 +167,19 @@ int main(int argc, char **argv)
        }
        else {
                cplen =
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                        strlen(CACAO_VM_ZIP) +
                        strlen(":") +
 #endif
-                       strlen(CLASSPATH_CLASSES) +
+                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
                        strlen("0");
 
                bootclasspath = MNEW(char, cplen);
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                strcat(bootclasspath, CACAO_VM_ZIP);
                strcat(bootclasspath, ":");
 #endif
-               strcat(bootclasspath, CLASSPATH_CLASSES);
+               strcat(bootclasspath, JAVA_RUNTIME_LIBRARY_CLASSES);
        }
 
 
index 72c90270e218dfdc602b9c3e974019b4b1f525aa..9ddec49705cbcf2cbc404f6813ea5087afdc1507 100644 (file)
@@ -1,4 +1,4 @@
-## src/lib/Makefile.am
+## src/classes/Makefile.am
 ##
 ## Copyright (C) 1996-2005, 2006, 2007, 2008
 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
 
 EXTRA_DIST = \
-       $(VM_JAVA_FILES_GNU) \
-       $(VM_JAVA_FILES_GNU_ANNOTATIONS) \
+       $(VM_JAVA_FILES_GNU_CLASSPATH) \
+       $(VM_JAVA_FILES_GNU_CLASSPATH_ANNOTATIONS) \
        $(VM_JAVA_FILES_CLDC1_1)
 
 CLEANFILES = vm.zip
 
-VM_JAVA_FILES_GNU = \
-       $(top_srcdir)/src/classes/gnu/gnu/classpath/VMStackWalker.java \
-       $(top_srcdir)/src/classes/gnu/gnu/classpath/VMSystemProperties.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/VMClassLoader.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/VMString.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/VMThread.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/VMConstructor.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/VMField.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/VMMethod.java \
-       $(top_srcdir)/src/classes/gnu/java/security/VMAccessController.java \
-       $(top_srcdir)/src/classes/gnu/sun/misc/Unsafe.java
+VM_JAVA_FILES_GNU_CLASSPATH = \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/VMClassLoader.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/VMString.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/VMThread.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/VMField.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/VMMethod.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/security/VMAccessController.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/misc/Unsafe.java
 
 # Remove these files when a new GNU Classpath release (> 0.97.1) is
 # available.
 
-VM_JAVA_FILES_GNU += \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Constructor.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Field.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Method.java \
-       $(top_srcdir)/src/classes/gnu/java/lang/reflect/Modifier.java \
-       $(top_srcdir)/src/classes/gnu/gnu/java/lang/CPStringBuilder.java
-
-VM_JAVA_FILES_GNU_ANNOTATIONS = \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/ConstantPool.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/AnnotationType.java \
-       $(top_srcdir)/src/classes/gnu/sun/reflect/annotation/AnnotationParser.java
+VM_JAVA_FILES_GNU_CLASSPATH += \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Constructor.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Field.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Method.java \
+       $(top_srcdir)/src/classes/gnuclasspath/java/lang/reflect/Modifier.java \
+       $(top_srcdir)/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java
+
+VM_JAVA_FILES_GNU_CLASSPATH_ANNOTATIONS = \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/ConstantPool.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java \
+       $(top_srcdir)/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java
 
 VM_JAVA_FILES_CLDC1_1 = \
        $(top_srcdir)/src/classes/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java
 
-BOOTCLASSPATH = $(top_builddir)/src/classes/classes:$(CLASSPATH_CLASSES)
-
-if WITH_CLASSPATH_GNU
+if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
 VM_JAVA_FILES = \
-       $(VM_JAVA_FILES_GNU)
+       $(VM_JAVA_FILES_GNU_CLASSPATH)
 
 if ENABLE_ANNOTATIONS
 VM_JAVA_FILES += \
-       $(VM_JAVA_FILES_GNU_ANNOTATIONS)
+       $(VM_JAVA_FILES_GNU_CLASSPATH_ANNOTATIONS)
 endif
 
 if ENABLE_ZLIB
@@ -83,7 +81,7 @@ pkgdata_DATA = nozip
 endif
 endif
 
-if WITH_CLASSPATH_CLDC1_1
+if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
 VM_JAVA_FILES = \
        $(VM_JAVA_FILES_CLDC1_1)
 
diff --git a/src/classes/gnu/gnu/classpath/VMStackWalker.java b/src/classes/gnu/gnu/classpath/VMStackWalker.java
deleted file mode 100644 (file)
index 434edd2..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* VMStackWalker.java -- Reference implementation of VM hooks for stack access
-   Copyright (C) 2005 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath;
-
-/**
- * This class provides access to the classes on the Java stack
- * for reflection and security purposes.
- *
- * <p>
- * This class is only available to privileged code (i.e., code loaded
- * by the bootstrap loader).
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @author Archie Cobbs
- */
-public final class VMStackWalker
-{
-  /**
-   * Get a list of all the classes currently executing methods on the
-   * Java stack. <code>getClassContext()[0]</code> is the class associated
-   * with the currently executing method, i.e., the method that called
-   * <code>VMStackWalker.getClassContext()</code> (possibly through
-   * reflection). So you may need to pop off these stack frames from
-   * the top of the stack:
-   * <ul>
-   * <li><code>VMStackWalker.getClassContext()</code>
-   * <li><code>Method.invoke()</code>
-   * </ul>
-   *
-   * @return an array of the declaring classes of each stack frame
-   */
-  public static native Class[] getClassContext();
-
-  /**
-   * Get the class associated with the method invoking the method
-   * invoking this method, or <code>null</code> if the stack is not
-   * that deep (e.g., invoked via JNI invocation API). This method
-   * is an optimization for the expression <code>getClassContext()[1]</code>
-   * and should return the same result.
-   *
-   * <p>
-   * VM implementers are encouraged to provide a more efficient
-   * version of this method.
-   */
-//    public static Class getCallingClass()
-//    {
-//      Class[] ctx = getClassContext();
-//      if (ctx.length < 3)
-//        return null;
-//      return ctx[2];
-//    }
-  public static native Class getCallingClass();
-
-  /**
-   * Get the class loader associated with the Class returned by
-   * <code>getCallingClass()</code>, or <code>null</code> if no such class
-   * exists or it is the boot loader. This method is an optimization for the
-   * expression <code>VMStackWalker.getClassLoader(getClassContext()[1])</code>
-   * and should return the same result.
-   *
-   * <p>
-   * VM implementers are encouraged to provide a more efficient
-   * version of this method.
-   */
-//    public static ClassLoader getCallingClassLoader()
-//    {
-//      Class[] ctx = getClassContext();
-//      if (ctx.length < 3)
-//        return null;
-//      return getClassLoader(ctx[2]);
-//    }
-  public static native ClassLoader getCallingClassLoader();
-
-
-  /**
-   * Retrieve the class's ClassLoader, or <code>null</code> if loaded
-   * by the bootstrap loader. I.e., this should return the same thing
-   * as {@link java.lang.VMClass#getClassLoader}. This duplicate version
-   * is here to work around access permissions.
-   */
-//    public static native ClassLoader getClassLoader(Class cl);
-
-  /**
-   * Walk up the stack and return the first non-null class loader.
-   * If there aren't any non-null class loaders on the stack, return null.
-   */
-//   public static ClassLoader firstNonNullClassLoader()
-//   {
-//     Class[] stack = getClassContext();
-//     for (int i = 0; i < stack.length; i++)
-//       {
-//         ClassLoader loader = getClassLoader(stack[i]);
-//         if (loader != null)
-//           return loader;
-//       }
-//     return null;
-//   }
-    public static native ClassLoader firstNonNullClassLoader();
-}
diff --git a/src/classes/gnu/gnu/classpath/VMSystemProperties.java b/src/classes/gnu/gnu/classpath/VMSystemProperties.java
deleted file mode 100644 (file)
index 287a933..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* VMSystemProperties.java -- Allow the VM to set System properties.
-   Copyright (C) 2004 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath;
-
-import java.util.Properties;
-
-class VMSystemProperties
-{
-    /**
-     * Get the system properties. This is done here, instead of in System,
-     * because of the bootstrap sequence. Note that the native code should
-     * not try to use the Java I/O classes yet, as they rely on the properties
-     * already existing. The only safe method to use to insert these default
-     * system properties is {@link Properties#setProperty(String, String)}.
-     *
-     * <p>These properties MUST include:
-     * <dl>
-     * <dt>java.version         <dd>Java version number
-     * <dt>java.vendor          <dd>Java vendor specific string
-     * <dt>java.vendor.url      <dd>Java vendor URL
-     * <dt>java.home            <dd>Java installation directory
-     * <dt>java.vm.specification.version <dd>VM Spec version
-     * <dt>java.vm.specification.vendor  <dd>VM Spec vendor
-     * <dt>java.vm.specification.name    <dd>VM Spec name
-     * <dt>java.vm.version      <dd>VM implementation version
-     * <dt>java.vm.vendor       <dd>VM implementation vendor
-     * <dt>java.vm.name         <dd>VM implementation name
-     * <dt>java.specification.version    <dd>Java Runtime Environment version
-     * <dt>java.specification.vendor     <dd>Java Runtime Environment vendor
-     * <dt>java.specification.name       <dd>Java Runtime Environment name
-     * <dt>java.class.version   <dd>Java class version number
-     * <dt>java.class.path      <dd>Java classpath
-     * <dt>java.library.path    <dd>Path for finding Java libraries
-     * <dt>java.io.tmpdir       <dd>Default temp file path
-     * <dt>java.compiler        <dd>Name of JIT to use
-     * <dt>java.ext.dirs        <dd>Java extension path
-     * <dt>os.name              <dd>Operating System Name
-     * <dt>os.arch              <dd>Operating System Architecture
-     * <dt>os.version           <dd>Operating System Version
-     * <dt>file.separator       <dd>File separator ("/" on Unix)
-     * <dt>path.separator       <dd>Path separator (":" on Unix)
-     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
-     * <dt>user.name            <dd>User account name
-     * <dt>user.home            <dd>User home directory
-     * <dt>user.dir             <dd>User's current working directory
-     * <dt>gnu.cpu.endian       <dd>"big" or "little"
-     * </dl>
-     *
-     * @param properties the Properties object to insert the system properties into
-     */
-    static native void preInit(Properties properties);
-
-    /**
-     * Here you get a chance to overwrite some of the properties set by
-     * the common SystemProperties code. For example, it might be
-     * a good idea to process the properties specified on the command
-     * line here.
-     */
-//     static void postInit(Properties properties)
-//     {
-//     }
-    static native void postInit(Properties properties);
-}
diff --git a/src/classes/gnu/gnu/java/lang/CPStringBuilder.java b/src/classes/gnu/gnu/java/lang/CPStringBuilder.java
deleted file mode 100644 (file)
index 978a204..0000000
+++ /dev/null
@@ -1,1084 +0,0 @@
-/* ClasspathStringBuffer.java -- Growable strings without locking or copying
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
-   Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.lang;
-
-import java.io.Serializable;
-
-/**
- * This class is based on java.lang.AbstractStringBuffer but
- * without the copying of the string by toString.
- * If you modify this, please consider also modifying that code.
- * This code is not thread-safe; limit its use to internal use within
- * methods.
- */
-public final class CPStringBuilder
-  implements Serializable, CharSequence, Appendable
-{
-
-  /**
-   * Index of next available character (and thus the size of the current
-   * string contents).  Note that this has permissions set this way so that
-   * String can get the value.
-   *
-   * @serial the number of characters in the buffer
-   */
-  int count;
-
-  /**
-   * The buffer.  Note that this has permissions set this way so that String
-   * can get the value.
-   *
-   * @serial the buffer
-   */
-  char[] value;
-
-  /**
-   * The default capacity of a buffer.
-   */
-  private static final int DEFAULT_CAPACITY = 16;
-
-  /**
-   * Create a new CPStringBuilder with default capacity 16.
-   */
-  public CPStringBuilder()
-  {
-    this(DEFAULT_CAPACITY);
-  }
-
-  /**
-   * Create an empty <code>StringBuffer</code> with the specified initial
-   * capacity.
-   *
-   * @param capacity the initial capacity
-   * @throws NegativeArraySizeException if capacity is negative
-   */
-  public CPStringBuilder(int capacity)
-  {
-    value = new char[capacity];
-  }
-
-  /**
-   * Create a new <code>StringBuffer</code> with the characters in the
-   * specified <code>String</code>. Initial capacity will be the size of the
-   * String plus 16.
-   *
-   * @param str the <code>String</code> to convert
-   * @throws NullPointerException if str is null
-   */
-  public CPStringBuilder(String str)
-  {
-    count = str.length();
-    value = new char[count + DEFAULT_CAPACITY];
-    str.getChars(0, count, value, 0);
-  }
-
-  /**
-   * Create a new <code>StringBuffer</code> with the characters in the
-   * specified <code>CharSequence</code>. Initial capacity will be the
-   * length of the sequence plus 16; if the sequence reports a length
-   * less than or equal to 0, then the initial capacity will be 16.
-   *
-   * @param seq the initializing <code>CharSequence</code>
-   * @throws NullPointerException if str is null
-   * @since 1.5
-   */
-  public CPStringBuilder(CharSequence seq)
-  {
-    int len = seq.length();
-    count = len <= 0 ? 0 : len;
-    value = new char[count + DEFAULT_CAPACITY];
-    for (int i = 0; i < len; ++i)
-      value[i] = seq.charAt(i);
-  }
-
-  /**
-   * Increase the capacity of this <code>StringBuffer</code>. This will
-   * ensure that an expensive growing operation will not occur until
-   * <code>minimumCapacity</code> is reached. The buffer is grown to the
-   * larger of <code>minimumCapacity</code> and
-   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
-   *
-   * @param minimumCapacity the new capacity
-   * @see #capacity()
-   */
-  public void ensureCapacity(int minimumCapacity)
-  {
-    ensureCapacity_unsynchronized(minimumCapacity);
-  }
-
-  /**
-   * Set the length of this StringBuffer. If the new length is greater than
-   * the current length, all the new characters are set to '\0'. If the new
-   * length is less than the current length, the first <code>newLength</code>
-   * characters of the old array will be preserved, and the remaining
-   * characters are truncated.
-   *
-   * @param newLength the new length
-   * @throws IndexOutOfBoundsException if the new length is negative
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   * @see #length()
-   */
-  public void setLength(int newLength)
-  {
-    if (newLength < 0)
-      throw new StringIndexOutOfBoundsException(newLength);
-
-    int valueLength = value.length;
-
-    /* Always call ensureCapacity_unsynchronized in order to preserve
-       copy-on-write semantics.  */
-    ensureCapacity_unsynchronized(newLength);
-
-    if (newLength < valueLength)
-      {
-        /* If the StringBuffer's value just grew, then we know that
-           value is newly allocated and the region between count and
-           newLength is filled with '\0'.  */
-       count = newLength;
-      }
-    else
-      {
-       /* The StringBuffer's value doesn't need to grow.  However,
-          we should clear out any cruft that may exist.  */
-       while (count < newLength)
-          value[count++] = '\0';
-      }
-  }
-
-  /**
-   * Get the character at the specified index.
-   *
-   * @param index the index of the character to get, starting at 0
-   * @return the character at the specified index
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   */
-  public char charAt(int index)
-  {
-    if (index < 0 || index >= count)
-      throw new StringIndexOutOfBoundsException(index);
-    return value[index];
-  }
-
-  /**
-   * Get the code point at the specified index.  This is like #charAt(int),
-   * but if the character is the start of a surrogate pair, and the
-   * following character completes the pair, then the corresponding
-   * supplementary code point is returned.
-   * @param index the index of the codepoint to get, starting at 0
-   * @return the codepoint at the specified index
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   * @since 1.5
-   */
-  public int codePointAt(int index)
-  {
-    return Character.codePointAt(value, index, count);
-  }
-
-  /**
-   * Get the code point before the specified index.  This is like
-   * #codePointAt(int), but checks the characters at <code>index-1</code> and
-   * <code>index-2</code> to see if they form a supplementary code point.
-   * @param index the index just past the codepoint to get, starting at 0
-   * @return the codepoint at the specified index
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   * @since 1.5
-   */
-  public int codePointBefore(int index)
-  {
-    // Character.codePointBefore() doesn't perform this check.  We
-    // could use the CharSequence overload, but this is just as easy.
-    if (index >= count)
-      throw new IndexOutOfBoundsException();
-    return Character.codePointBefore(value, index, 1);
-  }
-
-  /**
-   * Get the specified array of characters. <code>srcOffset - srcEnd</code>
-   * characters will be copied into the array you pass in.
-   *
-   * @param srcOffset the index to start copying from (inclusive)
-   * @param srcEnd the index to stop copying from (exclusive)
-   * @param dst the array to copy into
-   * @param dstOffset the index to start copying into
-   * @throws NullPointerException if dst is null
-   * @throws IndexOutOfBoundsException if any source or target indices are
-   *         out of range (while unspecified, source problems cause a
-   *         StringIndexOutOfBoundsException, and dest problems cause an
-   *         ArrayIndexOutOfBoundsException)
-   * @see System#arraycopy(Object, int, Object, int, int)
-   */
-  public void getChars(int srcOffset, int srcEnd,
-                      char[] dst, int dstOffset)
-  {
-    if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
-      throw new StringIndexOutOfBoundsException();
-    System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
-  }
-
-  /**
-   * Set the character at the specified index.
-   *
-   * @param index the index of the character to set starting at 0
-   * @param ch the value to set that character to
-   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   */
-  public void setCharAt(int index, char ch)
-  {
-    if (index < 0 || index >= count)
-      throw new StringIndexOutOfBoundsException(index);
-    // Call ensureCapacity to enforce copy-on-write.
-    ensureCapacity_unsynchronized(count);
-    value[index] = ch;
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param obj the <code>Object</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(Object)
-   * @see #append(String)
-   */
-  public CPStringBuilder append(Object obj)
-  {
-    return append(String.valueOf(obj));
-  }
-
-  /**
-   * Append the <code>String</code> to this <code>StringBuffer</code>. If
-   * str is null, the String "null" is appended.
-   *
-   * @param str the <code>String</code> to append
-   * @return this <code>StringBuffer</code>
-   */
-  public CPStringBuilder append(String str)
-  {
-    if (str == null)
-      str = "null";
-    int len = str.length();
-    ensureCapacity_unsynchronized(count + len);
-    str.getChars(0, len, value, count);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Append the <code>StringBuilder</code> value of the argument to this
-   * <code>StringBuilder</code>. This behaves the same as
-   * <code>append((Object) stringBuffer)</code>, except it is more efficient.
-   *
-   * @param stringBuffer the <code>StringBuilder</code> to convert and append
-   * @return this <code>StringBuilder</code>
-   * @see #append(Object)
-   */
-  public CPStringBuilder append(StringBuffer stringBuffer)
-  {
-    if (stringBuffer == null)
-      return append("null");
-    synchronized (stringBuffer)
-      {
-       int len = stringBuffer.length();
-       ensureCapacity(count + len);
-       stringBuffer.getChars(0, len, value, count);
-       count += len;
-      }
-    return this;
-  }
-
-  /**
-   * Append the <code>char</code> array to this <code>StringBuffer</code>.
-   * This is similar (but more efficient) than
-   * <code>append(new String(data))</code>, except in the case of null.
-   *
-   * @param data the <code>char[]</code> to append
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>str</code> is <code>null</code>
-   * @see #append(char[], int, int)
-   */
-  public CPStringBuilder append(char[] data)
-  {
-    return append(data, 0, data.length);
-  }
-
-  /**
-   * Append part of the <code>char</code> array to this
-   * <code>StringBuffer</code>. This is similar (but more efficient) than
-   * <code>append(new String(data, offset, count))</code>, except in the case
-   * of null.
-   *
-   * @param data the <code>char[]</code> to append
-   * @param offset the start location in <code>str</code>
-   * @param count the number of characters to get from <code>str</code>
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>str</code> is <code>null</code>
-   * @throws IndexOutOfBoundsException if offset or count is out of range
-   *         (while unspecified, this is a StringIndexOutOfBoundsException)
-   */
-  public CPStringBuilder append(char[] data, int offset, int count)
-  {
-    if (offset < 0 || count < 0 || offset > data.length - count)
-      throw new StringIndexOutOfBoundsException();
-    ensureCapacity_unsynchronized(this.count + count);
-    System.arraycopy(data, offset, value, this.count, count);
-    this.count += count;
-    return this;
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param bool the <code>boolean</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(boolean)
-   */
-  public CPStringBuilder append(boolean bool)
-  {
-    return append(bool ? "true" : "false");
-  }
-
-  /**
-   * Append the <code>char</code> to this <code>StringBuffer</code>.
-   *
-   * @param ch the <code>char</code> to append
-   * @return this <code>StringBuffer</code>
-   */
-  public CPStringBuilder append(char ch)
-  {
-    ensureCapacity_unsynchronized(count + 1);
-    value[count++] = ch;
-    return this;
-  }
-
-  /**
-   * Append the characters in the <code>CharSequence</code> to this
-   * buffer.
-   *
-   * @param seq the <code>CharSequence</code> providing the characters
-   * @return this <code>StringBuffer</code>
-   * @since 1.5
-   */
-  public CPStringBuilder append(CharSequence seq)
-  {
-    return append(seq, 0, seq.length());
-  }
-
-  /**
-   * Append some characters from the <code>CharSequence</code> to this
-   * buffer.  If the argument is null, the four characters "null" are
-   * appended.
-   *
-   * @param seq the <code>CharSequence</code> providing the characters
-   * @param start the starting index
-   * @param end one past the final index
-   * @return this <code>StringBuffer</code>
-   * @since 1.5
-   */
-  public CPStringBuilder append(CharSequence seq, int start, int end)
-  {
-    if (seq == null)
-      return append("null");
-    if (end - start > 0)
-      {
-       ensureCapacity_unsynchronized(count + end - start);
-       for (; start < end; ++start)
-         value[count++] = seq.charAt(start);
-      }
-    return this;
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param inum the <code>int</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(int)
-   */
-  // This is native in libgcj, for efficiency.
-  public CPStringBuilder append(int inum)
-  {
-    return append(String.valueOf(inum));
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param lnum the <code>long</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(long)
-   */
-  public CPStringBuilder append(long lnum)
-  {
-    return append(Long.toString(lnum, 10));
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param fnum the <code>float</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(float)
-   */
-  public CPStringBuilder append(float fnum)
-  {
-    return append(Float.toString(fnum));
-  }
-
-  /**
-   * Append the <code>String</code> value of the argument to this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param dnum the <code>double</code> to convert and append
-   * @return this <code>StringBuffer</code>
-   * @see String#valueOf(double)
-   */
-  public CPStringBuilder append(double dnum)
-  {
-    return append(Double.toString(dnum));
-  }
-
-  /**
-   * Append the code point to this <code>StringBuffer</code>.
-   * This is like #append(char), but will append two characters
-   * if a supplementary code point is given.
-   *
-   * @param code the code point to append
-   * @return this <code>StringBuffer</code>
-   * @see Character#toChars(int, char[], int)
-   * @since 1.5
-   */
-  public CPStringBuilder appendCodePoint(int code)
-  {
-    int len = Character.charCount(code);
-    ensureCapacity_unsynchronized(count + len);
-    Character.toChars(code, value, count);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Delete characters from this <code>StringBuffer</code>.
-   * <code>delete(10, 12)</code> will delete 10 and 11, but not 12. It is
-   * harmless for end to be larger than length().
-   *
-   * @param start the first character to delete
-   * @param end the index after the last character to delete
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
-   * @since 1.2
-   */
-  public CPStringBuilder delete(int start, int end)
-  {
-    if (start < 0 || start > count || start > end)
-      throw new StringIndexOutOfBoundsException(start);
-    if (end > count)
-      end = count;
-    ensureCapacity_unsynchronized(count);
-    if (count - end != 0)
-      System.arraycopy(value, end, value, start, count - end);
-    count -= end - start;
-    return this;
-  }
-
-  /**
-   * Delete a character from this <code>StringBuffer</code>.
-   *
-   * @param index the index of the character to delete
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if index is out of bounds
-   * @since 1.2
-   */
-  public CPStringBuilder deleteCharAt(int index)
-  {
-    return delete(index, index + 1);
-  }
-
-  /**
-   * Replace characters between index <code>start</code> (inclusive) and
-   * <code>end</code> (exclusive) with <code>str</code>. If <code>end</code>
-   * is larger than the size of this StringBuffer, all characters after
-   * <code>start</code> are replaced.
-   *
-   * @param start the beginning index of characters to delete (inclusive)
-   * @param end the ending index of characters to delete (exclusive)
-   * @param str the new <code>String</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
-   * @throws NullPointerException if str is null
-   * @since 1.2
-   */
-  public CPStringBuilder replace(int start, int end, String str)
-  {
-    if (start < 0 || start > count || start > end)
-      throw new StringIndexOutOfBoundsException(start);
-
-    int len = str.length();
-    // Calculate the difference in 'count' after the replace.
-    int delta = len - (end > count ? count : end) + start;
-    ensureCapacity_unsynchronized(count + delta);
-
-    if (delta != 0 && end < count)
-      System.arraycopy(value, end, value, end + delta, count - end);
-
-    str.getChars(0, len, value, start);
-    count += delta;
-    return this;
-  }
-
-  /**
-   * Insert a subarray of the <code>char[]</code> argument into this
-   * <code>StringBuffer</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param str the <code>char[]</code> to insert
-   * @param str_offset the index in <code>str</code> to start inserting from
-   * @param len the number of characters to insert
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>str</code> is <code>null</code>
-   * @throws StringIndexOutOfBoundsException if any index is out of bounds
-   * @since 1.2
-   */
-  public CPStringBuilder insert(int offset, char[] str, int str_offset, int len)
-  {
-    if (offset < 0 || offset > count || len < 0
-        || str_offset < 0 || str_offset > str.length - len)
-      throw new StringIndexOutOfBoundsException();
-    ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
-    System.arraycopy(str, str_offset, value, offset, len);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param obj the <code>Object</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @exception StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(Object)
-   */
-  public CPStringBuilder insert(int offset, Object obj)
-  {
-    return insert(offset, obj == null ? "null" : obj.toString());
-  }
-
-  /**
-   * Insert the <code>String</code> argument into this
-   * <code>StringBuffer</code>. If str is null, the String "null" is used
-   * instead.
-   *
-   * @param offset the place to insert in this buffer
-   * @param str the <code>String</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   */
-  public CPStringBuilder insert(int offset, String str)
-  {
-    if (offset < 0 || offset > count)
-      throw new StringIndexOutOfBoundsException(offset);
-    if (str == null)
-      str = "null";
-    int len = str.length();
-    ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
-    str.getChars(0, len, value, offset);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Insert the <code>CharSequence</code> argument into this
-   * <code>StringBuffer</code>.  If the sequence is null, the String
-   * "null" is used instead.
-   *
-   * @param offset the place to insert in this buffer
-   * @param sequence the <code>CharSequence</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws IndexOutOfBoundsException if offset is out of bounds
-   * @since 1.5
-   */
-  public CPStringBuilder insert(int offset, CharSequence sequence)
-  {
-    if (sequence == null)
-      sequence = "null";
-    return insert(offset, sequence, 0, sequence.length());
-  }
-
-  /**
-   * Insert a subsequence of the <code>CharSequence</code> argument into this
-   * <code>StringBuffer</code>.  If the sequence is null, the String
-   * "null" is used instead.
-   *
-   * @param offset the place to insert in this buffer
-   * @param sequence the <code>CharSequence</code> to insert
-   * @param start the starting index of the subsequence
-   * @param end one past the ending index of the subsequence
-   * @return this <code>StringBuffer</code>
-   * @throws IndexOutOfBoundsException if offset, start,
-   * or end are out of bounds
-   * @since 1.5
-   */
-  public CPStringBuilder insert(int offset, CharSequence sequence, int start, int end)
-  {
-    if (sequence == null)
-      sequence = "null";
-    if (start < 0 || end < 0 || start > end || end > sequence.length())
-      throw new IndexOutOfBoundsException();
-    int len = end - start;
-    ensureCapacity_unsynchronized(count + len);
-    System.arraycopy(value, offset, value, offset + len, count - offset);
-    for (int i = start; i < end; ++i)
-      value[offset++] = sequence.charAt(i);
-    count += len;
-    return this;
-  }
-
-  /**
-   * Insert the <code>char[]</code> argument into this
-   * <code>StringBuffer</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param data the <code>char[]</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws NullPointerException if <code>data</code> is <code>null</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see #insert(int, char[], int, int)
-   */
-  public CPStringBuilder insert(int offset, char[] data)
-  {
-    return insert(offset, data, 0, data.length);
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param bool the <code>boolean</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(boolean)
-   */
-  public CPStringBuilder insert(int offset, boolean bool)
-  {
-    return insert(offset, bool ? "true" : "false");
-  }
-
-  /**
-   * Insert the <code>char</code> argument into this <code>StringBuffer</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param ch the <code>char</code> to insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   */
-  public CPStringBuilder insert(int offset, char ch)
-  {
-    if (offset < 0 || offset > count)
-      throw new StringIndexOutOfBoundsException(offset);
-    ensureCapacity_unsynchronized(count + 1);
-    System.arraycopy(value, offset, value, offset + 1, count - offset);
-    value[offset] = ch;
-    count++;
-    return this;
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param inum the <code>int</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(int)
-   */
-  public CPStringBuilder insert(int offset, int inum)
-  {
-    return insert(offset, String.valueOf(inum));
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param lnum the <code>long</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(long)
-   */
-  public CPStringBuilder insert(int offset, long lnum)
-  {
-    return insert(offset, Long.toString(lnum, 10));
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param fnum the <code>float</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(float)
-   */
-  public CPStringBuilder insert(int offset, float fnum)
-  {
-    return insert(offset, Float.toString(fnum));
-  }
-
-  /**
-   * Insert the <code>String</code> value of the argument into this
-   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
-   * to <code>String</code>.
-   *
-   * @param offset the place to insert in this buffer
-   * @param dnum the <code>double</code> to convert and insert
-   * @return this <code>StringBuffer</code>
-   * @throws StringIndexOutOfBoundsException if offset is out of bounds
-   * @see String#valueOf(double)
-   */
-  public CPStringBuilder insert(int offset, double dnum)
-  {
-    return insert(offset, Double.toString(dnum));
-  }
-
-  /**
-   * Finds the first instance of a substring in this StringBuilder.
-   *
-   * @param str String to find
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @see #indexOf(String, int)
-   */
-  public int indexOf(String str)
-  {
-    return indexOf(str, 0);
-  }
-
-  /**
-   * Finds the first instance of a String in this StringBuffer, starting at
-   * a given index.  If starting index is less than 0, the search starts at
-   * the beginning of this String.  If the starting index is greater than the
-   * length of this String, or the substring is not found, -1 is returned.
-   *
-   * @param str String to find
-   * @param fromIndex index to start the search
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @since 1.4
-   */
-  public int indexOf(String str, int fromIndex)
-  {
-    if (fromIndex < 0)
-      fromIndex = 0;
-    int olength = str.length();
-    int limit = count - olength;
-    String s = VMCPStringBuilder.toString(value, 0, count);
-    for (; fromIndex <= limit; ++fromIndex)
-      if (s.regionMatches(fromIndex, str, 0, olength))
-        return fromIndex;
-    return -1;
-  }
-
-  /**
-   * Finds the last instance of a substring in this StringBuffer.
-   *
-   * @param str String to find
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @see #lastIndexOf(String, int)
-   * @since 1.4
-   */
-  public int lastIndexOf(String str)
-  {
-    return lastIndexOf(str, count - str.length());
-  }
-
-  /**
-   * Finds the last instance of a String in this StringBuffer, starting at a
-   * given index.  If starting index is greater than the maximum valid index,
-   * then the search begins at the end of this String.  If the starting index
-   * is less than zero, or the substring is not found, -1 is returned.
-   *
-   * @param str String to find
-   * @param fromIndex index to start the search
-   * @return location (base 0) of the String, or -1 if not found
-   * @throws NullPointerException if str is null
-   * @since 1.4
-   */
-  public int lastIndexOf(String str, int fromIndex)
-  {
-    fromIndex = Math.min(fromIndex, count - str.length());
-    String s = VMCPStringBuilder.toString(value, 0, count);
-    int olength = str.length();
-    for ( ; fromIndex >= 0; fromIndex--)
-      if (s.regionMatches(fromIndex, str, 0, olength))
-        return fromIndex;
-    return -1;
-  }
-
-  /**
-   * Reverse the characters in this StringBuffer. The same sequence of
-   * characters exists, but in the reverse index ordering.
-   *
-   * @return this <code>StringBuffer</code>
-   */
-  public CPStringBuilder reverse()
-  {
-    // Call ensureCapacity to enforce copy-on-write.
-    ensureCapacity_unsynchronized(count);
-    for (int i = count >> 1, j = count - i; --i >= 0; ++j)
-      {
-        char c = value[i];
-        value[i] = value[j];
-        value[j] = c;
-      }
-    return this;
-  }
-
-  /**
-   * This may reduce the amount of memory used by the StringBuffer,
-   * by resizing the internal array to remove unused space.  However,
-   * this method is not required to resize, so this behavior cannot
-   * be relied upon.
-   * @since 1.5
-   */
-  public void trimToSize()
-  {
-    int wouldSave = value.length - count;
-    // Some random heuristics: if we save less than 20 characters, who
-    // cares.
-    if (wouldSave < 20)
-      return;
-    // If we save more than 200 characters, shrink.
-    // If we save more than 1/4 of the buffer, shrink.
-    if (wouldSave > 200 || wouldSave * 4 > value.length)
-      {
-       char[] newValue = new char[count];
-       System.arraycopy(value, 0, newValue, 0, count);
-       value = newValue;
-      }
-  }
-
-  /**
-   * Return the number of code points between two indices in the
-   * <code>StringBuffer</code>.  An unpaired surrogate counts as a
-   * code point for this purpose.  Characters outside the indicated
-   * range are not examined, even if the range ends in the middle of a
-   * surrogate pair.
-   *
-   * @param start the starting index
-   * @param end one past the ending index
-   * @return the number of code points
-   * @since 1.5
-   */
-  public int codePointCount(int start, int end)
-  {
-    if (start < 0 || end >= count || start > end)
-      throw new StringIndexOutOfBoundsException();
-
-    int count = 0;
-    while (start < end)
-      {
-       char base = value[start];
-       if (base < Character.MIN_HIGH_SURROGATE
-           || base > Character.MAX_HIGH_SURROGATE
-           || start == end
-           || start == count
-           || value[start + 1] < Character.MIN_LOW_SURROGATE
-           || value[start + 1] > Character.MAX_LOW_SURROGATE)
-         {
-           // Nothing.
-         }
-       else
-         {
-           // Surrogate pair.
-           ++start;
-         }
-       ++start;
-       ++count;
-      }
-    return count;
-  }
-
-  /**
-   * Starting at the given index, this counts forward by the indicated
-   * number of code points, and then returns the resulting index.  An
-   * unpaired surrogate counts as a single code point for this
-   * purpose.
-   *
-   * @param start the starting index
-   * @param codePoints the number of code points
-   * @return the resulting index
-   * @since 1.5
-   */
-  public int offsetByCodePoints(int start, int codePoints)
-  {
-    while (codePoints > 0)
-      {
-       char base = value[start];
-       if (base < Character.MIN_HIGH_SURROGATE
-           || base > Character.MAX_HIGH_SURROGATE
-           || start == count
-           || value[start + 1] < Character.MIN_LOW_SURROGATE
-           || value[start + 1] > Character.MAX_LOW_SURROGATE)
-         {
-           // Nothing.
-         }
-       else
-         {
-           // Surrogate pair.
-           ++start;
-         }
-       ++start;
-       --codePoints;
-      }
-    return start;
-  }
-
-  /**
-   * Increase the capacity of this <code>StringBuilder</code>. This will
-   * ensure that an expensive growing operation will not occur until
-   * <code>minimumCapacity</code> is reached. The buffer is grown to the
-   * larger of <code>minimumCapacity</code> and
-   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
-   *
-   * @param minimumCapacity the new capacity
-   * @see #capacity()
-   */
-  protected void ensureCapacity_unsynchronized(int minimumCapacity)
-  {
-    if (minimumCapacity > value.length)
-      {
-        int max = value.length * 2 + 2;
-        minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
-        char[] nb = new char[minimumCapacity];
-        System.arraycopy(value, 0, nb, 0, count);
-        value = nb;
-      }
-  }
-
-  /**
-   * Get the length of the <code>String</code> this <code>StringBuilder</code>
-   * would create. Not to be confused with the <em>capacity</em> of the
-   * <code>StringBuilder</code>.
-   *
-   * @return the length of this <code>StringBuilder</code>
-   * @see #capacity()
-   * @see #setLength(int)
-   */
-  public int length()
-  {
-    return count;
-  }
-
-  /**
-   * Creates a substring of this StringBuilder, starting at a specified index
-   * and ending at one character before a specified index. This is implemented
-   * the same as <code>substring(beginIndex, endIndex)</code>, to satisfy
-   * the CharSequence interface.
-   *
-   * @param beginIndex index to start at (inclusive, base 0)
-   * @param endIndex index to end at (exclusive)
-   * @return new String which is a substring of this StringBuilder
-   * @throws IndexOutOfBoundsException if beginIndex or endIndex is out of
-   *         bounds
-   * @see #substring(int, int)
-   */
-  public CharSequence subSequence(int beginIndex, int endIndex)
-  {
-    return substring(beginIndex, endIndex);
-  }
-
-  /**
-   * Creates a substring of this StringBuilder, starting at a specified index
-   * and ending at one character before a specified index.
-   *
-   * @param beginIndex index to start at (inclusive, base 0)
-   * @param endIndex index to end at (exclusive)
-   * @return new String which is a substring of this StringBuilder
-   * @throws StringIndexOutOfBoundsException if beginIndex or endIndex is out
-   *         of bounds
-   */
-  public String substring(int beginIndex, int endIndex)
-  {
-    if (beginIndex < 0 || endIndex > count || endIndex < beginIndex)
-      throw new StringIndexOutOfBoundsException();
-    int len = endIndex - beginIndex;
-    if (len == 0)
-      return "";
-    return VMCPStringBuilder.toString(value, beginIndex, len);
-  }
-
-  /**
-   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
-   * String is composed of the characters currently in this StringBuilder. Note
-   * that the result is not a copy, so future modifications to this buffer
-   * do affect the String.
-   *
-   * @return the characters in this StringBuilder
-   */
-  public String toString()
-  {
-    return VMCPStringBuilder.toString(value, 0, count);
-  }
-
-}
diff --git a/src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java b/src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java
deleted file mode 100644 (file)
index ca1c39d..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* VMCPStringBuilder.java -- Growable strings without locking or copying
-   Copyright (C) 2008 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.lang;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * This class provides VM support for CPStringBuilder
- * by allowing the package-private constructor
- * of java.lang.String to be invoked.  The default
- * implementation uses reflection.  VMs may replace
- * this class with a more efficient version.
- */
-final class VMCPStringBuilder
-{
-
-  /**
-   * The package-private constructor for String objects without copying.
-   */
-//   private static final Constructor<String> cons;
-
-//   static
-//   {
-//     try
-//       {
-//     cons = String.class.getDeclaredConstructor(char[].class, Integer.TYPE,
-//                                                Integer.TYPE, Boolean.TYPE);
-//     cons.setAccessible(true);
-//       }
-//     catch (NoSuchMethodException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Could not get no-copy String constructor").initCause(e);
-//       }
-//   }
-
-  /**
-   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
-   * String is composed of the characters currently in this StringBuilder. Note
-   * that the result is not a copy, so future modifications to this buffer
-   * do affect the String.
-   *
-   * @param value the buffered characters.
-   * @param startIndex the index at which to start taking characters from the buffer.
-   * @param count the number of characters used in the buffer.
-   * @return the characters in this StringBuilder
-   */
-//   public static String toString(char[] value, int startIndex, int count)
-//   {
-//     try
-//       {
-//     return cons.newInstance(value, startIndex, count, true);
-//       }
-//     catch (InstantiationException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Could not instantiate no-copy String constructor").initCause(e);
-//       }
-//     catch (IllegalAccessException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Could not access no-copy String constructor").initCause(e);
-//       }
-//     catch (InvocationTargetException e)
-//       {
-//     throw (Error) 
-//       new InternalError("Error calling no-copy String constructor").initCause(e);
-//       }
-//   }
-  public static native String toString(char[] value, int startIndex, int count);
-
-}
diff --git a/src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java
deleted file mode 100644 (file)
index d71a06d..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
-   Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.lang.management;
-
-import java.lang.management.MemoryUsage;
-
-/**
- * Provides access to information about the memory
- * management of the current invocation of the virtual
- * machine.  Instances of this bean are obtained by calling
- * {@link ManagementFactory#getMemoryMXBean()}.
- *
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- * @since 1.5
- */
-final class VMMemoryMXBeanImpl
-{
-
-  /**
-   * Returns an instance of {@link java.lang.management.MemoryUsage}
-   * with appropriate initial, used, committed and maximum values
-   * for the heap.  By default, this uses the methods of
-   * {@link java.lang.Runtime} to provide some of the values.
-   *
-   * @return an {@link java.lang.management.MemoryUsage} instance
-   *         for the heap.
-   */
-//   static MemoryUsage getHeapMemoryUsage()
-//   {
-//     Runtime runtime = Runtime.getRuntime();
-//     long totalMem = runtime.totalMemory();
-//     return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
-//                        totalMem, runtime.maxMemory());
-//   }
-  static native MemoryUsage getHeapMemoryUsage();
-
-  /**
-   * Returns an instance of {@link java.lang.management.MemoryUsage}
-   * with appropriate initial, used, committed and maximum values
-   * for non-heap memory.
-   *
-   * @return an {@link java.lang.management.MemoryUsage} instance
-   *         for non-heap memory.
-   */
-  static native MemoryUsage getNonHeapMemoryUsage();
-
-  /**
-   * Returns the number of objects ready to be garbage collected.
-   *
-   * @return the number of finalizable objects.
-   */
-  static native int getObjectPendingFinalizationCount();
-
-  /**
-   * Returns true if the virtual machine will emit additional
-   * information when memory is allocated and deallocated.  The
-   * format of the output is left up to the virtual machine.
-   *
-   * @return true if verbose class loading output is on.
-   */
-  static native boolean isVerbose();
-
-  /**
-   * Turns on or off the emission of additional information
-   * when memory is allocated and deallocated.  The format of the
-   * output is left up to the virtual machine.  This method
-   * may be called by multiple threads concurrently, but there
-   * is only one global setting of verbosity that is affected.
-   *
-   * @param verbose the new setting for verbose class loading
-   *                output.
-   */
-  static native void setVerbose(boolean verbose);
-
-}
diff --git a/src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
deleted file mode 100644 (file)
index 32a8660..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean
-   Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.lang.management;
-
-import gnu.classpath.SystemProperties;
-
-/**
- * Provides access to information about the virtual machine.
- *
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- * @since 1.5
- */
-final class VMRuntimeMXBeanImpl
-{
-
-  /**
-   * Returns the command-line arguments supplied
-   * to the virtual machine, excluding those supplied
-   * to <code>main()</code>.
-   *
-   * @return the command-line arguments.
-   */
-  static native String[] getInputArguments();
-
-  /**
-   * Returns a developer-chosen name for the virtual
-   * machine, which may differ over different running
-   * instances of the same virtual machine binary.
-   * For example, this may include the particular
-   * process identifier used by this instance or
-   * the host name of the machine on which it is
-   * running.  The intention is that this name refers
-   * to the precise entity that the other data supplied
-   * by the bean refers to, rather than the VM in general.
-   *
-   * @return the custom name of the VM.
-   */
-  static String getName()
-  {
-    return SystemProperties.getProperty("java.vm.name") + " " +
-      SystemProperties.getProperty("java.vm.version");
-  }
-
-  /**
-   * The time in milliseconds at which the virtual
-   * machine was started.  This method is only executed
-   * once (for efficency), as the value is not expected
-   * to change.
-   *
-   * @return the VM start time.
-   */
-  static native long getStartTime();
-
-}
diff --git a/src/classes/gnu/java/lang/VMClassLoader.java b/src/classes/gnu/java/lang/VMClassLoader.java
deleted file mode 100644 (file)
index f09838b..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-/* VMClassLoader.java -- Reference implementation of native interface
-   required by ClassLoader
-   Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang;
-
-import gnu.classpath.Configuration;
-import gnu.classpath.SystemProperties;
-import gnu.java.lang.InstrumentationImpl;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.instrument.Instrumentation;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.ProtectionDomain;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.zip.ZipFile;
-import java.util.Collections;
-import java.lang.Boolean;
-
-/**
- * java.lang.VMClassLoader is a package-private helper for VMs to implement
- * on behalf of java.lang.ClassLoader.
- *
- * @author John Keiser
- * @author Mark Wielaard (mark@klomp.org)
- * @author Eric Blake (ebb9@email.byu.edu)
- */
-final class VMClassLoader
-{
-
-
-  /** packages loaded by the bootstrap class loader */
-  static final HashMap definedPackages = new HashMap();
-
-  /** jars from property java.boot.class.path */
-  static final HashMap bootjars = new HashMap();
-  
-
-  /**
-   * Converts the array string of native package names to
-   * Packages. The packages are then put into the
-   * definedPackages hashMap
-   */
-  static
-  {
-    String[] packages = getBootPackages();
-    
-    if( packages != null)
-      {
-        String specName = 
-              SystemProperties.getProperty("java.specification.name");
-        String vendor =
-              SystemProperties.getProperty("java.specification.vendor");
-        String version =
-              SystemProperties.getProperty("java.specification.version");
-        
-        Package p;
-              
-        for(int i = 0; i < packages.length; i++)
-          {
-            p = new Package(packages[i],
-                  specName,
-                  vendor,
-                  version,
-                  "GNU Classpath",
-                  "GNU",
-                  Configuration.CLASSPATH_VERSION,
-                  null,
-                  null);
-
-            definedPackages.put(packages[i], p);
-          }
-      }
-  }
-
-  
-  /**
-   * Helper to define a class using a string of bytes. This assumes that
-   * the security checks have already been performed, if necessary.
-   *
-   * Implementations of this method are advised to consider the
-   * situation where user code modifies the byte array after it has
-   * been passed to defineClass.  This can be handled by making a
-   * private copy of the array, or arranging to only read any given
-   * byte a single time.
-   *
-   * @param name the name to give the class, or null if unknown
-   * @param data the data representing the classfile, in classfile format
-   * @param offset the offset into the data where the classfile starts
-   * @param len the length of the classfile data in the array
-   * @param pd the protection domain
-   * @return the class that was defined
-   * @throws ClassFormatError if data is not in proper classfile format
-   */
-  static final native Class defineClass(ClassLoader cl, String name,
-                                 byte[] data, int offset, int len,
-                                 ProtectionDomain pd)
-    throws ClassFormatError;
-
-  /**
-   * Helper to resolve all references to other classes from this class.
-   *
-   * @param c the class to resolve
-   */
-  static final native void resolveClass(Class c);
-
-  /**
-   * Helper to load a class from the bootstrap class loader.
-   *
-   * @param name the class name to load
-   * @param resolve whether to resolve it
-   * @return the class, loaded by the bootstrap classloader or null
-   * if the class wasn't found. Returning null is equivalent to throwing
-   * a ClassNotFoundException (but a possible performance optimization).
-   */
-  static final native Class loadClass(String name, boolean resolve)
-    throws ClassNotFoundException;
-
-  /**
-   * Helper to load a resource from the bootstrap class loader.
-   *
-   * @param name the resource to find
-   * @return the URL to the resource
-   */
-  static URL getResource(String name)
-  {
-    Enumeration e = getResources(name);
-    if (e.hasMoreElements())
-      return (URL)e.nextElement();
-    return null;
-  }
-  /**
-   * Helper to get a list of resources from the bootstrap class loader.
-   *
-   * @param name the resource to find
-   * @return an enumeration of resources
-   */
-  static Enumeration getResources(String name)
-  {
-//     StringTokenizer st = new StringTokenizer(
-//       SystemProperties.getProperty("java.boot.class.path", "."),
-//       File.pathSeparator);
-//     Vector v = new Vector();
-//     while (st.hasMoreTokens())
-//       {
-//     File file = new File(st.nextToken());
-//     if (file.isDirectory())
-//       {
-//         try
-//           {
-//                 File f = new File(file, name);
-//                 if (!f.exists()) continue;
-//                 v.add(new URL("file://" + f.getAbsolutePath()));
-//           }
-//         catch (MalformedURLException e)
-//           {
-//             throw new Error(e);
-//           }
-//       }
-//     else if (file.isFile())
-//       {
-//         ZipFile zip;
-//             synchronized(bootjars)
-//               {
-//                 zip = (ZipFile) bootjars.get(file.getName());
-//               }
-//             if(zip == null)
-//               {
-//                 try
-//               {
-//                     zip = new ZipFile(file);
-//                     synchronized(bootjars)
-//                       {
-//                         bootjars.put(file.getName(), zip);
-//                       }
-//               }
-//             catch (IOException e)
-//               {
-//                 continue;
-//               }
-//               }
-//         String zname = name.startsWith("/") ? name.substring(1) : name;
-//         if (zip.getEntry(zname) == null)
-//           continue;
-//         try
-//           {
-//             v.add(new URL("jar:file://"
-//               + file.getAbsolutePath() + "!/" + zname));
-//           }
-//         catch (MalformedURLException e)
-//           {
-//             throw new Error(e);
-//           }
-//       }
-//       }
-//     return v.elements();
-//   }
-    Vector urls = nativeGetResources(name);
-    Vector v = new Vector();
-    for (Enumeration en = urls.elements(); en.hasMoreElements();)
-      {
-       try
-         {
-           v.add(new URL((String) en.nextElement()));
-         }
-       catch (MalformedURLException e)
-         {
-           throw new Error(e);
-         }
-      }
-    return v.elements();
-  }
-
-  private native static final Vector nativeGetResources(String name);
-
-
-  /**
-   * Returns a String[] of native package names. The default
-   * implementation tries to load a list of package from
-   * the META-INF/INDEX.LIST file in the boot jar file.
-   * If not found or if any exception is raised, it returns
-   * an empty array. You may decide this needs native help.
-   */
-  private static String[] getBootPackages()
-  {
-    try
-      {
-        Enumeration indexListEnumeration = getResources("META-INF/INDEX.LIST");
-        Set packageSet = new HashSet();
-
-        while (indexListEnumeration.hasMoreElements())
-          {
-            try
-              {
-                String line;
-                int lineToSkip = 3;
-                BufferedReader reader = new BufferedReader(
-                                                           new InputStreamReader(
-                                                                                 ((URL) indexListEnumeration.nextElement()).openStream()));
-                while ((line = reader.readLine()) != null)
-                  {
-                    if (lineToSkip == 0)
-                      {
-                        if (line.length() == 0)
-                          lineToSkip = 1;
-                        else
-                          packageSet.add(line.replace('/', '.'));
-                      }
-                    else
-                      lineToSkip--;
-                  }
-                reader.close();
-              }
-            catch (IOException e)
-              {
-                // Empty catch block on purpose
-              }
-          }
-        return (String[]) packageSet.toArray(new String[packageSet.size()]);
-      }
-    catch (Exception e)
-      {
-        return new String[0];
-      }
-  }
-
-
-  /**
-   * Helper to get a package from the bootstrap class loader.
-   *
-   * @param name the name to find
-   * @return the named package, if it exists
-   */
-  static Package getPackage(String name)
-  {
-    return (Package)definedPackages.get(name);
-  }
-
-
-  
-  /**
-   * Helper to get all packages from the bootstrap class loader.  
-   *
-   * @return all named packages, if any exist
-   */
-  static Package[] getPackages()
-  {
-    Package[] packages = new Package[definedPackages.size()];
-    definedPackages.values().toArray(packages);
-    return packages;
-  }
-
-  /**
-   * Helper for java.lang.Integer, Byte, etc to get the TYPE class
-   * at initialization time. The type code is one of the chars that
-   * represents the primitive type as in JNI.
-   *
-   * <ul>
-   * <li>'Z' - boolean</li>
-   * <li>'B' - byte</li>
-   * <li>'C' - char</li>
-   * <li>'D' - double</li>
-   * <li>'F' - float</li>
-   * <li>'I' - int</li>
-   * <li>'J' - long</li>
-   * <li>'S' - short</li>
-   * <li>'V' - void</li>
-   * </ul>
-   *
-   * @param type the primitive type
-   * @return a "bogus" class representing the primitive type
-   */
-  static final native Class getPrimitiveClass(char type);
-
-  /**
-   * The system default for assertion status. This is used for all system
-   * classes (those with a null ClassLoader), as well as the initial value for
-   * every ClassLoader's default assertion status.
-   *
-   * @return the system-wide default assertion status
-   */
-  static native final boolean defaultAssertionStatus();
-
-  static native final boolean defaultUserAssertionStatus();
-
-
-  static final Map packageAssertionMap = 
-    Collections.unmodifiableMap(packageAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
-  
-  static native final Map packageAssertionStatus0(Boolean jtrue, Boolean jfalse);
-  /**
-   * The system default for package assertion status. This is used for all
-   * ClassLoader's packageAssertionStatus defaults. It must be a map of
-   * package names to Boolean.TRUE or Boolean.FALSE, with the unnamed package
-   * represented as a null key.
-   *
-   * @return a (read-only) map for the default packageAssertionStatus
-   */
-   
-  static final Map packageAssertionStatus() {
-    return packageAssertionMap;
-  }
-
-  static final Map classAssertionMap = 
-    Collections.unmodifiableMap(classAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
-  
-  static native final Map classAssertionStatus0(Boolean jtrue, Boolean jfalse);
-
-  /**
-   * The system default for class assertion status. This is used for all
-   * ClassLoader's classAssertionStatus defaults. It must be a map of
-   * class names to Boolean.TRUE or Boolean.FALSE
-   *
-   * @return a (read-only) map for the default classAssertionStatus
-   */
-  static final Map classAssertionStatus() {
-    return classAssertionMap;
-  }
-  
-  static ClassLoader getSystemClassLoader()
-  {
-    return ClassLoader.defaultGetSystemClassLoader();
-  }
-
-  /**
-   * Find the class if this class loader previously defined this class
-   * or if this class loader has been recorded as the initiating class loader
-   * for this class.
-   */
-  static native Class findLoadedClass(ClassLoader cl, String name);
-
-  /**
-   * The Instrumentation object created by the vm when agents are defined.
-   */
-  static final Instrumentation instrumenter = null;
-
-  /**
-   * Call the transformers of the possible Instrumentation object. This
-   * implementation assumes the instrumenter is a
-   * <code>InstrumentationImpl</code> object. VM implementors would
-   * have to redefine this method if they provide their own implementation
-   * of the <code>Instrumentation</code> interface.
-   *
-   * @param loader the initiating loader
-   * @param name the name of the class
-   * @param data the data representing the classfile, in classfile format
-   * @param offset the offset into the data where the classfile starts
-   * @param len the length of the classfile data in the array
-   * @param pd the protection domain
-   * @return the new data representing the classfile
-   */
-  static final Class defineClassWithTransformers(ClassLoader loader,
-      String name, byte[] data, int offset, int len, ProtectionDomain pd)
-  {
-    
-    if (instrumenter != null)
-      {
-        byte[] modifiedData = new byte[len];
-        System.arraycopy(data, offset, modifiedData, 0, len);
-        modifiedData =
-          ((InstrumentationImpl)instrumenter).callTransformers(loader, name,
-            null, pd, modifiedData);
-        
-        return defineClass(loader, name, modifiedData, 0, modifiedData.length,
-            pd);
-      }
-    else
-      {
-        return defineClass(loader, name, data, offset, len, pd);
-      }
-  }
-}
diff --git a/src/classes/gnu/java/lang/VMString.java b/src/classes/gnu/java/lang/VMString.java
deleted file mode 100644 (file)
index 57e4423..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* VMString.java -- VM Specific String methods
-   Copyright (C) 2003 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-/*
- * This class is a reference version, mainly for compiling a class library
- * jar.  It is likely that VM implementers replace this with their own
- * version that can communicate effectively with the VM.
- */
-
-/**
- * Code relocated from java.lang.String by 
- * @author Dave Grove <groved@us.ibm.com>
- */
-final class VMString
-{
-
-  /**
-   * Holds the references for each intern()'d String. If all references to
-   * the string disappear, and the VM properly supports weak references,
-   * the String will be GC'd.
-   */
-//    private static final WeakHashMap internTable = new WeakHashMap();
-
-  /**
-   * Fetches this String from the intern hashtable. If two Strings are
-   * considered equal, by the equals() method, then intern() will return the
-   * same String instance. ie. if (s1.equals(s2)) then
-   * (s1.intern() == s2.intern()). All string literals and string-valued
-   * constant expressions are already interned.
-   *
-   * @param str the String to intern
-   * @return the interned String
-   */
-//    static String intern(String str)
-//    {
-//      synchronized (internTable)
-//        {
-//          WeakReference ref = (WeakReference) internTable.get(str);
-//          if (ref != null)
-//            {
-//              String s = (String) ref.get();
-//              // If s is null, then no strong references exist to the String;
-//              // the weak hash map will soon delete the key.
-//              if (s != null)
-//                return s;
-//            }
-//          internTable.put(str, new WeakReference(str));
-//        }
-//      return str;
-//    }
-
-  /**
-   * this one is native in CACAO
-   */
-  static native String intern(String str);
-
-} // class VMString
diff --git a/src/classes/gnu/java/lang/VMThread.java b/src/classes/gnu/java/lang/VMThread.java
deleted file mode 100644 (file)
index a511f3c..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/* VMThread -- VM interface for Thread of executable code
-   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-/**
- * VM interface for Thread of executable code. Holds VM dependent state.
- * It is deliberately package local and final and should only be accessed
- * by the Thread class.
- * <p>
- * This is the GNU Classpath reference implementation, it should be adapted
- * for a specific VM.
- * <p>
- * The following methods must be implemented:
- * <ul>
- * <li>native void start(long stacksize);
- * <li>native void interrupt();
- * <li>native boolean isInterrupted();
- * <li>native void suspend();
- * <li>native void resume();
- * <li>native void nativeSetPriority(int priority);
- * <li>native void nativeStop(Throwable t);
- * <li>native static Thread currentThread();
- * <li>static native void yield();
- * <li>static native boolean interrupted();
- * </ul>
- * All other methods may be implemented to make Thread handling more efficient
- * or to implement some optional (and sometimes deprecated) behaviour. Default
- * implementations are provided but it is highly recommended to optimize them
- * for a specific VM.
- * 
- * @author Jeroen Frijters (jeroen@frijters.net)
- * @author Dalibor Topic (robilad@kaffe.org)
- */
-final class VMThread
-{
-    /**
-     * The Thread object that this VM state belongs to.
-     * Used in currentThread() and start().
-     * Note: when this thread dies, this reference is *not* cleared
-     */
-    volatile Thread thread;
-
-    /**
-     * Flag that is set when the thread runs, used by stop() to protect against
-     * stop's getting lost.
-     */
-    private volatile boolean running;
-
-    /**
-     * VM private data.
-     */
-    private transient Object vmdata;
-
-    /**
-     * Private constructor, create VMThreads with the static create method.
-     *
-     * @param thread The Thread object that was just created.
-     */
-    private VMThread(Thread thread)
-    {
-       this.thread = thread;
-    }
-
-    /**
-     * This method is the initial Java code that gets executed when a native
-     * thread starts. It's job is to coordinate with the rest of the VMThread
-     * logic and to start executing user code and afterwards handle clean up.
-     */
-    private void run()
-    {
-       try
-       {
-           try
-           {
-               running = true;
-               synchronized(thread)
-               {
-                   Throwable t = thread.stillborn;
-                   if(t != null)
-                   {
-                       thread.stillborn = null;
-                       throw t;
-                   }
-               }
-               thread.run();
-           }
-           catch(Throwable t)
-           {
-               try
-               {
-                 Thread.UncaughtExceptionHandler handler;
-                 handler = thread.getUncaughtExceptionHandler();
-                 handler.uncaughtException(thread, t);
-               }
-               catch(Throwable ignore)
-               {
-               }
-           }
-       }
-       finally
-       {
-           // Setting runnable to false is partial protection against stop
-           // being called while we're cleaning up. To be safe all code in
-           // VMThread be unstoppable.
-           running = false;
-           thread.die();
-           synchronized(this)
-           {
-               // release the threads waiting to join us
-               notifyAll();
-           }
-       }
-    }
-
-    /**
-     * Creates a native Thread. This is called from the start method of Thread.
-     * The Thread is started.
-     *
-     * @param thread The newly created Thread object
-     * @param stacksize Indicates the requested stacksize. Normally zero,
-     * non-zero values indicate requested stack size in bytes but it is up
-     * to the specific VM implementation to interpret them and may be ignored.
-     */
-    static void create(Thread thread, long stacksize)
-    {
-       VMThread vmThread = new VMThread(thread);
-       thread.vmThread = vmThread;
-       vmThread.start(stacksize);
-    }
-
-    /**
-     * Gets the name of the thread. Usually this is the name field of the
-     * associated Thread object, but some implementation might choose to
-     * return the name of the underlying platform thread.
-     */
-    String getName()
-    {
-       return thread.name;
-    }
-
-    /**
-     * Set the name of the thread. Usually this sets the name field of the
-     * associated Thread object, but some implementations might choose to
-     * set the name of the underlying platform thread.
-     * @param name The new name
-     */
-    void setName(String name)
-    {
-       thread.name = name;
-    }
-
-    /**
-     * Set the thread priority field in the associated Thread object and
-     * calls the native method to set the priority of the underlying
-     * platform thread.
-     * @param priority The new priority
-     */
-    void setPriority(int priority)
-    {
-       thread.priority = priority;
-       nativeSetPriority(priority);
-    }
-
-    /**
-     * Returns the priority. Usually this is the priority field from the
-     * associated Thread object, but some implementation might choose to
-     * return the priority of the underlying platform thread.
-     * @return this Thread's priority
-     */
-    int getPriority()
-    {
-        return thread.priority;
-    }
-
-    /**
-     * Returns true if the thread is a daemon thread. Usually this is the
-     * daemon field from the associated Thread object, but some
-     * implementation might choose to return the daemon state of the underlying
-     * platform thread.
-     * @return whether this is a daemon Thread or not
-     */
-    boolean isDaemon()
-    {
-        return thread.daemon;
-    }
-
-    /**
-     * Returns the number of stack frames in this Thread.
-     * Will only be called when when a previous call to suspend() returned true.
-     *
-     * @deprecated unsafe operation
-     */
-    native int countStackFrames();
-
-    /**
-     * Wait the specified amount of time for the Thread in question to die.
-     *
-     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
-     * not offer that fine a grain of timing resolution. Besides, there is
-     * no guarantee that this thread can start up immediately when time expires,
-     * because some other thread may be active.  So don't expect real-time
-     * performance.
-     *
-     * @param ms the number of milliseconds to wait, or 0 for forever
-     * @param ns the number of extra nanoseconds to sleep (0-999999)
-     * @throws InterruptedException if the Thread is interrupted; it's
-     *         <i>interrupted status</i> will be cleared
-     */
-    synchronized void join(long ms, int ns) throws InterruptedException
-    {
-       // Round up
-       ms += (ns != 0) ? 1 : 0;
-
-       // Compute end time, but don't overflow
-       long now = System.currentTimeMillis();
-       long end = now + ms;
-       if (end < now)
-           end = Long.MAX_VALUE;
-
-       // A VM is allowed to return from wait() without notify() having been
-       // called, so we loop to handle possible spurious wakeups.
-       while(thread.vmThread != null)
-       {
-           // We use the VMThread object to wait on, because this is a private
-           // object, so client code cannot call notify on us.
-           wait(ms);
-           if(ms != 0)
-           {
-               now = System.currentTimeMillis();
-               ms = end - now;
-               if(ms <= 0)
-               {
-                   break;
-               }
-           }
-       }
-    }
-
-    /**
-     * Cause this Thread to stop abnormally and throw the specified exception.
-     * If you stop a Thread that has not yet started, the stop is ignored
-     * (contrary to what the JDK documentation says).
-     * <b>WARNING</b>This bypasses Java security, and can throw a checked
-     * exception which the call stack is unprepared to handle. Do not abuse 
-     * this power.
-     *
-     * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
-     * leave data in bad states.
-     *
-     * <p><b>NOTE</b> stop() should take care not to stop a thread if it is
-     * executing code in this class.
-     *
-     * @param t the Throwable to throw when the Thread dies
-     * @deprecated unsafe operation, try not to use
-     */
-    void stop(Throwable t)
-    {
-       // Note: we assume that we own the lock on thread
-       // (i.e. that Thread.stop() is synchronized)
-       if(running)
-           nativeStop(t);
-       else
-           thread.stillborn = t;
-    }
-
-    /**
-     * Create a native thread on the underlying platform and start it executing
-     * on the run method of this object.
-     * @param stacksize the requested size of the native thread stack
-     */
-    native void start(long stacksize);
-
-    /**
-     * Interrupt this thread.
-     */
-    native void interrupt();
-
-    /**
-     * Determine whether this Thread has been interrupted, but leave
-     * the <i>interrupted status</i> alone in the process.
-     *
-     * @return whether the Thread has been interrupted
-     */
-    native boolean isInterrupted();
-
-    /**
-     * Suspend this Thread.  It will not come back, ever, unless it is resumed.
-     */
-    native void suspend();
-
-    /**
-     * Resume this Thread.  If the thread is not suspended, this method does
-     * nothing.
-     */
-    native void resume();
-
-    /**
-     * Set the priority of the underlying platform thread.
-     *
-     * @param priority the new priority
-     */
-    native void nativeSetPriority(int priority);
-
-    /**
-     * Asynchronously throw the specified throwable in this Thread.
-     *
-     * @param t the exception to throw
-     */
-    native void nativeStop(Throwable t);
-
-    /**
-     * Return the Thread object associated with the currently executing
-     * thread.
-     *
-     * @return the currently executing Thread
-     */
-    static native Thread currentThread();
-
-    /**
-     * Yield to another thread. The Thread will not lose any locks it holds
-     * during this time. There are no guarantees which thread will be
-     * next to run, and it could even be this one, but most VMs will choose
-     * the highest priority thread that has been waiting longest.
-     */
-    static native void yield();
-
-    /**
-     * Suspend the current Thread's execution for the specified amount of
-     * time. The Thread will not lose any locks it has during this time. There
-     * are no guarantees which thread will be next to run, but most VMs will
-     * choose the highest priority thread that has been waiting longest.
-     *
-     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
-     * not offer that fine a grain of timing resolution. Besides, there is
-     * no guarantee that this thread can start up immediately when time expires,
-     * because some other thread may be active.  So don't expect real-time
-     * performance.
-     *
-     * @param ms the number of milliseconds to sleep.
-     * @param ns the number of extra nanoseconds to sleep (0-999999)
-     * @throws InterruptedException if the Thread is (or was) interrupted;
-     *         it's <i>interrupted status</i> will be cleared
-     */
-    static void sleep(long ms, int ns) throws InterruptedException
-    {
-      // Note: JDK treats a zero length sleep is like Thread.yield(),
-      // without checking the interrupted status of the thread.
-      // It's unclear if this is a bug in the implementation or the spec.
-      // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
-      if (ms == 0 && ns == 0)
-       {
-         if (Thread.interrupted())
-           throw new InterruptedException();
-         return;
-       }
-
-      // Compute end time, but don't overflow
-      long now = System.currentTimeMillis();
-      long end = now + ms;
-      if (end < now)
-         end = Long.MAX_VALUE;
-
-      // A VM is allowed to return from wait() without notify() having been
-      // called, so we loop to handle possible spurious wakeups.
-      VMThread vt = Thread.currentThread().vmThread;
-      synchronized (vt)
-       {
-         while (true)
-           {
-             vt.wait(ms, ns);
-             now = System.currentTimeMillis();
-             if (now >= end)
-               break;
-             ms = end - now;
-             ns = 0;
-           }
-       }
-    }
-
-    /**
-     * Determine whether the current Thread has been interrupted, and clear
-     * the <i>interrupted status</i> in the process.
-     *
-     * @return whether the current Thread has been interrupted
-     */
-    static native boolean interrupted();
-
-    /**
-     * Checks whether the current thread holds the monitor on a given object.
-     * This allows you to do <code>assert Thread.holdsLock(obj)</code>.
-     *
-     * @param obj the object to check
-     * @return true if the current thread is currently synchronized on obj
-     * @throws NullPointerException if obj is null
-     */
-//     static boolean holdsLock(Object obj) 
-//     {
-//       /* Use obj.notify to check if the current thread holds
-//        * the monitor of the object.
-//        * If it doesn't, notify will throw an exception.
-//        */
-//       try 
-//     {
-//       obj.notify();
-//       // okay, current thread holds lock
-//       return true;
-//     }
-//       catch (IllegalMonitorStateException e)
-//     {
-//       // it doesn't hold the lock
-//       return false;
-//     }
-//     }
-    static native boolean holdsLock(Object obj);
-
-  /**
-   * Returns the current state of the thread.
-   * The value must be one of "BLOCKED", "NEW",
-   * "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
-   * "WAITING".
-   *
-   * @return a string corresponding to one of the 
-   *         thread enumeration states specified above.
-   */
-  native String getState();
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Constructor.java b/src/classes/gnu/java/lang/reflect/Constructor.java
deleted file mode 100644 (file)
index 55b82e8..0000000
+++ /dev/null
@@ -1,449 +0,0 @@
-/* java.lang.reflect.Constructor - reflection of Java constructors
-   Copyright (C) 1998, 2001, 2004, 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang.reflect;
-
-import gnu.java.lang.ClassHelper;
-import gnu.java.lang.CPStringBuilder;
-
-import gnu.java.lang.reflect.MethodSignatureParser;
-
-import java.lang.annotation.Annotation;
-
-/**
- * The Constructor class represents a constructor of a class. It also allows
- * dynamic creation of an object, via reflection. Invocation on Constructor
- * objects knows how to do widening conversions, but throws
- * {@link IllegalArgumentException} if a narrowing conversion would be
- * necessary. You can query for information on this Constructor regardless
- * of location, but construction access may be limited by Java language
- * access controls. If you can't do it in the compiler, you can't normally
- * do it here either.<p>
- *
- * <B>Note:</B> This class returns and accepts types as Classes, even
- * primitive types; there are Class types defined that represent each
- * different primitive type.  They are <code>java.lang.Boolean.TYPE,
- * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
- * byte.class</code>, etc.  These are not to be confused with the
- * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
- * real classes.<p>
- *
- * Also note that this is not a serializable class.  It is entirely feasible
- * to make it serializable using the Externalizable interface, but this is
- * on Sun, not me.
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @see Member
- * @see Class
- * @see java.lang.Class#getConstructor(Class[])
- * @see java.lang.Class#getDeclaredConstructor(Class[])
- * @see java.lang.Class#getConstructors()
- * @see java.lang.Class#getDeclaredConstructors()
- * @since 1.1
- * @status updated to 1.4
- */
-public final class Constructor<T>
-  extends AccessibleObject
-  implements GenericDeclaration, Member
-{  
-  private static final int CONSTRUCTOR_MODIFIERS
-    = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
-
-  private MethodSignatureParser p;
-
-  VMConstructor cons;
-
-  /**
-   * This class is uninstantiable outside this package.
-   */
-  Constructor(VMConstructor cons)
-  {
-    this.cons = cons;
-    cons.cons = this;
-  }
-
-  private Constructor()
-  {
-  }
-
-  /**
-   * Gets the class that declared this constructor.
-   * @return the class that declared this member
-   */
-  @SuppressWarnings("unchecked")
-  public Class<T> getDeclaringClass()
-  {
-    return (Class<T>) cons.getDeclaringClass();
-  }
-
-  /**
-   * Gets the name of this constructor (the non-qualified name of the class
-   * it was declared in).
-   * @return the name of this constructor
-   */
-  public String getName()
-  {
-    return cons.getDeclaringClass().getName();
-  }
-
-  /**
-   * Gets the modifiers this constructor uses.  Use the <code>Modifier</code>
-   * class to interpret the values. A constructor can only have a subset of the
-   * following modifiers: public, private, protected.
-   *
-   * @return an integer representing the modifiers to this Member
-   * @see Modifier
-   */
-  public int getModifiers()
-  {
-    return cons.getModifiersInternal() & CONSTRUCTOR_MODIFIERS;
-  }
-
-  /**
-   * Return true if this constructor is synthetic, false otherwise.
-   * A synthetic member is one which is created by the compiler,
-   * and which does not appear in the user's source code.
-   * @since 1.5
-   */
-  public boolean isSynthetic()
-  {
-    return (cons.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
-  }
-
-  /**
-   * Return true if this is a varargs constructor, that is if
-   * the constructor takes a variable number of arguments.
-   * @since 1.5
-   */
-  public boolean isVarArgs()
-  {
-    return (cons.getModifiersInternal() & Modifier.VARARGS) != 0;
-  }
-
-  /**
-   * Get the parameter list for this constructor, in declaration order. If the
-   * constructor takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the constructor's parameters
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getParameterTypes()
-  {
-    return (Class<?>[]) cons.getParameterTypes();
-  }
-
-  /**
-   * Get the exception types this constructor says it throws, in no particular
-   * order. If the constructor has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the constructor's throws clause
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getExceptionTypes()
-  {
-    return (Class<?>[]) cons.getExceptionTypes();
-  }
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Constructors are semantically equivalent if they have the same
-   * declaring class and the same parameter list.  This ignores different
-   * exception clauses, but since you can't create a Method except through the
-   * VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not.
-   */
-  public boolean equals(Object o)
-  {
-    return cons.equals(o);
-  }
-
-  /**
-   * Get the hash code for the Constructor. The Constructor hash code is the
-   * hash code of the declaring class's name.
-   *
-   * @return the hash code for the object
-   */
-  public int hashCode()
-  {
-    return getName().hashCode();
-  }
-
-  /**
-   * Get a String representation of the Constructor. A Constructor's String
-   * representation is "&lt;modifier&gt; &lt;classname&gt;(&lt;paramtypes&gt;)
-   * throws &lt;exceptions&gt;", where everything after ')' is omitted if
-   * there are no exceptions.<br> Example:
-   * <code>public java.io.FileInputStream(java.lang.Runnable)
-   * throws java.io.FileNotFoundException</code>
-   *
-   * @return the String representation of the Constructor
-   */
-  public String toString()
-  {
-    // 128 is a reasonable buffer initial size for constructor
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(getDeclaringClass().getName()).append('(');
-    Class[] c = getParameterTypes();
-    if (c.length > 0)
-      {
-        sb.append(ClassHelper.getUserName(c[0]));
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(ClassHelper.getUserName(c[i]));
-      }
-    sb.append(')');
-    c = getExceptionTypes();
-    if (c.length > 0)
-      {
-        sb.append(" throws ").append(c[0].getName());
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(c[i].getName());
-      }
-    return sb.toString();
-  }
-
-  static <X extends GenericDeclaration>
-  void addTypeParameters(CPStringBuilder sb, TypeVariable<X>[] typeArgs)
-  {
-    if (typeArgs.length == 0)
-      return;
-    sb.append('<');
-    for (int i = 0; i < typeArgs.length; ++i)
-      {
-        if (i > 0)
-          sb.append(',');
-        sb.append(typeArgs[i]);
-      }
-    sb.append("> ");
-  }
-
-  public String toGenericString()
-  {
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    addTypeParameters(sb, getTypeParameters());
-    sb.append(getDeclaringClass().getName()).append('(');
-    Type[] types = getGenericParameterTypes();
-    if (types.length > 0)
-      {
-        sb.append(types[0]);
-        for (int i = 1; i < types.length; ++i)
-          sb.append(',').append(types[i]);
-      }
-    sb.append(')');
-    types = getGenericExceptionTypes();
-    if (types.length > 0)
-      {
-        sb.append(" throws ").append(types[0]);
-        for (int i = 1; i < types.length; i++)
-          sb.append(',').append(types[i]);
-      }
-    return sb.toString();
-  }
-
-  /**
-   * Create a new instance by invoking the constructor. Arguments are
-   * automatically unwrapped and widened, if needed.<p>
-   *
-   * If this class is abstract, you will get an
-   * <code>InstantiationException</code>. If the constructor takes 0
-   * arguments, you may use null or a 0-length array for <code>args</code>.<p>
-   *
-   * If this Constructor enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not create this object in similar compiled code. If the class
-   * is uninitialized, you trigger class initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Then, the constructor is invoked. If it completes normally, the return
-   * value will be the new object. If it completes abruptly, the exception is
-   * wrapped in an <code>InvocationTargetException</code>.
-   *
-   * @param args the arguments to the constructor
-   * @return the newly created object
-   * @throws IllegalAccessException if the constructor could not normally be
-   *         called by the Java code (i.e. it is not public)
-   * @throws IllegalArgumentException if the number of arguments is incorrect;
-   *         or if the arguments types are wrong even with a widening
-   *         conversion
-   * @throws InstantiationException if the class is abstract
-   * @throws InvocationTargetException if the constructor throws an exception
-   * @throws ExceptionInInitializerError if construction triggered class
-   *         initialization, which then failed
-   */
-  @SuppressWarnings("unchecked")
-  public T newInstance(Object... args)
-    throws InstantiationException, IllegalAccessException,
-           InvocationTargetException
-  {
-    return (T) cons.construct(args);
-  }
-
-  /**
-   * Returns an array of <code>TypeVariable</code> objects that represents
-   * the type variables declared by this constructor, in declaration order.
-   * An array of size zero is returned if this constructor has no type
-   * variables.
-   *
-   * @return the type variables associated with this constructor.
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public TypeVariable<Constructor<T>>[] getTypeParameters()
-  {
-    if (p == null)
-      {
-       String sig = cons.getSignature();
-       if (sig == null)
-         return new TypeVariable[0];
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getTypeParameters();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the exception types declared by this constructor, in declaration order.
-   * An array of size zero is returned if this constructor declares no
-   * exceptions.
-   *
-   * @return the exception types declared by this constructor. 
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericExceptionTypes()
-  {
-    if (p == null)
-      {
-       String sig = cons.getSignature();
-       if (sig == null)
-         return getExceptionTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericExceptionTypes();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the parameter list for this constructor, in declaration order.
-   * An array of size zero is returned if this constructor takes no
-   * parameters.
-   *
-   * @return a list of the types of the constructor's parameters
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericParameterTypes()
-  {
-    if (p == null)
-      {
-       String sig = cons.getSignature();
-       if (sig == null)
-         return getParameterTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericParameterTypes();
-  }
-
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the constructor's parameters.  The outer array is aligned against
-   * the parameters of the constructors and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this constructor.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  public Annotation[][] getParameterAnnotations()
-  {
-    return cons.getParameterAnnotations();
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-  @SuppressWarnings("unchecked")
-  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
-  {
-    return (T) cons.getAnnotation(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-  public Annotation[] getDeclaredAnnotations()
-  {
-    return cons.getDeclaredAnnotations();
-  }
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Field.java b/src/classes/gnu/java/lang/reflect/Field.java
deleted file mode 100644 (file)
index 4c2c183..0000000
+++ /dev/null
@@ -1,735 +0,0 @@
-/* java.lang.reflect.Field - reflection of Java fields
-   Copyright (C) 1998, 2001, 2005, 2008 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang.reflect;
-
-import gnu.java.lang.ClassHelper;
-import gnu.java.lang.CPStringBuilder;
-
-import gnu.java.lang.reflect.FieldSignatureParser;
-
-import java.lang.annotation.Annotation;
-
-/**
- * The Field class represents a member variable of a class. It also allows
- * dynamic access to a member, via reflection. This works for both
- * static and instance fields. Operations on Field objects know how to
- * do widening conversions, but throw {@link IllegalArgumentException} if
- * a narrowing conversion would be necessary. You can query for information
- * on this Field regardless of location, but get and set access may be limited
- * by Java language access controls. If you can't do it in the compiler, you
- * can't normally do it here either.<p>
- *
- * <B>Note:</B> This class returns and accepts types as Classes, even
- * primitive types; there are Class types defined that represent each
- * different primitive type.  They are <code>java.lang.Boolean.TYPE,
- * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
- * byte.class</code>, etc.  These are not to be confused with the
- * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
- * real classes.<p>
- *
- * Also note that this is not a serializable class.  It is entirely feasible
- * to make it serializable using the Externalizable interface, but this is
- * on Sun, not me.
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @see Member
- * @see Class
- * @see Class#getField(String)
- * @see Class#getDeclaredField(String)
- * @see Class#getFields()
- * @see Class#getDeclaredFields()
- * @since 1.1
- * @status updated to 1.4
- */
-public final class Field
-extends AccessibleObject implements Member
-{
-  static final int FIELD_MODIFIERS
-    = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED
-      | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT
-      | Modifier.VOLATILE;
-
-  private FieldSignatureParser p;
-
-  VMField f;
-
-  /**
-   * This class is uninstantiable outside the package.
-   */
-  Field(VMField f)
-  {
-    this.f = f;
-    f.f = this;
-  }
-
-  /**
-   * Gets the class that declared this field, or the class where this field
-   * is a non-inherited member.
-   * @return the class that declared this member
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?> getDeclaringClass()
-  {
-    return (Class<?>) f.getDeclaringClass();
-  }
-
-  /**
-   * Gets the name of this field.
-   * @return the name of this field
-   */
-  public String getName()
-  {
-    return f.getName();
-  }
-
-  /**
-   * Gets the modifiers this field uses.  Use the <code>Modifier</code>
-   * class to interpret the values.  A field can only have a subset of the
-   * following modifiers: public, private, protected, static, final,
-   * transient, and volatile.
-   *
-   * @return an integer representing the modifiers to this Member
-   * @see Modifier
-   */
-  public int getModifiers()
-  {
-    return f.getModifiersInternal() & FIELD_MODIFIERS;
-  }
-
-  /**
-   * Return true if this field is synthetic, false otherwise.
-   * @since 1.5
-   */
-  public boolean isSynthetic()
-  {
-    return (f.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
-  }
-
-  /**
-   * Return true if this field represents an enum constant,
-   * false otherwise.
-   * @since 1.5
-   */
-  public boolean isEnumConstant()
-  {
-    return (f.getModifiersInternal() & Modifier.ENUM) != 0;
-  }
-
-  /**
-   * Gets the type of this field.
-   * @return the type of this field
-   */
-  public Class<?> getType()
-  {
-    return f.getType();
-  }
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Fields are semantically equivalent if they have the same declaring
-   * class, name, and type. Since you can't creat a Field except through
-   * the VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-    return f.equals(o);
-  }
-
-  /**
-   * Get the hash code for the Field. The Field hash code is the hash code
-   * of its name XOR'd with the hash code of its class name.
-   *
-   * @return the hash code for the object.
-   */
-  public int hashCode()
-  {
-    return f.getDeclaringClass().getName().hashCode() ^ f.getName().hashCode();
-  }
-
-  /**
-   * Get a String representation of the Field. A Field's String
-   * representation is "&lt;modifiers&gt; &lt;type&gt;
-   * &lt;class&gt;.&lt;fieldname&gt;".<br> Example:
-   * <code>public transient boolean gnu.parse.Parser.parseComplete</code>
-   *
-   * @return the String representation of the Field
-   */
-  public String toString()
-  {
-    // 64 is a reasonable buffer initial size for field
-    CPStringBuilder sb = new CPStringBuilder(64);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(ClassHelper.getUserName(getType())).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName());
-    return sb.toString();
-  }
-
-  public String toGenericString()
-  {
-    CPStringBuilder sb = new CPStringBuilder(64);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(getGenericType()).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName());
-    return sb.toString();
-  }
-
-  /**
-   * Get the value of this Field.  If it is primitive, it will be wrapped
-   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. If the field
-   * is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is accessed, and primitives are wrapped (but not
-   * necessarily in new objects). This method accesses the field of the
-   * declaring class, even if the instance passed in belongs to a subclass
-   * which declares another field to hide this one.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>o</code> is not an instance of
-   *         the class or interface declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #getBoolean(Object)
-   * @see #getByte(Object)
-   * @see #getChar(Object)
-   * @see #getShort(Object)
-   * @see #getInt(Object)
-   * @see #getLong(Object)
-   * @see #getFloat(Object)
-   * @see #getDouble(Object)
-   */
-  public Object get(Object o)
-    throws IllegalAccessException
-  {
-    return f.get(o);
-  }
-
-  /**
-   * Get the value of this boolean Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public boolean getBoolean(Object o)
-    throws IllegalAccessException
-  {
-    return f.getBoolean(o);
-  }
-
-  /**
-   * Get the value of this byte Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public byte getByte(Object o)
-    throws IllegalAccessException
-  {
-    return f.getByte(o);
-  }
-
-  /**
-   * Get the value of this Field as a char. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char field of
-   *         <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public char getChar(Object o)
-    throws IllegalAccessException
-  {
-    return f.getChar(o);
-  }
-
-  /**
-   * Get the value of this Field as a short. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte or short
-   *         field of <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public short getShort(Object o)
-    throws IllegalAccessException
-  {
-    return f.getShort(o);
-  }
-
-  /**
-   * Get the value of this Field as an int. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, or
-   *         int field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public int getInt(Object o)
-    throws IllegalAccessException
-  {
-    return f.getInt(o);
-  }
-
-  /**
-   * Get the value of this Field as a long. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         or long field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public long getLong(Object o)
-    throws IllegalAccessException
-  {
-    return f.getLong(o);
-  }
-
-  /**
-   * Get the value of this Field as a float. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, or float field of <code>o</code>, or if <code>o</code> is
-   *         not an instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public float getFloat(Object o)
-    throws IllegalAccessException
-  {
-    return f.getFloat(o);
-  }
-
-  /**
-   * Get the value of this Field as a double. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, float, or double field of <code>o</code>, or if
-   *         <code>o</code> is not an instance of the declaring class of this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  public double getDouble(Object o)
-    throws IllegalAccessException
-  {
-    return f.getDouble(o);
-  }
-
-  /**
-   * Set the value of this Field.  If it is a primitive field, the value
-   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. This also
-   * occurs whether or not there is access control if the field is final.
-   * If the field is primitive, and unwrapping your argument fails, you will
-   * get an <code>IllegalArgumentException</code>; likewise, this error
-   * happens if <code>value</code> cannot be cast to the correct object type.
-   * If the field is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is set with the widened value. This method accesses
-   * the field of the declaring class, even if the instance passed in belongs
-   * to a subclass which declares another field to hide this one.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>value</code> cannot be
-   *         converted by a widening conversion to the underlying type of
-   *         the Field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #setBoolean(Object, boolean)
-   * @see #setByte(Object, byte)
-   * @see #setChar(Object, char)
-   * @see #setShort(Object, short)
-   * @see #setInt(Object, int)
-   * @see #setLong(Object, long)
-   * @see #setFloat(Object, float)
-   * @see #setDouble(Object, double)
-   */
-  public void set(Object o, Object value)
-    throws IllegalAccessException
-  {
-    f.set(o, value);
-  }
-
-  /**
-   * Set this boolean Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setBoolean(Object o, boolean value)
-    throws IllegalAccessException
-  {
-    f.setBoolean(o, value);
-  }
-
-  /**
-   * Set this byte Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setByte(Object o, byte value)
-    throws IllegalAccessException
-  {
-    f.setByte(o, value);
-  }
-
-  /**
-   * Set this char Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setChar(Object o, char value)
-    throws IllegalAccessException
-  {
-    f.setChar(o, value);
-  }
-
-  /**
-   * Set this short Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setShort(Object o, short value)
-    throws IllegalAccessException
-  {
-    f.setShort(o, value);
-  }
-
-  /**
-   * Set this int Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not an int, long, float, or
-   *         double field, or if <code>o</code> is not an instance of the
-   *         class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setInt(Object o, int value)
-    throws IllegalAccessException
-  {
-    f.setInt(o, value);
-  }
-
-  /**
-   * Set this long Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a long, float, or double
-   *         field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setLong(Object o, long value)
-    throws IllegalAccessException
-  {
-    f.setLong(o, value);
-  }
-
-  /**
-   * Set this float Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a float or long field, or
-   *         if <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setFloat(Object o, float value)
-    throws IllegalAccessException
-  {
-    f.setFloat(o, value);
-  }
-
-  /**
-   * Set this double Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a double field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  public void setDouble(Object o, double value)
-    throws IllegalAccessException
-  {
-    f.setDouble(o, value);
-  }
-
-  /**
-   * Return the generic type of the field. If the field type is not a generic
-   * type, the method returns the same as <code>getType()</code>.
-   *
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type getGenericType()
-  {
-    if (p == null)
-      {
-       String signature = f.getSignature();
-       if (signature == null)
-         return getType();
-       p = new FieldSignatureParser(getDeclaringClass(),
-                                    signature);
-      }
-    return p.getFieldType();
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-  @SuppressWarnings("unchecked")
-  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
-  {
-    return (T) f.getAnnotation(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-  public Annotation[] getDeclaredAnnotations()
-  {
-    return f.getDeclaredAnnotations();
-  }
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Method.java b/src/classes/gnu/java/lang/reflect/Method.java
deleted file mode 100644 (file)
index e787fb3..0000000
+++ /dev/null
@@ -1,499 +0,0 @@
-/* java.lang.reflect.Method - reflection of Java methods
-   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang.reflect;
-
-import gnu.java.lang.ClassHelper;
-import gnu.java.lang.CPStringBuilder;
-
-import gnu.java.lang.reflect.MethodSignatureParser;
-
-import java.lang.annotation.Annotation;
-
-/**
- * The Method class represents a member method of a class. It also allows
- * dynamic invocation, via reflection. This works for both static and
- * instance methods. Invocation on Method objects knows how to do
- * widening conversions, but throws {@link IllegalArgumentException} if
- * a narrowing conversion would be necessary. You can query for information
- * on this Method regardless of location, but invocation access may be limited
- * by Java language access controls. If you can't do it in the compiler, you
- * can't normally do it here either.<p>
- *
- * <B>Note:</B> This class returns and accepts types as Classes, even
- * primitive types; there are Class types defined that represent each
- * different primitive type.  They are <code>java.lang.Boolean.TYPE,
- * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
- * byte.class</code>, etc.  These are not to be confused with the
- * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
- * real classes.<p>
- *
- * Also note that this is not a serializable class.  It is entirely feasible
- * to make it serializable using the Externalizable interface, but this is
- * on Sun, not me.
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @see Member
- * @see Class
- * @see java.lang.Class#getMethod(String,Class[])
- * @see java.lang.Class#getDeclaredMethod(String,Class[])
- * @see java.lang.Class#getMethods()
- * @see java.lang.Class#getDeclaredMethods()
- * @since 1.1
- * @status updated to 1.4
- */
-public final class Method
-extends AccessibleObject implements Member, GenericDeclaration
-{
-  private static final int METHOD_MODIFIERS
-    = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE
-      | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC
-      | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED;
-
-  private MethodSignatureParser p;
-
-  VMMethod m;
-
-  /**
-   * This class is uninstantiable outside this package.
-   */
-  Method(VMMethod m)
-  {
-    this.m = m;
-    m.m = this;
-  }
-
-  /**
-   * Gets the class that declared this method, or the class where this method
-   * is a non-inherited member.
-   * @return the class that declared this member
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?> getDeclaringClass()
-  {
-    return (Class<?>) m.getDeclaringClass();
-  }
-
-  /**
-   * Gets the name of this method.
-   * @return the name of this method
-   */
-  public String getName()
-  {
-    return m.getName();
-  }
-
-  /**
-   * Gets the modifiers this method uses.  Use the <code>Modifier</code>
-   * class to interpret the values.  A method can only have a subset of the
-   * following modifiers: public, private, protected, abstract, static,
-   * final, synchronized, native, and strictfp.
-   *
-   * @return an integer representing the modifiers to this Member
-   * @see Modifier
-   */
-  public int getModifiers()
-  {
-    return m.getModifiersInternal() & METHOD_MODIFIERS;
-  }
-
-  /**
-   * Return true if this method is a bridge method.  A bridge method
-   * is generated by the compiler in some situations involving
-   * generics and inheritance.
-   * @since 1.5
-   */
-  public boolean isBridge()
-  {
-    return (m.getModifiersInternal() & Modifier.BRIDGE) != 0;
-  }
-
-  /**
-   * Return true if this method is synthetic, false otherwise.
-   * @since 1.5
-   */
-  public boolean isSynthetic()
-  {
-    return (m.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
-  }
-
-  /**
-   * Return true if this is a varargs method, that is if
-   * the method takes a variable number of arguments.
-   * @since 1.5
-   */
-  public boolean isVarArgs()
-  {
-    return (m.getModifiersInternal() & Modifier.VARARGS) != 0;
-  }
-
-  /**
-   * Gets the return type of this method.
-   * @return the type of this method
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?> getReturnType()
-  {
-    return (Class<?>) m.getReturnType();
-  }
-
-  /**
-   * Get the parameter list for this method, in declaration order. If the
-   * method takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the method's parameters
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getParameterTypes()
-  {
-    return (Class<?>[]) m.getParameterTypes();
-  }
-
-  /**
-   * Get the exception types this method says it throws, in no particular
-   * order. If the method has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the method's throws clause
-   */
-  @SuppressWarnings("unchecked")
-  public Class<?>[] getExceptionTypes()
-  {
-    return (Class<?>[]) m.getExceptionTypes();
-  }
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Methods are semantically equivalent if they have the same declaring
-   * class, name, parameter list, and return type.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-    return m.equals(o);
-  }
-
-  /**
-   * Get the hash code for the Method. The Method hash code is the hash code
-   * of its name XOR'd with the hash code of its class name.
-   *
-   * @return the hash code for the object
-   */
-  public int hashCode()
-  {
-    return m.getDeclaringClass().getName().hashCode() ^ m.getName().hashCode();
-  }
-
-  /**
-   * Get a String representation of the Method. A Method's String
-   * representation is "&lt;modifiers&gt; &lt;returntype&gt;
-   * &lt;methodname&gt;(&lt;paramtypes&gt;) throws &lt;exceptions&gt;", where
-   * everything after ')' is omitted if there are no exceptions.<br> Example:
-   * <code>public static int run(java.lang.Runnable,int)</code>
-   *
-   * @return the String representation of the Method
-   */
-  public String toString()
-  {
-    // 128 is a reasonable buffer initial size for constructor
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    sb.append(ClassHelper.getUserName(getReturnType())).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName()).append('(');
-    Class[] c = getParameterTypes();
-    if (c.length > 0)
-      {
-        sb.append(ClassHelper.getUserName(c[0]));
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(ClassHelper.getUserName(c[i]));
-      }
-    sb.append(')');
-    c = getExceptionTypes();
-    if (c.length > 0)
-      {
-        sb.append(" throws ").append(c[0].getName());
-        for (int i = 1; i < c.length; i++)
-          sb.append(',').append(c[i].getName());
-      }
-    return sb.toString();
-  }
-
-  public String toGenericString()
-  {
-    // 128 is a reasonable buffer initial size for constructor
-    CPStringBuilder sb = new CPStringBuilder(128);
-    Modifier.toString(getModifiers(), sb).append(' ');
-    Constructor.addTypeParameters(sb, getTypeParameters());
-    sb.append(getGenericReturnType()).append(' ');
-    sb.append(getDeclaringClass().getName()).append('.');
-    sb.append(getName()).append('(');
-    Type[] types = getGenericParameterTypes();
-    if (types.length > 0)
-      {
-        sb.append(types[0]);
-        for (int i = 1; i < types.length; i++)
-          sb.append(',').append(types[i]);
-      }
-    sb.append(')');
-    types = getGenericExceptionTypes();
-    if (types.length > 0)
-      {
-        sb.append(" throws ").append(types[0]);
-        for (int i = 1; i < types.length; i++)
-          sb.append(',').append(types[i]);
-      }
-    return sb.toString();
-  }
-
-  /**
-   * Invoke the method. Arguments are automatically unwrapped and widened,
-   * and the result is automatically wrapped, if needed.<p>
-   *
-   * If the method is static, <code>o</code> will be ignored. Otherwise,
-   * the method uses dynamic lookup as described in JLS 15.12.4.4. You cannot
-   * mimic the behavior of nonvirtual lookup (as in super.foo()). This means
-   * you will get a <code>NullPointerException</code> if <code>o</code> is
-   * null, and an <code>IllegalArgumentException</code> if it is incompatible
-   * with the declaring class of the method. If the method takes 0 arguments,
-   * you may use null or a 0-length array for <code>args</code>.<p>
-   *
-   * Next, if this Method enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not acces this method in similar compiled code. If the method
-   * is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the method is invoked. If it completes normally, the return value
-   * will be null for a void method, a wrapped object for a primitive return
-   * method, or the actual return of an Object method. If it completes
-   * abruptly, the exception is wrapped in an
-   * <code>InvocationTargetException</code>.
-   *
-   * @param o the object to invoke the method on
-   * @param args the arguments to the method
-   * @return the return value of the method, wrapped in the appropriate
-   *         wrapper if it is primitive
-   * @throws IllegalAccessException if the method could not normally be called
-   *         by the Java code (i.e. it is not public)
-   * @throws IllegalArgumentException if the number of arguments is incorrect;
-   *         if the arguments types are wrong even with a widening conversion;
-   *         or if <code>o</code> is not an instance of the class or interface
-   *         declaring this method
-   * @throws InvocationTargetException if the method throws an exception
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static method triggered
-   *         class initialization, which then failed
-   */
-  public Object invoke(Object o, Object... args)
-    throws IllegalAccessException, InvocationTargetException
-  {
-    return m.invoke(o, args);
-  }
-
-  /**
-   * Returns an array of <code>TypeVariable</code> objects that represents
-   * the type variables declared by this constructor, in declaration order.
-   * An array of size zero is returned if this class has no type
-   * variables.
-   *
-   * @return the type variables associated with this class. 
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public TypeVariable<Method>[] getTypeParameters()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return (TypeVariable<Method>[]) new TypeVariable[0];
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getTypeParameters();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the exception types declared by this method, in declaration order.
-   * An array of size zero is returned if this method declares no
-   * exceptions.
-   *
-   * @return the exception types declared by this method. 
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericExceptionTypes()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return getExceptionTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericExceptionTypes();
-  }
-
-  /**
-   * Returns an array of <code>Type</code> objects that represents
-   * the parameter list for this method, in declaration order.
-   * An array of size zero is returned if this method takes no
-   * parameters.
-   *
-   * @return a list of the types of the method's parameters
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type[] getGenericParameterTypes()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return getParameterTypes();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericParameterTypes();
-  }
-
-  /**
-   * Returns the return type of this method.
-   *
-   * @return the return type of this method
-   * @throws GenericSignatureFormatError if the generic signature does
-   *         not conform to the format specified in the Virtual Machine
-   *         specification, version 3.
-   * @since 1.5
-   */
-  public Type getGenericReturnType()
-  {
-    if (p == null)
-      {
-       String sig = m.getSignature();
-       if (sig == null)
-         return getReturnType();
-       p = new MethodSignatureParser(this, sig);
-      }
-    return p.getGenericReturnType();
-  }
-
-  /**
-   * If this method is an annotation method, returns the default
-   * value for the method.  If there is no default value, or if the
-   * method is not a member of an annotation type, returns null.
-   * Primitive types are wrapped.
-   *
-   * @throws TypeNotPresentException if the method returns a Class,
-   * and the class cannot be found
-   *
-   * @since 1.5
-   */
-  public Object getDefaultValue()
-  {
-    return m.getDefaultValue();
-  }
-
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the method's parameters.  The outer array is aligned against
-   * the parameters of the method and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this method.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  public Annotation[][] getParameterAnnotations()
-  {
-    return m.getParameterAnnotations();
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-  @SuppressWarnings("unchecked")
-  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
-  {
-    return (T) m.getAnnotation(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-  public Annotation[] getDeclaredAnnotations()
-  {
-    return m.getDeclaredAnnotations();
-  }
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/Modifier.java b/src/classes/gnu/java/lang/reflect/Modifier.java
deleted file mode 100644 (file)
index 45d9b51..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/* java.lang.reflect.Modifier
-   Copyright (C) 1998, 1999, 2001, 2002, 2005, 2008  Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang.reflect;
-
-import gnu.java.lang.CPStringBuilder;
-
-/**
- * Modifier is a helper class with static methods to determine whether an
- * int returned from getModifiers() represents static, public, protected,
- * native, final, etc... and provides an additional method to print
- * out all of the modifiers in an int in order.
- * <p>
- * The methods in this class use the bitmask values in the VM spec to
- * determine the modifiers of an int. This means that a VM must return a
- * standard mask, conformant with the VM spec.  I don't know if this is how
- * Sun does it, but I'm willing to bet money that it is.
- *
- * @author John Keiser
- * @author Tom Tromey (tromey@cygnus.com)
- * @author Eric Blake (ebb9@email.byu.edu)
- * @see Member#getModifiers()
- * @see Method#getModifiers()
- * @see Field#getModifiers()
- * @see Constructor#getModifiers()
- * @see Class#getModifiers()
- * @since 1.1
- */
-public class Modifier
-{
-  /** <STRONG>This constructor really shouldn't be here ... there are no
-   * instance methods or variables of this class, so instantiation is
-   * worthless.  However, this function is in the 1.1 spec, so it is added
-   * for completeness.</STRONG>
-   */
-  public Modifier()
-  {
-  }
-
-  /**
-   * Public: accessible from any other class.
-   */
-  public static final int PUBLIC = 0x0001;
-
-  /**
-   * Private: accessible only from the same enclosing class.
-   */
-  public static final int PRIVATE = 0x0002;
-
-  /**
-   * Protected: accessible only to subclasses, or within the package.
-   */
-  public static final int PROTECTED = 0x0004;
-
-  /**
-   * Static:<br><ul>
-   * <li>Class: no enclosing instance for nested class.</li>
-   * <li>Field or Method: can be accessed or invoked without an
-   *     instance of the declaring class.</li>
-   * </ul>
-   */
-  public static final int STATIC = 0x0008;
-
-  /**
-   * Final:<br><ul>
-   * <li>Class: no subclasses allowed.</li>
-   * <li>Field: cannot be changed.</li>
-   * <li>Method: cannot be overriden.</li>
-   * </ul>
-   */
-  public static final int FINAL = 0x0010;
-
-  /**
-   * Synchronized: Method: lock the class while calling this method.
-   */
-  public static final int SYNCHRONIZED = 0x0020;
-
-  /**
-   * Volatile: Field: cannot be cached.
-   */
-  public static final int VOLATILE = 0x0040;
-
-  /**
-   * Transient: Field: not serialized or deserialized.
-   */
-  public static final int TRANSIENT = 0x0080;
-
-  /**
-   * Native: Method: use JNI to call this method.
-   */
-  public static final int NATIVE = 0x0100;
-
-  /**
-   * Interface: Class: is an interface.
-   */
-  public static final int INTERFACE = 0x0200;
-
-  /**
-   * Abstract:<br><ul>
-   * <li>Class: may not be instantiated.</li>
-   * <li>Method: may not be called.</li>
-   * </ul>
-   */
-  public static final int ABSTRACT = 0x0400;
-
-  /**
-   * Strictfp: Method: expressions are FP-strict.<p>
-   * Also used as a modifier for classes, to mean that all initializers
-   * and constructors are FP-strict, but does not show up in
-   * Class.getModifiers.
-   */
-  public static final int STRICT = 0x0800;
-
-
-  /**
-   * Super - treat invokespecial as polymorphic so that super.foo() works
-   * according to the JLS. This is a reuse of the synchronized constant
-   * to patch a hole in JDK 1.0. *shudder*.
-   */
-  static final int SUPER = 0x0020;
-
-  /**
-   * All the flags, only used by code in this package.
-   */
-  static final int ALL_FLAGS = 0xfff;
-
-  /**
-   * Flag indicating a bridge method.
-   */
-  static final int BRIDGE = 0x40;
-
-  /**
-   * Flag indicating a varargs method.
-   */
-  static final int VARARGS = 0x80;
-
-  /**
-   * Flag indicating a synthetic member.
-   */
-  static final int SYNTHETIC = 0x1000;
-
-  /**
-   * Flag indicating an enum constant or an enum class.
-   */
-  static final int ENUM = 0x4000;
-
-  /**
-   * Check whether the given modifier is abstract.
-   * @param mod the modifier.
-   * @return <code>true</code> if abstract, <code>false</code> otherwise.
-   */
-  public static boolean isAbstract(int mod)
-  {
-    return (mod & ABSTRACT) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is final.
-   * @param mod the modifier.
-   * @return <code>true</code> if final, <code>false</code> otherwise.
-   */
-  public static boolean isFinal(int mod)
-  {
-    return (mod & FINAL) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is an interface.
-   * @param mod the modifier.
-   * @return <code>true</code> if an interface, <code>false</code> otherwise.
-   */
-  public static boolean isInterface(int mod)
-  {
-    return (mod & INTERFACE) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is native.
-   * @param mod the modifier.
-   * @return <code>true</code> if native, <code>false</code> otherwise.
-   */
-  public static boolean isNative(int mod)
-  {
-    return (mod & NATIVE) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is private.
-   * @param mod the modifier.
-   * @return <code>true</code> if private, <code>false</code> otherwise.
-   */
-  public static boolean isPrivate(int mod)
-  {
-    return (mod & PRIVATE) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is protected.
-   * @param mod the modifier.
-   * @return <code>true</code> if protected, <code>false</code> otherwise.
-   */
-  public static boolean isProtected(int mod)
-  {
-    return (mod & PROTECTED) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is public.
-   * @param mod the modifier.
-   * @return <code>true</code> if public, <code>false</code> otherwise.
-   */
-  public static boolean isPublic(int mod)
-  {
-    return (mod & PUBLIC) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is static.
-   * @param mod the modifier.
-   * @return <code>true</code> if static, <code>false</code> otherwise.
-   */
-  public static boolean isStatic(int mod)
-  {
-    return (mod & STATIC) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is strictfp.
-   * @param mod the modifier.
-   * @return <code>true</code> if strictfp, <code>false</code> otherwise.
-   */
-  public static boolean isStrict(int mod)
-  {
-    return (mod & STRICT) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is synchronized.
-   * @param mod the modifier.
-   * @return <code>true</code> if synchronized, <code>false</code> otherwise.
-   */
-  public static boolean isSynchronized(int mod)
-  {
-    return (mod & SYNCHRONIZED) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is transient.
-   * @param mod the modifier.
-   * @return <code>true</code> if transient, <code>false</code> otherwise.
-   */
-  public static boolean isTransient(int mod)
-  {
-    return (mod & TRANSIENT) != 0;
-  }
-
-  /**
-   * Check whether the given modifier is volatile.
-   * @param mod the modifier.
-   * @return <code>true</code> if volatile, <code>false</code> otherwise.
-   */
-  public static boolean isVolatile(int mod)
-  {
-    return (mod & VOLATILE) != 0;
-  }
-
-  /**
-   * Get a string representation of all the modifiers represented by the
-   * given int. The keywords are printed in this order:
-   * <code>&lt;public|protected|private&gt; abstract static final transient
-   * volatile synchronized native strictfp interface</code>.
-   *
-   * @param mod the modifier.
-   * @return the String representing the modifiers.
-   */
-  public static String toString(int mod)
-  {
-    return toString(mod, new CPStringBuilder()).toString();
-  }
-
-  /**
-   * Package helper method that can take a CPStringBuilder.
-   * @param mod the modifier
-   * @param r the CPStringBuilder to which the String representation is appended
-   * @return r, with information appended
-   */
-  static CPStringBuilder toString(int mod, CPStringBuilder r)
-  {
-    if (isPublic(mod))
-      r.append("public ");
-    if (isProtected(mod))
-      r.append("protected ");
-    if (isPrivate(mod))
-      r.append("private ");
-    if (isAbstract(mod))
-      r.append("abstract ");
-    if (isStatic(mod))
-      r.append("static ");
-    if (isFinal(mod))
-      r.append("final ");
-    if (isTransient(mod))
-      r.append("transient ");
-    if (isVolatile(mod))
-      r.append("volatile ");
-    if (isSynchronized(mod))
-      r.append("synchronized ");
-    if (isNative(mod))
-      r.append("native ");
-    if (isStrict(mod))
-      r.append("strictfp ");
-    if (isInterface(mod))
-      r.append("interface ");
-    
-    // Trim trailing space.
-    if ((mod & ALL_FLAGS) != 0)
-      r.setLength(r.length() - 1);
-    return r;
-  }
-}
diff --git a/src/classes/gnu/java/lang/reflect/VMConstructor.java b/src/classes/gnu/java/lang/reflect/VMConstructor.java
deleted file mode 100644 (file)
index 6a94711..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/* java.lang.reflect.VMConstructor - VM interface for reflection of Java constructors
-   Copyright (C) 1998, 2001, 2004, 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang.reflect;
-
-import java.lang.annotation.Annotation;
-
-import java.util.Arrays;
-import java.util.Map;
-
-final class VMConstructor
-{
-  Class clazz;
-  int slot;
-
-  /**
-   * Unparsed annotations.
-   */
-  private byte[] annotations = null;
-
-  /**
-   * Unparsed parameter annotations.
-   */
-  private byte[] parameterAnnotations = null;
-
-  /**
-   * Annotations get parsed the first time they are
-   * accessed and are then cached it this map.
-   */
-  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
-
-  /**
-   * Helper array for creating a new array from a java.util.Container.
-   */
-  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-    new Annotation[0];
-
-  /** 
-   * This field allows us to refer back to the main constructor instance.
-   *  It is set by the constructor of Constructor.
-   */
-  Constructor cons;
-
-  VMConstructor(Class clazz, int slot)
-  {
-    this.clazz = clazz;
-    this.slot = slot;
-  }
-
-  public Class getDeclaringClass()
-  {
-    return clazz;
-  }
-
-  /**
-   * Return the raw modifiers for this constructor.  In particular
-   * this will include the synthetic and varargs bits.
-   * @return the constructor's modifiers
-   */
-  native int getModifiersInternal();
-
-  /**
-   * Get the parameter list for this constructor, in declaration order. If the
-   * constructor takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the constructor's parameters
-   */
-  native Class[] getParameterTypes();
-
-  /**
-   * Get the exception types this constructor says it throws, in no particular
-   * order. If the constructor has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the constructor's throws clause
-   */
-  native Class[] getExceptionTypes();
-
-  native Object construct(Object[] args)
-    throws InstantiationException, IllegalAccessException,
-    InvocationTargetException;
-
-  /**
-   * Return the String in the Signature attribute for this constructor. If there
-   * is no Signature attribute, return null.
-   */
-  native String getSignature();
-  
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the constructor's parameters.  The outer array is aligned against
-   * the parameters of the constructors and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this constructor.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  native Annotation[][] getParameterAnnotations();
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Constructors are semantically equivalent if they have the same
-   * declaring class and the same parameter list.  This ignores different
-   * exception clauses, but since you can't create a Method except through the
-   * VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not.
-   */
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof Constructor))
-      return false;
-    Constructor that = (Constructor)o; 
-    if (clazz != that.getDeclaringClass())
-      return false;
-    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
-      return false;
-    return true;
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-//   native Annotation getAnnotation(Class annotationClass);
-  Annotation getAnnotation(Class annotationClass) {
-    if (annotationClass == null)
-      throw new NullPointerException();
-
-    return declaredAnnotations().get(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-//   native Annotation[] getDeclaredAnnotations();
-  Annotation[] getDeclaredAnnotations() {
-    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-  }
-
-  /**
-   * Parses the annotations if they aren't parsed yet and stores them into
-   * the declaredAnnotations map and return this map.
-   */
-  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/VMField.java b/src/classes/gnu/java/lang/reflect/VMField.java
deleted file mode 100644 (file)
index eeb30a8..0000000
+++ /dev/null
@@ -1,583 +0,0 @@
-/* java.lang.reflect.Field - VM interface for reflection of Java fields
-   Copyright (C) 1998, 2001, 2005, 2008 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang.reflect;
-
-import java.lang.annotation.Annotation;
-
-import java.util.Map;
-
-final class VMField
-{
-  Class clazz;
-  String name;
-  int slot;
-  
-  /**
-   * Unparsed annotations.
-   */
-  private byte[] annotations = null;
-
-  /**
-   * Annotations get parsed the first time they are
-   * accessed and are then cached it this map.
-   */
-  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
-
-  /**
-   * Helper array for creating a new array from a java.util.Container.
-   */
-  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-    new Annotation[0];
-
-  /** 
-   * This field allows us to refer back to the main constructor instance.
-   *  It is set by the constructor of Field.
-   */
-  Field f;
-
-  VMField(Class clazz, String name, int slot)
-  {
-    this.clazz = clazz;
-    this.name = name;
-    this.slot = slot;
-  }
-
-  public Class getDeclaringClass()
-  {
-    return clazz;
-  }
-
-  public String getName()
-  {
-    return name;
-  }
-
-  /**
-   * Return the raw modifiers for this field.
-   * @return the field's modifiers
-   */
-  native int getModifiersInternal();
-
-  /**
-   * Gets the type of this field.
-   * @return the type of this field
-   */
-  native Class getType();
-
-  /**
-   * Get the value of this Field.  If it is primitive, it will be wrapped
-   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. If the field
-   * is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is accessed, and primitives are wrapped (but not
-   * necessarily in new objects). This method accesses the field of the
-   * declaring class, even if the instance passed in belongs to a subclass
-   * which declares another field to hide this one.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>o</code> is not an instance of
-   *         the class or interface declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #getBoolean(Object)
-   * @see #getByte(Object)
-   * @see #getChar(Object)
-   * @see #getShort(Object)
-   * @see #getInt(Object)
-   * @see #getLong(Object)
-   * @see #getFloat(Object)
-   * @see #getDouble(Object)
-   */
-  native Object get(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this boolean Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native boolean getBoolean(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this byte Field. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte field of
-   *         <code>o</code>, or if <code>o</code> is not an instance of the
-   *         declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native byte getByte(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a char. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char field of
-   *         <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native char getChar(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a short. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte or short
-   *         field of <code>o</code>, or if <code>o</code> is not an instance
-   *         of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native short getShort(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as an int. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, or
-   *         int field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native int getInt(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a long. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         or long field of <code>o</code>, or if <code>o</code> is not an
-   *         instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native long getLong(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a float. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, or float field of <code>o</code>, or if <code>o</code> is
-   *         not an instance of the declaring class of this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native float getFloat(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Get the value of this Field as a double. If the field is static,
-   * <code>o</code> will be ignored.
-   *
-   * @param o the object to get the value of this Field from
-   * @return the value of the Field
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, char, int,
-   *         long, float, or double field of <code>o</code>, or if
-   *         <code>o</code> is not an instance of the declaring class of this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #get(Object)
-   */
-  native double getDouble(Object o)
-    throws IllegalAccessException;
-
-  /**
-   * Set the value of this Field.  If it is a primitive field, the value
-   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
-   *
-   * If the field is static, <code>o</code> will be ignored. Otherwise, if
-   * <code>o</code> is null, you get a <code>NullPointerException</code>,
-   * and if it is incompatible with the declaring class of the field, you
-   * get an <code>IllegalArgumentException</code>.<p>
-   *
-   * Next, if this Field enforces access control, your runtime context is
-   * evaluated, and you may have an <code>IllegalAccessException</code> if
-   * you could not access this field in similar compiled code. This also
-   * occurs whether or not there is access control if the field is final.
-   * If the field is primitive, and unwrapping your argument fails, you will
-   * get an <code>IllegalArgumentException</code>; likewise, this error
-   * happens if <code>value</code> cannot be cast to the correct object type.
-   * If the field is static, and its class is uninitialized, you trigger class
-   * initialization, which may end in a
-   * <code>ExceptionInInitializerError</code>.<p>
-   *
-   * Finally, the field is set with the widened value. This method accesses
-   * the field of the declaring class, even if the instance passed in belongs
-   * to a subclass which declares another field to hide this one.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if <code>value</code> cannot be
-   *         converted by a widening conversion to the underlying type of
-   *         the Field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #setBoolean(Object, boolean)
-   * @see #setByte(Object, byte)
-   * @see #setChar(Object, char)
-   * @see #setShort(Object, short)
-   * @see #setInt(Object, int)
-   * @see #setLong(Object, long)
-   * @see #setFloat(Object, float)
-   * @see #setDouble(Object, double)
-   */
-  native void set(Object o, Object value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this boolean Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a boolean field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setBoolean(Object o, boolean value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this byte Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a byte, short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setByte(Object o, byte value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this char Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a char, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setChar(Object o, char value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this short Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a short, int, long,
-   *         float, or double field, or if <code>o</code> is not an instance
-   *         of the class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setShort(Object o, short value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this int Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not an int, long, float, or
-   *         double field, or if <code>o</code> is not an instance of the
-   *         class declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setInt(Object o, int value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this long Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a long, float, or double
-   *         field, or if <code>o</code> is not an instance of the class
-   *         declaring this field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setLong(Object o, long value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this float Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a float or long field, or
-   *         if <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setFloat(Object o, float value)
-    throws IllegalAccessException;
-
-  /**
-   * Set this double Field. If the field is static, <code>o</code> will be
-   * ignored.
-   *
-   * @param o the object to set this Field on
-   * @param value the value to set this Field to
-   * @throws IllegalAccessException if you could not normally access this field
-   *         (i.e. it is not public)
-   * @throws IllegalArgumentException if this is not a double field, or if
-   *         <code>o</code> is not an instance of the class declaring this
-   *         field
-   * @throws NullPointerException if <code>o</code> is null and this field
-   *         requires an instance
-   * @throws ExceptionInInitializerError if accessing a static field triggered
-   *         class initialization, which then failed
-   * @see #set(Object, Object)
-   */
-  native void setDouble(Object o, double value)
-    throws IllegalAccessException;
-
-  /**
-   * Return the String in the Signature attribute for this field. If there
-   * is no Signature attribute, return null.
-   *
-   */
-  native String getSignature();
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Fields are semantically equivalent if they have the same declaring
-   * class, name, and type. Since you can't create a Field except through
-   * the VM, this is just the == relation.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-    if (!(o instanceof Field))
-      return false;
-    Field that = (Field)o; 
-    if (clazz != that.getDeclaringClass())
-      return false;
-    if (!name.equals(that.getName()))
-      return false;
-    if (getType() != that.getType())
-      return false;
-    return true;
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-//   native Annotation getAnnotation(Class annotationClass);
-  Annotation getAnnotation(Class annotationClass){
-    if (annotationClass == null)
-      throw new NullPointerException();
-
-    return declaredAnnotations().get(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-//   native Annotation[] getDeclaredAnnotations();
-  Annotation[] getDeclaredAnnotations() {
-    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-  }
-
-  /**
-   * Parses the annotations if they aren't parsed yet and stores them into
-   * the declaredAnnotations map and return this map.
-   */
-  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
-
-}
diff --git a/src/classes/gnu/java/lang/reflect/VMMethod.java b/src/classes/gnu/java/lang/reflect/VMMethod.java
deleted file mode 100644 (file)
index ad556f2..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/* java.lang.reflect.VMMethod - VM interface for reflection of Java methods
-   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang.reflect;
-
-import java.lang.annotation.Annotation;
-
-import java.util.Arrays;
-import java.util.Map;
-
-final class VMMethod
-{
-  Class clazz;
-  String name;
-  int slot;
-
-  /**
-   * Unparsed annotations.
-   */
-  private byte[] annotations          = null;
-
-  /**
-   * Unparsed parameter annotations.
-   */
-  private byte[] parameterAnnotations = null;
-  
-  /**
-   * Unparsed annotation default value.
-   */
-  private byte[] annotationDefault    = null;
-
-  /**
-   * Annotations get parsed the first time they are
-   * accessed and are then cached it this map.
-   */
-  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
-
-  /**
-   * Helper array for creating a new array from a java.util.Container.
-   */
-  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-    new Annotation[0];
-
-  /** 
-   * This field allows us to refer back to the main constructor instance.
-   *  It is set by the constructor of Field.
-   */
-  Method m;
-
-  public Class getDeclaringClass()
-  {
-    return clazz;
-  }
-
-  public String getName()
-  {
-    return name;
-  }
-
-  /**
-   * Return the raw modifiers for this method.
-   * @return the method's modifiers
-   */
-  native int getModifiersInternal();
-
-  /**
-   * Gets the return type of this method.
-   * @return the type of this method
-   */
-  native Class getReturnType();
-
-  /**
-   * Get the parameter list for this method, in declaration order. If the
-   * method takes no parameters, returns a 0-length array (not null).
-   *
-   * @return a list of the types of the method's parameters
-   */
-  native Class[] getParameterTypes();
-
-  /**
-   * Get the exception types this method says it throws, in no particular
-   * order. If the method has no throws clause, returns a 0-length array
-   * (not null).
-   *
-   * @return a list of the types in the method's throws clause
-   */
-  native Class[] getExceptionTypes();
-
-  native Object invoke(Object o, Object[] args)
-    throws IllegalAccessException, InvocationTargetException;
-
-  /**
-   * Return the String in the Signature attribute for this method. If there
-   * is no Signature attribute, return null.
-   */
-  native String getSignature();
-
-  /**
-   * If this method is an annotation method, returns the default
-   * value for the method.  If there is no default value, or if the
-   * method is not a member of an annotation type, returns null.
-   * Primitive types are wrapped.
-   *
-   * @throws TypeNotPresentException if the method returns a Class,
-   * and the class cannot be found
-   *
-   * @since 1.5
-   */
-  native Object getDefaultValue();
-
-  /**
-   * <p>
-   * Return an array of arrays representing the annotations on each
-   * of the method's parameters.  The outer array is aligned against
-   * the parameters of the method and is thus equal in length to
-   * the number of parameters (thus having a length zero if there are none).
-   * Each array element in the outer array contains an inner array which
-   * holds the annotations.  This array has a length of zero if the parameter
-   * has no annotations.
-   * </p>
-   * <p>
-   * The returned annotations are serialized.  Changing the annotations has
-   * no affect on the return value of future calls to this method.
-   * </p>
-   * 
-   * @return an array of arrays which represents the annotations used on the
-   *         parameters of this method.  The order of the array elements
-   *         matches the declaration order of the parameters.
-   * @since 1.5
-   */
-  native Annotation[][] getParameterAnnotations();
-
-  /**
-   * Compare two objects to see if they are semantically equivalent.
-   * Two Methods are semantically equivalent if they have the same declaring
-   * class, name, parameter list, and return type.
-   *
-   * @param o the object to compare to
-   * @return <code>true</code> if they are equal; <code>false</code> if not
-   */
-  public boolean equals(Object o)
-  {
-      // Implementation note:
-      // The following is a correct but possibly slow implementation.
-      //
-      // This class has a private field 'slot' that could be used by
-      // the VM implementation to "link" a particular method to a Class.
-      // In that case equals could be simply implemented as:
-      //
-      // if (o instanceof Method)
-      // {
-      //    Method m = (Method)o;
-      //    return m.declaringClass == this.declaringClass
-      //           && m.slot == this.slot;
-      // }
-      // return false;
-      //
-      // If a VM uses the Method class as their native/internal representation
-      // then just using the following would be optimal:
-      //
-      // return this == o;
-      //
-    if (!(o instanceof Method))
-      return false;
-    Method that = (Method)o;
-    if (clazz != that.getDeclaringClass())
-      return false;
-    if (!name.equals(that.getName()))
-      return false;
-    if (getReturnType() != that.getReturnType())
-      return false;
-    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
-      return false;
-    return true;
-  }
-
-  /**
-   * Returns the element's annotation for the specified annotation type,
-   * or <code>null</code> if no such annotation exists.
-   *
-   * @param annotationClass the type of annotation to look for.
-   * @return this element's annotation for the specified type, or
-   *         <code>null</code> if no such annotation exists.
-   * @throws NullPointerException if the annotation class is <code>null</code>.
-   */
-//   native Annotation getAnnotation(Class annotationClass);
-  Annotation getAnnotation(Class annotationClass) {
-    if (annotationClass == null)
-      throw new NullPointerException();
-
-    return declaredAnnotations().get(annotationClass);
-  }
-
-  /**
-   * Returns all annotations directly defined by the element.  If there are
-   * no annotations directly associated with the element, then a zero-length
-   * array will be returned.  The returned array may be modified by the client
-   * code, but this will have no effect on the annotation content of this
-   * class, and hence no effect on the return value of this method for
-   * future callers.
-   *
-   * @return the annotations directly defined by the element.
-   * @since 1.5
-   */
-//   native Annotation[] getDeclaredAnnotations();
-  Annotation[] getDeclaredAnnotations() {
-    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-  }
-
-  /**
-   * Parses the annotations if they aren't parsed yet and stores them into
-   * the declaredAnnotations map and return this map.
-   */
-  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
-
-}
-
diff --git a/src/classes/gnu/java/security/VMAccessController.java b/src/classes/gnu/java/security/VMAccessController.java
deleted file mode 100644 (file)
index 160df10..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/* VMAccessController.java -- VM-specific access controller methods.
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
-
-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; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.security;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-
-final class VMAccessController
-{
-
-  // Fields.
-  // -------------------------------------------------------------------------
-
-  /**
-   * This is a per-thread stack of AccessControlContext objects (which can
-   * be null) for each call to AccessController.doPrivileged in each thread's
-   * call stack. We use this to remember which context object corresponds to
-   * which call.
-   */
-  private static final ThreadLocal contexts = new ThreadLocal();
-
-  /**
-   * This is a Boolean that, if set, tells getContext that it has already
-   * been called once, allowing us to handle recursive permission checks
-   * caused by methods getContext calls.
-   */
-  private static final ThreadLocal inGetContext = new ThreadLocal();
-
-  /**
-   * And we return this all-permissive context to ensure that privileged
-   * methods called from getContext succeed.
-   */
-  private static final AccessControlContext DEFAULT_CONTEXT;
-  static
-  {
-    CodeSource source = new CodeSource(null, null);
-    Permissions permissions = new Permissions();
-    permissions.add(new AllPermission());
-    ProtectionDomain[] domain = new ProtectionDomain[] {
-      new ProtectionDomain(source, permissions)
-    };
-    DEFAULT_CONTEXT = new AccessControlContext(domain);
-  }
-
-  private static final boolean DEBUG = gnu.classpath.Configuration.DEBUG;
-  private static void debug(String msg)
-  {
-    System.err.print(">>> VMAccessController: ");
-    System.err.println(msg);
-  }
-
-  // Constructors.
-  // -------------------------------------------------------------------------
-
-  private VMAccessController() { }
-
-  // Class methods.
-  // -------------------------------------------------------------------------
-
-  /**
-   * Relate a class (which should be an instance of {@link PrivilegedAction}
-   * with an access control context. This method is used by {@link
-   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}
-   * to set up the context that will be returned by {@link #getContext()}.
-   * This method relates the class to the current thread, so contexts
-   * pushed from one thread will not be available to another.
-   *
-   * @param acc The access control context.
-   */
-  static void pushContext (AccessControlContext acc)
-  {
-    if (DEBUG)
-      debug("pushing " + acc);
-    LinkedList stack = (LinkedList) contexts.get();
-    if (stack == null)
-      {
-         if (DEBUG)
-           debug("no stack... creating ");
-        stack = new LinkedList();
-        contexts.set(stack);
-      }
-    stack.addFirst(acc);
-  }
-
-  /**
-   * Removes the relation of a class to an {@link AccessControlContext}.
-   * This method is used by {@link AccessController} when exiting from a
-   * call to {@link
-   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}.
-   */
-  static void popContext()
-  {
-    if (DEBUG)
-      debug("popping context");
-
-    // Stack should never be null, nor should it be empty, if this method
-    // and its counterpart has been called properly.
-    LinkedList stack = (LinkedList) contexts.get();
-    if (stack != null)
-      {
-        stack.removeFirst();
-        if (stack.isEmpty())
-          contexts.set(null);
-      }
-    else if (DEBUG)
-      {
-        debug("no stack during pop?????");
-      }
-  }
-
-  /**
-   * Examine the method stack of the currently running thread, and create
-   * an {@link AccessControlContext} filled in with the appropriate {@link
-   * ProtectionDomain} objects given this stack.
-   *
-   * @return The context.
-   */
-  static AccessControlContext getContext()
-  {
-    // If we are already in getContext, but called a method that needs
-    // a permission check, return the all-permissive context so methods
-    // called from here succeed.
-    //
-    // XXX is this necessary? We should verify if there are any calls in
-    // the stack below this method that require permission checks.
-    Boolean inCall = (Boolean) inGetContext.get();
-    if (inCall != null && inCall.booleanValue())
-      {
-        if (DEBUG)
-          debug("already in getContext");
-        return DEFAULT_CONTEXT;
-      }
-
-    inGetContext.set(Boolean.TRUE);
-
-    Object[][] stack = getStack();
-    Class[] classes = (Class[]) stack[0];
-    String[] methods = (String[]) stack[1];
-
-    if (DEBUG)
-      debug("got trace of length " + classes.length);
-
-    HashSet domains = new HashSet();
-    HashSet seenDomains = new HashSet();
-    AccessControlContext context = null;
-    int privileged = 0;
-
-    // We walk down the stack, adding each ProtectionDomain for each
-    // class in the call stack. If we reach a call to doPrivileged,
-    // we don't add any more stack frames. We skip the first three stack
-    // frames, since they comprise the calls to getStack, getContext,
-    // and AccessController.getContext.
-    for (int i = 3; i < classes.length && privileged < 2; i++)
-      {
-        Class clazz = classes[i];
-        String method = methods[i];
-
-        if (DEBUG)
-          {
-            debug("checking " + clazz + "." + method);
-            // subject to getClassLoader RuntimePermission
-            debug("loader = " + clazz.getClassLoader());
-          }
-
-        // If the previous frame was a call to doPrivileged, then this is
-        // the last frame we look at.
-        if (privileged == 1)
-          privileged = 2;
-
-        if (clazz.equals (AccessController.class)
-            && method.equals ("doPrivileged"))
-          {
-            // If there was a call to doPrivileged with a supplied context,
-            // return that context. If using JAAS doAs*, it should be 
-           // a context with a SubjectDomainCombiner
-            LinkedList l = (LinkedList) contexts.get();
-            if (l != null)
-              context = (AccessControlContext) l.getFirst();
-            privileged = 1;
-          }
-
-        // subject to getProtectionDomain RuntimePermission
-       ProtectionDomain domain = clazz.getProtectionDomain();
-
-        if (domain == null)
-          continue;
-        if (seenDomains.contains(domain))
-          continue;
-        seenDomains.add(domain);
-
-        // Create a static snapshot of this domain, which may change over time
-        // if the current policy changes.
-        domains.add(new ProtectionDomain(domain.getCodeSource(),
-                                         domain.getPermissions()));
-      }
-
-    if (DEBUG)
-      debug("created domains: " + domains);
-
-    ProtectionDomain[] result = (ProtectionDomain[])
-      domains.toArray(new ProtectionDomain[domains.size()]);
-
-    if (context != null)
-      {
-        DomainCombiner dc = context.getDomainCombiner ();
-        // If the supplied context had no explicit DomainCombiner, use
-        // our private version, which computes the intersection of the
-        // context's domains with the derived set.
-        if (dc == null)
-          context = new AccessControlContext
-            (IntersectingDomainCombiner.SINGLETON.combine
-             (result, context.getProtectionDomains ()));
-        // Use the supplied DomainCombiner. This should be secure,
-        // because only trusted code may create an
-        // AccessControlContext with a custom DomainCombiner.
-        else
-          context = new AccessControlContext (result, context, dc);
-      }
-    // No context was supplied. Return the derived one.
-    else
-      context = new AccessControlContext (result);
-
-    inGetContext.set(Boolean.FALSE);
-    return context;
-  }
-
-  /**
-   * Returns a snapshot of the current call stack as a pair of arrays:
-   * the first an array of classes in the call stack, the second an array
-   * of strings containing the method names in the call stack. The two
-   * arrays match up, meaning that method <i>i</i> is declared in class
-   * <i>i</i>. The arrays are clean; it will only contain Java methods,
-   * and no element of the list should be null.
-   *
-   * <p>The default implementation returns an empty stack, which will be
-   * interpreted as having no permissions whatsoever.
-   *
-   * @return A pair of arrays describing the current call stack. The first
-   *    element is an array of Class objects, and the second is an array
-   *    of Strings comprising the method names.
-   */
-//    private static Object[][] getStack()
-//    {
-//      return new Object[][] { new Class[0], new String[0] };
-//    }
-  private native static Object[][] getStack();
-}
diff --git a/src/classes/gnu/sun/misc/Unsafe.java b/src/classes/gnu/sun/misc/Unsafe.java
deleted file mode 100644 (file)
index 2577488..0000000
+++ /dev/null
@@ -1,861 +0,0 @@
-/*
- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.misc;
-
-import java.security.*;
-import java.lang.reflect.*;
-
-
-/**
- * A collection of methods for performing low-level, unsafe operations.
- * Although the class and all methods are public, use of this class is
- * limited because only trusted code can obtain instances of it.
- *
- * @author John R. Rose
- * @see #getUnsafe
- */
-
-public final class Unsafe {
-
-    private static native void registerNatives();
-    static {
-        registerNatives();
-//        sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
-    }
-
-    private Unsafe() {}
-
-    private static final Unsafe theUnsafe = new Unsafe();
-
-    /**
-     * Provides the caller with the capability of performing unsafe
-     * operations.
-     *
-     * <p> The returned <code>Unsafe</code> object should be carefully guarded
-     * by the caller, since it can be used to read and write data at arbitrary
-     * memory addresses.  It must never be passed to untrusted code.
-     *
-     * <p> Most methods in this class are very low-level, and correspond to a
-     * small number of hardware instructions (on typical machines).  Compilers
-     * are encouraged to optimize these methods accordingly.
-     *
-     * <p> Here is a suggested idiom for using unsafe operations:
-     *
-     * <blockquote><pre>
-     * class MyTrustedClass {
-     *   private static final Unsafe unsafe = Unsafe.getUnsafe();
-     *   ...
-     *   private long myCountAddress = ...;
-     *   public int getCount() { return unsafe.getByte(myCountAddress); }
-     * }
-     * </pre></blockquote>
-     *
-     * (It may assist compilers to make the local variable be
-     * <code>final</code>.)
-     *
-     * @exception  SecurityException  if a security manager exists and its
-     *             <code>checkPropertiesAccess</code> method doesn't allow
-     *             access to the system properties.
-     */
-    public static Unsafe getUnsafe() {
-        Class cc = sun.reflect.Reflection.getCallerClass(2);
-        if (cc.getClassLoader() != null)
-            throw new SecurityException("Unsafe");
-        return theUnsafe;
-    }
-
-    /// peek and poke operations
-    /// (compilers should optimize these to memory ops)
-
-    // These work on object fields in the Java heap.
-    // They will not work on elements of packed arrays.
-
-    /**
-     * Fetches a value from a given Java variable.
-     * More specifically, fetches a field or array element within the given
-     * object <code>o</code> at the given offset, or (if <code>o</code> is
-     * null) from the memory address whose numerical value is the given
-     * offset.
-     * <p>
-     * The results are undefined unless one of the following cases is true:
-     * <ul>
-     * <li>The offset was obtained from {@link #objectFieldOffset} on
-     * the {@link java.lang.reflect.Field} of some Java field and the object
-     * referred to by <code>o</code> is of a class compatible with that
-     * field's class.
-     *
-     * <li>The offset and object reference <code>o</code> (either null or
-     * non-null) were both obtained via {@link #staticFieldOffset}
-     * and {@link #staticFieldBase} (respectively) from the
-     * reflective {@link Field} representation of some Java field.
-     *
-     * <li>The object referred to by <code>o</code> is an array, and the offset
-     * is an integer of the form <code>B+N*S</code>, where <code>N</code> is
-     * a valid index into the array, and <code>B</code> and <code>S</code> are
-     * the values obtained by {@link #arrayBaseOffset} and {@link
-     * #arrayIndexScale} (respectively) from the array's class.  The value
-     * referred to is the <code>N</code><em>th</em> element of the array.
-     *
-     * </ul>
-     * <p>
-     * If one of the above cases is true, the call references a specific Java
-     * variable (field or array element).  However, the results are undefined
-     * if that variable is not in fact of the type returned by this method.
-     * <p>
-     * This method refers to a variable by means of two parameters, and so
-     * it provides (in effect) a <em>double-register</em> addressing mode
-     * for Java variables.  When the object reference is null, this method
-     * uses its offset as an absolute address.  This is similar in operation
-     * to methods such as {@link #getInt(long)}, which provide (in effect) a
-     * <em>single-register</em> addressing mode for non-Java variables.
-     * However, because Java variables may have a different layout in memory
-     * from non-Java variables, programmers should not assume that these
-     * two addressing modes are ever equivalent.  Also, programmers should
-     * remember that offsets from the double-register addressing mode cannot
-     * be portably confused with longs used in the single-register addressing
-     * mode.
-     *
-     * @param o Java heap object in which the variable resides, if any, else
-     *        null
-     * @param offset indication of where the variable resides in a Java heap
-     *        object, if any, else a memory address locating the variable
-     *        statically
-     * @return the value fetched from the indicated Java variable
-     * @throws RuntimeException No defined exceptions are thrown, not even
-     *         {@link NullPointerException}
-     */
-    public native int getInt(Object o, long offset);
-
-    /**
-     * Stores a value into a given Java variable.
-     * <p>
-     * The first two parameters are interpreted exactly as with
-     * {@link #getInt(Object, long)} to refer to a specific
-     * Java variable (field or array element).  The given value
-     * is stored into that variable.
-     * <p>
-     * The variable must be of the same type as the method
-     * parameter <code>x</code>.
-     *
-     * @param o Java heap object in which the variable resides, if any, else
-     *        null
-     * @param offset indication of where the variable resides in a Java heap
-     *        object, if any, else a memory address locating the variable
-     *        statically
-     * @param x the value to store into the indicated Java variable
-     * @throws RuntimeException No defined exceptions are thrown, not even
-     *         {@link NullPointerException}
-     */
-    public native void putInt(Object o, long offset, int x);
-
-    /**
-     * Fetches a reference value from a given Java variable.
-     * @see #getInt(Object, long)
-     */
-    public native Object getObject(Object o, long offset);
-
-    /**
-     * Stores a reference value into a given Java variable.
-     * <p>
-     * Unless the reference <code>x</code> being stored is either null
-     * or matches the field type, the results are undefined.
-     * If the reference <code>o</code> is non-null, car marks or
-     * other store barriers for that object (if the VM requires them)
-     * are updated.
-     * @see #putInt(Object, int, int)
-     */
-    public native void putObject(Object o, long offset, Object x);
-
-    /** @see #getInt(Object, long) */
-    public native boolean getBoolean(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putBoolean(Object o, long offset, boolean x);
-    /** @see #getInt(Object, long) */
-    public native byte    getByte(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putByte(Object o, long offset, byte x);
-    /** @see #getInt(Object, long) */
-    public native short   getShort(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putShort(Object o, long offset, short x);
-    /** @see #getInt(Object, long) */
-    public native char    getChar(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putChar(Object o, long offset, char x);
-    /** @see #getInt(Object, long) */
-    public native long    getLong(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putLong(Object o, long offset, long x);
-    /** @see #getInt(Object, long) */
-    public native float   getFloat(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putFloat(Object o, long offset, float x);
-    /** @see #getInt(Object, long) */
-    public native double  getDouble(Object o, long offset);
-    /** @see #putInt(Object, int, int) */
-    public native void    putDouble(Object o, long offset, double x);
-
-    /**
-     * This method, like all others with 32-bit offsets, was native
-     * in a previous release but is now a wrapper which simply casts
-     * the offset to a long value.  It provides backward compatibility
-     * with bytecodes compiled against 1.4.
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public int getInt(Object o, int offset) {
-        return getInt(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putInt(Object o, int offset, int x) {
-        putInt(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public Object getObject(Object o, int offset) {
-        return getObject(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putObject(Object o, int offset, Object x) {
-        putObject(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public boolean getBoolean(Object o, int offset) {
-        return getBoolean(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putBoolean(Object o, int offset, boolean x) {
-        putBoolean(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public byte getByte(Object o, int offset) {
-        return getByte(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putByte(Object o, int offset, byte x) {
-        putByte(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public short getShort(Object o, int offset) {
-        return getShort(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putShort(Object o, int offset, short x) {
-        putShort(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public char getChar(Object o, int offset) {
-        return getChar(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putChar(Object o, int offset, char x) {
-        putChar(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public long getLong(Object o, int offset) {
-        return getLong(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putLong(Object o, int offset, long x) {
-        putLong(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public float getFloat(Object o, int offset) {
-        return getFloat(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putFloat(Object o, int offset, float x) {
-        putFloat(o, (long)offset, x);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public double getDouble(Object o, int offset) {
-        return getDouble(o, (long)offset);
-    }
-
-    /**
-     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
-     * See {@link #staticFieldOffset}.
-     */
-    @Deprecated
-    public void putDouble(Object o, int offset, double x) {
-        putDouble(o, (long)offset, x);
-    }
-
-    // These work on values in the C heap.
-
-    /**
-     * Fetches a value from a given memory address.  If the address is zero, or
-     * does not point into a block obtained from {@link #allocateMemory}, the
-     * results are undefined.
-     *
-     * @see #allocateMemory
-     */
-    public native byte    getByte(long address);
-
-    /**
-     * Stores a value into a given memory address.  If the address is zero, or
-     * does not point into a block obtained from {@link #allocateMemory}, the
-     * results are undefined.
-     *
-     * @see #getByte(long)
-     */
-    public native void    putByte(long address, byte x);
-
-    /** @see #getByte(long) */
-    public native short   getShort(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putShort(long address, short x);
-    /** @see #getByte(long) */
-    public native char    getChar(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putChar(long address, char x);
-    /** @see #getByte(long) */
-    public native int     getInt(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putInt(long address, int x);
-    /** @see #getByte(long) */
-    public native long    getLong(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putLong(long address, long x);
-    /** @see #getByte(long) */
-    public native float   getFloat(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putFloat(long address, float x);
-    /** @see #getByte(long) */
-    public native double  getDouble(long address);
-    /** @see #putByte(long, byte) */
-    public native void    putDouble(long address, double x);
-
-    /**
-     * Fetches a native pointer from a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p> If the native pointer is less than 64 bits wide, it is extended as
-     * an unsigned number to a Java long.  The pointer may be indexed by any
-     * given byte offset, simply by adding that offset (as a simple integer) to
-     * the long representing the pointer.  The number of bytes actually read
-     * from the target address maybe determined by consulting {@link
-     * #addressSize}.
-     *
-     * @see #allocateMemory
-     */
-    public native long getAddress(long address);
-
-    /**
-     * Stores a native pointer into a given memory address.  If the address is
-     * zero, or does not point into a block obtained from {@link
-     * #allocateMemory}, the results are undefined.
-     *
-     * <p> The number of bytes actually written at the target address maybe
-     * determined by consulting {@link #addressSize}.
-     *
-     * @see #getAddress(long)
-     */
-    public native void putAddress(long address, long x);
-
-    /// wrappers for malloc, realloc, free:
-
-    /**
-     * Allocates a new block of native memory, of the given size in bytes.  The
-     * contents of the memory are uninitialized; they will generally be
-     * garbage.  The resulting native pointer will never be zero, and will be
-     * aligned for all value types.  Dispose of this memory by calling {@link
-     * #freeMemory}, or resize it with {@link #reallocateMemory}.
-     *
-     * @throws IllegalArgumentException if the size is negative or too large
-     *         for the native size_t type
-     *
-     * @throws OutOfMemoryError if the allocation is refused by the system
-     *
-     * @see #getByte(long)
-     * @see #putByte(long, byte)
-     */
-    public native long allocateMemory(long bytes);
-
-    /**
-     * Resizes a new block of native memory, to the given size in bytes.  The
-     * contents of the new block past the size of the old block are
-     * uninitialized; they will generally be garbage.  The resulting native
-     * pointer will be zero if and only if the requested size is zero.  The
-     * resulting native pointer will be aligned for all value types.  Dispose
-     * of this memory by calling {@link #freeMemory}, or resize it with {@link
-     * #reallocateMemory}.  The address passed to this method may be null, in
-     * which case an allocation will be performed.
-     *
-     * @throws IllegalArgumentException if the size is negative or too large
-     *         for the native size_t type
-     *
-     * @throws OutOfMemoryError if the allocation is refused by the system
-     *
-     * @see #allocateMemory
-     */
-    public native long reallocateMemory(long address, long bytes);
-
-    /**
-     * Sets all bytes in a given block of memory to a fixed value
-     * (usually zero).
-     */
-    public native void setMemory(long address, long bytes, byte value);
-
-    /**
-     * Sets all bytes in a given block of memory to a copy of another
-     * block.
-     */
-    public native void copyMemory(long srcAddress, long destAddress,
-                                  long bytes);
-
-    /**
-     * Disposes of a block of native memory, as obtained from {@link
-     * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
-     * this method may be null, in which case no action is taken.
-     *
-     * @see #allocateMemory
-     */
-    public native void freeMemory(long address);
-
-    /// random queries
-
-    /**
-     * This constant differs from all results that will ever be returned from
-     * {@link #staticFieldOffset}, {@link #objectFieldOffset},
-     * or {@link #arrayBaseOffset}.
-     */
-    public static final int INVALID_FIELD_OFFSET   = -1;
-
-    /**
-     * Returns the offset of a field, truncated to 32 bits.
-     * This method is implemented as follows:
-     * <blockquote><pre>
-     * public int fieldOffset(Field f) {
-     *     if (Modifier.isStatic(f.getModifiers()))
-     *         return (int) staticFieldOffset(f);
-     *     else
-     *         return (int) objectFieldOffset(f);
-     * }
-     * </pre></blockquote>
-     * @deprecated As of 1.4.1, use {@link #staticFieldOffset} for static
-     * fields and {@link #objectFieldOffset} for non-static fields.
-     */
-    @Deprecated
-    public int fieldOffset(Field f) {
-        if (Modifier.isStatic(f.getModifiers()))
-            return (int) staticFieldOffset(f);
-        else
-            return (int) objectFieldOffset(f);
-    }
-
-    /**
-     * Returns the base address for accessing some static field
-     * in the given class.  This method is implemented as follows:
-     * <blockquote><pre>
-     * public Object staticFieldBase(Class c) {
-     *     Field[] fields = c.getDeclaredFields();
-     *     for (int i = 0; i < fields.length; i++) {
-     *         if (Modifier.isStatic(fields[i].getModifiers())) {
-     *             return staticFieldBase(fields[i]);
-     *         }
-     *     }
-     *     return null;
-     * }
-     * </pre></blockquote>
-     * @deprecated As of 1.4.1, use {@link #staticFieldBase(Field)}
-     * to obtain the base pertaining to a specific {@link Field}.
-     * This method works only for JVMs which store all statics
-     * for a given class in one place.
-     */
-    @Deprecated
-    public Object staticFieldBase(Class c) {
-        Field[] fields = c.getDeclaredFields();
-        for (int i = 0; i < fields.length; i++) {
-            if (Modifier.isStatic(fields[i].getModifiers())) {
-                return staticFieldBase(fields[i]);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Report the location of a given field in the storage allocation of its
-     * class.  Do not expect to perform any sort of arithmetic on this offset;
-     * it is just a cookie which is passed to the unsafe heap memory accessors.
-     *
-     * <p>Any given field will always have the same offset and base, and no
-     * two distinct fields of the same class will ever have the same offset
-     * and base.
-     *
-     * <p>As of 1.4.1, offsets for fields are represented as long values,
-     * although the Sun JVM does not use the most significant 32 bits.
-     * However, JVM implementations which store static fields at absolute
-     * addresses can use long offsets and null base pointers to express
-     * the field locations in a form usable by {@link #getInt(Object,long)}.
-     * Therefore, code which will be ported to such JVMs on 64-bit platforms
-     * must preserve all bits of static field offsets.
-     * @see #getInt(Object, long)
-     */
-    public native long staticFieldOffset(Field f);
-
-    /**
-     * Report the location of a given static field, in conjunction with {@link
-     * #staticFieldBase}.
-     * <p>Do not expect to perform any sort of arithmetic on this offset;
-     * it is just a cookie which is passed to the unsafe heap memory accessors.
-     *
-     * <p>Any given field will always have the same offset, and no two distinct
-     * fields of the same class will ever have the same offset.
-     *
-     * <p>As of 1.4.1, offsets for fields are represented as long values,
-     * although the Sun JVM does not use the most significant 32 bits.
-     * It is hard to imagine a JVM technology which needs more than
-     * a few bits to encode an offset within a non-array object,
-     * However, for consistency with other methods in this class,
-     * this method reports its result as a long value.
-     * @see #getInt(Object, long)
-     */
-    public native long objectFieldOffset(Field f);
-
-    /**
-     * Report the location of a given static field, in conjunction with {@link
-     * #staticFieldOffset}.
-     * <p>Fetch the base "Object", if any, with which static fields of the
-     * given class can be accessed via methods like {@link #getInt(Object,
-     * long)}.  This value may be null.  This value may refer to an object
-     * which is a "cookie", not guaranteed to be a real Object, and it should
-     * not be used in any way except as argument to the get and put routines in
-     * this class.
-     */
-    public native Object staticFieldBase(Field f);
-
-    /**
-     * Ensure the given class has been initialized. This is often
-     * needed in conjunction with obtaining the static field base of a
-     * class.
-     */
-    public native void ensureClassInitialized(Class c);
-
-    /**
-     * Report the offset of the first element in the storage allocation of a
-     * given array class.  If {@link #arrayIndexScale} returns a non-zero value
-     * for the same class, you may use that scale factor, together with this
-     * base offset, to form new offsets to access elements of arrays of the
-     * given class.
-     *
-     * @see #getInt(Object, long)
-     * @see #putInt(Object, long, int)
-     */
-    public native int arrayBaseOffset(Class arrayClass);
-
-    /**
-     * Report the scale factor for addressing elements in the storage
-     * allocation of a given array class.  However, arrays of "narrow" types
-     * will generally not work properly with accessors like {@link
-     * #getByte(Object, int)}, so the scale factor for such classes is reported
-     * as zero.
-     *
-     * @see #arrayBaseOffset
-     * @see #getInt(Object, long)
-     * @see #putInt(Object, long, int)
-     */
-    public native int arrayIndexScale(Class arrayClass);
-
-    /**
-     * Report the size in bytes of a native pointer, as stored via {@link
-     * #putAddress}.  This value will be either 4 or 8.  Note that the sizes of
-     * other primitive types (as stored in native memory blocks) is determined
-     * fully by their information content.
-     */
-    public native int addressSize();
-
-    /**
-     * Report the size in bytes of a native memory page (whatever that is).
-     * This value will always be a power of two.
-     */
-    public native int pageSize();
-
-
-    /// random trusted operations from JNI:
-
-    /**
-     * Tell the VM to define a class, without security checks.  By default, the
-     * class loader and protection domain come from the caller's class.
-     */
-    public native Class defineClass(String name, byte[] b, int off, int len,
-                                    ClassLoader loader,
-                                    ProtectionDomain protectionDomain);
-
-    public native Class defineClass(String name, byte[] b, int off, int len);
-
-    /** Allocate an instance but do not run any constructor.
-        Initializes the class if it has not yet been. */
-    public native Object allocateInstance(Class cls)
-        throws InstantiationException;
-
-    /** Lock the object.  It must get unlocked via {@link #monitorExit}. */
-    public native void monitorEnter(Object o);
-
-    /**
-     * Unlock the object.  It must have been locked via {@link
-     * #monitorEnter}.
-     */
-    public native void monitorExit(Object o);
-
-    /**
-     * Tries to lock the object.  Returns true or false to indicate
-     * whether the lock succeeded.  If it did, the object must be
-     * unlocked via {@link #monitorExit}.
-     */
-    public native boolean tryMonitorEnter(Object o);
-
-    /** Throw the exception without telling the verifier. */
-    public native void throwException(Throwable ee);
-
-
-    /**
-     * Atomically update Java variable to <tt>x</tt> if it is currently
-     * holding <tt>expected</tt>.
-     * @return <tt>true</tt> if successful
-     */
-    public final native boolean compareAndSwapObject(Object o, long offset,
-                                                     Object expected,
-                                                     Object x);
-
-    /**
-     * Atomically update Java variable to <tt>x</tt> if it is currently
-     * holding <tt>expected</tt>.
-     * @return <tt>true</tt> if successful
-     */
-    public final native boolean compareAndSwapInt(Object o, long offset,
-                                                  int expected,
-                                                  int x);
-
-    /**
-     * Atomically update Java variable to <tt>x</tt> if it is currently
-     * holding <tt>expected</tt>.
-     * @return <tt>true</tt> if successful
-     */
-    public final native boolean compareAndSwapLong(Object o, long offset,
-                                                   long expected,
-                                                   long x);
-
-    /**
-     * Fetches a reference value from a given Java variable, with volatile
-     * load semantics. Otherwise identical to {@link #getObject(Object, long)}
-     */
-    public native Object getObjectVolatile(Object o, long offset);
-
-    /**
-     * Stores a reference value into a given Java variable, with
-     * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)}
-     */
-    public native void    putObjectVolatile(Object o, long offset, Object x);
-
-    /** Volatile version of {@link #getInt(Object, long)}  */
-    public native int     getIntVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putInt(Object, long, int)}  */
-    public native void    putIntVolatile(Object o, long offset, int x);
-
-    /** Volatile version of {@link #getBoolean(Object, long)}  */
-    public native boolean getBooleanVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putBoolean(Object, long, boolean)}  */
-    public native void    putBooleanVolatile(Object o, long offset, boolean x);
-
-    /** Volatile version of {@link #getByte(Object, long)}  */
-    public native byte    getByteVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putByte(Object, long, byte)}  */
-    public native void    putByteVolatile(Object o, long offset, byte x);
-
-    /** Volatile version of {@link #getShort(Object, long)}  */
-    public native short   getShortVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putShort(Object, long, short)}  */
-    public native void    putShortVolatile(Object o, long offset, short x);
-
-    /** Volatile version of {@link #getChar(Object, long)}  */
-    public native char    getCharVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putChar(Object, long, char)}  */
-    public native void    putCharVolatile(Object o, long offset, char x);
-
-    /** Volatile version of {@link #getLong(Object, long)}  */
-    public native long    getLongVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putLong(Object, long, long)}  */
-    public native void    putLongVolatile(Object o, long offset, long x);
-
-    /** Volatile version of {@link #getFloat(Object, long)}  */
-    public native float   getFloatVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putFloat(Object, long, float)}  */
-    public native void    putFloatVolatile(Object o, long offset, float x);
-
-    /** Volatile version of {@link #getDouble(Object, long)}  */
-    public native double  getDoubleVolatile(Object o, long offset);
-
-    /** Volatile version of {@link #putDouble(Object, long, double)}  */
-    public native void    putDoubleVolatile(Object o, long offset, double x);
-
-    /**
-     * Version of {@link #putObjectVolatile(Object, long, Object)}
-     * that does not guarantee immediate visibility of the store to
-     * other threads. This method is generally only useful if the
-     * underlying field is a Java volatile (or if an array cell, one
-     * that is otherwise only accessed using volatile accesses).
-     */
-    public native void    putOrderedObject(Object o, long offset, Object x);
-
-    /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)}  */
-    public native void    putOrderedInt(Object o, long offset, int x);
-
-    /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */
-    public native void    putOrderedLong(Object o, long offset, long x);
-
-    /**
-     * Unblock the given thread blocked on <tt>park</tt>, or, if it is
-     * not blocked, cause the subsequent call to <tt>park</tt> not to
-     * block.  Note: this operation is "unsafe" solely because the
-     * caller must somehow ensure that the thread has not been
-     * destroyed. Nothing special is usually required to ensure this
-     * when called from Java (in which there will ordinarily be a live
-     * reference to the thread) but this is not nearly-automatically
-     * so when calling from native code.
-     * @param thread the thread to unpark.
-     *
-     */
-    public native void unpark(Object thread);
-
-    /**
-     * Block current thread, returning when a balancing
-     * <tt>unpark</tt> occurs, or a balancing <tt>unpark</tt> has
-     * already occurred, or the thread is interrupted, or, if not
-     * absolute and time is not zero, the given time nanoseconds have
-     * elapsed, or if absolute, the given deadline in milliseconds
-     * since Epoch has passed, or spuriously (i.e., returning for no
-     * "reason"). Note: This operation is in the Unsafe class only
-     * because <tt>unpark</tt> is, so it would be strange to place it
-     * elsewhere.
-     */
-    public native void park(boolean isAbsolute, long time);
-
-    /**
-     * Gets the load average in the system run queue assigned
-     * to the available processors averaged over various periods of time.
-     * This method retrieves the given <tt>nelem</tt> samples and
-     * assigns to the elements of the given <tt>loadavg</tt> array.
-     * The system imposes a maximum of 3 samples, representing
-     * averages over the last 1,  5,  and  15 minutes, respectively.
-     *
-     * @params loadavg an array of double of size nelems
-     * @params nelems the number of samples to be retrieved and
-     *         must be 1 to 3.
-     *
-     * @return the number of samples actually retrieved; or -1
-     *         if the load average is unobtainable.
-     */
-    public native int getLoadAverage(double[] loadavg, int nelems);
-}
diff --git a/src/classes/gnu/sun/reflect/ConstantPool.java b/src/classes/gnu/sun/reflect/ConstantPool.java
deleted file mode 100644 (file)
index b24d28e..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect;
-
-import java.lang.reflect.*;
-
-/** Provides reflective access to the constant pools of classes.
-    Currently this is needed to provide reflective access to annotations
-    but may be used by other internal subsystems in the future. */
-
-public class ConstantPool {
-  // Number of entries in this constant pool (= maximum valid constant pool index)
-  public int      getSize()                      { return getSize0            (constantPoolOop);        }
-  public Class    getClassAt         (int index) { return getClassAt0         (constantPoolOop, index); }
-  public Class    getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
-  // Returns either a Method or Constructor.
-  // Static initializers are returned as Method objects.
-  public Member   getMethodAt        (int index) { return getMethodAt0        (constantPoolOop, index); }
-  public Member   getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }
-  public Field    getFieldAt         (int index) { return getFieldAt0         (constantPoolOop, index); }
-  public Field    getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }
-  // Fetches the class name, member (field, method or interface
-  // method) name, and type descriptor as an array of three Strings
-  public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }
-  public int      getIntAt           (int index) { return getIntAt0           (constantPoolOop, index); }
-  public long     getLongAt          (int index) { return getLongAt0          (constantPoolOop, index); }
-  public float    getFloatAt         (int index) { return getFloatAt0         (constantPoolOop, index); }
-  public double   getDoubleAt        (int index) { return getDoubleAt0        (constantPoolOop, index); }
-  public String   getStringAt        (int index) { return getStringAt0        (constantPoolOop, index); }
-  public String   getUTF8At          (int index) { return getUTF8At0          (constantPoolOop, index); }
-
-  //---------------------------------------------------------------------------
-  // Internals only below this point
-  //
-/* This hides this member from being visible through the reflection API in OpenJDK
- * TODO: find out how to do this with GNU Classpath (if it's realy neccesary).
-
-  static {
-      Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });
-  }
-*/
-  // HotSpot-internal constant pool object (set by the VM, name known to the VM)
-  private Object constantPoolOop;
-
-  private native int      getSize0            (Object constantPoolOop);
-  private native Class    getClassAt0         (Object constantPoolOop, int index);
-  private native Class    getClassAtIfLoaded0 (Object constantPoolOop, int index);
-  private native Member   getMethodAt0        (Object constantPoolOop, int index);
-  private native Member   getMethodAtIfLoaded0(Object constantPoolOop, int index);
-  private native Field    getFieldAt0         (Object constantPoolOop, int index);
-  private native Field    getFieldAtIfLoaded0 (Object constantPoolOop, int index);
-  private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);
-  private native int      getIntAt0           (Object constantPoolOop, int index);
-  private native long     getLongAt0          (Object constantPoolOop, int index);
-  private native float    getFloatAt0         (Object constantPoolOop, int index);
-  private native double   getDoubleAt0        (Object constantPoolOop, int index);
-  private native String   getStringAt0        (Object constantPoolOop, int index);
-  private native String   getUTF8At0          (Object constantPoolOop, int index);
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/AnnotationParser.java b/src/classes/gnu/sun/reflect/annotation/AnnotationParser.java
deleted file mode 100644 (file)
index 8c5aca3..0000000
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
- * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-
-import java.lang.annotation.*;
-import java.util.*;
-import java.nio.ByteBuffer;
-import java.nio.BufferUnderflowException;
-import java.lang.reflect.*;
-import sun.reflect.ConstantPool;
-
-import gnu.java.lang.reflect.FieldSignatureParser;
-
-
-/**
- * Parser for Java programming language annotations.  Translates
- * annotation byte streams emitted by compiler into annotation objects.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class AnnotationParser {
-    /**
-     * Parses the annotations described by the passed byte array,
-     * but returns Annotation[] so I don't have to do this in C.
-     *
-     * @author Mathias Panzenböck
-     * 
-     * @param rawAnnotations are the unparsed annotations
-     * @param constPool is the constant pool of the declaring class
-     * @param container is the containing class
-     * @return the parsed annotations in an array
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Annotation[] parseAnnotationsIntoArray(
-                byte[] rawAnnotations,
-                ConstantPool constPool,
-                Class container) {
-        Map<Class, Annotation> annotations = parseAnnotations(rawAnnotations, constPool, container);
-        return annotations.values().toArray(EMPTY_ANNOTATIONS_ARRAY);
-    }
-
-    /**
-     * Parses parameter annotations.
-     * 
-     * @author Mathias Panzenböck
-     * 
-     * @param parameterAnnotations are the unparsed parameter annotations
-     * @param constPool is the constant pool of the declaring class
-     * @param container is the containing class
-     * @return the parsed parameter annotations in an array 2 dimensional array
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Annotation[][] parseParameterAnnotations(
-                    byte[] parameterAnnotations,
-                    ConstantPool constPool,
-                    Class container,
-                    int numParameters) {
-        if (parameterAnnotations == null)
-            return new Annotation[numParameters][0];
-
-        Annotation[][] result = parseParameterAnnotations(
-            parameterAnnotations, constPool, container); 
-
-        if (result.length != numParameters)
-            throw new AnnotationFormatError(
-                "Parameter annotations don't match number of parameters (count was " +
-               result.length + " but should be " + numParameters + ").");
-        return result;
-    }
-
-    /**
-     * Parses the annotation default value of the supplied method.
-     * This method is basically copied from OpenJDKs
-     * java.lang.reflect.Method.getAnnotationDefault()
-     * 
-     * @author Mathias Panzenböck
-     *
-     * @param method represents the method for which the annotation default value has to be parsed
-     * @param annotationDefault is the unparsed annotation default value
-     * @param constPool is the constant pool of the declaring class
-     * @return the parsed annotation default value (boxed, if it's a primitive type)
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Object parseAnnotationDefault(Method method,
-                                                byte[] annotationDefault,
-                                                ConstantPool constPool) {
-        if  (annotationDefault == null)
-            return null;
-        
-       Class memberType = AnnotationType.invocationHandlerReturnType(
-            method.getReturnType());
-        
-       Object result = AnnotationParser.parseMemberValue(
-            memberType, ByteBuffer.wrap(annotationDefault),
-            constPool, method.getDeclaringClass());
-
-        if (result instanceof sun.reflect.annotation.ExceptionProxy)
-            throw new AnnotationFormatError("Invalid default: " + method);
-        
-       return result;
-    }
-
-    /**
-     * Parses the annotations described by the specified byte array.
-     * resolving constant references in the specified constant pool.
-     * The array must contain an array of annotations as described
-     * in the RuntimeVisibleAnnotations_attribute:
-     *
-     *   u2 num_annotations;
-     *   annotation annotations[num_annotations];
-     *
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Map<Class, Annotation> parseAnnotations(
-                byte[] rawAnnotations,
-                ConstantPool constPool,
-                Class container) {
-        if (rawAnnotations == null)
-            return Collections.emptyMap();
-
-        try {
-            return parseAnnotations2(rawAnnotations, constPool, container);
-        } catch(BufferUnderflowException e) {
-            throw new AnnotationFormatError("Unexpected end of annotations.");
-        } catch(IllegalArgumentException e) {
-            // Type mismatch in constant pool
-            throw new AnnotationFormatError(e);
-        }
-    }
-
-    private static Map<Class, Annotation> parseAnnotations2(
-                byte[] rawAnnotations,
-                ConstantPool constPool,
-                Class container) {
-        Map<Class, Annotation> result = new LinkedHashMap<Class, Annotation>();
-        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
-        int numAnnotations = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < numAnnotations; i++) {
-           Annotation a = parseAnnotation(buf, constPool, container, false);
-            if (a != null) {
-                Class klass = a.annotationType();
-                AnnotationType type = AnnotationType.getInstance(klass);
-                if (type.retention() == RetentionPolicy.RUNTIME)
-                    if (result.put(klass, a) != null)
-                        throw new AnnotationFormatError(
-                            "Duplicate annotation for class: "+klass+": " + a);
-            }
-        }
-        return result;
-    }
-
-    /**
-     * Parses the parameter annotations described by the specified byte array.
-     * resolving constant references in the specified constant pool.
-     * The array must contain an array of annotations as described
-     * in the RuntimeVisibleParameterAnnotations_attribute:
-     *
-     *    u1 num_parameters;
-     *    {
-     *        u2 num_annotations;
-     *        annotation annotations[num_annotations];
-     *    } parameter_annotations[num_parameters];
-     *
-     * Unlike parseAnnotations, rawAnnotations must not be null!
-     * A null value must be handled by the caller.  This is so because
-     * we cannot determine the number of parameters if rawAnnotations
-     * is null.  Also, the caller should check that the number
-     * of parameters indicated by the return value of this method
-     * matches the actual number of method parameters.  A mismatch
-     * indicates that an AnnotationFormatError should be thrown.
-     *
-     * @throws AnnotationFormatError if an annotation is found to be
-     *         malformed.
-     */
-    public static Annotation[][] parseParameterAnnotations(
-                    byte[] rawAnnotations,
-                    ConstantPool constPool,
-                    Class container) {
-        try {
-            return parseParameterAnnotations2(rawAnnotations, constPool, container);
-        } catch(BufferUnderflowException e) {
-            throw new AnnotationFormatError(
-                "Unexpected end of parameter annotations.");
-        } catch(IllegalArgumentException e) {
-            // Type mismatch in constant pool
-            throw new AnnotationFormatError(e);
-        }
-    }
-
-    private static Annotation[][] parseParameterAnnotations2(
-                    byte[] rawAnnotations,
-                    ConstantPool constPool,
-                    Class container) {
-        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
-        int numParameters = buf.get() & 0xFF;
-        Annotation[][] result = new Annotation[numParameters][];
-
-        for (int i = 0; i < numParameters; i++) {
-            int numAnnotations = buf.getShort() & 0xFFFF;
-            List<Annotation> annotations =
-                new ArrayList<Annotation>(numAnnotations);
-            for (int j = 0; j < numAnnotations; j++) {
-                Annotation a = parseAnnotation(buf, constPool, container, false);
-                if (a != null) {
-                    AnnotationType type = AnnotationType.getInstance(
-                                              a.annotationType());
-                    if (type.retention() == RetentionPolicy.RUNTIME)
-                        annotations.add(a);
-                }
-            }
-            result[i] = annotations.toArray(EMPTY_ANNOTATIONS_ARRAY);
-        }
-        return result;
-    }
-
-    private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
-                    new Annotation[0];
-
-    /**
-     * Parses the annotation at the current position in the specified
-     * byte buffer, resolving constant references in the specified constant
-     * pool.  The cursor of the byte buffer must point to an "annotation
-     * structure" as described in the RuntimeVisibleAnnotations_attribute:
-     *
-     * annotation {
-     *    u2    type_index;
-     *       u2    num_member_value_pairs;
-     *       {    u2    member_name_index;
-     *             member_value value;
-     *       }    member_value_pairs[num_member_value_pairs];
-     *    }
-     * }
-     *
-     * Returns the annotation, or null if the annotation's type cannot
-     * be found by the VM, or is not a valid annotation type.
-     *
-     * @param exceptionOnMissingAnnotationClass if true, throw
-     * TypeNotPresentException if a referenced annotation type is not
-     * available at runtime
-     */
-    private static Annotation parseAnnotation(ByteBuffer buf,
-                                              ConstantPool constPool,
-                                              Class container,
-                                             boolean exceptionOnMissingAnnotationClass) {
-        int typeIndex = buf.getShort() & 0xFFFF;
-        Class annotationClass = null;
-       String sig = "[unknown]";
-        try {
-            try {
-                sig = constPool.getUTF8At(typeIndex);
-                annotationClass = parseSig(sig, container);
-            } catch (IllegalArgumentException ex) {
-                // support obsolete early jsr175 format class files
-                annotationClass = constPool.getClassAt(typeIndex);
-            }
-        } catch (NoClassDefFoundError e) {
-           if (exceptionOnMissingAnnotationClass)
-               // note: at this point sig is "[unknown]" or VM-style
-               // name instead of a binary name
-               throw new TypeNotPresentException(sig, e);
-            skipAnnotation(buf, false);
-            return null;
-        }
-       catch (TypeNotPresentException e) {
-           if (exceptionOnMissingAnnotationClass)
-               throw e;
-            skipAnnotation(buf, false);
-            return null;
-        }
-        AnnotationType type = null;
-        try {
-            type = AnnotationType.getInstance(annotationClass);
-        } catch (IllegalArgumentException e) {
-            skipAnnotation(buf, false);
-            return null;
-        }
-
-        Map<String, Class> memberTypes = type.memberTypes();
-        Map<String, Object> memberValues =
-            new LinkedHashMap<String, Object>(type.memberDefaults());
-
-        int numMembers = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < numMembers; i++) {
-            int memberNameIndex = buf.getShort() & 0xFFFF;
-            String memberName = constPool.getUTF8At(memberNameIndex);
-            Class memberType = memberTypes.get(memberName);
-
-            if (memberType == null) {
-                // Member is no longer present in annotation type; ignore it
-                skipMemberValue(buf);
-            } else {
-                Object value = parseMemberValue(memberType, buf, constPool, container);
-                if (value instanceof AnnotationTypeMismatchExceptionProxy)
-                    ((AnnotationTypeMismatchExceptionProxy) value).
-                        setMember(type.members().get(memberName));
-                memberValues.put(memberName, value);
-            }
-        }
-        return annotationForMap(annotationClass, memberValues);
-    }
-
-    /**
-     * Returns an annotation of the given type backed by the given
-     * member -> value map.
-     */
-    public static Annotation annotationForMap(
-        Class type, Map<String, Object> memberValues)
-    {
-        return (Annotation) Proxy.newProxyInstance(
-            type.getClassLoader(), new Class[] { type },
-            new AnnotationInvocationHandler(type, memberValues));
-    }
-
-    /**
-     * Parses the annotation member value at the current position in the
-     * specified byte buffer, resolving constant references in the specified
-     * constant pool.  The cursor of the byte buffer must point to a
-     * "member_value structure" as described in the
-     * RuntimeVisibleAnnotations_attribute:
-     *
-     *  member_value {
-     *    u1 tag;
-     *    union {
-     *       u2   const_value_index;
-     *       {
-     *           u2   type_name_index;
-     *           u2   const_name_index;
-     *       } enum_const_value;
-     *       u2   class_info_index;
-     *       annotation annotation_value; 
-     *       {
-     *           u2    num_values;
-     *           member_value values[num_values];
-     *       } array_value;
-     *    } value;
-     * }
-     *
-     * The member must be of the indicated type. If it is not, this
-     * method returns an AnnotationTypeMismatchExceptionProxy.
-     */
-    public static Object parseMemberValue(Class memberType, ByteBuffer buf,
-                                          ConstantPool constPool,
-                                          Class container) {
-        Object result = null;
-        int tag = buf.get();
-        switch(tag) {
-          case 'e':
-              return parseEnumValue(memberType, buf, constPool, container);
-          case 'c':
-              result = parseClassValue(buf, constPool, container);
-              break;
-          case '@':
-              result = parseAnnotation(buf, constPool, container, true);
-              break;
-          case '[':
-              return parseArray(memberType, buf, constPool, container);
-          default:
-              result = parseConst(tag, buf, constPool);
-        }
-
-        if (!(result instanceof ExceptionProxy) &&
-            !memberType.isInstance(result))
-            result = new AnnotationTypeMismatchExceptionProxy(
-                result.getClass() + "[" + result + "]");
-        return result;
-    }
-
-    /**
-     * Parses the primitive or String annotation member value indicated by 
-     * the specified tag byte at the current position in the specified byte
-     * buffer, resolving constant reference in the specified constant pool.
-     * The cursor of the byte buffer must point to an annotation member value
-     * of the type indicated by the specified tag, as described in the
-     * RuntimeVisibleAnnotations_attribute:
-     *
-     *       u2   const_value_index;
-     */
-    private static Object parseConst(int tag,
-                                     ByteBuffer buf, ConstantPool constPool) {
-        int constIndex = buf.getShort() & 0xFFFF;
-        switch(tag) {
-          case 'B':
-            return Byte.valueOf((byte) constPool.getIntAt(constIndex));
-          case 'C':
-            return Character.valueOf((char) constPool.getIntAt(constIndex));
-          case 'D':
-            return Double.valueOf(constPool.getDoubleAt(constIndex));
-          case 'F':
-            return Float.valueOf(constPool.getFloatAt(constIndex));
-          case 'I':
-            return Integer.valueOf(constPool.getIntAt(constIndex));
-          case 'J':
-            return Long.valueOf(constPool.getLongAt(constIndex));
-          case 'S':
-            return Short.valueOf((short) constPool.getIntAt(constIndex));
-          case 'Z':
-            return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
-          case 's':
-            return constPool.getUTF8At(constIndex);
-          default:
-            throw new AnnotationFormatError(
-                "Invalid member-value tag in annotation: " + tag);
-        }
-    }
-
-    /**
-     * Parses the Class member value at the current position in the
-     * specified byte buffer, resolving constant references in the specified
-     * constant pool.  The cursor of the byte buffer must point to a "class
-     * info index" as described in the RuntimeVisibleAnnotations_attribute:
-     *
-     *       u2   class_info_index;
-     */
-    private static Object parseClassValue(ByteBuffer buf,
-                                          ConstantPool constPool,
-                                          Class container) {
-        int classIndex = buf.getShort() & 0xFFFF;
-        try {
-            try {
-                String sig = constPool.getUTF8At(classIndex);
-                return parseSig(sig, container);
-            } catch (IllegalArgumentException ex) {
-                // support obsolete early jsr175 format class files
-                return constPool.getClassAt(classIndex);
-            }
-        } catch (NoClassDefFoundError e) {
-            return new TypeNotPresentExceptionProxy("[unknown]", e);
-        }
-        catch (TypeNotPresentException e) {
-            return new TypeNotPresentExceptionProxy(e.typeName(), e.getCause());
-        }
-    }
-
-    /**
-     * Parses a return type signature and returns the according Class object.
-     */
-    private static Class<?> parseSig(String sig, Class container) {
-        if (sig.equals("V")) {
-            return void.class;
-        }
-        else {
-            return toClass(new FieldSignatureParser(container, sig).getFieldType());
-        }
-    }
-
-    static Class<?> toClass(Type o) {
-        if (o instanceof GenericArrayType)
-            return Array.newInstance(toClass(((GenericArrayType)o).getGenericComponentType()),
-                                     0)
-                .getClass();
-        return (Class<?>)o;
-    }
-
-    /**
-     * Parses the enum constant member value at the current position in the
-     * specified byte buffer, resolving constant references in the specified
-     * constant pool.  The cursor of the byte buffer must point to a
-     * "enum_const_value structure" as described in the
-     * RuntimeVisibleAnnotations_attribute:
-     *
-     *       {
-     *           u2   type_name_index;
-     *           u2   const_name_index;
-     *       } enum_const_value;
-     */
-    private static Object parseEnumValue(Class enumType, ByteBuffer buf,
-                                         ConstantPool constPool,
-                                         Class container) {
-        int typeNameIndex = buf.getShort() & 0xFFFF;
-        String typeName  = constPool.getUTF8At(typeNameIndex);
-        int constNameIndex = buf.getShort() & 0xFFFF;
-        String constName = constPool.getUTF8At(constNameIndex);
-
-        if (!typeName.endsWith(";")) {
-            // support now-obsolete early jsr175-format class files.
-            if (!enumType.getName().equals(typeName))
-            return new AnnotationTypeMismatchExceptionProxy(
-                typeName + "." + constName);
-        } else if (enumType != parseSig(typeName, container)) {
-            return new AnnotationTypeMismatchExceptionProxy(
-                typeName + "." + constName);
-        }
-
-        try {
-            return  Enum.valueOf(enumType, constName);
-        } catch(IllegalArgumentException e) {
-            return new EnumConstantNotPresentExceptionProxy(
-                (Class<? extends Enum>)enumType, constName);
-        }
-    }
-
-    /**
-     * Parses the array value at the current position in the specified byte
-     * buffer, resolving constant references in the specified constant pool.
-     * The cursor of the byte buffer must point to an array value struct
-     * as specified in the RuntimeVisibleAnnotations_attribute:
-     *
-     *       {
-     *           u2    num_values;
-     *           member_value values[num_values];
-     *       } array_value;
-     *
-     * If the array values do not match arrayType, an
-     * AnnotationTypeMismatchExceptionProxy will be returned.
-     */
-    private static Object parseArray(Class arrayType,
-                                     ByteBuffer buf,
-                                     ConstantPool constPool,
-                                     Class container) {
-        int length = buf.getShort() & 0xFFFF;  // Number of array components
-        Class componentType = arrayType.getComponentType();
-
-        if (componentType == byte.class) {
-            return parseByteArray(length, buf, constPool); 
-        } else if (componentType == char.class) {
-            return parseCharArray(length, buf, constPool);
-        } else if (componentType == double.class) {
-            return parseDoubleArray(length, buf, constPool);
-        } else if (componentType == float.class) {
-            return parseFloatArray(length, buf, constPool);
-        } else if (componentType == int.class) {
-            return parseIntArray(length, buf, constPool);
-        } else if (componentType == long.class) {
-            return parseLongArray(length, buf, constPool);
-        } else if (componentType == short.class) {
-            return parseShortArray(length, buf, constPool);
-        } else if (componentType == boolean.class) {
-            return parseBooleanArray(length, buf, constPool);
-        } else if (componentType == String.class) {
-            return parseStringArray(length, buf, constPool);
-        } else if (componentType == Class.class) {
-            return parseClassArray(length, buf, constPool, container);
-        } else if (componentType.isEnum()) {
-            return parseEnumArray(length, componentType, buf,
-                                  constPool, container);
-        } else {
-            assert componentType.isAnnotation();
-            return parseAnnotationArray(length, componentType, buf,
-                                        constPool, container);
-        }
-    }
-
-    private static Object parseByteArray(int length,
-                                  ByteBuffer buf, ConstantPool constPool) {
-        byte[] result = new byte[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'B') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (byte) constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseCharArray(int length,
-                                  ByteBuffer buf, ConstantPool constPool) {
-        char[] result = new char[length];
-        boolean typeMismatch = false;
-        byte tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'C') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (char) constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseDoubleArray(int length,
-                                    ByteBuffer buf, ConstantPool constPool) {
-        double[] result = new  double[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'D') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getDoubleAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseFloatArray(int length,
-                                   ByteBuffer buf, ConstantPool constPool) {
-        float[] result = new float[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'F') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getFloatAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseIntArray(int length,
-                                 ByteBuffer buf, ConstantPool constPool) {
-        int[] result = new  int[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'I') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-    
-    private static Object parseLongArray(int length,
-                                  ByteBuffer buf, ConstantPool constPool) {
-        long[] result = new long[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'J') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getLongAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseShortArray(int length,
-                                   ByteBuffer buf, ConstantPool constPool) {
-        short[] result = new short[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'S') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (short) constPool.getIntAt(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseBooleanArray(int length,
-                                     ByteBuffer buf, ConstantPool constPool) {
-        boolean[] result = new boolean[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'Z') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = (constPool.getIntAt(index) != 0);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseStringArray(int length,
-                                    ByteBuffer buf,  ConstantPool constPool) {
-        String[] result = new String[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 's') {
-                int index = buf.getShort() & 0xFFFF;
-                result[i] = constPool.getUTF8At(index);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseClassArray(int length,
-                                          ByteBuffer buf,
-                                          ConstantPool constPool,
-                                          Class container) {
-        Object[] result = new Class[length];
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'c') {
-                result[i] = parseClassValue(buf, constPool, container);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseEnumArray(int length, Class enumType,
-                                         ByteBuffer buf,
-                                         ConstantPool constPool,
-                                         Class container) {
-        Object[] result = (Object[]) Array.newInstance(enumType, length);
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == 'e') {
-                result[i] = parseEnumValue(enumType, buf, constPool, container);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    private static Object parseAnnotationArray(int length,
-                                               Class annotationType,
-                                               ByteBuffer buf,
-                                               ConstantPool constPool,
-                                               Class container) {
-        Object[] result = (Object[]) Array.newInstance(annotationType, length);
-        boolean typeMismatch = false;
-        int tag = 0;
-
-        for (int i = 0; i < length; i++) {
-            tag = buf.get();
-            if (tag == '@') {
-                result[i] = parseAnnotation(buf, constPool, container, true);
-            } else {
-                skipMemberValue(tag, buf);
-                typeMismatch = true;
-            }
-        }
-        return typeMismatch ? exceptionProxy(tag) : result;
-    }
-
-    /**
-     * Return an appropriate exception proxy for a mismatching array
-     * annotation where the erroneous array has the specified tag.
-     */
-    private static ExceptionProxy exceptionProxy(int tag) {
-        return new AnnotationTypeMismatchExceptionProxy(
-            "Array with component tag: " + tag);
-    }
-
-    /**
-     * Skips the annotation at the current position in the specified
-     * byte buffer.  The cursor of the byte buffer must point to 
-     * an "annotation structure" OR two bytes into an annotation
-     * structure (i.e., after the type index).
-     * 
-     * @parameter complete true if the byte buffer points to the beginning
-     *     of an annotation structure (rather than two bytes in).
-     */
-    private static void skipAnnotation(ByteBuffer buf, boolean complete) {
-        if (complete)
-            buf.getShort();   // Skip type index
-        int numMembers = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < numMembers; i++) {
-            buf.getShort();   // Skip memberNameIndex
-            skipMemberValue(buf);
-        }
-    }
-
-    /**
-     * Skips the annotation member value at the current position in the
-     * specified byte buffer.  The cursor of the byte buffer must point to a
-     * "member_value structure."
-     */
-    private static void skipMemberValue(ByteBuffer buf) {
-        int tag = buf.get();
-        skipMemberValue(tag, buf);
-    }
-
-    /**
-     * Skips the annotation member value at the current position in the
-     * specified byte buffer.  The cursor of the byte buffer must point
-     * immediately after the tag in a "member_value structure."
-     */
-    private static void skipMemberValue(int tag, ByteBuffer buf) {
-        switch(tag) {
-          case 'e': // Enum value
-            buf.getInt();  // (Two shorts, actually.)
-            break;
-          case '@':
-            skipAnnotation(buf, true);
-            break;
-          case '[':
-            skipArray(buf);
-            break;
-          default:
-            // Class, primitive, or String
-            buf.getShort();
-        }
-    }
-
-    /**
-     * Skips the array value at the current position in the specified byte
-     * buffer.  The cursor of the byte buffer must point to an array value
-     * struct.
-     */
-    private static void skipArray(ByteBuffer buf) {
-        int length = buf.getShort() & 0xFFFF;
-        for (int i = 0; i < length; i++)
-            skipMemberValue(buf);
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/AnnotationType.java b/src/classes/gnu/sun/reflect/annotation/AnnotationType.java
deleted file mode 100644 (file)
index ea559bb..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * Represents an annotation type at run time.  Used to type-check annotations
- * and apply member defaults.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class AnnotationType {
-    /**
-     * Annotation class -> AnnotationType mapping. This emulates
-     * sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and
-     * sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType() so
-     * this class can be used with gnu classpath.
-     *
-     * @author Mathias Panzenböck
-     */
-    private static Map<Class, AnnotationType> annotationTypes =
-        new HashMap<Class, AnnotationType>();
-
-    /**
-     * Member name -> type mapping. Note that primitive types
-     * are represented by the class objects for the corresponding wrapper
-     * types.  This matches the return value that must be used for a
-     * dynamic proxy, allowing for a simple isInstance test.
-     */
-    private final Map<String, Class> memberTypes = new HashMap<String,Class>();
-
-    /**
-     * Member name -> default value mapping.
-     */
-    private final Map<String, Object> memberDefaults =
-        new HashMap<String, Object>();
-
-    /**
-     * Member name -> Method object mapping. This (and its assoicated
-     * accessor) are used only to generate AnnotationTypeMismatchExceptions.
-     */
-    private final Map<String, Method> members = new HashMap<String, Method>();
-
-    /**
-     * The retention policy for this annotation type.
-     */
-    private RetentionPolicy retention = RetentionPolicy.RUNTIME;;
-
-    /**
-     * Whether this annotation type is inherited.
-     */
-    private boolean inherited = false;
-
-    /**
-     * Returns an AnnotationType instance for the specified annotation type.
-     *
-     * @throw IllegalArgumentException if the specified class object for
-     *     does not represent a valid annotation type
-     */
-    public static synchronized AnnotationType getInstance(
-        Class annotationClass)
-    {
-        /*
-       AnnotationType result = sun.misc.SharedSecrets.getJavaLangAccess(). 
-            getAnnotationType(annotationClass); 
-        */
-       // emulating OpenJDKs SharedSecrets in GNU Classpath:
-       AnnotationType result = annotationTypes.get(annotationClass); 
-       if (result == null)
-            result = new AnnotationType((Class<?>) annotationClass);
-
-        return result;
-    }
-
-    /**
-     * Sole constructor.
-     *
-     * @param annotationClass the class object for the annotation type
-     * @throw IllegalArgumentException if the specified class object for
-     *     does not represent a valid annotation type
-     */
-    private AnnotationType(final Class<?> annotationClass) {
-        if (!annotationClass.isAnnotation())
-            throw new IllegalArgumentException("Not an annotation type");
-
-       Method[] methods =      
-           AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
-               public Method[] run() {
-                   // Initialize memberTypes and defaultValues
-                   return annotationClass.getDeclaredMethods();
-               }
-           });
-
-
-       for (Method method :  methods) {
-           if (method.getParameterTypes().length != 0)
-               throw new IllegalArgumentException(method + " has params");
-           String name = method.getName();
-           Class type = method.getReturnType();
-           memberTypes.put(name, invocationHandlerReturnType(type));
-           members.put(name, method);
-                   
-           Object defaultValue = method.getDefaultValue();
-           if (defaultValue != null)
-               memberDefaults.put(name, defaultValue);
-
-           members.put(name, method);
-       }
-
-       /*
-        sun.misc.SharedSecrets.getJavaLangAccess(). 
-            setAnnotationType(annotationClass, this); 
-        */
-       // emulating OpenJDKs SharedSecrets in GNU Classpath:
-       annotationTypes.put(annotationClass, this);
-
-        // Initialize retention, & inherited fields.  Special treatment
-        // of the corresponding annotation types breaks infinite recursion.
-        if (annotationClass != Retention.class &&
-            annotationClass != Inherited.class) {
-            Retention ret = annotationClass.getAnnotation(Retention.class);
-            retention = (ret == null ? RetentionPolicy.CLASS : ret.value());
-            inherited = annotationClass.isAnnotationPresent(Inherited.class);
-        }
-    }
-
-    /**
-     * Returns the type that must be returned by the invocation handler
-     * of a dynamic proxy in order to have the dynamic proxy return
-     * the specified type (which is assumed to be a legal member type
-     * for an annotation).
-     */
-    public static Class invocationHandlerReturnType(Class type) {
-        // Translate primitives to wrappers
-        if (type == byte.class)
-            return Byte.class;
-        if (type == char.class)
-            return Character.class;
-        if (type == double.class)
-            return Double.class;
-        if (type == float.class)
-            return Float.class;
-        if (type == int.class)
-            return Integer.class;
-        if (type == long.class)
-            return Long.class;
-        if (type == short.class)
-            return Short.class;
-        if (type == boolean.class)
-            return Boolean.class;
-
-        // Otherwise, just return declared type
-        return type;
-    }
-
-    /**
-     * Returns member types for this annotation type
-     * (member name -> type mapping).
-     */
-    public Map<String, Class> memberTypes() {
-        return memberTypes;
-    }
-
-    /**
-     * Returns members of this annotation type
-     * (member name -> associated Method object mapping).
-     */
-    public Map<String, Method> members() {
-        return members;
-    }
-
-    /**
-     * Returns the default values for this annotation type
-     * (Member name -> default value mapping).
-     */
-    public Map<String, Object> memberDefaults() {
-        return memberDefaults;
-    }
-
-    /**
-     * Returns the retention policy for this annotation type.
-     */
-    public RetentionPolicy retention() {
-        return retention;
-    }
-
-    /**
-     * Returns true if this this annotation type is inherited.
-     */
-    public boolean isInherited() {
-        return inherited;
-    }
-
-    /**
-     * For debugging.
-     */
-    public String toString() {
-        StringBuffer s = new StringBuffer("Annotation Type:" + "\n");
-        s.append("   Member types: " + memberTypes + "\n");
-        s.append("   Member defaults: " + memberDefaults + "\n");
-        s.append("   Retention policy: " + retention + "\n");
-        s.append("   Inherited: " + inherited);
-        return s.toString();
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
deleted file mode 100644 (file)
index a7f434f..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-import java.lang.annotation.*;
-import java.lang.reflect.Method;
-
-/**
- * ExceptionProxy for AnnotationTypeMismatchException.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
-    private Method member;
-    private String foundType;
-
-    /**
-     * It turns out to be convenient to construct these proxies in
-     * two stages.  Since this is a private implementation class, we
-     * permit ourselves this liberty even though it's normally a very
-     * bad idea.
-     */
-    AnnotationTypeMismatchExceptionProxy(String foundType) {
-        this.foundType = foundType;
-    }
-
-    AnnotationTypeMismatchExceptionProxy setMember(Method member) {
-        this.member = member;
-        return this;
-    }
-
-    protected RuntimeException generateException() {
-        return new AnnotationTypeMismatchException(member, foundType);
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
deleted file mode 100644 (file)
index 6049a3f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-import java.lang.annotation.*;
-
-/**
- * ExceptionProxy for EnumConstantNotPresentException.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
-    Class<? extends Enum> enumType;
-    String constName;
-
-    public EnumConstantNotPresentExceptionProxy(Class<? extends Enum> enumType,
-                                                String constName) {
-        this.enumType = enumType;
-        this.constName = constName;
-    }
-
-    protected RuntimeException generateException() {
-        return new EnumConstantNotPresentException(enumType, constName);
-    }
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java
deleted file mode 100644 (file)
index e9cda0b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-
-/**
- * An instance of this class is stored in an AnnotationInvocationHandler's
- * "memberValues" map in lieu of a value for an annotation member that
- * cannot be returned due to some exceptional condition (typically some
- * form of illegal evolution of the annotation class).  The ExceptionProxy
- * instance describes the exception that the dynamic proxy should throw if
- * it is queried for this member.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public abstract class ExceptionProxy implements java.io.Serializable {
-    protected abstract RuntimeException generateException();
-}
diff --git a/src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java b/src/classes/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
deleted file mode 100644 (file)
index 22cab5d..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.reflect.annotation;
-import java.lang.annotation.*;
-
-/**
- * ExceptionProxy for TypeNotPresentException.
- *
- * @author  Josh Bloch
- * @since   1.5
- */
-public class TypeNotPresentExceptionProxy extends ExceptionProxy {
-    String typeName;
-    Throwable cause;
-
-    public TypeNotPresentExceptionProxy(String typeName, Throwable cause) {
-        this.typeName = typeName;
-        this.cause = cause;
-    }
-
-    protected RuntimeException generateException() {
-        return new TypeNotPresentException(typeName, cause);
-    }
-}
diff --git a/src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java b/src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java
new file mode 100644 (file)
index 0000000..434edd2
--- /dev/null
@@ -0,0 +1,135 @@
+/* VMStackWalker.java -- Reference implementation of VM hooks for stack access
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath;
+
+/**
+ * This class provides access to the classes on the Java stack
+ * for reflection and security purposes.
+ *
+ * <p>
+ * This class is only available to privileged code (i.e., code loaded
+ * by the bootstrap loader).
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @author Archie Cobbs
+ */
+public final class VMStackWalker
+{
+  /**
+   * Get a list of all the classes currently executing methods on the
+   * Java stack. <code>getClassContext()[0]</code> is the class associated
+   * with the currently executing method, i.e., the method that called
+   * <code>VMStackWalker.getClassContext()</code> (possibly through
+   * reflection). So you may need to pop off these stack frames from
+   * the top of the stack:
+   * <ul>
+   * <li><code>VMStackWalker.getClassContext()</code>
+   * <li><code>Method.invoke()</code>
+   * </ul>
+   *
+   * @return an array of the declaring classes of each stack frame
+   */
+  public static native Class[] getClassContext();
+
+  /**
+   * Get the class associated with the method invoking the method
+   * invoking this method, or <code>null</code> if the stack is not
+   * that deep (e.g., invoked via JNI invocation API). This method
+   * is an optimization for the expression <code>getClassContext()[1]</code>
+   * and should return the same result.
+   *
+   * <p>
+   * VM implementers are encouraged to provide a more efficient
+   * version of this method.
+   */
+//    public static Class getCallingClass()
+//    {
+//      Class[] ctx = getClassContext();
+//      if (ctx.length < 3)
+//        return null;
+//      return ctx[2];
+//    }
+  public static native Class getCallingClass();
+
+  /**
+   * Get the class loader associated with the Class returned by
+   * <code>getCallingClass()</code>, or <code>null</code> if no such class
+   * exists or it is the boot loader. This method is an optimization for the
+   * expression <code>VMStackWalker.getClassLoader(getClassContext()[1])</code>
+   * and should return the same result.
+   *
+   * <p>
+   * VM implementers are encouraged to provide a more efficient
+   * version of this method.
+   */
+//    public static ClassLoader getCallingClassLoader()
+//    {
+//      Class[] ctx = getClassContext();
+//      if (ctx.length < 3)
+//        return null;
+//      return getClassLoader(ctx[2]);
+//    }
+  public static native ClassLoader getCallingClassLoader();
+
+
+  /**
+   * Retrieve the class's ClassLoader, or <code>null</code> if loaded
+   * by the bootstrap loader. I.e., this should return the same thing
+   * as {@link java.lang.VMClass#getClassLoader}. This duplicate version
+   * is here to work around access permissions.
+   */
+//    public static native ClassLoader getClassLoader(Class cl);
+
+  /**
+   * Walk up the stack and return the first non-null class loader.
+   * If there aren't any non-null class loaders on the stack, return null.
+   */
+//   public static ClassLoader firstNonNullClassLoader()
+//   {
+//     Class[] stack = getClassContext();
+//     for (int i = 0; i < stack.length; i++)
+//       {
+//         ClassLoader loader = getClassLoader(stack[i]);
+//         if (loader != null)
+//           return loader;
+//       }
+//     return null;
+//   }
+    public static native ClassLoader firstNonNullClassLoader();
+}
diff --git a/src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java b/src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java
new file mode 100644 (file)
index 0000000..287a933
--- /dev/null
@@ -0,0 +1,98 @@
+/* VMSystemProperties.java -- Allow the VM to set System properties.
+   Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath;
+
+import java.util.Properties;
+
+class VMSystemProperties
+{
+    /**
+     * Get the system properties. This is done here, instead of in System,
+     * because of the bootstrap sequence. Note that the native code should
+     * not try to use the Java I/O classes yet, as they rely on the properties
+     * already existing. The only safe method to use to insert these default
+     * system properties is {@link Properties#setProperty(String, String)}.
+     *
+     * <p>These properties MUST include:
+     * <dl>
+     * <dt>java.version         <dd>Java version number
+     * <dt>java.vendor          <dd>Java vendor specific string
+     * <dt>java.vendor.url      <dd>Java vendor URL
+     * <dt>java.home            <dd>Java installation directory
+     * <dt>java.vm.specification.version <dd>VM Spec version
+     * <dt>java.vm.specification.vendor  <dd>VM Spec vendor
+     * <dt>java.vm.specification.name    <dd>VM Spec name
+     * <dt>java.vm.version      <dd>VM implementation version
+     * <dt>java.vm.vendor       <dd>VM implementation vendor
+     * <dt>java.vm.name         <dd>VM implementation name
+     * <dt>java.specification.version    <dd>Java Runtime Environment version
+     * <dt>java.specification.vendor     <dd>Java Runtime Environment vendor
+     * <dt>java.specification.name       <dd>Java Runtime Environment name
+     * <dt>java.class.version   <dd>Java class version number
+     * <dt>java.class.path      <dd>Java classpath
+     * <dt>java.library.path    <dd>Path for finding Java libraries
+     * <dt>java.io.tmpdir       <dd>Default temp file path
+     * <dt>java.compiler        <dd>Name of JIT to use
+     * <dt>java.ext.dirs        <dd>Java extension path
+     * <dt>os.name              <dd>Operating System Name
+     * <dt>os.arch              <dd>Operating System Architecture
+     * <dt>os.version           <dd>Operating System Version
+     * <dt>file.separator       <dd>File separator ("/" on Unix)
+     * <dt>path.separator       <dd>Path separator (":" on Unix)
+     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
+     * <dt>user.name            <dd>User account name
+     * <dt>user.home            <dd>User home directory
+     * <dt>user.dir             <dd>User's current working directory
+     * <dt>gnu.cpu.endian       <dd>"big" or "little"
+     * </dl>
+     *
+     * @param properties the Properties object to insert the system properties into
+     */
+    static native void preInit(Properties properties);
+
+    /**
+     * Here you get a chance to overwrite some of the properties set by
+     * the common SystemProperties code. For example, it might be
+     * a good idea to process the properties specified on the command
+     * line here.
+     */
+//     static void postInit(Properties properties)
+//     {
+//     }
+    static native void postInit(Properties properties);
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java b/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java
new file mode 100644 (file)
index 0000000..978a204
--- /dev/null
@@ -0,0 +1,1084 @@
+/* ClasspathStringBuffer.java -- Growable strings without locking or copying
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang;
+
+import java.io.Serializable;
+
+/**
+ * This class is based on java.lang.AbstractStringBuffer but
+ * without the copying of the string by toString.
+ * If you modify this, please consider also modifying that code.
+ * This code is not thread-safe; limit its use to internal use within
+ * methods.
+ */
+public final class CPStringBuilder
+  implements Serializable, CharSequence, Appendable
+{
+
+  /**
+   * Index of next available character (and thus the size of the current
+   * string contents).  Note that this has permissions set this way so that
+   * String can get the value.
+   *
+   * @serial the number of characters in the buffer
+   */
+  int count;
+
+  /**
+   * The buffer.  Note that this has permissions set this way so that String
+   * can get the value.
+   *
+   * @serial the buffer
+   */
+  char[] value;
+
+  /**
+   * The default capacity of a buffer.
+   */
+  private static final int DEFAULT_CAPACITY = 16;
+
+  /**
+   * Create a new CPStringBuilder with default capacity 16.
+   */
+  public CPStringBuilder()
+  {
+    this(DEFAULT_CAPACITY);
+  }
+
+  /**
+   * Create an empty <code>StringBuffer</code> with the specified initial
+   * capacity.
+   *
+   * @param capacity the initial capacity
+   * @throws NegativeArraySizeException if capacity is negative
+   */
+  public CPStringBuilder(int capacity)
+  {
+    value = new char[capacity];
+  }
+
+  /**
+   * Create a new <code>StringBuffer</code> with the characters in the
+   * specified <code>String</code>. Initial capacity will be the size of the
+   * String plus 16.
+   *
+   * @param str the <code>String</code> to convert
+   * @throws NullPointerException if str is null
+   */
+  public CPStringBuilder(String str)
+  {
+    count = str.length();
+    value = new char[count + DEFAULT_CAPACITY];
+    str.getChars(0, count, value, 0);
+  }
+
+  /**
+   * Create a new <code>StringBuffer</code> with the characters in the
+   * specified <code>CharSequence</code>. Initial capacity will be the
+   * length of the sequence plus 16; if the sequence reports a length
+   * less than or equal to 0, then the initial capacity will be 16.
+   *
+   * @param seq the initializing <code>CharSequence</code>
+   * @throws NullPointerException if str is null
+   * @since 1.5
+   */
+  public CPStringBuilder(CharSequence seq)
+  {
+    int len = seq.length();
+    count = len <= 0 ? 0 : len;
+    value = new char[count + DEFAULT_CAPACITY];
+    for (int i = 0; i < len; ++i)
+      value[i] = seq.charAt(i);
+  }
+
+  /**
+   * Increase the capacity of this <code>StringBuffer</code>. This will
+   * ensure that an expensive growing operation will not occur until
+   * <code>minimumCapacity</code> is reached. The buffer is grown to the
+   * larger of <code>minimumCapacity</code> and
+   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
+   *
+   * @param minimumCapacity the new capacity
+   * @see #capacity()
+   */
+  public void ensureCapacity(int minimumCapacity)
+  {
+    ensureCapacity_unsynchronized(minimumCapacity);
+  }
+
+  /**
+   * Set the length of this StringBuffer. If the new length is greater than
+   * the current length, all the new characters are set to '\0'. If the new
+   * length is less than the current length, the first <code>newLength</code>
+   * characters of the old array will be preserved, and the remaining
+   * characters are truncated.
+   *
+   * @param newLength the new length
+   * @throws IndexOutOfBoundsException if the new length is negative
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @see #length()
+   */
+  public void setLength(int newLength)
+  {
+    if (newLength < 0)
+      throw new StringIndexOutOfBoundsException(newLength);
+
+    int valueLength = value.length;
+
+    /* Always call ensureCapacity_unsynchronized in order to preserve
+       copy-on-write semantics.  */
+    ensureCapacity_unsynchronized(newLength);
+
+    if (newLength < valueLength)
+      {
+        /* If the StringBuffer's value just grew, then we know that
+           value is newly allocated and the region between count and
+           newLength is filled with '\0'.  */
+       count = newLength;
+      }
+    else
+      {
+       /* The StringBuffer's value doesn't need to grow.  However,
+          we should clear out any cruft that may exist.  */
+       while (count < newLength)
+          value[count++] = '\0';
+      }
+  }
+
+  /**
+   * Get the character at the specified index.
+   *
+   * @param index the index of the character to get, starting at 0
+   * @return the character at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public char charAt(int index)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    return value[index];
+  }
+
+  /**
+   * Get the code point at the specified index.  This is like #charAt(int),
+   * but if the character is the start of a surrogate pair, and the
+   * following character completes the pair, then the corresponding
+   * supplementary code point is returned.
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   * @since 1.5
+   */
+  public int codePointAt(int index)
+  {
+    return Character.codePointAt(value, index, count);
+  }
+
+  /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(int), but checks the characters at <code>index-1</code> and
+   * <code>index-2</code> to see if they form a supplementary code point.
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   * @since 1.5
+   */
+  public int codePointBefore(int index)
+  {
+    // Character.codePointBefore() doesn't perform this check.  We
+    // could use the CharSequence overload, but this is just as easy.
+    if (index >= count)
+      throw new IndexOutOfBoundsException();
+    return Character.codePointBefore(value, index, 1);
+  }
+
+  /**
+   * Get the specified array of characters. <code>srcOffset - srcEnd</code>
+   * characters will be copied into the array you pass in.
+   *
+   * @param srcOffset the index to start copying from (inclusive)
+   * @param srcEnd the index to stop copying from (exclusive)
+   * @param dst the array to copy into
+   * @param dstOffset the index to start copying into
+   * @throws NullPointerException if dst is null
+   * @throws IndexOutOfBoundsException if any source or target indices are
+   *         out of range (while unspecified, source problems cause a
+   *         StringIndexOutOfBoundsException, and dest problems cause an
+   *         ArrayIndexOutOfBoundsException)
+   * @see System#arraycopy(Object, int, Object, int, int)
+   */
+  public void getChars(int srcOffset, int srcEnd,
+                      char[] dst, int dstOffset)
+  {
+    if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
+      throw new StringIndexOutOfBoundsException();
+    System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
+  }
+
+  /**
+   * Set the character at the specified index.
+   *
+   * @param index the index of the character to set starting at 0
+   * @param ch the value to set that character to
+   * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public void setCharAt(int index, char ch)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity_unsynchronized(count);
+    value[index] = ch;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param obj the <code>Object</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(Object)
+   * @see #append(String)
+   */
+  public CPStringBuilder append(Object obj)
+  {
+    return append(String.valueOf(obj));
+  }
+
+  /**
+   * Append the <code>String</code> to this <code>StringBuffer</code>. If
+   * str is null, the String "null" is appended.
+   *
+   * @param str the <code>String</code> to append
+   * @return this <code>StringBuffer</code>
+   */
+  public CPStringBuilder append(String str)
+  {
+    if (str == null)
+      str = "null";
+    int len = str.length();
+    ensureCapacity_unsynchronized(count + len);
+    str.getChars(0, len, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Append the <code>StringBuilder</code> value of the argument to this
+   * <code>StringBuilder</code>. This behaves the same as
+   * <code>append((Object) stringBuffer)</code>, except it is more efficient.
+   *
+   * @param stringBuffer the <code>StringBuilder</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see #append(Object)
+   */
+  public CPStringBuilder append(StringBuffer stringBuffer)
+  {
+    if (stringBuffer == null)
+      return append("null");
+    synchronized (stringBuffer)
+      {
+       int len = stringBuffer.length();
+       ensureCapacity(count + len);
+       stringBuffer.getChars(0, len, value, count);
+       count += len;
+      }
+    return this;
+  }
+
+  /**
+   * Append the <code>char</code> array to this <code>StringBuffer</code>.
+   * This is similar (but more efficient) than
+   * <code>append(new String(data))</code>, except in the case of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @see #append(char[], int, int)
+   */
+  public CPStringBuilder append(char[] data)
+  {
+    return append(data, 0, data.length);
+  }
+
+  /**
+   * Append part of the <code>char</code> array to this
+   * <code>StringBuffer</code>. This is similar (but more efficient) than
+   * <code>append(new String(data, offset, count))</code>, except in the case
+   * of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @param offset the start location in <code>str</code>
+   * @param count the number of characters to get from <code>str</code>
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws IndexOutOfBoundsException if offset or count is out of range
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public CPStringBuilder append(char[] data, int offset, int count)
+  {
+    if (offset < 0 || count < 0 || offset > data.length - count)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity_unsynchronized(this.count + count);
+    System.arraycopy(data, offset, value, this.count, count);
+    this.count += count;
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param bool the <code>boolean</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(boolean)
+   */
+  public CPStringBuilder append(boolean bool)
+  {
+    return append(bool ? "true" : "false");
+  }
+
+  /**
+   * Append the <code>char</code> to this <code>StringBuffer</code>.
+   *
+   * @param ch the <code>char</code> to append
+   * @return this <code>StringBuffer</code>
+   */
+  public CPStringBuilder append(char ch)
+  {
+    ensureCapacity_unsynchronized(count + 1);
+    value[count++] = ch;
+    return this;
+  }
+
+  /**
+   * Append the characters in the <code>CharSequence</code> to this
+   * buffer.
+   *
+   * @param seq the <code>CharSequence</code> providing the characters
+   * @return this <code>StringBuffer</code>
+   * @since 1.5
+   */
+  public CPStringBuilder append(CharSequence seq)
+  {
+    return append(seq, 0, seq.length());
+  }
+
+  /**
+   * Append some characters from the <code>CharSequence</code> to this
+   * buffer.  If the argument is null, the four characters "null" are
+   * appended.
+   *
+   * @param seq the <code>CharSequence</code> providing the characters
+   * @param start the starting index
+   * @param end one past the final index
+   * @return this <code>StringBuffer</code>
+   * @since 1.5
+   */
+  public CPStringBuilder append(CharSequence seq, int start, int end)
+  {
+    if (seq == null)
+      return append("null");
+    if (end - start > 0)
+      {
+       ensureCapacity_unsynchronized(count + end - start);
+       for (; start < end; ++start)
+         value[count++] = seq.charAt(start);
+      }
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param inum the <code>int</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(int)
+   */
+  // This is native in libgcj, for efficiency.
+  public CPStringBuilder append(int inum)
+  {
+    return append(String.valueOf(inum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param lnum the <code>long</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(long)
+   */
+  public CPStringBuilder append(long lnum)
+  {
+    return append(Long.toString(lnum, 10));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param fnum the <code>float</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(float)
+   */
+  public CPStringBuilder append(float fnum)
+  {
+    return append(Float.toString(fnum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param dnum the <code>double</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(double)
+   */
+  public CPStringBuilder append(double dnum)
+  {
+    return append(Double.toString(dnum));
+  }
+
+  /**
+   * Append the code point to this <code>StringBuffer</code>.
+   * This is like #append(char), but will append two characters
+   * if a supplementary code point is given.
+   *
+   * @param code the code point to append
+   * @return this <code>StringBuffer</code>
+   * @see Character#toChars(int, char[], int)
+   * @since 1.5
+   */
+  public CPStringBuilder appendCodePoint(int code)
+  {
+    int len = Character.charCount(code);
+    ensureCapacity_unsynchronized(count + len);
+    Character.toChars(code, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Delete characters from this <code>StringBuffer</code>.
+   * <code>delete(10, 12)</code> will delete 10 and 11, but not 12. It is
+   * harmless for end to be larger than length().
+   *
+   * @param start the first character to delete
+   * @param end the index after the last character to delete
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   * @since 1.2
+   */
+  public CPStringBuilder delete(int start, int end)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+    if (end > count)
+      end = count;
+    ensureCapacity_unsynchronized(count);
+    if (count - end != 0)
+      System.arraycopy(value, end, value, start, count - end);
+    count -= end - start;
+    return this;
+  }
+
+  /**
+   * Delete a character from this <code>StringBuffer</code>.
+   *
+   * @param index the index of the character to delete
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if index is out of bounds
+   * @since 1.2
+   */
+  public CPStringBuilder deleteCharAt(int index)
+  {
+    return delete(index, index + 1);
+  }
+
+  /**
+   * Replace characters between index <code>start</code> (inclusive) and
+   * <code>end</code> (exclusive) with <code>str</code>. If <code>end</code>
+   * is larger than the size of this StringBuffer, all characters after
+   * <code>start</code> are replaced.
+   *
+   * @param start the beginning index of characters to delete (inclusive)
+   * @param end the ending index of characters to delete (exclusive)
+   * @param str the new <code>String</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   * @throws NullPointerException if str is null
+   * @since 1.2
+   */
+  public CPStringBuilder replace(int start, int end, String str)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+
+    int len = str.length();
+    // Calculate the difference in 'count' after the replace.
+    int delta = len - (end > count ? count : end) + start;
+    ensureCapacity_unsynchronized(count + delta);
+
+    if (delta != 0 && end < count)
+      System.arraycopy(value, end, value, end + delta, count - end);
+
+    str.getChars(0, len, value, start);
+    count += delta;
+    return this;
+  }
+
+  /**
+   * Insert a subarray of the <code>char[]</code> argument into this
+   * <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>char[]</code> to insert
+   * @param str_offset the index in <code>str</code> to start inserting from
+   * @param len the number of characters to insert
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if any index is out of bounds
+   * @since 1.2
+   */
+  public CPStringBuilder insert(int offset, char[] str, int str_offset, int len)
+  {
+    if (offset < 0 || offset > count || len < 0
+        || str_offset < 0 || str_offset > str.length - len)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity_unsynchronized(count + len);
+    System.arraycopy(value, offset, value, offset + len, count - offset);
+    System.arraycopy(str, str_offset, value, offset, len);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param obj the <code>Object</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @exception StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(Object)
+   */
+  public CPStringBuilder insert(int offset, Object obj)
+  {
+    return insert(offset, obj == null ? "null" : obj.toString());
+  }
+
+  /**
+   * Insert the <code>String</code> argument into this
+   * <code>StringBuffer</code>. If str is null, the String "null" is used
+   * instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>String</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public CPStringBuilder insert(int offset, String str)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    if (str == null)
+      str = "null";
+    int len = str.length();
+    ensureCapacity_unsynchronized(count + len);
+    System.arraycopy(value, offset, value, offset + len, count - offset);
+    str.getChars(0, len, value, offset);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>CharSequence</code> argument into this
+   * <code>StringBuffer</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws IndexOutOfBoundsException if offset is out of bounds
+   * @since 1.5
+   */
+  public CPStringBuilder insert(int offset, CharSequence sequence)
+  {
+    if (sequence == null)
+      sequence = "null";
+    return insert(offset, sequence, 0, sequence.length());
+  }
+
+  /**
+   * Insert a subsequence of the <code>CharSequence</code> argument into this
+   * <code>StringBuffer</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @param start the starting index of the subsequence
+   * @param end one past the ending index of the subsequence
+   * @return this <code>StringBuffer</code>
+   * @throws IndexOutOfBoundsException if offset, start,
+   * or end are out of bounds
+   * @since 1.5
+   */
+  public CPStringBuilder insert(int offset, CharSequence sequence, int start, int end)
+  {
+    if (sequence == null)
+      sequence = "null";
+    if (start < 0 || end < 0 || start > end || end > sequence.length())
+      throw new IndexOutOfBoundsException();
+    int len = end - start;
+    ensureCapacity_unsynchronized(count + len);
+    System.arraycopy(value, offset, value, offset + len, count - offset);
+    for (int i = start; i < end; ++i)
+      value[offset++] = sequence.charAt(i);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>char[]</code> argument into this
+   * <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param data the <code>char[]</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>data</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see #insert(int, char[], int, int)
+   */
+  public CPStringBuilder insert(int offset, char[] data)
+  {
+    return insert(offset, data, 0, data.length);
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param bool the <code>boolean</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(boolean)
+   */
+  public CPStringBuilder insert(int offset, boolean bool)
+  {
+    return insert(offset, bool ? "true" : "false");
+  }
+
+  /**
+   * Insert the <code>char</code> argument into this <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param ch the <code>char</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public CPStringBuilder insert(int offset, char ch)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    ensureCapacity_unsynchronized(count + 1);
+    System.arraycopy(value, offset, value, offset + 1, count - offset);
+    value[offset] = ch;
+    count++;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param inum the <code>int</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(int)
+   */
+  public CPStringBuilder insert(int offset, int inum)
+  {
+    return insert(offset, String.valueOf(inum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param lnum the <code>long</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(long)
+   */
+  public CPStringBuilder insert(int offset, long lnum)
+  {
+    return insert(offset, Long.toString(lnum, 10));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param fnum the <code>float</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(float)
+   */
+  public CPStringBuilder insert(int offset, float fnum)
+  {
+    return insert(offset, Float.toString(fnum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param dnum the <code>double</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(double)
+   */
+  public CPStringBuilder insert(int offset, double dnum)
+  {
+    return insert(offset, Double.toString(dnum));
+  }
+
+  /**
+   * Finds the first instance of a substring in this StringBuilder.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #indexOf(String, int)
+   */
+  public int indexOf(String str)
+  {
+    return indexOf(str, 0);
+  }
+
+  /**
+   * Finds the first instance of a String in this StringBuffer, starting at
+   * a given index.  If starting index is less than 0, the search starts at
+   * the beginning of this String.  If the starting index is greater than the
+   * length of this String, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @since 1.4
+   */
+  public int indexOf(String str, int fromIndex)
+  {
+    if (fromIndex < 0)
+      fromIndex = 0;
+    int olength = str.length();
+    int limit = count - olength;
+    String s = VMCPStringBuilder.toString(value, 0, count);
+    for (; fromIndex <= limit; ++fromIndex)
+      if (s.regionMatches(fromIndex, str, 0, olength))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Finds the last instance of a substring in this StringBuffer.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #lastIndexOf(String, int)
+   * @since 1.4
+   */
+  public int lastIndexOf(String str)
+  {
+    return lastIndexOf(str, count - str.length());
+  }
+
+  /**
+   * Finds the last instance of a String in this StringBuffer, starting at a
+   * given index.  If starting index is greater than the maximum valid index,
+   * then the search begins at the end of this String.  If the starting index
+   * is less than zero, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @since 1.4
+   */
+  public int lastIndexOf(String str, int fromIndex)
+  {
+    fromIndex = Math.min(fromIndex, count - str.length());
+    String s = VMCPStringBuilder.toString(value, 0, count);
+    int olength = str.length();
+    for ( ; fromIndex >= 0; fromIndex--)
+      if (s.regionMatches(fromIndex, str, 0, olength))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Reverse the characters in this StringBuffer. The same sequence of
+   * characters exists, but in the reverse index ordering.
+   *
+   * @return this <code>StringBuffer</code>
+   */
+  public CPStringBuilder reverse()
+  {
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity_unsynchronized(count);
+    for (int i = count >> 1, j = count - i; --i >= 0; ++j)
+      {
+        char c = value[i];
+        value[i] = value[j];
+        value[j] = c;
+      }
+    return this;
+  }
+
+  /**
+   * This may reduce the amount of memory used by the StringBuffer,
+   * by resizing the internal array to remove unused space.  However,
+   * this method is not required to resize, so this behavior cannot
+   * be relied upon.
+   * @since 1.5
+   */
+  public void trimToSize()
+  {
+    int wouldSave = value.length - count;
+    // Some random heuristics: if we save less than 20 characters, who
+    // cares.
+    if (wouldSave < 20)
+      return;
+    // If we save more than 200 characters, shrink.
+    // If we save more than 1/4 of the buffer, shrink.
+    if (wouldSave > 200 || wouldSave * 4 > value.length)
+      {
+       char[] newValue = new char[count];
+       System.arraycopy(value, 0, newValue, 0, count);
+       value = newValue;
+      }
+  }
+
+  /**
+   * Return the number of code points between two indices in the
+   * <code>StringBuffer</code>.  An unpaired surrogate counts as a
+   * code point for this purpose.  Characters outside the indicated
+   * range are not examined, even if the range ends in the middle of a
+   * surrogate pair.
+   *
+   * @param start the starting index
+   * @param end one past the ending index
+   * @return the number of code points
+   * @since 1.5
+   */
+  public int codePointCount(int start, int end)
+  {
+    if (start < 0 || end >= count || start > end)
+      throw new StringIndexOutOfBoundsException();
+
+    int count = 0;
+    while (start < end)
+      {
+       char base = value[start];
+       if (base < Character.MIN_HIGH_SURROGATE
+           || base > Character.MAX_HIGH_SURROGATE
+           || start == end
+           || start == count
+           || value[start + 1] < Character.MIN_LOW_SURROGATE
+           || value[start + 1] > Character.MAX_LOW_SURROGATE)
+         {
+           // Nothing.
+         }
+       else
+         {
+           // Surrogate pair.
+           ++start;
+         }
+       ++start;
+       ++count;
+      }
+    return count;
+  }
+
+  /**
+   * Starting at the given index, this counts forward by the indicated
+   * number of code points, and then returns the resulting index.  An
+   * unpaired surrogate counts as a single code point for this
+   * purpose.
+   *
+   * @param start the starting index
+   * @param codePoints the number of code points
+   * @return the resulting index
+   * @since 1.5
+   */
+  public int offsetByCodePoints(int start, int codePoints)
+  {
+    while (codePoints > 0)
+      {
+       char base = value[start];
+       if (base < Character.MIN_HIGH_SURROGATE
+           || base > Character.MAX_HIGH_SURROGATE
+           || start == count
+           || value[start + 1] < Character.MIN_LOW_SURROGATE
+           || value[start + 1] > Character.MAX_LOW_SURROGATE)
+         {
+           // Nothing.
+         }
+       else
+         {
+           // Surrogate pair.
+           ++start;
+         }
+       ++start;
+       --codePoints;
+      }
+    return start;
+  }
+
+  /**
+   * Increase the capacity of this <code>StringBuilder</code>. This will
+   * ensure that an expensive growing operation will not occur until
+   * <code>minimumCapacity</code> is reached. The buffer is grown to the
+   * larger of <code>minimumCapacity</code> and
+   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
+   *
+   * @param minimumCapacity the new capacity
+   * @see #capacity()
+   */
+  protected void ensureCapacity_unsynchronized(int minimumCapacity)
+  {
+    if (minimumCapacity > value.length)
+      {
+        int max = value.length * 2 + 2;
+        minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
+        char[] nb = new char[minimumCapacity];
+        System.arraycopy(value, 0, nb, 0, count);
+        value = nb;
+      }
+  }
+
+  /**
+   * Get the length of the <code>String</code> this <code>StringBuilder</code>
+   * would create. Not to be confused with the <em>capacity</em> of the
+   * <code>StringBuilder</code>.
+   *
+   * @return the length of this <code>StringBuilder</code>
+   * @see #capacity()
+   * @see #setLength(int)
+   */
+  public int length()
+  {
+    return count;
+  }
+
+  /**
+   * Creates a substring of this StringBuilder, starting at a specified index
+   * and ending at one character before a specified index. This is implemented
+   * the same as <code>substring(beginIndex, endIndex)</code>, to satisfy
+   * the CharSequence interface.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuilder
+   * @throws IndexOutOfBoundsException if beginIndex or endIndex is out of
+   *         bounds
+   * @see #substring(int, int)
+   */
+  public CharSequence subSequence(int beginIndex, int endIndex)
+  {
+    return substring(beginIndex, endIndex);
+  }
+
+  /**
+   * Creates a substring of this StringBuilder, starting at a specified index
+   * and ending at one character before a specified index.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuilder
+   * @throws StringIndexOutOfBoundsException if beginIndex or endIndex is out
+   *         of bounds
+   */
+  public String substring(int beginIndex, int endIndex)
+  {
+    if (beginIndex < 0 || endIndex > count || endIndex < beginIndex)
+      throw new StringIndexOutOfBoundsException();
+    int len = endIndex - beginIndex;
+    if (len == 0)
+      return "";
+    return VMCPStringBuilder.toString(value, beginIndex, len);
+  }
+
+  /**
+   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
+   * String is composed of the characters currently in this StringBuilder. Note
+   * that the result is not a copy, so future modifications to this buffer
+   * do affect the String.
+   *
+   * @return the characters in this StringBuilder
+   */
+  public String toString()
+  {
+    return VMCPStringBuilder.toString(value, 0, count);
+  }
+
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java b/src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java
new file mode 100644 (file)
index 0000000..ca1c39d
--- /dev/null
@@ -0,0 +1,108 @@
+/* VMCPStringBuilder.java -- Growable strings without locking or copying
+   Copyright (C) 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * This class provides VM support for CPStringBuilder
+ * by allowing the package-private constructor
+ * of java.lang.String to be invoked.  The default
+ * implementation uses reflection.  VMs may replace
+ * this class with a more efficient version.
+ */
+final class VMCPStringBuilder
+{
+
+  /**
+   * The package-private constructor for String objects without copying.
+   */
+//   private static final Constructor<String> cons;
+
+//   static
+//   {
+//     try
+//       {
+//     cons = String.class.getDeclaredConstructor(char[].class, Integer.TYPE,
+//                                                Integer.TYPE, Boolean.TYPE);
+//     cons.setAccessible(true);
+//       }
+//     catch (NoSuchMethodException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Could not get no-copy String constructor").initCause(e);
+//       }
+//   }
+
+  /**
+   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
+   * String is composed of the characters currently in this StringBuilder. Note
+   * that the result is not a copy, so future modifications to this buffer
+   * do affect the String.
+   *
+   * @param value the buffered characters.
+   * @param startIndex the index at which to start taking characters from the buffer.
+   * @param count the number of characters used in the buffer.
+   * @return the characters in this StringBuilder
+   */
+//   public static String toString(char[] value, int startIndex, int count)
+//   {
+//     try
+//       {
+//     return cons.newInstance(value, startIndex, count, true);
+//       }
+//     catch (InstantiationException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Could not instantiate no-copy String constructor").initCause(e);
+//       }
+//     catch (IllegalAccessException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Could not access no-copy String constructor").initCause(e);
+//       }
+//     catch (InvocationTargetException e)
+//       {
+//     throw (Error) 
+//       new InternalError("Error calling no-copy String constructor").initCause(e);
+//       }
+//   }
+  public static native String toString(char[] value, int startIndex, int count);
+
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/src/classes/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java
new file mode 100644 (file)
index 0000000..d71a06d
--- /dev/null
@@ -0,0 +1,110 @@
+/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
+   Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information about the memory
+ * management of the current invocation of the virtual
+ * machine.  Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getMemoryMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMMemoryMXBeanImpl
+{
+
+  /**
+   * Returns an instance of {@link java.lang.management.MemoryUsage}
+   * with appropriate initial, used, committed and maximum values
+   * for the heap.  By default, this uses the methods of
+   * {@link java.lang.Runtime} to provide some of the values.
+   *
+   * @return an {@link java.lang.management.MemoryUsage} instance
+   *         for the heap.
+   */
+//   static MemoryUsage getHeapMemoryUsage()
+//   {
+//     Runtime runtime = Runtime.getRuntime();
+//     long totalMem = runtime.totalMemory();
+//     return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
+//                        totalMem, runtime.maxMemory());
+//   }
+  static native MemoryUsage getHeapMemoryUsage();
+
+  /**
+   * Returns an instance of {@link java.lang.management.MemoryUsage}
+   * with appropriate initial, used, committed and maximum values
+   * for non-heap memory.
+   *
+   * @return an {@link java.lang.management.MemoryUsage} instance
+   *         for non-heap memory.
+   */
+  static native MemoryUsage getNonHeapMemoryUsage();
+
+  /**
+   * Returns the number of objects ready to be garbage collected.
+   *
+   * @return the number of finalizable objects.
+   */
+  static native int getObjectPendingFinalizationCount();
+
+  /**
+   * Returns true if the virtual machine will emit additional
+   * information when memory is allocated and deallocated.  The
+   * format of the output is left up to the virtual machine.
+   *
+   * @return true if verbose class loading output is on.
+   */
+  static native boolean isVerbose();
+
+  /**
+   * Turns on or off the emission of additional information
+   * when memory is allocated and deallocated.  The format of the
+   * output is left up to the virtual machine.  This method
+   * may be called by multiple threads concurrently, but there
+   * is only one global setting of verbosity that is affected.
+   *
+   * @param verbose the new setting for verbose class loading
+   *                output.
+   */
+  static native void setVerbose(boolean verbose);
+
+}
diff --git a/src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
new file mode 100644 (file)
index 0000000..32a8660
--- /dev/null
@@ -0,0 +1,89 @@
+/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean
+   Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+/**
+ * Provides access to information about the virtual machine.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMRuntimeMXBeanImpl
+{
+
+  /**
+   * Returns the command-line arguments supplied
+   * to the virtual machine, excluding those supplied
+   * to <code>main()</code>.
+   *
+   * @return the command-line arguments.
+   */
+  static native String[] getInputArguments();
+
+  /**
+   * Returns a developer-chosen name for the virtual
+   * machine, which may differ over different running
+   * instances of the same virtual machine binary.
+   * For example, this may include the particular
+   * process identifier used by this instance or
+   * the host name of the machine on which it is
+   * running.  The intention is that this name refers
+   * to the precise entity that the other data supplied
+   * by the bean refers to, rather than the VM in general.
+   *
+   * @return the custom name of the VM.
+   */
+  static String getName()
+  {
+    return SystemProperties.getProperty("java.vm.name") + " " +
+      SystemProperties.getProperty("java.vm.version");
+  }
+
+  /**
+   * The time in milliseconds at which the virtual
+   * machine was started.  This method is only executed
+   * once (for efficency), as the value is not expected
+   * to change.
+   *
+   * @return the VM start time.
+   */
+  static native long getStartTime();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/VMClassLoader.java b/src/classes/gnuclasspath/java/lang/VMClassLoader.java
new file mode 100644 (file)
index 0000000..f09838b
--- /dev/null
@@ -0,0 +1,457 @@
+/* VMClassLoader.java -- Reference implementation of native interface
+   required by ClassLoader
+   Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.java.lang.InstrumentationImpl;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.instrument.Instrumentation;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.zip.ZipFile;
+import java.util.Collections;
+import java.lang.Boolean;
+
+/**
+ * java.lang.VMClassLoader is a package-private helper for VMs to implement
+ * on behalf of java.lang.ClassLoader.
+ *
+ * @author John Keiser
+ * @author Mark Wielaard (mark@klomp.org)
+ * @author Eric Blake (ebb9@email.byu.edu)
+ */
+final class VMClassLoader
+{
+
+
+  /** packages loaded by the bootstrap class loader */
+  static final HashMap definedPackages = new HashMap();
+
+  /** jars from property java.boot.class.path */
+  static final HashMap bootjars = new HashMap();
+  
+
+  /**
+   * Converts the array string of native package names to
+   * Packages. The packages are then put into the
+   * definedPackages hashMap
+   */
+  static
+  {
+    String[] packages = getBootPackages();
+    
+    if( packages != null)
+      {
+        String specName = 
+              SystemProperties.getProperty("java.specification.name");
+        String vendor =
+              SystemProperties.getProperty("java.specification.vendor");
+        String version =
+              SystemProperties.getProperty("java.specification.version");
+        
+        Package p;
+              
+        for(int i = 0; i < packages.length; i++)
+          {
+            p = new Package(packages[i],
+                  specName,
+                  vendor,
+                  version,
+                  "GNU Classpath",
+                  "GNU",
+                  Configuration.CLASSPATH_VERSION,
+                  null,
+                  null);
+
+            definedPackages.put(packages[i], p);
+          }
+      }
+  }
+
+  
+  /**
+   * Helper to define a class using a string of bytes. This assumes that
+   * the security checks have already been performed, if necessary.
+   *
+   * Implementations of this method are advised to consider the
+   * situation where user code modifies the byte array after it has
+   * been passed to defineClass.  This can be handled by making a
+   * private copy of the array, or arranging to only read any given
+   * byte a single time.
+   *
+   * @param name the name to give the class, or null if unknown
+   * @param data the data representing the classfile, in classfile format
+   * @param offset the offset into the data where the classfile starts
+   * @param len the length of the classfile data in the array
+   * @param pd the protection domain
+   * @return the class that was defined
+   * @throws ClassFormatError if data is not in proper classfile format
+   */
+  static final native Class defineClass(ClassLoader cl, String name,
+                                 byte[] data, int offset, int len,
+                                 ProtectionDomain pd)
+    throws ClassFormatError;
+
+  /**
+   * Helper to resolve all references to other classes from this class.
+   *
+   * @param c the class to resolve
+   */
+  static final native void resolveClass(Class c);
+
+  /**
+   * Helper to load a class from the bootstrap class loader.
+   *
+   * @param name the class name to load
+   * @param resolve whether to resolve it
+   * @return the class, loaded by the bootstrap classloader or null
+   * if the class wasn't found. Returning null is equivalent to throwing
+   * a ClassNotFoundException (but a possible performance optimization).
+   */
+  static final native Class loadClass(String name, boolean resolve)
+    throws ClassNotFoundException;
+
+  /**
+   * Helper to load a resource from the bootstrap class loader.
+   *
+   * @param name the resource to find
+   * @return the URL to the resource
+   */
+  static URL getResource(String name)
+  {
+    Enumeration e = getResources(name);
+    if (e.hasMoreElements())
+      return (URL)e.nextElement();
+    return null;
+  }
+  /**
+   * Helper to get a list of resources from the bootstrap class loader.
+   *
+   * @param name the resource to find
+   * @return an enumeration of resources
+   */
+  static Enumeration getResources(String name)
+  {
+//     StringTokenizer st = new StringTokenizer(
+//       SystemProperties.getProperty("java.boot.class.path", "."),
+//       File.pathSeparator);
+//     Vector v = new Vector();
+//     while (st.hasMoreTokens())
+//       {
+//     File file = new File(st.nextToken());
+//     if (file.isDirectory())
+//       {
+//         try
+//           {
+//                 File f = new File(file, name);
+//                 if (!f.exists()) continue;
+//                 v.add(new URL("file://" + f.getAbsolutePath()));
+//           }
+//         catch (MalformedURLException e)
+//           {
+//             throw new Error(e);
+//           }
+//       }
+//     else if (file.isFile())
+//       {
+//         ZipFile zip;
+//             synchronized(bootjars)
+//               {
+//                 zip = (ZipFile) bootjars.get(file.getName());
+//               }
+//             if(zip == null)
+//               {
+//                 try
+//               {
+//                     zip = new ZipFile(file);
+//                     synchronized(bootjars)
+//                       {
+//                         bootjars.put(file.getName(), zip);
+//                       }
+//               }
+//             catch (IOException e)
+//               {
+//                 continue;
+//               }
+//               }
+//         String zname = name.startsWith("/") ? name.substring(1) : name;
+//         if (zip.getEntry(zname) == null)
+//           continue;
+//         try
+//           {
+//             v.add(new URL("jar:file://"
+//               + file.getAbsolutePath() + "!/" + zname));
+//           }
+//         catch (MalformedURLException e)
+//           {
+//             throw new Error(e);
+//           }
+//       }
+//       }
+//     return v.elements();
+//   }
+    Vector urls = nativeGetResources(name);
+    Vector v = new Vector();
+    for (Enumeration en = urls.elements(); en.hasMoreElements();)
+      {
+       try
+         {
+           v.add(new URL((String) en.nextElement()));
+         }
+       catch (MalformedURLException e)
+         {
+           throw new Error(e);
+         }
+      }
+    return v.elements();
+  }
+
+  private native static final Vector nativeGetResources(String name);
+
+
+  /**
+   * Returns a String[] of native package names. The default
+   * implementation tries to load a list of package from
+   * the META-INF/INDEX.LIST file in the boot jar file.
+   * If not found or if any exception is raised, it returns
+   * an empty array. You may decide this needs native help.
+   */
+  private static String[] getBootPackages()
+  {
+    try
+      {
+        Enumeration indexListEnumeration = getResources("META-INF/INDEX.LIST");
+        Set packageSet = new HashSet();
+
+        while (indexListEnumeration.hasMoreElements())
+          {
+            try
+              {
+                String line;
+                int lineToSkip = 3;
+                BufferedReader reader = new BufferedReader(
+                                                           new InputStreamReader(
+                                                                                 ((URL) indexListEnumeration.nextElement()).openStream()));
+                while ((line = reader.readLine()) != null)
+                  {
+                    if (lineToSkip == 0)
+                      {
+                        if (line.length() == 0)
+                          lineToSkip = 1;
+                        else
+                          packageSet.add(line.replace('/', '.'));
+                      }
+                    else
+                      lineToSkip--;
+                  }
+                reader.close();
+              }
+            catch (IOException e)
+              {
+                // Empty catch block on purpose
+              }
+          }
+        return (String[]) packageSet.toArray(new String[packageSet.size()]);
+      }
+    catch (Exception e)
+      {
+        return new String[0];
+      }
+  }
+
+
+  /**
+   * Helper to get a package from the bootstrap class loader.
+   *
+   * @param name the name to find
+   * @return the named package, if it exists
+   */
+  static Package getPackage(String name)
+  {
+    return (Package)definedPackages.get(name);
+  }
+
+
+  
+  /**
+   * Helper to get all packages from the bootstrap class loader.  
+   *
+   * @return all named packages, if any exist
+   */
+  static Package[] getPackages()
+  {
+    Package[] packages = new Package[definedPackages.size()];
+    definedPackages.values().toArray(packages);
+    return packages;
+  }
+
+  /**
+   * Helper for java.lang.Integer, Byte, etc to get the TYPE class
+   * at initialization time. The type code is one of the chars that
+   * represents the primitive type as in JNI.
+   *
+   * <ul>
+   * <li>'Z' - boolean</li>
+   * <li>'B' - byte</li>
+   * <li>'C' - char</li>
+   * <li>'D' - double</li>
+   * <li>'F' - float</li>
+   * <li>'I' - int</li>
+   * <li>'J' - long</li>
+   * <li>'S' - short</li>
+   * <li>'V' - void</li>
+   * </ul>
+   *
+   * @param type the primitive type
+   * @return a "bogus" class representing the primitive type
+   */
+  static final native Class getPrimitiveClass(char type);
+
+  /**
+   * The system default for assertion status. This is used for all system
+   * classes (those with a null ClassLoader), as well as the initial value for
+   * every ClassLoader's default assertion status.
+   *
+   * @return the system-wide default assertion status
+   */
+  static native final boolean defaultAssertionStatus();
+
+  static native final boolean defaultUserAssertionStatus();
+
+
+  static final Map packageAssertionMap = 
+    Collections.unmodifiableMap(packageAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
+  
+  static native final Map packageAssertionStatus0(Boolean jtrue, Boolean jfalse);
+  /**
+   * The system default for package assertion status. This is used for all
+   * ClassLoader's packageAssertionStatus defaults. It must be a map of
+   * package names to Boolean.TRUE or Boolean.FALSE, with the unnamed package
+   * represented as a null key.
+   *
+   * @return a (read-only) map for the default packageAssertionStatus
+   */
+   
+  static final Map packageAssertionStatus() {
+    return packageAssertionMap;
+  }
+
+  static final Map classAssertionMap = 
+    Collections.unmodifiableMap(classAssertionStatus0(Boolean.TRUE, Boolean.FALSE));
+  
+  static native final Map classAssertionStatus0(Boolean jtrue, Boolean jfalse);
+
+  /**
+   * The system default for class assertion status. This is used for all
+   * ClassLoader's classAssertionStatus defaults. It must be a map of
+   * class names to Boolean.TRUE or Boolean.FALSE
+   *
+   * @return a (read-only) map for the default classAssertionStatus
+   */
+  static final Map classAssertionStatus() {
+    return classAssertionMap;
+  }
+  
+  static ClassLoader getSystemClassLoader()
+  {
+    return ClassLoader.defaultGetSystemClassLoader();
+  }
+
+  /**
+   * Find the class if this class loader previously defined this class
+   * or if this class loader has been recorded as the initiating class loader
+   * for this class.
+   */
+  static native Class findLoadedClass(ClassLoader cl, String name);
+
+  /**
+   * The Instrumentation object created by the vm when agents are defined.
+   */
+  static final Instrumentation instrumenter = null;
+
+  /**
+   * Call the transformers of the possible Instrumentation object. This
+   * implementation assumes the instrumenter is a
+   * <code>InstrumentationImpl</code> object. VM implementors would
+   * have to redefine this method if they provide their own implementation
+   * of the <code>Instrumentation</code> interface.
+   *
+   * @param loader the initiating loader
+   * @param name the name of the class
+   * @param data the data representing the classfile, in classfile format
+   * @param offset the offset into the data where the classfile starts
+   * @param len the length of the classfile data in the array
+   * @param pd the protection domain
+   * @return the new data representing the classfile
+   */
+  static final Class defineClassWithTransformers(ClassLoader loader,
+      String name, byte[] data, int offset, int len, ProtectionDomain pd)
+  {
+    
+    if (instrumenter != null)
+      {
+        byte[] modifiedData = new byte[len];
+        System.arraycopy(data, offset, modifiedData, 0, len);
+        modifiedData =
+          ((InstrumentationImpl)instrumenter).callTransformers(loader, name,
+            null, pd, modifiedData);
+        
+        return defineClass(loader, name, modifiedData, 0, modifiedData.length,
+            pd);
+      }
+    else
+      {
+        return defineClass(loader, name, data, offset, len, pd);
+      }
+  }
+}
diff --git a/src/classes/gnuclasspath/java/lang/VMString.java b/src/classes/gnuclasspath/java/lang/VMString.java
new file mode 100644 (file)
index 0000000..57e4423
--- /dev/null
@@ -0,0 +1,96 @@
+/* VMString.java -- VM Specific String methods
+   Copyright (C) 2003 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang;
+
+import java.lang.ref.WeakReference;
+import java.util.WeakHashMap;
+
+/*
+ * This class is a reference version, mainly for compiling a class library
+ * jar.  It is likely that VM implementers replace this with their own
+ * version that can communicate effectively with the VM.
+ */
+
+/**
+ * Code relocated from java.lang.String by 
+ * @author Dave Grove <groved@us.ibm.com>
+ */
+final class VMString
+{
+
+  /**
+   * Holds the references for each intern()'d String. If all references to
+   * the string disappear, and the VM properly supports weak references,
+   * the String will be GC'd.
+   */
+//    private static final WeakHashMap internTable = new WeakHashMap();
+
+  /**
+   * Fetches this String from the intern hashtable. If two Strings are
+   * considered equal, by the equals() method, then intern() will return the
+   * same String instance. ie. if (s1.equals(s2)) then
+   * (s1.intern() == s2.intern()). All string literals and string-valued
+   * constant expressions are already interned.
+   *
+   * @param str the String to intern
+   * @return the interned String
+   */
+//    static String intern(String str)
+//    {
+//      synchronized (internTable)
+//        {
+//          WeakReference ref = (WeakReference) internTable.get(str);
+//          if (ref != null)
+//            {
+//              String s = (String) ref.get();
+//              // If s is null, then no strong references exist to the String;
+//              // the weak hash map will soon delete the key.
+//              if (s != null)
+//                return s;
+//            }
+//          internTable.put(str, new WeakReference(str));
+//        }
+//      return str;
+//    }
+
+  /**
+   * this one is native in CACAO
+   */
+  static native String intern(String str);
+
+} // class VMString
diff --git a/src/classes/gnuclasspath/java/lang/VMThread.java b/src/classes/gnuclasspath/java/lang/VMThread.java
new file mode 100644 (file)
index 0000000..a511f3c
--- /dev/null
@@ -0,0 +1,462 @@
+/* VMThread -- VM interface for Thread of executable code
+   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang;
+
+/**
+ * VM interface for Thread of executable code. Holds VM dependent state.
+ * It is deliberately package local and final and should only be accessed
+ * by the Thread class.
+ * <p>
+ * This is the GNU Classpath reference implementation, it should be adapted
+ * for a specific VM.
+ * <p>
+ * The following methods must be implemented:
+ * <ul>
+ * <li>native void start(long stacksize);
+ * <li>native void interrupt();
+ * <li>native boolean isInterrupted();
+ * <li>native void suspend();
+ * <li>native void resume();
+ * <li>native void nativeSetPriority(int priority);
+ * <li>native void nativeStop(Throwable t);
+ * <li>native static Thread currentThread();
+ * <li>static native void yield();
+ * <li>static native boolean interrupted();
+ * </ul>
+ * All other methods may be implemented to make Thread handling more efficient
+ * or to implement some optional (and sometimes deprecated) behaviour. Default
+ * implementations are provided but it is highly recommended to optimize them
+ * for a specific VM.
+ * 
+ * @author Jeroen Frijters (jeroen@frijters.net)
+ * @author Dalibor Topic (robilad@kaffe.org)
+ */
+final class VMThread
+{
+    /**
+     * The Thread object that this VM state belongs to.
+     * Used in currentThread() and start().
+     * Note: when this thread dies, this reference is *not* cleared
+     */
+    volatile Thread thread;
+
+    /**
+     * Flag that is set when the thread runs, used by stop() to protect against
+     * stop's getting lost.
+     */
+    private volatile boolean running;
+
+    /**
+     * VM private data.
+     */
+    private transient Object vmdata;
+
+    /**
+     * Private constructor, create VMThreads with the static create method.
+     *
+     * @param thread The Thread object that was just created.
+     */
+    private VMThread(Thread thread)
+    {
+       this.thread = thread;
+    }
+
+    /**
+     * This method is the initial Java code that gets executed when a native
+     * thread starts. It's job is to coordinate with the rest of the VMThread
+     * logic and to start executing user code and afterwards handle clean up.
+     */
+    private void run()
+    {
+       try
+       {
+           try
+           {
+               running = true;
+               synchronized(thread)
+               {
+                   Throwable t = thread.stillborn;
+                   if(t != null)
+                   {
+                       thread.stillborn = null;
+                       throw t;
+                   }
+               }
+               thread.run();
+           }
+           catch(Throwable t)
+           {
+               try
+               {
+                 Thread.UncaughtExceptionHandler handler;
+                 handler = thread.getUncaughtExceptionHandler();
+                 handler.uncaughtException(thread, t);
+               }
+               catch(Throwable ignore)
+               {
+               }
+           }
+       }
+       finally
+       {
+           // Setting runnable to false is partial protection against stop
+           // being called while we're cleaning up. To be safe all code in
+           // VMThread be unstoppable.
+           running = false;
+           thread.die();
+           synchronized(this)
+           {
+               // release the threads waiting to join us
+               notifyAll();
+           }
+       }
+    }
+
+    /**
+     * Creates a native Thread. This is called from the start method of Thread.
+     * The Thread is started.
+     *
+     * @param thread The newly created Thread object
+     * @param stacksize Indicates the requested stacksize. Normally zero,
+     * non-zero values indicate requested stack size in bytes but it is up
+     * to the specific VM implementation to interpret them and may be ignored.
+     */
+    static void create(Thread thread, long stacksize)
+    {
+       VMThread vmThread = new VMThread(thread);
+       thread.vmThread = vmThread;
+       vmThread.start(stacksize);
+    }
+
+    /**
+     * Gets the name of the thread. Usually this is the name field of the
+     * associated Thread object, but some implementation might choose to
+     * return the name of the underlying platform thread.
+     */
+    String getName()
+    {
+       return thread.name;
+    }
+
+    /**
+     * Set the name of the thread. Usually this sets the name field of the
+     * associated Thread object, but some implementations might choose to
+     * set the name of the underlying platform thread.
+     * @param name The new name
+     */
+    void setName(String name)
+    {
+       thread.name = name;
+    }
+
+    /**
+     * Set the thread priority field in the associated Thread object and
+     * calls the native method to set the priority of the underlying
+     * platform thread.
+     * @param priority The new priority
+     */
+    void setPriority(int priority)
+    {
+       thread.priority = priority;
+       nativeSetPriority(priority);
+    }
+
+    /**
+     * Returns the priority. Usually this is the priority field from the
+     * associated Thread object, but some implementation might choose to
+     * return the priority of the underlying platform thread.
+     * @return this Thread's priority
+     */
+    int getPriority()
+    {
+        return thread.priority;
+    }
+
+    /**
+     * Returns true if the thread is a daemon thread. Usually this is the
+     * daemon field from the associated Thread object, but some
+     * implementation might choose to return the daemon state of the underlying
+     * platform thread.
+     * @return whether this is a daemon Thread or not
+     */
+    boolean isDaemon()
+    {
+        return thread.daemon;
+    }
+
+    /**
+     * Returns the number of stack frames in this Thread.
+     * Will only be called when when a previous call to suspend() returned true.
+     *
+     * @deprecated unsafe operation
+     */
+    native int countStackFrames();
+
+    /**
+     * Wait the specified amount of time for the Thread in question to die.
+     *
+     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
+     * not offer that fine a grain of timing resolution. Besides, there is
+     * no guarantee that this thread can start up immediately when time expires,
+     * because some other thread may be active.  So don't expect real-time
+     * performance.
+     *
+     * @param ms the number of milliseconds to wait, or 0 for forever
+     * @param ns the number of extra nanoseconds to sleep (0-999999)
+     * @throws InterruptedException if the Thread is interrupted; it's
+     *         <i>interrupted status</i> will be cleared
+     */
+    synchronized void join(long ms, int ns) throws InterruptedException
+    {
+       // Round up
+       ms += (ns != 0) ? 1 : 0;
+
+       // Compute end time, but don't overflow
+       long now = System.currentTimeMillis();
+       long end = now + ms;
+       if (end < now)
+           end = Long.MAX_VALUE;
+
+       // A VM is allowed to return from wait() without notify() having been
+       // called, so we loop to handle possible spurious wakeups.
+       while(thread.vmThread != null)
+       {
+           // We use the VMThread object to wait on, because this is a private
+           // object, so client code cannot call notify on us.
+           wait(ms);
+           if(ms != 0)
+           {
+               now = System.currentTimeMillis();
+               ms = end - now;
+               if(ms <= 0)
+               {
+                   break;
+               }
+           }
+       }
+    }
+
+    /**
+     * Cause this Thread to stop abnormally and throw the specified exception.
+     * If you stop a Thread that has not yet started, the stop is ignored
+     * (contrary to what the JDK documentation says).
+     * <b>WARNING</b>This bypasses Java security, and can throw a checked
+     * exception which the call stack is unprepared to handle. Do not abuse 
+     * this power.
+     *
+     * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
+     * leave data in bad states.
+     *
+     * <p><b>NOTE</b> stop() should take care not to stop a thread if it is
+     * executing code in this class.
+     *
+     * @param t the Throwable to throw when the Thread dies
+     * @deprecated unsafe operation, try not to use
+     */
+    void stop(Throwable t)
+    {
+       // Note: we assume that we own the lock on thread
+       // (i.e. that Thread.stop() is synchronized)
+       if(running)
+           nativeStop(t);
+       else
+           thread.stillborn = t;
+    }
+
+    /**
+     * Create a native thread on the underlying platform and start it executing
+     * on the run method of this object.
+     * @param stacksize the requested size of the native thread stack
+     */
+    native void start(long stacksize);
+
+    /**
+     * Interrupt this thread.
+     */
+    native void interrupt();
+
+    /**
+     * Determine whether this Thread has been interrupted, but leave
+     * the <i>interrupted status</i> alone in the process.
+     *
+     * @return whether the Thread has been interrupted
+     */
+    native boolean isInterrupted();
+
+    /**
+     * Suspend this Thread.  It will not come back, ever, unless it is resumed.
+     */
+    native void suspend();
+
+    /**
+     * Resume this Thread.  If the thread is not suspended, this method does
+     * nothing.
+     */
+    native void resume();
+
+    /**
+     * Set the priority of the underlying platform thread.
+     *
+     * @param priority the new priority
+     */
+    native void nativeSetPriority(int priority);
+
+    /**
+     * Asynchronously throw the specified throwable in this Thread.
+     *
+     * @param t the exception to throw
+     */
+    native void nativeStop(Throwable t);
+
+    /**
+     * Return the Thread object associated with the currently executing
+     * thread.
+     *
+     * @return the currently executing Thread
+     */
+    static native Thread currentThread();
+
+    /**
+     * Yield to another thread. The Thread will not lose any locks it holds
+     * during this time. There are no guarantees which thread will be
+     * next to run, and it could even be this one, but most VMs will choose
+     * the highest priority thread that has been waiting longest.
+     */
+    static native void yield();
+
+    /**
+     * Suspend the current Thread's execution for the specified amount of
+     * time. The Thread will not lose any locks it has during this time. There
+     * are no guarantees which thread will be next to run, but most VMs will
+     * choose the highest priority thread that has been waiting longest.
+     *
+     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
+     * not offer that fine a grain of timing resolution. Besides, there is
+     * no guarantee that this thread can start up immediately when time expires,
+     * because some other thread may be active.  So don't expect real-time
+     * performance.
+     *
+     * @param ms the number of milliseconds to sleep.
+     * @param ns the number of extra nanoseconds to sleep (0-999999)
+     * @throws InterruptedException if the Thread is (or was) interrupted;
+     *         it's <i>interrupted status</i> will be cleared
+     */
+    static void sleep(long ms, int ns) throws InterruptedException
+    {
+      // Note: JDK treats a zero length sleep is like Thread.yield(),
+      // without checking the interrupted status of the thread.
+      // It's unclear if this is a bug in the implementation or the spec.
+      // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
+      if (ms == 0 && ns == 0)
+       {
+         if (Thread.interrupted())
+           throw new InterruptedException();
+         return;
+       }
+
+      // Compute end time, but don't overflow
+      long now = System.currentTimeMillis();
+      long end = now + ms;
+      if (end < now)
+         end = Long.MAX_VALUE;
+
+      // A VM is allowed to return from wait() without notify() having been
+      // called, so we loop to handle possible spurious wakeups.
+      VMThread vt = Thread.currentThread().vmThread;
+      synchronized (vt)
+       {
+         while (true)
+           {
+             vt.wait(ms, ns);
+             now = System.currentTimeMillis();
+             if (now >= end)
+               break;
+             ms = end - now;
+             ns = 0;
+           }
+       }
+    }
+
+    /**
+     * Determine whether the current Thread has been interrupted, and clear
+     * the <i>interrupted status</i> in the process.
+     *
+     * @return whether the current Thread has been interrupted
+     */
+    static native boolean interrupted();
+
+    /**
+     * Checks whether the current thread holds the monitor on a given object.
+     * This allows you to do <code>assert Thread.holdsLock(obj)</code>.
+     *
+     * @param obj the object to check
+     * @return true if the current thread is currently synchronized on obj
+     * @throws NullPointerException if obj is null
+     */
+//     static boolean holdsLock(Object obj) 
+//     {
+//       /* Use obj.notify to check if the current thread holds
+//        * the monitor of the object.
+//        * If it doesn't, notify will throw an exception.
+//        */
+//       try 
+//     {
+//       obj.notify();
+//       // okay, current thread holds lock
+//       return true;
+//     }
+//       catch (IllegalMonitorStateException e)
+//     {
+//       // it doesn't hold the lock
+//       return false;
+//     }
+//     }
+    static native boolean holdsLock(Object obj);
+
+  /**
+   * Returns the current state of the thread.
+   * The value must be one of "BLOCKED", "NEW",
+   * "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
+   * "WAITING".
+   *
+   * @return a string corresponding to one of the 
+   *         thread enumeration states specified above.
+   */
+  native String getState();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Constructor.java b/src/classes/gnuclasspath/java/lang/reflect/Constructor.java
new file mode 100644 (file)
index 0000000..55b82e8
--- /dev/null
@@ -0,0 +1,449 @@
+/* java.lang.reflect.Constructor - reflection of Java constructors
+   Copyright (C) 1998, 2001, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import gnu.java.lang.ClassHelper;
+import gnu.java.lang.CPStringBuilder;
+
+import gnu.java.lang.reflect.MethodSignatureParser;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * The Constructor class represents a constructor of a class. It also allows
+ * dynamic creation of an object, via reflection. Invocation on Constructor
+ * objects knows how to do widening conversions, but throws
+ * {@link IllegalArgumentException} if a narrowing conversion would be
+ * necessary. You can query for information on this Constructor regardless
+ * of location, but construction access may be limited by Java language
+ * access controls. If you can't do it in the compiler, you can't normally
+ * do it here either.<p>
+ *
+ * <B>Note:</B> This class returns and accepts types as Classes, even
+ * primitive types; there are Class types defined that represent each
+ * different primitive type.  They are <code>java.lang.Boolean.TYPE,
+ * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
+ * byte.class</code>, etc.  These are not to be confused with the
+ * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
+ * real classes.<p>
+ *
+ * Also note that this is not a serializable class.  It is entirely feasible
+ * to make it serializable using the Externalizable interface, but this is
+ * on Sun, not me.
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see Member
+ * @see Class
+ * @see java.lang.Class#getConstructor(Class[])
+ * @see java.lang.Class#getDeclaredConstructor(Class[])
+ * @see java.lang.Class#getConstructors()
+ * @see java.lang.Class#getDeclaredConstructors()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Constructor<T>
+  extends AccessibleObject
+  implements GenericDeclaration, Member
+{  
+  private static final int CONSTRUCTOR_MODIFIERS
+    = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
+
+  private MethodSignatureParser p;
+
+  VMConstructor cons;
+
+  /**
+   * This class is uninstantiable outside this package.
+   */
+  Constructor(VMConstructor cons)
+  {
+    this.cons = cons;
+    cons.cons = this;
+  }
+
+  private Constructor()
+  {
+  }
+
+  /**
+   * Gets the class that declared this constructor.
+   * @return the class that declared this member
+   */
+  @SuppressWarnings("unchecked")
+  public Class<T> getDeclaringClass()
+  {
+    return (Class<T>) cons.getDeclaringClass();
+  }
+
+  /**
+   * Gets the name of this constructor (the non-qualified name of the class
+   * it was declared in).
+   * @return the name of this constructor
+   */
+  public String getName()
+  {
+    return cons.getDeclaringClass().getName();
+  }
+
+  /**
+   * Gets the modifiers this constructor uses.  Use the <code>Modifier</code>
+   * class to interpret the values. A constructor can only have a subset of the
+   * following modifiers: public, private, protected.
+   *
+   * @return an integer representing the modifiers to this Member
+   * @see Modifier
+   */
+  public int getModifiers()
+  {
+    return cons.getModifiersInternal() & CONSTRUCTOR_MODIFIERS;
+  }
+
+  /**
+   * Return true if this constructor is synthetic, false otherwise.
+   * A synthetic member is one which is created by the compiler,
+   * and which does not appear in the user's source code.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (cons.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+  }
+
+  /**
+   * Return true if this is a varargs constructor, that is if
+   * the constructor takes a variable number of arguments.
+   * @since 1.5
+   */
+  public boolean isVarArgs()
+  {
+    return (cons.getModifiersInternal() & Modifier.VARARGS) != 0;
+  }
+
+  /**
+   * Get the parameter list for this constructor, in declaration order. If the
+   * constructor takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the constructor's parameters
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getParameterTypes()
+  {
+    return (Class<?>[]) cons.getParameterTypes();
+  }
+
+  /**
+   * Get the exception types this constructor says it throws, in no particular
+   * order. If the constructor has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the constructor's throws clause
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getExceptionTypes()
+  {
+    return (Class<?>[]) cons.getExceptionTypes();
+  }
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Constructors are semantically equivalent if they have the same
+   * declaring class and the same parameter list.  This ignores different
+   * exception clauses, but since you can't create a Method except through the
+   * VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not.
+   */
+  public boolean equals(Object o)
+  {
+    return cons.equals(o);
+  }
+
+  /**
+   * Get the hash code for the Constructor. The Constructor hash code is the
+   * hash code of the declaring class's name.
+   *
+   * @return the hash code for the object
+   */
+  public int hashCode()
+  {
+    return getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Constructor. A Constructor's String
+   * representation is "&lt;modifier&gt; &lt;classname&gt;(&lt;paramtypes&gt;)
+   * throws &lt;exceptions&gt;", where everything after ')' is omitted if
+   * there are no exceptions.<br> Example:
+   * <code>public java.io.FileInputStream(java.lang.Runnable)
+   * throws java.io.FileNotFoundException</code>
+   *
+   * @return the String representation of the Constructor
+   */
+  public String toString()
+  {
+    // 128 is a reasonable buffer initial size for constructor
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(getDeclaringClass().getName()).append('(');
+    Class[] c = getParameterTypes();
+    if (c.length > 0)
+      {
+        sb.append(ClassHelper.getUserName(c[0]));
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(ClassHelper.getUserName(c[i]));
+      }
+    sb.append(')');
+    c = getExceptionTypes();
+    if (c.length > 0)
+      {
+        sb.append(" throws ").append(c[0].getName());
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(c[i].getName());
+      }
+    return sb.toString();
+  }
+
+  static <X extends GenericDeclaration>
+  void addTypeParameters(CPStringBuilder sb, TypeVariable<X>[] typeArgs)
+  {
+    if (typeArgs.length == 0)
+      return;
+    sb.append('<');
+    for (int i = 0; i < typeArgs.length; ++i)
+      {
+        if (i > 0)
+          sb.append(',');
+        sb.append(typeArgs[i]);
+      }
+    sb.append("> ");
+  }
+
+  public String toGenericString()
+  {
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    addTypeParameters(sb, getTypeParameters());
+    sb.append(getDeclaringClass().getName()).append('(');
+    Type[] types = getGenericParameterTypes();
+    if (types.length > 0)
+      {
+        sb.append(types[0]);
+        for (int i = 1; i < types.length; ++i)
+          sb.append(',').append(types[i]);
+      }
+    sb.append(')');
+    types = getGenericExceptionTypes();
+    if (types.length > 0)
+      {
+        sb.append(" throws ").append(types[0]);
+        for (int i = 1; i < types.length; i++)
+          sb.append(',').append(types[i]);
+      }
+    return sb.toString();
+  }
+
+  /**
+   * Create a new instance by invoking the constructor. Arguments are
+   * automatically unwrapped and widened, if needed.<p>
+   *
+   * If this class is abstract, you will get an
+   * <code>InstantiationException</code>. If the constructor takes 0
+   * arguments, you may use null or a 0-length array for <code>args</code>.<p>
+   *
+   * If this Constructor enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not create this object in similar compiled code. If the class
+   * is uninitialized, you trigger class initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Then, the constructor is invoked. If it completes normally, the return
+   * value will be the new object. If it completes abruptly, the exception is
+   * wrapped in an <code>InvocationTargetException</code>.
+   *
+   * @param args the arguments to the constructor
+   * @return the newly created object
+   * @throws IllegalAccessException if the constructor could not normally be
+   *         called by the Java code (i.e. it is not public)
+   * @throws IllegalArgumentException if the number of arguments is incorrect;
+   *         or if the arguments types are wrong even with a widening
+   *         conversion
+   * @throws InstantiationException if the class is abstract
+   * @throws InvocationTargetException if the constructor throws an exception
+   * @throws ExceptionInInitializerError if construction triggered class
+   *         initialization, which then failed
+   */
+  @SuppressWarnings("unchecked")
+  public T newInstance(Object... args)
+    throws InstantiationException, IllegalAccessException,
+           InvocationTargetException
+  {
+    return (T) cons.construct(args);
+  }
+
+  /**
+   * Returns an array of <code>TypeVariable</code> objects that represents
+   * the type variables declared by this constructor, in declaration order.
+   * An array of size zero is returned if this constructor has no type
+   * variables.
+   *
+   * @return the type variables associated with this constructor.
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public TypeVariable<Constructor<T>>[] getTypeParameters()
+  {
+    if (p == null)
+      {
+       String sig = cons.getSignature();
+       if (sig == null)
+         return new TypeVariable[0];
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getTypeParameters();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the exception types declared by this constructor, in declaration order.
+   * An array of size zero is returned if this constructor declares no
+   * exceptions.
+   *
+   * @return the exception types declared by this constructor. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericExceptionTypes()
+  {
+    if (p == null)
+      {
+       String sig = cons.getSignature();
+       if (sig == null)
+         return getExceptionTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericExceptionTypes();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the parameter list for this constructor, in declaration order.
+   * An array of size zero is returned if this constructor takes no
+   * parameters.
+   *
+   * @return a list of the types of the constructor's parameters
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericParameterTypes()
+  {
+    if (p == null)
+      {
+       String sig = cons.getSignature();
+       if (sig == null)
+         return getParameterTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericParameterTypes();
+  }
+
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the constructor's parameters.  The outer array is aligned against
+   * the parameters of the constructors and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this constructor.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  public Annotation[][] getParameterAnnotations()
+  {
+    return cons.getParameterAnnotations();
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+  @SuppressWarnings("unchecked")
+  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+  {
+    return (T) cons.getAnnotation(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    return cons.getDeclaredAnnotations();
+  }
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Field.java b/src/classes/gnuclasspath/java/lang/reflect/Field.java
new file mode 100644 (file)
index 0000000..4c2c183
--- /dev/null
@@ -0,0 +1,735 @@
+/* java.lang.reflect.Field - reflection of Java fields
+   Copyright (C) 1998, 2001, 2005, 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import gnu.java.lang.ClassHelper;
+import gnu.java.lang.CPStringBuilder;
+
+import gnu.java.lang.reflect.FieldSignatureParser;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * The Field class represents a member variable of a class. It also allows
+ * dynamic access to a member, via reflection. This works for both
+ * static and instance fields. Operations on Field objects know how to
+ * do widening conversions, but throw {@link IllegalArgumentException} if
+ * a narrowing conversion would be necessary. You can query for information
+ * on this Field regardless of location, but get and set access may be limited
+ * by Java language access controls. If you can't do it in the compiler, you
+ * can't normally do it here either.<p>
+ *
+ * <B>Note:</B> This class returns and accepts types as Classes, even
+ * primitive types; there are Class types defined that represent each
+ * different primitive type.  They are <code>java.lang.Boolean.TYPE,
+ * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
+ * byte.class</code>, etc.  These are not to be confused with the
+ * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
+ * real classes.<p>
+ *
+ * Also note that this is not a serializable class.  It is entirely feasible
+ * to make it serializable using the Externalizable interface, but this is
+ * on Sun, not me.
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see Member
+ * @see Class
+ * @see Class#getField(String)
+ * @see Class#getDeclaredField(String)
+ * @see Class#getFields()
+ * @see Class#getDeclaredFields()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Field
+extends AccessibleObject implements Member
+{
+  static final int FIELD_MODIFIERS
+    = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED
+      | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT
+      | Modifier.VOLATILE;
+
+  private FieldSignatureParser p;
+
+  VMField f;
+
+  /**
+   * This class is uninstantiable outside the package.
+   */
+  Field(VMField f)
+  {
+    this.f = f;
+    f.f = this;
+  }
+
+  /**
+   * Gets the class that declared this field, or the class where this field
+   * is a non-inherited member.
+   * @return the class that declared this member
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?> getDeclaringClass()
+  {
+    return (Class<?>) f.getDeclaringClass();
+  }
+
+  /**
+   * Gets the name of this field.
+   * @return the name of this field
+   */
+  public String getName()
+  {
+    return f.getName();
+  }
+
+  /**
+   * Gets the modifiers this field uses.  Use the <code>Modifier</code>
+   * class to interpret the values.  A field can only have a subset of the
+   * following modifiers: public, private, protected, static, final,
+   * transient, and volatile.
+   *
+   * @return an integer representing the modifiers to this Member
+   * @see Modifier
+   */
+  public int getModifiers()
+  {
+    return f.getModifiersInternal() & FIELD_MODIFIERS;
+  }
+
+  /**
+   * Return true if this field is synthetic, false otherwise.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (f.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+  }
+
+  /**
+   * Return true if this field represents an enum constant,
+   * false otherwise.
+   * @since 1.5
+   */
+  public boolean isEnumConstant()
+  {
+    return (f.getModifiersInternal() & Modifier.ENUM) != 0;
+  }
+
+  /**
+   * Gets the type of this field.
+   * @return the type of this field
+   */
+  public Class<?> getType()
+  {
+    return f.getType();
+  }
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Fields are semantically equivalent if they have the same declaring
+   * class, name, and type. Since you can't creat a Field except through
+   * the VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+    return f.equals(o);
+  }
+
+  /**
+   * Get the hash code for the Field. The Field hash code is the hash code
+   * of its name XOR'd with the hash code of its class name.
+   *
+   * @return the hash code for the object.
+   */
+  public int hashCode()
+  {
+    return f.getDeclaringClass().getName().hashCode() ^ f.getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Field. A Field's String
+   * representation is "&lt;modifiers&gt; &lt;type&gt;
+   * &lt;class&gt;.&lt;fieldname&gt;".<br> Example:
+   * <code>public transient boolean gnu.parse.Parser.parseComplete</code>
+   *
+   * @return the String representation of the Field
+   */
+  public String toString()
+  {
+    // 64 is a reasonable buffer initial size for field
+    CPStringBuilder sb = new CPStringBuilder(64);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(ClassHelper.getUserName(getType())).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName());
+    return sb.toString();
+  }
+
+  public String toGenericString()
+  {
+    CPStringBuilder sb = new CPStringBuilder(64);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(getGenericType()).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName());
+    return sb.toString();
+  }
+
+  /**
+   * Get the value of this Field.  If it is primitive, it will be wrapped
+   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. If the field
+   * is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is accessed, and primitives are wrapped (but not
+   * necessarily in new objects). This method accesses the field of the
+   * declaring class, even if the instance passed in belongs to a subclass
+   * which declares another field to hide this one.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>o</code> is not an instance of
+   *         the class or interface declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #getBoolean(Object)
+   * @see #getByte(Object)
+   * @see #getChar(Object)
+   * @see #getShort(Object)
+   * @see #getInt(Object)
+   * @see #getLong(Object)
+   * @see #getFloat(Object)
+   * @see #getDouble(Object)
+   */
+  public Object get(Object o)
+    throws IllegalAccessException
+  {
+    return f.get(o);
+  }
+
+  /**
+   * Get the value of this boolean Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public boolean getBoolean(Object o)
+    throws IllegalAccessException
+  {
+    return f.getBoolean(o);
+  }
+
+  /**
+   * Get the value of this byte Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public byte getByte(Object o)
+    throws IllegalAccessException
+  {
+    return f.getByte(o);
+  }
+
+  /**
+   * Get the value of this Field as a char. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char field of
+   *         <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public char getChar(Object o)
+    throws IllegalAccessException
+  {
+    return f.getChar(o);
+  }
+
+  /**
+   * Get the value of this Field as a short. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte or short
+   *         field of <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public short getShort(Object o)
+    throws IllegalAccessException
+  {
+    return f.getShort(o);
+  }
+
+  /**
+   * Get the value of this Field as an int. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, or
+   *         int field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public int getInt(Object o)
+    throws IllegalAccessException
+  {
+    return f.getInt(o);
+  }
+
+  /**
+   * Get the value of this Field as a long. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         or long field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public long getLong(Object o)
+    throws IllegalAccessException
+  {
+    return f.getLong(o);
+  }
+
+  /**
+   * Get the value of this Field as a float. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, or float field of <code>o</code>, or if <code>o</code> is
+   *         not an instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public float getFloat(Object o)
+    throws IllegalAccessException
+  {
+    return f.getFloat(o);
+  }
+
+  /**
+   * Get the value of this Field as a double. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, float, or double field of <code>o</code>, or if
+   *         <code>o</code> is not an instance of the declaring class of this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  public double getDouble(Object o)
+    throws IllegalAccessException
+  {
+    return f.getDouble(o);
+  }
+
+  /**
+   * Set the value of this Field.  If it is a primitive field, the value
+   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. This also
+   * occurs whether or not there is access control if the field is final.
+   * If the field is primitive, and unwrapping your argument fails, you will
+   * get an <code>IllegalArgumentException</code>; likewise, this error
+   * happens if <code>value</code> cannot be cast to the correct object type.
+   * If the field is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is set with the widened value. This method accesses
+   * the field of the declaring class, even if the instance passed in belongs
+   * to a subclass which declares another field to hide this one.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>value</code> cannot be
+   *         converted by a widening conversion to the underlying type of
+   *         the Field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #setBoolean(Object, boolean)
+   * @see #setByte(Object, byte)
+   * @see #setChar(Object, char)
+   * @see #setShort(Object, short)
+   * @see #setInt(Object, int)
+   * @see #setLong(Object, long)
+   * @see #setFloat(Object, float)
+   * @see #setDouble(Object, double)
+   */
+  public void set(Object o, Object value)
+    throws IllegalAccessException
+  {
+    f.set(o, value);
+  }
+
+  /**
+   * Set this boolean Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setBoolean(Object o, boolean value)
+    throws IllegalAccessException
+  {
+    f.setBoolean(o, value);
+  }
+
+  /**
+   * Set this byte Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setByte(Object o, byte value)
+    throws IllegalAccessException
+  {
+    f.setByte(o, value);
+  }
+
+  /**
+   * Set this char Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setChar(Object o, char value)
+    throws IllegalAccessException
+  {
+    f.setChar(o, value);
+  }
+
+  /**
+   * Set this short Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setShort(Object o, short value)
+    throws IllegalAccessException
+  {
+    f.setShort(o, value);
+  }
+
+  /**
+   * Set this int Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not an int, long, float, or
+   *         double field, or if <code>o</code> is not an instance of the
+   *         class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setInt(Object o, int value)
+    throws IllegalAccessException
+  {
+    f.setInt(o, value);
+  }
+
+  /**
+   * Set this long Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a long, float, or double
+   *         field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setLong(Object o, long value)
+    throws IllegalAccessException
+  {
+    f.setLong(o, value);
+  }
+
+  /**
+   * Set this float Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a float or long field, or
+   *         if <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setFloat(Object o, float value)
+    throws IllegalAccessException
+  {
+    f.setFloat(o, value);
+  }
+
+  /**
+   * Set this double Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a double field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  public void setDouble(Object o, double value)
+    throws IllegalAccessException
+  {
+    f.setDouble(o, value);
+  }
+
+  /**
+   * Return the generic type of the field. If the field type is not a generic
+   * type, the method returns the same as <code>getType()</code>.
+   *
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type getGenericType()
+  {
+    if (p == null)
+      {
+       String signature = f.getSignature();
+       if (signature == null)
+         return getType();
+       p = new FieldSignatureParser(getDeclaringClass(),
+                                    signature);
+      }
+    return p.getFieldType();
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+  @SuppressWarnings("unchecked")
+  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+  {
+    return (T) f.getAnnotation(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    return f.getDeclaredAnnotations();
+  }
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Method.java b/src/classes/gnuclasspath/java/lang/reflect/Method.java
new file mode 100644 (file)
index 0000000..e787fb3
--- /dev/null
@@ -0,0 +1,499 @@
+/* java.lang.reflect.Method - reflection of Java methods
+   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import gnu.java.lang.ClassHelper;
+import gnu.java.lang.CPStringBuilder;
+
+import gnu.java.lang.reflect.MethodSignatureParser;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * The Method class represents a member method of a class. It also allows
+ * dynamic invocation, via reflection. This works for both static and
+ * instance methods. Invocation on Method objects knows how to do
+ * widening conversions, but throws {@link IllegalArgumentException} if
+ * a narrowing conversion would be necessary. You can query for information
+ * on this Method regardless of location, but invocation access may be limited
+ * by Java language access controls. If you can't do it in the compiler, you
+ * can't normally do it here either.<p>
+ *
+ * <B>Note:</B> This class returns and accepts types as Classes, even
+ * primitive types; there are Class types defined that represent each
+ * different primitive type.  They are <code>java.lang.Boolean.TYPE,
+ * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
+ * byte.class</code>, etc.  These are not to be confused with the
+ * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
+ * real classes.<p>
+ *
+ * Also note that this is not a serializable class.  It is entirely feasible
+ * to make it serializable using the Externalizable interface, but this is
+ * on Sun, not me.
+ *
+ * @author John Keiser
+ * @author Eric Blake <ebb9@email.byu.edu>
+ * @see Member
+ * @see Class
+ * @see java.lang.Class#getMethod(String,Class[])
+ * @see java.lang.Class#getDeclaredMethod(String,Class[])
+ * @see java.lang.Class#getMethods()
+ * @see java.lang.Class#getDeclaredMethods()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Method
+extends AccessibleObject implements Member, GenericDeclaration
+{
+  private static final int METHOD_MODIFIERS
+    = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE
+      | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC
+      | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED;
+
+  private MethodSignatureParser p;
+
+  VMMethod m;
+
+  /**
+   * This class is uninstantiable outside this package.
+   */
+  Method(VMMethod m)
+  {
+    this.m = m;
+    m.m = this;
+  }
+
+  /**
+   * Gets the class that declared this method, or the class where this method
+   * is a non-inherited member.
+   * @return the class that declared this member
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?> getDeclaringClass()
+  {
+    return (Class<?>) m.getDeclaringClass();
+  }
+
+  /**
+   * Gets the name of this method.
+   * @return the name of this method
+   */
+  public String getName()
+  {
+    return m.getName();
+  }
+
+  /**
+   * Gets the modifiers this method uses.  Use the <code>Modifier</code>
+   * class to interpret the values.  A method can only have a subset of the
+   * following modifiers: public, private, protected, abstract, static,
+   * final, synchronized, native, and strictfp.
+   *
+   * @return an integer representing the modifiers to this Member
+   * @see Modifier
+   */
+  public int getModifiers()
+  {
+    return m.getModifiersInternal() & METHOD_MODIFIERS;
+  }
+
+  /**
+   * Return true if this method is a bridge method.  A bridge method
+   * is generated by the compiler in some situations involving
+   * generics and inheritance.
+   * @since 1.5
+   */
+  public boolean isBridge()
+  {
+    return (m.getModifiersInternal() & Modifier.BRIDGE) != 0;
+  }
+
+  /**
+   * Return true if this method is synthetic, false otherwise.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    return (m.getModifiersInternal() & Modifier.SYNTHETIC) != 0;
+  }
+
+  /**
+   * Return true if this is a varargs method, that is if
+   * the method takes a variable number of arguments.
+   * @since 1.5
+   */
+  public boolean isVarArgs()
+  {
+    return (m.getModifiersInternal() & Modifier.VARARGS) != 0;
+  }
+
+  /**
+   * Gets the return type of this method.
+   * @return the type of this method
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?> getReturnType()
+  {
+    return (Class<?>) m.getReturnType();
+  }
+
+  /**
+   * Get the parameter list for this method, in declaration order. If the
+   * method takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the method's parameters
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getParameterTypes()
+  {
+    return (Class<?>[]) m.getParameterTypes();
+  }
+
+  /**
+   * Get the exception types this method says it throws, in no particular
+   * order. If the method has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the method's throws clause
+   */
+  @SuppressWarnings("unchecked")
+  public Class<?>[] getExceptionTypes()
+  {
+    return (Class<?>[]) m.getExceptionTypes();
+  }
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Methods are semantically equivalent if they have the same declaring
+   * class, name, parameter list, and return type.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+    return m.equals(o);
+  }
+
+  /**
+   * Get the hash code for the Method. The Method hash code is the hash code
+   * of its name XOR'd with the hash code of its class name.
+   *
+   * @return the hash code for the object
+   */
+  public int hashCode()
+  {
+    return m.getDeclaringClass().getName().hashCode() ^ m.getName().hashCode();
+  }
+
+  /**
+   * Get a String representation of the Method. A Method's String
+   * representation is "&lt;modifiers&gt; &lt;returntype&gt;
+   * &lt;methodname&gt;(&lt;paramtypes&gt;) throws &lt;exceptions&gt;", where
+   * everything after ')' is omitted if there are no exceptions.<br> Example:
+   * <code>public static int run(java.lang.Runnable,int)</code>
+   *
+   * @return the String representation of the Method
+   */
+  public String toString()
+  {
+    // 128 is a reasonable buffer initial size for constructor
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    sb.append(ClassHelper.getUserName(getReturnType())).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName()).append('(');
+    Class[] c = getParameterTypes();
+    if (c.length > 0)
+      {
+        sb.append(ClassHelper.getUserName(c[0]));
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(ClassHelper.getUserName(c[i]));
+      }
+    sb.append(')');
+    c = getExceptionTypes();
+    if (c.length > 0)
+      {
+        sb.append(" throws ").append(c[0].getName());
+        for (int i = 1; i < c.length; i++)
+          sb.append(',').append(c[i].getName());
+      }
+    return sb.toString();
+  }
+
+  public String toGenericString()
+  {
+    // 128 is a reasonable buffer initial size for constructor
+    CPStringBuilder sb = new CPStringBuilder(128);
+    Modifier.toString(getModifiers(), sb).append(' ');
+    Constructor.addTypeParameters(sb, getTypeParameters());
+    sb.append(getGenericReturnType()).append(' ');
+    sb.append(getDeclaringClass().getName()).append('.');
+    sb.append(getName()).append('(');
+    Type[] types = getGenericParameterTypes();
+    if (types.length > 0)
+      {
+        sb.append(types[0]);
+        for (int i = 1; i < types.length; i++)
+          sb.append(',').append(types[i]);
+      }
+    sb.append(')');
+    types = getGenericExceptionTypes();
+    if (types.length > 0)
+      {
+        sb.append(" throws ").append(types[0]);
+        for (int i = 1; i < types.length; i++)
+          sb.append(',').append(types[i]);
+      }
+    return sb.toString();
+  }
+
+  /**
+   * Invoke the method. Arguments are automatically unwrapped and widened,
+   * and the result is automatically wrapped, if needed.<p>
+   *
+   * If the method is static, <code>o</code> will be ignored. Otherwise,
+   * the method uses dynamic lookup as described in JLS 15.12.4.4. You cannot
+   * mimic the behavior of nonvirtual lookup (as in super.foo()). This means
+   * you will get a <code>NullPointerException</code> if <code>o</code> is
+   * null, and an <code>IllegalArgumentException</code> if it is incompatible
+   * with the declaring class of the method. If the method takes 0 arguments,
+   * you may use null or a 0-length array for <code>args</code>.<p>
+   *
+   * Next, if this Method enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not acces this method in similar compiled code. If the method
+   * is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the method is invoked. If it completes normally, the return value
+   * will be null for a void method, a wrapped object for a primitive return
+   * method, or the actual return of an Object method. If it completes
+   * abruptly, the exception is wrapped in an
+   * <code>InvocationTargetException</code>.
+   *
+   * @param o the object to invoke the method on
+   * @param args the arguments to the method
+   * @return the return value of the method, wrapped in the appropriate
+   *         wrapper if it is primitive
+   * @throws IllegalAccessException if the method could not normally be called
+   *         by the Java code (i.e. it is not public)
+   * @throws IllegalArgumentException if the number of arguments is incorrect;
+   *         if the arguments types are wrong even with a widening conversion;
+   *         or if <code>o</code> is not an instance of the class or interface
+   *         declaring this method
+   * @throws InvocationTargetException if the method throws an exception
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static method triggered
+   *         class initialization, which then failed
+   */
+  public Object invoke(Object o, Object... args)
+    throws IllegalAccessException, InvocationTargetException
+  {
+    return m.invoke(o, args);
+  }
+
+  /**
+   * Returns an array of <code>TypeVariable</code> objects that represents
+   * the type variables declared by this constructor, in declaration order.
+   * An array of size zero is returned if this class has no type
+   * variables.
+   *
+   * @return the type variables associated with this class. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public TypeVariable<Method>[] getTypeParameters()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return (TypeVariable<Method>[]) new TypeVariable[0];
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getTypeParameters();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the exception types declared by this method, in declaration order.
+   * An array of size zero is returned if this method declares no
+   * exceptions.
+   *
+   * @return the exception types declared by this method. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericExceptionTypes()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return getExceptionTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericExceptionTypes();
+  }
+
+  /**
+   * Returns an array of <code>Type</code> objects that represents
+   * the parameter list for this method, in declaration order.
+   * An array of size zero is returned if this method takes no
+   * parameters.
+   *
+   * @return a list of the types of the method's parameters
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type[] getGenericParameterTypes()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return getParameterTypes();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericParameterTypes();
+  }
+
+  /**
+   * Returns the return type of this method.
+   *
+   * @return the return type of this method
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+  public Type getGenericReturnType()
+  {
+    if (p == null)
+      {
+       String sig = m.getSignature();
+       if (sig == null)
+         return getReturnType();
+       p = new MethodSignatureParser(this, sig);
+      }
+    return p.getGenericReturnType();
+  }
+
+  /**
+   * If this method is an annotation method, returns the default
+   * value for the method.  If there is no default value, or if the
+   * method is not a member of an annotation type, returns null.
+   * Primitive types are wrapped.
+   *
+   * @throws TypeNotPresentException if the method returns a Class,
+   * and the class cannot be found
+   *
+   * @since 1.5
+   */
+  public Object getDefaultValue()
+  {
+    return m.getDefaultValue();
+  }
+
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the method's parameters.  The outer array is aligned against
+   * the parameters of the method and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this method.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  public Annotation[][] getParameterAnnotations()
+  {
+    return m.getParameterAnnotations();
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+  @SuppressWarnings("unchecked")
+  public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+  {
+    return (T) m.getAnnotation(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    return m.getDeclaredAnnotations();
+  }
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/Modifier.java b/src/classes/gnuclasspath/java/lang/reflect/Modifier.java
new file mode 100644 (file)
index 0000000..45d9b51
--- /dev/null
@@ -0,0 +1,354 @@
+/* java.lang.reflect.Modifier
+   Copyright (C) 1998, 1999, 2001, 2002, 2005, 2008  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import gnu.java.lang.CPStringBuilder;
+
+/**
+ * Modifier is a helper class with static methods to determine whether an
+ * int returned from getModifiers() represents static, public, protected,
+ * native, final, etc... and provides an additional method to print
+ * out all of the modifiers in an int in order.
+ * <p>
+ * The methods in this class use the bitmask values in the VM spec to
+ * determine the modifiers of an int. This means that a VM must return a
+ * standard mask, conformant with the VM spec.  I don't know if this is how
+ * Sun does it, but I'm willing to bet money that it is.
+ *
+ * @author John Keiser
+ * @author Tom Tromey (tromey@cygnus.com)
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @see Member#getModifiers()
+ * @see Method#getModifiers()
+ * @see Field#getModifiers()
+ * @see Constructor#getModifiers()
+ * @see Class#getModifiers()
+ * @since 1.1
+ */
+public class Modifier
+{
+  /** <STRONG>This constructor really shouldn't be here ... there are no
+   * instance methods or variables of this class, so instantiation is
+   * worthless.  However, this function is in the 1.1 spec, so it is added
+   * for completeness.</STRONG>
+   */
+  public Modifier()
+  {
+  }
+
+  /**
+   * Public: accessible from any other class.
+   */
+  public static final int PUBLIC = 0x0001;
+
+  /**
+   * Private: accessible only from the same enclosing class.
+   */
+  public static final int PRIVATE = 0x0002;
+
+  /**
+   * Protected: accessible only to subclasses, or within the package.
+   */
+  public static final int PROTECTED = 0x0004;
+
+  /**
+   * Static:<br><ul>
+   * <li>Class: no enclosing instance for nested class.</li>
+   * <li>Field or Method: can be accessed or invoked without an
+   *     instance of the declaring class.</li>
+   * </ul>
+   */
+  public static final int STATIC = 0x0008;
+
+  /**
+   * Final:<br><ul>
+   * <li>Class: no subclasses allowed.</li>
+   * <li>Field: cannot be changed.</li>
+   * <li>Method: cannot be overriden.</li>
+   * </ul>
+   */
+  public static final int FINAL = 0x0010;
+
+  /**
+   * Synchronized: Method: lock the class while calling this method.
+   */
+  public static final int SYNCHRONIZED = 0x0020;
+
+  /**
+   * Volatile: Field: cannot be cached.
+   */
+  public static final int VOLATILE = 0x0040;
+
+  /**
+   * Transient: Field: not serialized or deserialized.
+   */
+  public static final int TRANSIENT = 0x0080;
+
+  /**
+   * Native: Method: use JNI to call this method.
+   */
+  public static final int NATIVE = 0x0100;
+
+  /**
+   * Interface: Class: is an interface.
+   */
+  public static final int INTERFACE = 0x0200;
+
+  /**
+   * Abstract:<br><ul>
+   * <li>Class: may not be instantiated.</li>
+   * <li>Method: may not be called.</li>
+   * </ul>
+   */
+  public static final int ABSTRACT = 0x0400;
+
+  /**
+   * Strictfp: Method: expressions are FP-strict.<p>
+   * Also used as a modifier for classes, to mean that all initializers
+   * and constructors are FP-strict, but does not show up in
+   * Class.getModifiers.
+   */
+  public static final int STRICT = 0x0800;
+
+
+  /**
+   * Super - treat invokespecial as polymorphic so that super.foo() works
+   * according to the JLS. This is a reuse of the synchronized constant
+   * to patch a hole in JDK 1.0. *shudder*.
+   */
+  static final int SUPER = 0x0020;
+
+  /**
+   * All the flags, only used by code in this package.
+   */
+  static final int ALL_FLAGS = 0xfff;
+
+  /**
+   * Flag indicating a bridge method.
+   */
+  static final int BRIDGE = 0x40;
+
+  /**
+   * Flag indicating a varargs method.
+   */
+  static final int VARARGS = 0x80;
+
+  /**
+   * Flag indicating a synthetic member.
+   */
+  static final int SYNTHETIC = 0x1000;
+
+  /**
+   * Flag indicating an enum constant or an enum class.
+   */
+  static final int ENUM = 0x4000;
+
+  /**
+   * Check whether the given modifier is abstract.
+   * @param mod the modifier.
+   * @return <code>true</code> if abstract, <code>false</code> otherwise.
+   */
+  public static boolean isAbstract(int mod)
+  {
+    return (mod & ABSTRACT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is final.
+   * @param mod the modifier.
+   * @return <code>true</code> if final, <code>false</code> otherwise.
+   */
+  public static boolean isFinal(int mod)
+  {
+    return (mod & FINAL) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is an interface.
+   * @param mod the modifier.
+   * @return <code>true</code> if an interface, <code>false</code> otherwise.
+   */
+  public static boolean isInterface(int mod)
+  {
+    return (mod & INTERFACE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is native.
+   * @param mod the modifier.
+   * @return <code>true</code> if native, <code>false</code> otherwise.
+   */
+  public static boolean isNative(int mod)
+  {
+    return (mod & NATIVE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is private.
+   * @param mod the modifier.
+   * @return <code>true</code> if private, <code>false</code> otherwise.
+   */
+  public static boolean isPrivate(int mod)
+  {
+    return (mod & PRIVATE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is protected.
+   * @param mod the modifier.
+   * @return <code>true</code> if protected, <code>false</code> otherwise.
+   */
+  public static boolean isProtected(int mod)
+  {
+    return (mod & PROTECTED) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is public.
+   * @param mod the modifier.
+   * @return <code>true</code> if public, <code>false</code> otherwise.
+   */
+  public static boolean isPublic(int mod)
+  {
+    return (mod & PUBLIC) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is static.
+   * @param mod the modifier.
+   * @return <code>true</code> if static, <code>false</code> otherwise.
+   */
+  public static boolean isStatic(int mod)
+  {
+    return (mod & STATIC) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is strictfp.
+   * @param mod the modifier.
+   * @return <code>true</code> if strictfp, <code>false</code> otherwise.
+   */
+  public static boolean isStrict(int mod)
+  {
+    return (mod & STRICT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is synchronized.
+   * @param mod the modifier.
+   * @return <code>true</code> if synchronized, <code>false</code> otherwise.
+   */
+  public static boolean isSynchronized(int mod)
+  {
+    return (mod & SYNCHRONIZED) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is transient.
+   * @param mod the modifier.
+   * @return <code>true</code> if transient, <code>false</code> otherwise.
+   */
+  public static boolean isTransient(int mod)
+  {
+    return (mod & TRANSIENT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is volatile.
+   * @param mod the modifier.
+   * @return <code>true</code> if volatile, <code>false</code> otherwise.
+   */
+  public static boolean isVolatile(int mod)
+  {
+    return (mod & VOLATILE) != 0;
+  }
+
+  /**
+   * Get a string representation of all the modifiers represented by the
+   * given int. The keywords are printed in this order:
+   * <code>&lt;public|protected|private&gt; abstract static final transient
+   * volatile synchronized native strictfp interface</code>.
+   *
+   * @param mod the modifier.
+   * @return the String representing the modifiers.
+   */
+  public static String toString(int mod)
+  {
+    return toString(mod, new CPStringBuilder()).toString();
+  }
+
+  /**
+   * Package helper method that can take a CPStringBuilder.
+   * @param mod the modifier
+   * @param r the CPStringBuilder to which the String representation is appended
+   * @return r, with information appended
+   */
+  static CPStringBuilder toString(int mod, CPStringBuilder r)
+  {
+    if (isPublic(mod))
+      r.append("public ");
+    if (isProtected(mod))
+      r.append("protected ");
+    if (isPrivate(mod))
+      r.append("private ");
+    if (isAbstract(mod))
+      r.append("abstract ");
+    if (isStatic(mod))
+      r.append("static ");
+    if (isFinal(mod))
+      r.append("final ");
+    if (isTransient(mod))
+      r.append("transient ");
+    if (isVolatile(mod))
+      r.append("volatile ");
+    if (isSynchronized(mod))
+      r.append("synchronized ");
+    if (isNative(mod))
+      r.append("native ");
+    if (isStrict(mod))
+      r.append("strictfp ");
+    if (isInterface(mod))
+      r.append("interface ");
+    
+    // Trim trailing space.
+    if ((mod & ALL_FLAGS) != 0)
+      r.setLength(r.length() - 1);
+    return r;
+  }
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java b/src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java
new file mode 100644 (file)
index 0000000..6a94711
--- /dev/null
@@ -0,0 +1,207 @@
+/* java.lang.reflect.VMConstructor - VM interface for reflection of Java constructors
+   Copyright (C) 1998, 2001, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import java.lang.annotation.Annotation;
+
+import java.util.Arrays;
+import java.util.Map;
+
+final class VMConstructor
+{
+  Class clazz;
+  int slot;
+
+  /**
+   * Unparsed annotations.
+   */
+  private byte[] annotations = null;
+
+  /**
+   * Unparsed parameter annotations.
+   */
+  private byte[] parameterAnnotations = null;
+
+  /**
+   * Annotations get parsed the first time they are
+   * accessed and are then cached it this map.
+   */
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
+
+  /**
+   * Helper array for creating a new array from a java.util.Container.
+   */
+  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+    new Annotation[0];
+
+  /** 
+   * This field allows us to refer back to the main constructor instance.
+   *  It is set by the constructor of Constructor.
+   */
+  Constructor cons;
+
+  VMConstructor(Class clazz, int slot)
+  {
+    this.clazz = clazz;
+    this.slot = slot;
+  }
+
+  public Class getDeclaringClass()
+  {
+    return clazz;
+  }
+
+  /**
+   * Return the raw modifiers for this constructor.  In particular
+   * this will include the synthetic and varargs bits.
+   * @return the constructor's modifiers
+   */
+  native int getModifiersInternal();
+
+  /**
+   * Get the parameter list for this constructor, in declaration order. If the
+   * constructor takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the constructor's parameters
+   */
+  native Class[] getParameterTypes();
+
+  /**
+   * Get the exception types this constructor says it throws, in no particular
+   * order. If the constructor has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the constructor's throws clause
+   */
+  native Class[] getExceptionTypes();
+
+  native Object construct(Object[] args)
+    throws InstantiationException, IllegalAccessException,
+    InvocationTargetException;
+
+  /**
+   * Return the String in the Signature attribute for this constructor. If there
+   * is no Signature attribute, return null.
+   */
+  native String getSignature();
+  
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the constructor's parameters.  The outer array is aligned against
+   * the parameters of the constructors and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this constructor.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  native Annotation[][] getParameterAnnotations();
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Constructors are semantically equivalent if they have the same
+   * declaring class and the same parameter list.  This ignores different
+   * exception clauses, but since you can't create a Method except through the
+   * VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not.
+   */
+  public boolean equals(Object o)
+  {
+    if (!(o instanceof Constructor))
+      return false;
+    Constructor that = (Constructor)o; 
+    if (clazz != that.getDeclaringClass())
+      return false;
+    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
+      return false;
+    return true;
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+//   native Annotation getAnnotation(Class annotationClass);
+  Annotation getAnnotation(Class annotationClass) {
+    if (annotationClass == null)
+      throw new NullPointerException();
+
+    return declaredAnnotations().get(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+//   native Annotation[] getDeclaredAnnotations();
+  Annotation[] getDeclaredAnnotations() {
+    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+  }
+
+  /**
+   * Parses the annotations if they aren't parsed yet and stores them into
+   * the declaredAnnotations map and return this map.
+   */
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/VMField.java b/src/classes/gnuclasspath/java/lang/reflect/VMField.java
new file mode 100644 (file)
index 0000000..eeb30a8
--- /dev/null
@@ -0,0 +1,583 @@
+/* java.lang.reflect.Field - VM interface for reflection of Java fields
+   Copyright (C) 1998, 2001, 2005, 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import java.lang.annotation.Annotation;
+
+import java.util.Map;
+
+final class VMField
+{
+  Class clazz;
+  String name;
+  int slot;
+  
+  /**
+   * Unparsed annotations.
+   */
+  private byte[] annotations = null;
+
+  /**
+   * Annotations get parsed the first time they are
+   * accessed and are then cached it this map.
+   */
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
+
+  /**
+   * Helper array for creating a new array from a java.util.Container.
+   */
+  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+    new Annotation[0];
+
+  /** 
+   * This field allows us to refer back to the main constructor instance.
+   *  It is set by the constructor of Field.
+   */
+  Field f;
+
+  VMField(Class clazz, String name, int slot)
+  {
+    this.clazz = clazz;
+    this.name = name;
+    this.slot = slot;
+  }
+
+  public Class getDeclaringClass()
+  {
+    return clazz;
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Return the raw modifiers for this field.
+   * @return the field's modifiers
+   */
+  native int getModifiersInternal();
+
+  /**
+   * Gets the type of this field.
+   * @return the type of this field
+   */
+  native Class getType();
+
+  /**
+   * Get the value of this Field.  If it is primitive, it will be wrapped
+   * in the appropriate wrapper type (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. If the field
+   * is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is accessed, and primitives are wrapped (but not
+   * necessarily in new objects). This method accesses the field of the
+   * declaring class, even if the instance passed in belongs to a subclass
+   * which declares another field to hide this one.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>o</code> is not an instance of
+   *         the class or interface declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #getBoolean(Object)
+   * @see #getByte(Object)
+   * @see #getChar(Object)
+   * @see #getShort(Object)
+   * @see #getInt(Object)
+   * @see #getLong(Object)
+   * @see #getFloat(Object)
+   * @see #getDouble(Object)
+   */
+  native Object get(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this boolean Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native boolean getBoolean(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this byte Field. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte field of
+   *         <code>o</code>, or if <code>o</code> is not an instance of the
+   *         declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native byte getByte(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a char. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char field of
+   *         <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native char getChar(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a short. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte or short
+   *         field of <code>o</code>, or if <code>o</code> is not an instance
+   *         of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native short getShort(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as an int. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, or
+   *         int field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native int getInt(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a long. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         or long field of <code>o</code>, or if <code>o</code> is not an
+   *         instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native long getLong(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a float. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, or float field of <code>o</code>, or if <code>o</code> is
+   *         not an instance of the declaring class of this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native float getFloat(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Get the value of this Field as a double. If the field is static,
+   * <code>o</code> will be ignored.
+   *
+   * @param o the object to get the value of this Field from
+   * @return the value of the Field
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, char, int,
+   *         long, float, or double field of <code>o</code>, or if
+   *         <code>o</code> is not an instance of the declaring class of this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #get(Object)
+   */
+  native double getDouble(Object o)
+    throws IllegalAccessException;
+
+  /**
+   * Set the value of this Field.  If it is a primitive field, the value
+   * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
+   *
+   * If the field is static, <code>o</code> will be ignored. Otherwise, if
+   * <code>o</code> is null, you get a <code>NullPointerException</code>,
+   * and if it is incompatible with the declaring class of the field, you
+   * get an <code>IllegalArgumentException</code>.<p>
+   *
+   * Next, if this Field enforces access control, your runtime context is
+   * evaluated, and you may have an <code>IllegalAccessException</code> if
+   * you could not access this field in similar compiled code. This also
+   * occurs whether or not there is access control if the field is final.
+   * If the field is primitive, and unwrapping your argument fails, you will
+   * get an <code>IllegalArgumentException</code>; likewise, this error
+   * happens if <code>value</code> cannot be cast to the correct object type.
+   * If the field is static, and its class is uninitialized, you trigger class
+   * initialization, which may end in a
+   * <code>ExceptionInInitializerError</code>.<p>
+   *
+   * Finally, the field is set with the widened value. This method accesses
+   * the field of the declaring class, even if the instance passed in belongs
+   * to a subclass which declares another field to hide this one.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if <code>value</code> cannot be
+   *         converted by a widening conversion to the underlying type of
+   *         the Field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #setBoolean(Object, boolean)
+   * @see #setByte(Object, byte)
+   * @see #setChar(Object, char)
+   * @see #setShort(Object, short)
+   * @see #setInt(Object, int)
+   * @see #setLong(Object, long)
+   * @see #setFloat(Object, float)
+   * @see #setDouble(Object, double)
+   */
+  native void set(Object o, Object value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this boolean Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a boolean field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setBoolean(Object o, boolean value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this byte Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a byte, short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setByte(Object o, byte value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this char Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a char, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setChar(Object o, char value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this short Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a short, int, long,
+   *         float, or double field, or if <code>o</code> is not an instance
+   *         of the class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setShort(Object o, short value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this int Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not an int, long, float, or
+   *         double field, or if <code>o</code> is not an instance of the
+   *         class declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setInt(Object o, int value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this long Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a long, float, or double
+   *         field, or if <code>o</code> is not an instance of the class
+   *         declaring this field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setLong(Object o, long value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this float Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a float or long field, or
+   *         if <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setFloat(Object o, float value)
+    throws IllegalAccessException;
+
+  /**
+   * Set this double Field. If the field is static, <code>o</code> will be
+   * ignored.
+   *
+   * @param o the object to set this Field on
+   * @param value the value to set this Field to
+   * @throws IllegalAccessException if you could not normally access this field
+   *         (i.e. it is not public)
+   * @throws IllegalArgumentException if this is not a double field, or if
+   *         <code>o</code> is not an instance of the class declaring this
+   *         field
+   * @throws NullPointerException if <code>o</code> is null and this field
+   *         requires an instance
+   * @throws ExceptionInInitializerError if accessing a static field triggered
+   *         class initialization, which then failed
+   * @see #set(Object, Object)
+   */
+  native void setDouble(Object o, double value)
+    throws IllegalAccessException;
+
+  /**
+   * Return the String in the Signature attribute for this field. If there
+   * is no Signature attribute, return null.
+   *
+   */
+  native String getSignature();
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Fields are semantically equivalent if they have the same declaring
+   * class, name, and type. Since you can't create a Field except through
+   * the VM, this is just the == relation.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+    if (!(o instanceof Field))
+      return false;
+    Field that = (Field)o; 
+    if (clazz != that.getDeclaringClass())
+      return false;
+    if (!name.equals(that.getName()))
+      return false;
+    if (getType() != that.getType())
+      return false;
+    return true;
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+//   native Annotation getAnnotation(Class annotationClass);
+  Annotation getAnnotation(Class annotationClass){
+    if (annotationClass == null)
+      throw new NullPointerException();
+
+    return declaredAnnotations().get(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+//   native Annotation[] getDeclaredAnnotations();
+  Annotation[] getDeclaredAnnotations() {
+    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+  }
+
+  /**
+   * Parses the annotations if they aren't parsed yet and stores them into
+   * the declaredAnnotations map and return this map.
+   */
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
+
+}
diff --git a/src/classes/gnuclasspath/java/lang/reflect/VMMethod.java b/src/classes/gnuclasspath/java/lang/reflect/VMMethod.java
new file mode 100644 (file)
index 0000000..ad556f2
--- /dev/null
@@ -0,0 +1,252 @@
+/* java.lang.reflect.VMMethod - VM interface for reflection of Java methods
+   Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+import java.lang.annotation.Annotation;
+
+import java.util.Arrays;
+import java.util.Map;
+
+final class VMMethod
+{
+  Class clazz;
+  String name;
+  int slot;
+
+  /**
+   * Unparsed annotations.
+   */
+  private byte[] annotations          = null;
+
+  /**
+   * Unparsed parameter annotations.
+   */
+  private byte[] parameterAnnotations = null;
+  
+  /**
+   * Unparsed annotation default value.
+   */
+  private byte[] annotationDefault    = null;
+
+  /**
+   * Annotations get parsed the first time they are
+   * accessed and are then cached it this map.
+   */
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
+
+  /**
+   * Helper array for creating a new array from a java.util.Container.
+   */
+  private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+    new Annotation[0];
+
+  /** 
+   * This field allows us to refer back to the main constructor instance.
+   *  It is set by the constructor of Field.
+   */
+  Method m;
+
+  public Class getDeclaringClass()
+  {
+    return clazz;
+  }
+
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Return the raw modifiers for this method.
+   * @return the method's modifiers
+   */
+  native int getModifiersInternal();
+
+  /**
+   * Gets the return type of this method.
+   * @return the type of this method
+   */
+  native Class getReturnType();
+
+  /**
+   * Get the parameter list for this method, in declaration order. If the
+   * method takes no parameters, returns a 0-length array (not null).
+   *
+   * @return a list of the types of the method's parameters
+   */
+  native Class[] getParameterTypes();
+
+  /**
+   * Get the exception types this method says it throws, in no particular
+   * order. If the method has no throws clause, returns a 0-length array
+   * (not null).
+   *
+   * @return a list of the types in the method's throws clause
+   */
+  native Class[] getExceptionTypes();
+
+  native Object invoke(Object o, Object[] args)
+    throws IllegalAccessException, InvocationTargetException;
+
+  /**
+   * Return the String in the Signature attribute for this method. If there
+   * is no Signature attribute, return null.
+   */
+  native String getSignature();
+
+  /**
+   * If this method is an annotation method, returns the default
+   * value for the method.  If there is no default value, or if the
+   * method is not a member of an annotation type, returns null.
+   * Primitive types are wrapped.
+   *
+   * @throws TypeNotPresentException if the method returns a Class,
+   * and the class cannot be found
+   *
+   * @since 1.5
+   */
+  native Object getDefaultValue();
+
+  /**
+   * <p>
+   * Return an array of arrays representing the annotations on each
+   * of the method's parameters.  The outer array is aligned against
+   * the parameters of the method and is thus equal in length to
+   * the number of parameters (thus having a length zero if there are none).
+   * Each array element in the outer array contains an inner array which
+   * holds the annotations.  This array has a length of zero if the parameter
+   * has no annotations.
+   * </p>
+   * <p>
+   * The returned annotations are serialized.  Changing the annotations has
+   * no affect on the return value of future calls to this method.
+   * </p>
+   * 
+   * @return an array of arrays which represents the annotations used on the
+   *         parameters of this method.  The order of the array elements
+   *         matches the declaration order of the parameters.
+   * @since 1.5
+   */
+  native Annotation[][] getParameterAnnotations();
+
+  /**
+   * Compare two objects to see if they are semantically equivalent.
+   * Two Methods are semantically equivalent if they have the same declaring
+   * class, name, parameter list, and return type.
+   *
+   * @param o the object to compare to
+   * @return <code>true</code> if they are equal; <code>false</code> if not
+   */
+  public boolean equals(Object o)
+  {
+      // Implementation note:
+      // The following is a correct but possibly slow implementation.
+      //
+      // This class has a private field 'slot' that could be used by
+      // the VM implementation to "link" a particular method to a Class.
+      // In that case equals could be simply implemented as:
+      //
+      // if (o instanceof Method)
+      // {
+      //    Method m = (Method)o;
+      //    return m.declaringClass == this.declaringClass
+      //           && m.slot == this.slot;
+      // }
+      // return false;
+      //
+      // If a VM uses the Method class as their native/internal representation
+      // then just using the following would be optimal:
+      //
+      // return this == o;
+      //
+    if (!(o instanceof Method))
+      return false;
+    Method that = (Method)o;
+    if (clazz != that.getDeclaringClass())
+      return false;
+    if (!name.equals(that.getName()))
+      return false;
+    if (getReturnType() != that.getReturnType())
+      return false;
+    if (!Arrays.equals(getParameterTypes(), that.getParameterTypes()))
+      return false;
+    return true;
+  }
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+//   native Annotation getAnnotation(Class annotationClass);
+  Annotation getAnnotation(Class annotationClass) {
+    if (annotationClass == null)
+      throw new NullPointerException();
+
+    return declaredAnnotations().get(annotationClass);
+  }
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+//   native Annotation[] getDeclaredAnnotations();
+  Annotation[] getDeclaredAnnotations() {
+    return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+  }
+
+  /**
+   * Parses the annotations if they aren't parsed yet and stores them into
+   * the declaredAnnotations map and return this map.
+   */
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
+
+}
+
diff --git a/src/classes/gnuclasspath/java/security/VMAccessController.java b/src/classes/gnuclasspath/java/security/VMAccessController.java
new file mode 100644 (file)
index 0000000..160df10
--- /dev/null
@@ -0,0 +1,281 @@
+/* VMAccessController.java -- VM-specific access controller methods.
+   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+
+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; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.security;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+
+final class VMAccessController
+{
+
+  // Fields.
+  // -------------------------------------------------------------------------
+
+  /**
+   * This is a per-thread stack of AccessControlContext objects (which can
+   * be null) for each call to AccessController.doPrivileged in each thread's
+   * call stack. We use this to remember which context object corresponds to
+   * which call.
+   */
+  private static final ThreadLocal contexts = new ThreadLocal();
+
+  /**
+   * This is a Boolean that, if set, tells getContext that it has already
+   * been called once, allowing us to handle recursive permission checks
+   * caused by methods getContext calls.
+   */
+  private static final ThreadLocal inGetContext = new ThreadLocal();
+
+  /**
+   * And we return this all-permissive context to ensure that privileged
+   * methods called from getContext succeed.
+   */
+  private static final AccessControlContext DEFAULT_CONTEXT;
+  static
+  {
+    CodeSource source = new CodeSource(null, null);
+    Permissions permissions = new Permissions();
+    permissions.add(new AllPermission());
+    ProtectionDomain[] domain = new ProtectionDomain[] {
+      new ProtectionDomain(source, permissions)
+    };
+    DEFAULT_CONTEXT = new AccessControlContext(domain);
+  }
+
+  private static final boolean DEBUG = gnu.classpath.Configuration.DEBUG;
+  private static void debug(String msg)
+  {
+    System.err.print(">>> VMAccessController: ");
+    System.err.println(msg);
+  }
+
+  // Constructors.
+  // -------------------------------------------------------------------------
+
+  private VMAccessController() { }
+
+  // Class methods.
+  // -------------------------------------------------------------------------
+
+  /**
+   * Relate a class (which should be an instance of {@link PrivilegedAction}
+   * with an access control context. This method is used by {@link
+   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}
+   * to set up the context that will be returned by {@link #getContext()}.
+   * This method relates the class to the current thread, so contexts
+   * pushed from one thread will not be available to another.
+   *
+   * @param acc The access control context.
+   */
+  static void pushContext (AccessControlContext acc)
+  {
+    if (DEBUG)
+      debug("pushing " + acc);
+    LinkedList stack = (LinkedList) contexts.get();
+    if (stack == null)
+      {
+         if (DEBUG)
+           debug("no stack... creating ");
+        stack = new LinkedList();
+        contexts.set(stack);
+      }
+    stack.addFirst(acc);
+  }
+
+  /**
+   * Removes the relation of a class to an {@link AccessControlContext}.
+   * This method is used by {@link AccessController} when exiting from a
+   * call to {@link
+   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}.
+   */
+  static void popContext()
+  {
+    if (DEBUG)
+      debug("popping context");
+
+    // Stack should never be null, nor should it be empty, if this method
+    // and its counterpart has been called properly.
+    LinkedList stack = (LinkedList) contexts.get();
+    if (stack != null)
+      {
+        stack.removeFirst();
+        if (stack.isEmpty())
+          contexts.set(null);
+      }
+    else if (DEBUG)
+      {
+        debug("no stack during pop?????");
+      }
+  }
+
+  /**
+   * Examine the method stack of the currently running thread, and create
+   * an {@link AccessControlContext} filled in with the appropriate {@link
+   * ProtectionDomain} objects given this stack.
+   *
+   * @return The context.
+   */
+  static AccessControlContext getContext()
+  {
+    // If we are already in getContext, but called a method that needs
+    // a permission check, return the all-permissive context so methods
+    // called from here succeed.
+    //
+    // XXX is this necessary? We should verify if there are any calls in
+    // the stack below this method that require permission checks.
+    Boolean inCall = (Boolean) inGetContext.get();
+    if (inCall != null && inCall.booleanValue())
+      {
+        if (DEBUG)
+          debug("already in getContext");
+        return DEFAULT_CONTEXT;
+      }
+
+    inGetContext.set(Boolean.TRUE);
+
+    Object[][] stack = getStack();
+    Class[] classes = (Class[]) stack[0];
+    String[] methods = (String[]) stack[1];
+
+    if (DEBUG)
+      debug("got trace of length " + classes.length);
+
+    HashSet domains = new HashSet();
+    HashSet seenDomains = new HashSet();
+    AccessControlContext context = null;
+    int privileged = 0;
+
+    // We walk down the stack, adding each ProtectionDomain for each
+    // class in the call stack. If we reach a call to doPrivileged,
+    // we don't add any more stack frames. We skip the first three stack
+    // frames, since they comprise the calls to getStack, getContext,
+    // and AccessController.getContext.
+    for (int i = 3; i < classes.length && privileged < 2; i++)
+      {
+        Class clazz = classes[i];
+        String method = methods[i];
+
+        if (DEBUG)
+          {
+            debug("checking " + clazz + "." + method);
+            // subject to getClassLoader RuntimePermission
+            debug("loader = " + clazz.getClassLoader());
+          }
+
+        // If the previous frame was a call to doPrivileged, then this is
+        // the last frame we look at.
+        if (privileged == 1)
+          privileged = 2;
+
+        if (clazz.equals (AccessController.class)
+            && method.equals ("doPrivileged"))
+          {
+            // If there was a call to doPrivileged with a supplied context,
+            // return that context. If using JAAS doAs*, it should be 
+           // a context with a SubjectDomainCombiner
+            LinkedList l = (LinkedList) contexts.get();
+            if (l != null)
+              context = (AccessControlContext) l.getFirst();
+            privileged = 1;
+          }
+
+        // subject to getProtectionDomain RuntimePermission
+       ProtectionDomain domain = clazz.getProtectionDomain();
+
+        if (domain == null)
+          continue;
+        if (seenDomains.contains(domain))
+          continue;
+        seenDomains.add(domain);
+
+        // Create a static snapshot of this domain, which may change over time
+        // if the current policy changes.
+        domains.add(new ProtectionDomain(domain.getCodeSource(),
+                                         domain.getPermissions()));
+      }
+
+    if (DEBUG)
+      debug("created domains: " + domains);
+
+    ProtectionDomain[] result = (ProtectionDomain[])
+      domains.toArray(new ProtectionDomain[domains.size()]);
+
+    if (context != null)
+      {
+        DomainCombiner dc = context.getDomainCombiner ();
+        // If the supplied context had no explicit DomainCombiner, use
+        // our private version, which computes the intersection of the
+        // context's domains with the derived set.
+        if (dc == null)
+          context = new AccessControlContext
+            (IntersectingDomainCombiner.SINGLETON.combine
+             (result, context.getProtectionDomains ()));
+        // Use the supplied DomainCombiner. This should be secure,
+        // because only trusted code may create an
+        // AccessControlContext with a custom DomainCombiner.
+        else
+          context = new AccessControlContext (result, context, dc);
+      }
+    // No context was supplied. Return the derived one.
+    else
+      context = new AccessControlContext (result);
+
+    inGetContext.set(Boolean.FALSE);
+    return context;
+  }
+
+  /**
+   * Returns a snapshot of the current call stack as a pair of arrays:
+   * the first an array of classes in the call stack, the second an array
+   * of strings containing the method names in the call stack. The two
+   * arrays match up, meaning that method <i>i</i> is declared in class
+   * <i>i</i>. The arrays are clean; it will only contain Java methods,
+   * and no element of the list should be null.
+   *
+   * <p>The default implementation returns an empty stack, which will be
+   * interpreted as having no permissions whatsoever.
+   *
+   * @return A pair of arrays describing the current call stack. The first
+   *    element is an array of Class objects, and the second is an array
+   *    of Strings comprising the method names.
+   */
+//    private static Object[][] getStack()
+//    {
+//      return new Object[][] { new Class[0], new String[0] };
+//    }
+  private native static Object[][] getStack();
+}
diff --git a/src/classes/gnuclasspath/sun/misc/Unsafe.java b/src/classes/gnuclasspath/sun/misc/Unsafe.java
new file mode 100644 (file)
index 0000000..2577488
--- /dev/null
@@ -0,0 +1,861 @@
+/*
+ * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.misc;
+
+import java.security.*;
+import java.lang.reflect.*;
+
+
+/**
+ * A collection of methods for performing low-level, unsafe operations.
+ * Although the class and all methods are public, use of this class is
+ * limited because only trusted code can obtain instances of it.
+ *
+ * @author John R. Rose
+ * @see #getUnsafe
+ */
+
+public final class Unsafe {
+
+    private static native void registerNatives();
+    static {
+        registerNatives();
+//        sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
+    }
+
+    private Unsafe() {}
+
+    private static final Unsafe theUnsafe = new Unsafe();
+
+    /**
+     * Provides the caller with the capability of performing unsafe
+     * operations.
+     *
+     * <p> The returned <code>Unsafe</code> object should be carefully guarded
+     * by the caller, since it can be used to read and write data at arbitrary
+     * memory addresses.  It must never be passed to untrusted code.
+     *
+     * <p> Most methods in this class are very low-level, and correspond to a
+     * small number of hardware instructions (on typical machines).  Compilers
+     * are encouraged to optimize these methods accordingly.
+     *
+     * <p> Here is a suggested idiom for using unsafe operations:
+     *
+     * <blockquote><pre>
+     * class MyTrustedClass {
+     *   private static final Unsafe unsafe = Unsafe.getUnsafe();
+     *   ...
+     *   private long myCountAddress = ...;
+     *   public int getCount() { return unsafe.getByte(myCountAddress); }
+     * }
+     * </pre></blockquote>
+     *
+     * (It may assist compilers to make the local variable be
+     * <code>final</code>.)
+     *
+     * @exception  SecurityException  if a security manager exists and its
+     *             <code>checkPropertiesAccess</code> method doesn't allow
+     *             access to the system properties.
+     */
+    public static Unsafe getUnsafe() {
+        Class cc = sun.reflect.Reflection.getCallerClass(2);
+        if (cc.getClassLoader() != null)
+            throw new SecurityException("Unsafe");
+        return theUnsafe;
+    }
+
+    /// peek and poke operations
+    /// (compilers should optimize these to memory ops)
+
+    // These work on object fields in the Java heap.
+    // They will not work on elements of packed arrays.
+
+    /**
+     * Fetches a value from a given Java variable.
+     * More specifically, fetches a field or array element within the given
+     * object <code>o</code> at the given offset, or (if <code>o</code> is
+     * null) from the memory address whose numerical value is the given
+     * offset.
+     * <p>
+     * The results are undefined unless one of the following cases is true:
+     * <ul>
+     * <li>The offset was obtained from {@link #objectFieldOffset} on
+     * the {@link java.lang.reflect.Field} of some Java field and the object
+     * referred to by <code>o</code> is of a class compatible with that
+     * field's class.
+     *
+     * <li>The offset and object reference <code>o</code> (either null or
+     * non-null) were both obtained via {@link #staticFieldOffset}
+     * and {@link #staticFieldBase} (respectively) from the
+     * reflective {@link Field} representation of some Java field.
+     *
+     * <li>The object referred to by <code>o</code> is an array, and the offset
+     * is an integer of the form <code>B+N*S</code>, where <code>N</code> is
+     * a valid index into the array, and <code>B</code> and <code>S</code> are
+     * the values obtained by {@link #arrayBaseOffset} and {@link
+     * #arrayIndexScale} (respectively) from the array's class.  The value
+     * referred to is the <code>N</code><em>th</em> element of the array.
+     *
+     * </ul>
+     * <p>
+     * If one of the above cases is true, the call references a specific Java
+     * variable (field or array element).  However, the results are undefined
+     * if that variable is not in fact of the type returned by this method.
+     * <p>
+     * This method refers to a variable by means of two parameters, and so
+     * it provides (in effect) a <em>double-register</em> addressing mode
+     * for Java variables.  When the object reference is null, this method
+     * uses its offset as an absolute address.  This is similar in operation
+     * to methods such as {@link #getInt(long)}, which provide (in effect) a
+     * <em>single-register</em> addressing mode for non-Java variables.
+     * However, because Java variables may have a different layout in memory
+     * from non-Java variables, programmers should not assume that these
+     * two addressing modes are ever equivalent.  Also, programmers should
+     * remember that offsets from the double-register addressing mode cannot
+     * be portably confused with longs used in the single-register addressing
+     * mode.
+     *
+     * @param o Java heap object in which the variable resides, if any, else
+     *        null
+     * @param offset indication of where the variable resides in a Java heap
+     *        object, if any, else a memory address locating the variable
+     *        statically
+     * @return the value fetched from the indicated Java variable
+     * @throws RuntimeException No defined exceptions are thrown, not even
+     *         {@link NullPointerException}
+     */
+    public native int getInt(Object o, long offset);
+
+    /**
+     * Stores a value into a given Java variable.
+     * <p>
+     * The first two parameters are interpreted exactly as with
+     * {@link #getInt(Object, long)} to refer to a specific
+     * Java variable (field or array element).  The given value
+     * is stored into that variable.
+     * <p>
+     * The variable must be of the same type as the method
+     * parameter <code>x</code>.
+     *
+     * @param o Java heap object in which the variable resides, if any, else
+     *        null
+     * @param offset indication of where the variable resides in a Java heap
+     *        object, if any, else a memory address locating the variable
+     *        statically
+     * @param x the value to store into the indicated Java variable
+     * @throws RuntimeException No defined exceptions are thrown, not even
+     *         {@link NullPointerException}
+     */
+    public native void putInt(Object o, long offset, int x);
+
+    /**
+     * Fetches a reference value from a given Java variable.
+     * @see #getInt(Object, long)
+     */
+    public native Object getObject(Object o, long offset);
+
+    /**
+     * Stores a reference value into a given Java variable.
+     * <p>
+     * Unless the reference <code>x</code> being stored is either null
+     * or matches the field type, the results are undefined.
+     * If the reference <code>o</code> is non-null, car marks or
+     * other store barriers for that object (if the VM requires them)
+     * are updated.
+     * @see #putInt(Object, int, int)
+     */
+    public native void putObject(Object o, long offset, Object x);
+
+    /** @see #getInt(Object, long) */
+    public native boolean getBoolean(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putBoolean(Object o, long offset, boolean x);
+    /** @see #getInt(Object, long) */
+    public native byte    getByte(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putByte(Object o, long offset, byte x);
+    /** @see #getInt(Object, long) */
+    public native short   getShort(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putShort(Object o, long offset, short x);
+    /** @see #getInt(Object, long) */
+    public native char    getChar(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putChar(Object o, long offset, char x);
+    /** @see #getInt(Object, long) */
+    public native long    getLong(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putLong(Object o, long offset, long x);
+    /** @see #getInt(Object, long) */
+    public native float   getFloat(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putFloat(Object o, long offset, float x);
+    /** @see #getInt(Object, long) */
+    public native double  getDouble(Object o, long offset);
+    /** @see #putInt(Object, int, int) */
+    public native void    putDouble(Object o, long offset, double x);
+
+    /**
+     * This method, like all others with 32-bit offsets, was native
+     * in a previous release but is now a wrapper which simply casts
+     * the offset to a long value.  It provides backward compatibility
+     * with bytecodes compiled against 1.4.
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public int getInt(Object o, int offset) {
+        return getInt(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putInt(Object o, int offset, int x) {
+        putInt(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public Object getObject(Object o, int offset) {
+        return getObject(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putObject(Object o, int offset, Object x) {
+        putObject(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public boolean getBoolean(Object o, int offset) {
+        return getBoolean(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putBoolean(Object o, int offset, boolean x) {
+        putBoolean(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public byte getByte(Object o, int offset) {
+        return getByte(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putByte(Object o, int offset, byte x) {
+        putByte(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public short getShort(Object o, int offset) {
+        return getShort(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putShort(Object o, int offset, short x) {
+        putShort(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public char getChar(Object o, int offset) {
+        return getChar(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putChar(Object o, int offset, char x) {
+        putChar(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public long getLong(Object o, int offset) {
+        return getLong(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putLong(Object o, int offset, long x) {
+        putLong(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public float getFloat(Object o, int offset) {
+        return getFloat(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putFloat(Object o, int offset, float x) {
+        putFloat(o, (long)offset, x);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public double getDouble(Object o, int offset) {
+        return getDouble(o, (long)offset);
+    }
+
+    /**
+     * @deprecated As of 1.4.1, cast the 32-bit offset argument to a long.
+     * See {@link #staticFieldOffset}.
+     */
+    @Deprecated
+    public void putDouble(Object o, int offset, double x) {
+        putDouble(o, (long)offset, x);
+    }
+
+    // These work on values in the C heap.
+
+    /**
+     * Fetches a value from a given memory address.  If the address is zero, or
+     * does not point into a block obtained from {@link #allocateMemory}, the
+     * results are undefined.
+     *
+     * @see #allocateMemory
+     */
+    public native byte    getByte(long address);
+
+    /**
+     * Stores a value into a given memory address.  If the address is zero, or
+     * does not point into a block obtained from {@link #allocateMemory}, the
+     * results are undefined.
+     *
+     * @see #getByte(long)
+     */
+    public native void    putByte(long address, byte x);
+
+    /** @see #getByte(long) */
+    public native short   getShort(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putShort(long address, short x);
+    /** @see #getByte(long) */
+    public native char    getChar(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putChar(long address, char x);
+    /** @see #getByte(long) */
+    public native int     getInt(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putInt(long address, int x);
+    /** @see #getByte(long) */
+    public native long    getLong(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putLong(long address, long x);
+    /** @see #getByte(long) */
+    public native float   getFloat(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putFloat(long address, float x);
+    /** @see #getByte(long) */
+    public native double  getDouble(long address);
+    /** @see #putByte(long, byte) */
+    public native void    putDouble(long address, double x);
+
+    /**
+     * Fetches a native pointer from a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p> If the native pointer is less than 64 bits wide, it is extended as
+     * an unsigned number to a Java long.  The pointer may be indexed by any
+     * given byte offset, simply by adding that offset (as a simple integer) to
+     * the long representing the pointer.  The number of bytes actually read
+     * from the target address maybe determined by consulting {@link
+     * #addressSize}.
+     *
+     * @see #allocateMemory
+     */
+    public native long getAddress(long address);
+
+    /**
+     * Stores a native pointer into a given memory address.  If the address is
+     * zero, or does not point into a block obtained from {@link
+     * #allocateMemory}, the results are undefined.
+     *
+     * <p> The number of bytes actually written at the target address maybe
+     * determined by consulting {@link #addressSize}.
+     *
+     * @see #getAddress(long)
+     */
+    public native void putAddress(long address, long x);
+
+    /// wrappers for malloc, realloc, free:
+
+    /**
+     * Allocates a new block of native memory, of the given size in bytes.  The
+     * contents of the memory are uninitialized; they will generally be
+     * garbage.  The resulting native pointer will never be zero, and will be
+     * aligned for all value types.  Dispose of this memory by calling {@link
+     * #freeMemory}, or resize it with {@link #reallocateMemory}.
+     *
+     * @throws IllegalArgumentException if the size is negative or too large
+     *         for the native size_t type
+     *
+     * @throws OutOfMemoryError if the allocation is refused by the system
+     *
+     * @see #getByte(long)
+     * @see #putByte(long, byte)
+     */
+    public native long allocateMemory(long bytes);
+
+    /**
+     * Resizes a new block of native memory, to the given size in bytes.  The
+     * contents of the new block past the size of the old block are
+     * uninitialized; they will generally be garbage.  The resulting native
+     * pointer will be zero if and only if the requested size is zero.  The
+     * resulting native pointer will be aligned for all value types.  Dispose
+     * of this memory by calling {@link #freeMemory}, or resize it with {@link
+     * #reallocateMemory}.  The address passed to this method may be null, in
+     * which case an allocation will be performed.
+     *
+     * @throws IllegalArgumentException if the size is negative or too large
+     *         for the native size_t type
+     *
+     * @throws OutOfMemoryError if the allocation is refused by the system
+     *
+     * @see #allocateMemory
+     */
+    public native long reallocateMemory(long address, long bytes);
+
+    /**
+     * Sets all bytes in a given block of memory to a fixed value
+     * (usually zero).
+     */
+    public native void setMemory(long address, long bytes, byte value);
+
+    /**
+     * Sets all bytes in a given block of memory to a copy of another
+     * block.
+     */
+    public native void copyMemory(long srcAddress, long destAddress,
+                                  long bytes);
+
+    /**
+     * Disposes of a block of native memory, as obtained from {@link
+     * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
+     * this method may be null, in which case no action is taken.
+     *
+     * @see #allocateMemory
+     */
+    public native void freeMemory(long address);
+
+    /// random queries
+
+    /**
+     * This constant differs from all results that will ever be returned from
+     * {@link #staticFieldOffset}, {@link #objectFieldOffset},
+     * or {@link #arrayBaseOffset}.
+     */
+    public static final int INVALID_FIELD_OFFSET   = -1;
+
+    /**
+     * Returns the offset of a field, truncated to 32 bits.
+     * This method is implemented as follows:
+     * <blockquote><pre>
+     * public int fieldOffset(Field f) {
+     *     if (Modifier.isStatic(f.getModifiers()))
+     *         return (int) staticFieldOffset(f);
+     *     else
+     *         return (int) objectFieldOffset(f);
+     * }
+     * </pre></blockquote>
+     * @deprecated As of 1.4.1, use {@link #staticFieldOffset} for static
+     * fields and {@link #objectFieldOffset} for non-static fields.
+     */
+    @Deprecated
+    public int fieldOffset(Field f) {
+        if (Modifier.isStatic(f.getModifiers()))
+            return (int) staticFieldOffset(f);
+        else
+            return (int) objectFieldOffset(f);
+    }
+
+    /**
+     * Returns the base address for accessing some static field
+     * in the given class.  This method is implemented as follows:
+     * <blockquote><pre>
+     * public Object staticFieldBase(Class c) {
+     *     Field[] fields = c.getDeclaredFields();
+     *     for (int i = 0; i < fields.length; i++) {
+     *         if (Modifier.isStatic(fields[i].getModifiers())) {
+     *             return staticFieldBase(fields[i]);
+     *         }
+     *     }
+     *     return null;
+     * }
+     * </pre></blockquote>
+     * @deprecated As of 1.4.1, use {@link #staticFieldBase(Field)}
+     * to obtain the base pertaining to a specific {@link Field}.
+     * This method works only for JVMs which store all statics
+     * for a given class in one place.
+     */
+    @Deprecated
+    public Object staticFieldBase(Class c) {
+        Field[] fields = c.getDeclaredFields();
+        for (int i = 0; i < fields.length; i++) {
+            if (Modifier.isStatic(fields[i].getModifiers())) {
+                return staticFieldBase(fields[i]);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Report the location of a given field in the storage allocation of its
+     * class.  Do not expect to perform any sort of arithmetic on this offset;
+     * it is just a cookie which is passed to the unsafe heap memory accessors.
+     *
+     * <p>Any given field will always have the same offset and base, and no
+     * two distinct fields of the same class will ever have the same offset
+     * and base.
+     *
+     * <p>As of 1.4.1, offsets for fields are represented as long values,
+     * although the Sun JVM does not use the most significant 32 bits.
+     * However, JVM implementations which store static fields at absolute
+     * addresses can use long offsets and null base pointers to express
+     * the field locations in a form usable by {@link #getInt(Object,long)}.
+     * Therefore, code which will be ported to such JVMs on 64-bit platforms
+     * must preserve all bits of static field offsets.
+     * @see #getInt(Object, long)
+     */
+    public native long staticFieldOffset(Field f);
+
+    /**
+     * Report the location of a given static field, in conjunction with {@link
+     * #staticFieldBase}.
+     * <p>Do not expect to perform any sort of arithmetic on this offset;
+     * it is just a cookie which is passed to the unsafe heap memory accessors.
+     *
+     * <p>Any given field will always have the same offset, and no two distinct
+     * fields of the same class will ever have the same offset.
+     *
+     * <p>As of 1.4.1, offsets for fields are represented as long values,
+     * although the Sun JVM does not use the most significant 32 bits.
+     * It is hard to imagine a JVM technology which needs more than
+     * a few bits to encode an offset within a non-array object,
+     * However, for consistency with other methods in this class,
+     * this method reports its result as a long value.
+     * @see #getInt(Object, long)
+     */
+    public native long objectFieldOffset(Field f);
+
+    /**
+     * Report the location of a given static field, in conjunction with {@link
+     * #staticFieldOffset}.
+     * <p>Fetch the base "Object", if any, with which static fields of the
+     * given class can be accessed via methods like {@link #getInt(Object,
+     * long)}.  This value may be null.  This value may refer to an object
+     * which is a "cookie", not guaranteed to be a real Object, and it should
+     * not be used in any way except as argument to the get and put routines in
+     * this class.
+     */
+    public native Object staticFieldBase(Field f);
+
+    /**
+     * Ensure the given class has been initialized. This is often
+     * needed in conjunction with obtaining the static field base of a
+     * class.
+     */
+    public native void ensureClassInitialized(Class c);
+
+    /**
+     * Report the offset of the first element in the storage allocation of a
+     * given array class.  If {@link #arrayIndexScale} returns a non-zero value
+     * for the same class, you may use that scale factor, together with this
+     * base offset, to form new offsets to access elements of arrays of the
+     * given class.
+     *
+     * @see #getInt(Object, long)
+     * @see #putInt(Object, long, int)
+     */
+    public native int arrayBaseOffset(Class arrayClass);
+
+    /**
+     * Report the scale factor for addressing elements in the storage
+     * allocation of a given array class.  However, arrays of "narrow" types
+     * will generally not work properly with accessors like {@link
+     * #getByte(Object, int)}, so the scale factor for such classes is reported
+     * as zero.
+     *
+     * @see #arrayBaseOffset
+     * @see #getInt(Object, long)
+     * @see #putInt(Object, long, int)
+     */
+    public native int arrayIndexScale(Class arrayClass);
+
+    /**
+     * Report the size in bytes of a native pointer, as stored via {@link
+     * #putAddress}.  This value will be either 4 or 8.  Note that the sizes of
+     * other primitive types (as stored in native memory blocks) is determined
+     * fully by their information content.
+     */
+    public native int addressSize();
+
+    /**
+     * Report the size in bytes of a native memory page (whatever that is).
+     * This value will always be a power of two.
+     */
+    public native int pageSize();
+
+
+    /// random trusted operations from JNI:
+
+    /**
+     * Tell the VM to define a class, without security checks.  By default, the
+     * class loader and protection domain come from the caller's class.
+     */
+    public native Class defineClass(String name, byte[] b, int off, int len,
+                                    ClassLoader loader,
+                                    ProtectionDomain protectionDomain);
+
+    public native Class defineClass(String name, byte[] b, int off, int len);
+
+    /** Allocate an instance but do not run any constructor.
+        Initializes the class if it has not yet been. */
+    public native Object allocateInstance(Class cls)
+        throws InstantiationException;
+
+    /** Lock the object.  It must get unlocked via {@link #monitorExit}. */
+    public native void monitorEnter(Object o);
+
+    /**
+     * Unlock the object.  It must have been locked via {@link
+     * #monitorEnter}.
+     */
+    public native void monitorExit(Object o);
+
+    /**
+     * Tries to lock the object.  Returns true or false to indicate
+     * whether the lock succeeded.  If it did, the object must be
+     * unlocked via {@link #monitorExit}.
+     */
+    public native boolean tryMonitorEnter(Object o);
+
+    /** Throw the exception without telling the verifier. */
+    public native void throwException(Throwable ee);
+
+
+    /**
+     * Atomically update Java variable to <tt>x</tt> if it is currently
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapObject(Object o, long offset,
+                                                     Object expected,
+                                                     Object x);
+
+    /**
+     * Atomically update Java variable to <tt>x</tt> if it is currently
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapInt(Object o, long offset,
+                                                  int expected,
+                                                  int x);
+
+    /**
+     * Atomically update Java variable to <tt>x</tt> if it is currently
+     * holding <tt>expected</tt>.
+     * @return <tt>true</tt> if successful
+     */
+    public final native boolean compareAndSwapLong(Object o, long offset,
+                                                   long expected,
+                                                   long x);
+
+    /**
+     * Fetches a reference value from a given Java variable, with volatile
+     * load semantics. Otherwise identical to {@link #getObject(Object, long)}
+     */
+    public native Object getObjectVolatile(Object o, long offset);
+
+    /**
+     * Stores a reference value into a given Java variable, with
+     * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)}
+     */
+    public native void    putObjectVolatile(Object o, long offset, Object x);
+
+    /** Volatile version of {@link #getInt(Object, long)}  */
+    public native int     getIntVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putInt(Object, long, int)}  */
+    public native void    putIntVolatile(Object o, long offset, int x);
+
+    /** Volatile version of {@link #getBoolean(Object, long)}  */
+    public native boolean getBooleanVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putBoolean(Object, long, boolean)}  */
+    public native void    putBooleanVolatile(Object o, long offset, boolean x);
+
+    /** Volatile version of {@link #getByte(Object, long)}  */
+    public native byte    getByteVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putByte(Object, long, byte)}  */
+    public native void    putByteVolatile(Object o, long offset, byte x);
+
+    /** Volatile version of {@link #getShort(Object, long)}  */
+    public native short   getShortVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putShort(Object, long, short)}  */
+    public native void    putShortVolatile(Object o, long offset, short x);
+
+    /** Volatile version of {@link #getChar(Object, long)}  */
+    public native char    getCharVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putChar(Object, long, char)}  */
+    public native void    putCharVolatile(Object o, long offset, char x);
+
+    /** Volatile version of {@link #getLong(Object, long)}  */
+    public native long    getLongVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putLong(Object, long, long)}  */
+    public native void    putLongVolatile(Object o, long offset, long x);
+
+    /** Volatile version of {@link #getFloat(Object, long)}  */
+    public native float   getFloatVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putFloat(Object, long, float)}  */
+    public native void    putFloatVolatile(Object o, long offset, float x);
+
+    /** Volatile version of {@link #getDouble(Object, long)}  */
+    public native double  getDoubleVolatile(Object o, long offset);
+
+    /** Volatile version of {@link #putDouble(Object, long, double)}  */
+    public native void    putDoubleVolatile(Object o, long offset, double x);
+
+    /**
+     * Version of {@link #putObjectVolatile(Object, long, Object)}
+     * that does not guarantee immediate visibility of the store to
+     * other threads. This method is generally only useful if the
+     * underlying field is a Java volatile (or if an array cell, one
+     * that is otherwise only accessed using volatile accesses).
+     */
+    public native void    putOrderedObject(Object o, long offset, Object x);
+
+    /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)}  */
+    public native void    putOrderedInt(Object o, long offset, int x);
+
+    /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */
+    public native void    putOrderedLong(Object o, long offset, long x);
+
+    /**
+     * Unblock the given thread blocked on <tt>park</tt>, or, if it is
+     * not blocked, cause the subsequent call to <tt>park</tt> not to
+     * block.  Note: this operation is "unsafe" solely because the
+     * caller must somehow ensure that the thread has not been
+     * destroyed. Nothing special is usually required to ensure this
+     * when called from Java (in which there will ordinarily be a live
+     * reference to the thread) but this is not nearly-automatically
+     * so when calling from native code.
+     * @param thread the thread to unpark.
+     *
+     */
+    public native void unpark(Object thread);
+
+    /**
+     * Block current thread, returning when a balancing
+     * <tt>unpark</tt> occurs, or a balancing <tt>unpark</tt> has
+     * already occurred, or the thread is interrupted, or, if not
+     * absolute and time is not zero, the given time nanoseconds have
+     * elapsed, or if absolute, the given deadline in milliseconds
+     * since Epoch has passed, or spuriously (i.e., returning for no
+     * "reason"). Note: This operation is in the Unsafe class only
+     * because <tt>unpark</tt> is, so it would be strange to place it
+     * elsewhere.
+     */
+    public native void park(boolean isAbsolute, long time);
+
+    /**
+     * Gets the load average in the system run queue assigned
+     * to the available processors averaged over various periods of time.
+     * This method retrieves the given <tt>nelem</tt> samples and
+     * assigns to the elements of the given <tt>loadavg</tt> array.
+     * The system imposes a maximum of 3 samples, representing
+     * averages over the last 1,  5,  and  15 minutes, respectively.
+     *
+     * @params loadavg an array of double of size nelems
+     * @params nelems the number of samples to be retrieved and
+     *         must be 1 to 3.
+     *
+     * @return the number of samples actually retrieved; or -1
+     *         if the load average is unobtainable.
+     */
+    public native int getLoadAverage(double[] loadavg, int nelems);
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/ConstantPool.java b/src/classes/gnuclasspath/sun/reflect/ConstantPool.java
new file mode 100644 (file)
index 0000000..b24d28e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect;
+
+import java.lang.reflect.*;
+
+/** Provides reflective access to the constant pools of classes.
+    Currently this is needed to provide reflective access to annotations
+    but may be used by other internal subsystems in the future. */
+
+public class ConstantPool {
+  // Number of entries in this constant pool (= maximum valid constant pool index)
+  public int      getSize()                      { return getSize0            (constantPoolOop);        }
+  public Class    getClassAt         (int index) { return getClassAt0         (constantPoolOop, index); }
+  public Class    getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
+  // Returns either a Method or Constructor.
+  // Static initializers are returned as Method objects.
+  public Member   getMethodAt        (int index) { return getMethodAt0        (constantPoolOop, index); }
+  public Member   getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }
+  public Field    getFieldAt         (int index) { return getFieldAt0         (constantPoolOop, index); }
+  public Field    getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }
+  // Fetches the class name, member (field, method or interface
+  // method) name, and type descriptor as an array of three Strings
+  public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }
+  public int      getIntAt           (int index) { return getIntAt0           (constantPoolOop, index); }
+  public long     getLongAt          (int index) { return getLongAt0          (constantPoolOop, index); }
+  public float    getFloatAt         (int index) { return getFloatAt0         (constantPoolOop, index); }
+  public double   getDoubleAt        (int index) { return getDoubleAt0        (constantPoolOop, index); }
+  public String   getStringAt        (int index) { return getStringAt0        (constantPoolOop, index); }
+  public String   getUTF8At          (int index) { return getUTF8At0          (constantPoolOop, index); }
+
+  //---------------------------------------------------------------------------
+  // Internals only below this point
+  //
+/* This hides this member from being visible through the reflection API in OpenJDK
+ * TODO: find out how to do this with GNU Classpath (if it's realy neccesary).
+
+  static {
+      Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });
+  }
+*/
+  // HotSpot-internal constant pool object (set by the VM, name known to the VM)
+  private Object constantPoolOop;
+
+  private native int      getSize0            (Object constantPoolOop);
+  private native Class    getClassAt0         (Object constantPoolOop, int index);
+  private native Class    getClassAtIfLoaded0 (Object constantPoolOop, int index);
+  private native Member   getMethodAt0        (Object constantPoolOop, int index);
+  private native Member   getMethodAtIfLoaded0(Object constantPoolOop, int index);
+  private native Field    getFieldAt0         (Object constantPoolOop, int index);
+  private native Field    getFieldAtIfLoaded0 (Object constantPoolOop, int index);
+  private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);
+  private native int      getIntAt0           (Object constantPoolOop, int index);
+  private native long     getLongAt0          (Object constantPoolOop, int index);
+  private native float    getFloatAt0         (Object constantPoolOop, int index);
+  private native double   getDoubleAt0        (Object constantPoolOop, int index);
+  private native String   getStringAt0        (Object constantPoolOop, int index);
+  private native String   getUTF8At0          (Object constantPoolOop, int index);
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java
new file mode 100644 (file)
index 0000000..8c5aca3
--- /dev/null
@@ -0,0 +1,873 @@
+/*
+ * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+
+import java.lang.annotation.*;
+import java.util.*;
+import java.nio.ByteBuffer;
+import java.nio.BufferUnderflowException;
+import java.lang.reflect.*;
+import sun.reflect.ConstantPool;
+
+import gnu.java.lang.reflect.FieldSignatureParser;
+
+
+/**
+ * Parser for Java programming language annotations.  Translates
+ * annotation byte streams emitted by compiler into annotation objects.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class AnnotationParser {
+    /**
+     * Parses the annotations described by the passed byte array,
+     * but returns Annotation[] so I don't have to do this in C.
+     *
+     * @author Mathias Panzenböck
+     * 
+     * @param rawAnnotations are the unparsed annotations
+     * @param constPool is the constant pool of the declaring class
+     * @param container is the containing class
+     * @return the parsed annotations in an array
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Annotation[] parseAnnotationsIntoArray(
+                byte[] rawAnnotations,
+                ConstantPool constPool,
+                Class container) {
+        Map<Class, Annotation> annotations = parseAnnotations(rawAnnotations, constPool, container);
+        return annotations.values().toArray(EMPTY_ANNOTATIONS_ARRAY);
+    }
+
+    /**
+     * Parses parameter annotations.
+     * 
+     * @author Mathias Panzenböck
+     * 
+     * @param parameterAnnotations are the unparsed parameter annotations
+     * @param constPool is the constant pool of the declaring class
+     * @param container is the containing class
+     * @return the parsed parameter annotations in an array 2 dimensional array
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Annotation[][] parseParameterAnnotations(
+                    byte[] parameterAnnotations,
+                    ConstantPool constPool,
+                    Class container,
+                    int numParameters) {
+        if (parameterAnnotations == null)
+            return new Annotation[numParameters][0];
+
+        Annotation[][] result = parseParameterAnnotations(
+            parameterAnnotations, constPool, container); 
+
+        if (result.length != numParameters)
+            throw new AnnotationFormatError(
+                "Parameter annotations don't match number of parameters (count was " +
+               result.length + " but should be " + numParameters + ").");
+        return result;
+    }
+
+    /**
+     * Parses the annotation default value of the supplied method.
+     * This method is basically copied from OpenJDKs
+     * java.lang.reflect.Method.getAnnotationDefault()
+     * 
+     * @author Mathias Panzenböck
+     *
+     * @param method represents the method for which the annotation default value has to be parsed
+     * @param annotationDefault is the unparsed annotation default value
+     * @param constPool is the constant pool of the declaring class
+     * @return the parsed annotation default value (boxed, if it's a primitive type)
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Object parseAnnotationDefault(Method method,
+                                                byte[] annotationDefault,
+                                                ConstantPool constPool) {
+        if  (annotationDefault == null)
+            return null;
+        
+       Class memberType = AnnotationType.invocationHandlerReturnType(
+            method.getReturnType());
+        
+       Object result = AnnotationParser.parseMemberValue(
+            memberType, ByteBuffer.wrap(annotationDefault),
+            constPool, method.getDeclaringClass());
+
+        if (result instanceof sun.reflect.annotation.ExceptionProxy)
+            throw new AnnotationFormatError("Invalid default: " + method);
+        
+       return result;
+    }
+
+    /**
+     * Parses the annotations described by the specified byte array.
+     * resolving constant references in the specified constant pool.
+     * The array must contain an array of annotations as described
+     * in the RuntimeVisibleAnnotations_attribute:
+     *
+     *   u2 num_annotations;
+     *   annotation annotations[num_annotations];
+     *
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Map<Class, Annotation> parseAnnotations(
+                byte[] rawAnnotations,
+                ConstantPool constPool,
+                Class container) {
+        if (rawAnnotations == null)
+            return Collections.emptyMap();
+
+        try {
+            return parseAnnotations2(rawAnnotations, constPool, container);
+        } catch(BufferUnderflowException e) {
+            throw new AnnotationFormatError("Unexpected end of annotations.");
+        } catch(IllegalArgumentException e) {
+            // Type mismatch in constant pool
+            throw new AnnotationFormatError(e);
+        }
+    }
+
+    private static Map<Class, Annotation> parseAnnotations2(
+                byte[] rawAnnotations,
+                ConstantPool constPool,
+                Class container) {
+        Map<Class, Annotation> result = new LinkedHashMap<Class, Annotation>();
+        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
+        int numAnnotations = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < numAnnotations; i++) {
+           Annotation a = parseAnnotation(buf, constPool, container, false);
+            if (a != null) {
+                Class klass = a.annotationType();
+                AnnotationType type = AnnotationType.getInstance(klass);
+                if (type.retention() == RetentionPolicy.RUNTIME)
+                    if (result.put(klass, a) != null)
+                        throw new AnnotationFormatError(
+                            "Duplicate annotation for class: "+klass+": " + a);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Parses the parameter annotations described by the specified byte array.
+     * resolving constant references in the specified constant pool.
+     * The array must contain an array of annotations as described
+     * in the RuntimeVisibleParameterAnnotations_attribute:
+     *
+     *    u1 num_parameters;
+     *    {
+     *        u2 num_annotations;
+     *        annotation annotations[num_annotations];
+     *    } parameter_annotations[num_parameters];
+     *
+     * Unlike parseAnnotations, rawAnnotations must not be null!
+     * A null value must be handled by the caller.  This is so because
+     * we cannot determine the number of parameters if rawAnnotations
+     * is null.  Also, the caller should check that the number
+     * of parameters indicated by the return value of this method
+     * matches the actual number of method parameters.  A mismatch
+     * indicates that an AnnotationFormatError should be thrown.
+     *
+     * @throws AnnotationFormatError if an annotation is found to be
+     *         malformed.
+     */
+    public static Annotation[][] parseParameterAnnotations(
+                    byte[] rawAnnotations,
+                    ConstantPool constPool,
+                    Class container) {
+        try {
+            return parseParameterAnnotations2(rawAnnotations, constPool, container);
+        } catch(BufferUnderflowException e) {
+            throw new AnnotationFormatError(
+                "Unexpected end of parameter annotations.");
+        } catch(IllegalArgumentException e) {
+            // Type mismatch in constant pool
+            throw new AnnotationFormatError(e);
+        }
+    }
+
+    private static Annotation[][] parseParameterAnnotations2(
+                    byte[] rawAnnotations,
+                    ConstantPool constPool,
+                    Class container) {
+        ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
+        int numParameters = buf.get() & 0xFF;
+        Annotation[][] result = new Annotation[numParameters][];
+
+        for (int i = 0; i < numParameters; i++) {
+            int numAnnotations = buf.getShort() & 0xFFFF;
+            List<Annotation> annotations =
+                new ArrayList<Annotation>(numAnnotations);
+            for (int j = 0; j < numAnnotations; j++) {
+                Annotation a = parseAnnotation(buf, constPool, container, false);
+                if (a != null) {
+                    AnnotationType type = AnnotationType.getInstance(
+                                              a.annotationType());
+                    if (type.retention() == RetentionPolicy.RUNTIME)
+                        annotations.add(a);
+                }
+            }
+            result[i] = annotations.toArray(EMPTY_ANNOTATIONS_ARRAY);
+        }
+        return result;
+    }
+
+    private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
+                    new Annotation[0];
+
+    /**
+     * Parses the annotation at the current position in the specified
+     * byte buffer, resolving constant references in the specified constant
+     * pool.  The cursor of the byte buffer must point to an "annotation
+     * structure" as described in the RuntimeVisibleAnnotations_attribute:
+     *
+     * annotation {
+     *    u2    type_index;
+     *       u2    num_member_value_pairs;
+     *       {    u2    member_name_index;
+     *             member_value value;
+     *       }    member_value_pairs[num_member_value_pairs];
+     *    }
+     * }
+     *
+     * Returns the annotation, or null if the annotation's type cannot
+     * be found by the VM, or is not a valid annotation type.
+     *
+     * @param exceptionOnMissingAnnotationClass if true, throw
+     * TypeNotPresentException if a referenced annotation type is not
+     * available at runtime
+     */
+    private static Annotation parseAnnotation(ByteBuffer buf,
+                                              ConstantPool constPool,
+                                              Class container,
+                                             boolean exceptionOnMissingAnnotationClass) {
+        int typeIndex = buf.getShort() & 0xFFFF;
+        Class annotationClass = null;
+       String sig = "[unknown]";
+        try {
+            try {
+                sig = constPool.getUTF8At(typeIndex);
+                annotationClass = parseSig(sig, container);
+            } catch (IllegalArgumentException ex) {
+                // support obsolete early jsr175 format class files
+                annotationClass = constPool.getClassAt(typeIndex);
+            }
+        } catch (NoClassDefFoundError e) {
+           if (exceptionOnMissingAnnotationClass)
+               // note: at this point sig is "[unknown]" or VM-style
+               // name instead of a binary name
+               throw new TypeNotPresentException(sig, e);
+            skipAnnotation(buf, false);
+            return null;
+        }
+       catch (TypeNotPresentException e) {
+           if (exceptionOnMissingAnnotationClass)
+               throw e;
+            skipAnnotation(buf, false);
+            return null;
+        }
+        AnnotationType type = null;
+        try {
+            type = AnnotationType.getInstance(annotationClass);
+        } catch (IllegalArgumentException e) {
+            skipAnnotation(buf, false);
+            return null;
+        }
+
+        Map<String, Class> memberTypes = type.memberTypes();
+        Map<String, Object> memberValues =
+            new LinkedHashMap<String, Object>(type.memberDefaults());
+
+        int numMembers = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < numMembers; i++) {
+            int memberNameIndex = buf.getShort() & 0xFFFF;
+            String memberName = constPool.getUTF8At(memberNameIndex);
+            Class memberType = memberTypes.get(memberName);
+
+            if (memberType == null) {
+                // Member is no longer present in annotation type; ignore it
+                skipMemberValue(buf);
+            } else {
+                Object value = parseMemberValue(memberType, buf, constPool, container);
+                if (value instanceof AnnotationTypeMismatchExceptionProxy)
+                    ((AnnotationTypeMismatchExceptionProxy) value).
+                        setMember(type.members().get(memberName));
+                memberValues.put(memberName, value);
+            }
+        }
+        return annotationForMap(annotationClass, memberValues);
+    }
+
+    /**
+     * Returns an annotation of the given type backed by the given
+     * member -> value map.
+     */
+    public static Annotation annotationForMap(
+        Class type, Map<String, Object> memberValues)
+    {
+        return (Annotation) Proxy.newProxyInstance(
+            type.getClassLoader(), new Class[] { type },
+            new AnnotationInvocationHandler(type, memberValues));
+    }
+
+    /**
+     * Parses the annotation member value at the current position in the
+     * specified byte buffer, resolving constant references in the specified
+     * constant pool.  The cursor of the byte buffer must point to a
+     * "member_value structure" as described in the
+     * RuntimeVisibleAnnotations_attribute:
+     *
+     *  member_value {
+     *    u1 tag;
+     *    union {
+     *       u2   const_value_index;
+     *       {
+     *           u2   type_name_index;
+     *           u2   const_name_index;
+     *       } enum_const_value;
+     *       u2   class_info_index;
+     *       annotation annotation_value; 
+     *       {
+     *           u2    num_values;
+     *           member_value values[num_values];
+     *       } array_value;
+     *    } value;
+     * }
+     *
+     * The member must be of the indicated type. If it is not, this
+     * method returns an AnnotationTypeMismatchExceptionProxy.
+     */
+    public static Object parseMemberValue(Class memberType, ByteBuffer buf,
+                                          ConstantPool constPool,
+                                          Class container) {
+        Object result = null;
+        int tag = buf.get();
+        switch(tag) {
+          case 'e':
+              return parseEnumValue(memberType, buf, constPool, container);
+          case 'c':
+              result = parseClassValue(buf, constPool, container);
+              break;
+          case '@':
+              result = parseAnnotation(buf, constPool, container, true);
+              break;
+          case '[':
+              return parseArray(memberType, buf, constPool, container);
+          default:
+              result = parseConst(tag, buf, constPool);
+        }
+
+        if (!(result instanceof ExceptionProxy) &&
+            !memberType.isInstance(result))
+            result = new AnnotationTypeMismatchExceptionProxy(
+                result.getClass() + "[" + result + "]");
+        return result;
+    }
+
+    /**
+     * Parses the primitive or String annotation member value indicated by 
+     * the specified tag byte at the current position in the specified byte
+     * buffer, resolving constant reference in the specified constant pool.
+     * The cursor of the byte buffer must point to an annotation member value
+     * of the type indicated by the specified tag, as described in the
+     * RuntimeVisibleAnnotations_attribute:
+     *
+     *       u2   const_value_index;
+     */
+    private static Object parseConst(int tag,
+                                     ByteBuffer buf, ConstantPool constPool) {
+        int constIndex = buf.getShort() & 0xFFFF;
+        switch(tag) {
+          case 'B':
+            return Byte.valueOf((byte) constPool.getIntAt(constIndex));
+          case 'C':
+            return Character.valueOf((char) constPool.getIntAt(constIndex));
+          case 'D':
+            return Double.valueOf(constPool.getDoubleAt(constIndex));
+          case 'F':
+            return Float.valueOf(constPool.getFloatAt(constIndex));
+          case 'I':
+            return Integer.valueOf(constPool.getIntAt(constIndex));
+          case 'J':
+            return Long.valueOf(constPool.getLongAt(constIndex));
+          case 'S':
+            return Short.valueOf((short) constPool.getIntAt(constIndex));
+          case 'Z':
+            return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
+          case 's':
+            return constPool.getUTF8At(constIndex);
+          default:
+            throw new AnnotationFormatError(
+                "Invalid member-value tag in annotation: " + tag);
+        }
+    }
+
+    /**
+     * Parses the Class member value at the current position in the
+     * specified byte buffer, resolving constant references in the specified
+     * constant pool.  The cursor of the byte buffer must point to a "class
+     * info index" as described in the RuntimeVisibleAnnotations_attribute:
+     *
+     *       u2   class_info_index;
+     */
+    private static Object parseClassValue(ByteBuffer buf,
+                                          ConstantPool constPool,
+                                          Class container) {
+        int classIndex = buf.getShort() & 0xFFFF;
+        try {
+            try {
+                String sig = constPool.getUTF8At(classIndex);
+                return parseSig(sig, container);
+            } catch (IllegalArgumentException ex) {
+                // support obsolete early jsr175 format class files
+                return constPool.getClassAt(classIndex);
+            }
+        } catch (NoClassDefFoundError e) {
+            return new TypeNotPresentExceptionProxy("[unknown]", e);
+        }
+        catch (TypeNotPresentException e) {
+            return new TypeNotPresentExceptionProxy(e.typeName(), e.getCause());
+        }
+    }
+
+    /**
+     * Parses a return type signature and returns the according Class object.
+     */
+    private static Class<?> parseSig(String sig, Class container) {
+        if (sig.equals("V")) {
+            return void.class;
+        }
+        else {
+            return toClass(new FieldSignatureParser(container, sig).getFieldType());
+        }
+    }
+
+    static Class<?> toClass(Type o) {
+        if (o instanceof GenericArrayType)
+            return Array.newInstance(toClass(((GenericArrayType)o).getGenericComponentType()),
+                                     0)
+                .getClass();
+        return (Class<?>)o;
+    }
+
+    /**
+     * Parses the enum constant member value at the current position in the
+     * specified byte buffer, resolving constant references in the specified
+     * constant pool.  The cursor of the byte buffer must point to a
+     * "enum_const_value structure" as described in the
+     * RuntimeVisibleAnnotations_attribute:
+     *
+     *       {
+     *           u2   type_name_index;
+     *           u2   const_name_index;
+     *       } enum_const_value;
+     */
+    private static Object parseEnumValue(Class enumType, ByteBuffer buf,
+                                         ConstantPool constPool,
+                                         Class container) {
+        int typeNameIndex = buf.getShort() & 0xFFFF;
+        String typeName  = constPool.getUTF8At(typeNameIndex);
+        int constNameIndex = buf.getShort() & 0xFFFF;
+        String constName = constPool.getUTF8At(constNameIndex);
+
+        if (!typeName.endsWith(";")) {
+            // support now-obsolete early jsr175-format class files.
+            if (!enumType.getName().equals(typeName))
+            return new AnnotationTypeMismatchExceptionProxy(
+                typeName + "." + constName);
+        } else if (enumType != parseSig(typeName, container)) {
+            return new AnnotationTypeMismatchExceptionProxy(
+                typeName + "." + constName);
+        }
+
+        try {
+            return  Enum.valueOf(enumType, constName);
+        } catch(IllegalArgumentException e) {
+            return new EnumConstantNotPresentExceptionProxy(
+                (Class<? extends Enum>)enumType, constName);
+        }
+    }
+
+    /**
+     * Parses the array value at the current position in the specified byte
+     * buffer, resolving constant references in the specified constant pool.
+     * The cursor of the byte buffer must point to an array value struct
+     * as specified in the RuntimeVisibleAnnotations_attribute:
+     *
+     *       {
+     *           u2    num_values;
+     *           member_value values[num_values];
+     *       } array_value;
+     *
+     * If the array values do not match arrayType, an
+     * AnnotationTypeMismatchExceptionProxy will be returned.
+     */
+    private static Object parseArray(Class arrayType,
+                                     ByteBuffer buf,
+                                     ConstantPool constPool,
+                                     Class container) {
+        int length = buf.getShort() & 0xFFFF;  // Number of array components
+        Class componentType = arrayType.getComponentType();
+
+        if (componentType == byte.class) {
+            return parseByteArray(length, buf, constPool); 
+        } else if (componentType == char.class) {
+            return parseCharArray(length, buf, constPool);
+        } else if (componentType == double.class) {
+            return parseDoubleArray(length, buf, constPool);
+        } else if (componentType == float.class) {
+            return parseFloatArray(length, buf, constPool);
+        } else if (componentType == int.class) {
+            return parseIntArray(length, buf, constPool);
+        } else if (componentType == long.class) {
+            return parseLongArray(length, buf, constPool);
+        } else if (componentType == short.class) {
+            return parseShortArray(length, buf, constPool);
+        } else if (componentType == boolean.class) {
+            return parseBooleanArray(length, buf, constPool);
+        } else if (componentType == String.class) {
+            return parseStringArray(length, buf, constPool);
+        } else if (componentType == Class.class) {
+            return parseClassArray(length, buf, constPool, container);
+        } else if (componentType.isEnum()) {
+            return parseEnumArray(length, componentType, buf,
+                                  constPool, container);
+        } else {
+            assert componentType.isAnnotation();
+            return parseAnnotationArray(length, componentType, buf,
+                                        constPool, container);
+        }
+    }
+
+    private static Object parseByteArray(int length,
+                                  ByteBuffer buf, ConstantPool constPool) {
+        byte[] result = new byte[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'B') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (byte) constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseCharArray(int length,
+                                  ByteBuffer buf, ConstantPool constPool) {
+        char[] result = new char[length];
+        boolean typeMismatch = false;
+        byte tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'C') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (char) constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseDoubleArray(int length,
+                                    ByteBuffer buf, ConstantPool constPool) {
+        double[] result = new  double[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'D') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getDoubleAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseFloatArray(int length,
+                                   ByteBuffer buf, ConstantPool constPool) {
+        float[] result = new float[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'F') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getFloatAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseIntArray(int length,
+                                 ByteBuffer buf, ConstantPool constPool) {
+        int[] result = new  int[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'I') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+    
+    private static Object parseLongArray(int length,
+                                  ByteBuffer buf, ConstantPool constPool) {
+        long[] result = new long[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'J') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getLongAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseShortArray(int length,
+                                   ByteBuffer buf, ConstantPool constPool) {
+        short[] result = new short[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'S') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (short) constPool.getIntAt(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseBooleanArray(int length,
+                                     ByteBuffer buf, ConstantPool constPool) {
+        boolean[] result = new boolean[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'Z') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = (constPool.getIntAt(index) != 0);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseStringArray(int length,
+                                    ByteBuffer buf,  ConstantPool constPool) {
+        String[] result = new String[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 's') {
+                int index = buf.getShort() & 0xFFFF;
+                result[i] = constPool.getUTF8At(index);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseClassArray(int length,
+                                          ByteBuffer buf,
+                                          ConstantPool constPool,
+                                          Class container) {
+        Object[] result = new Class[length];
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'c') {
+                result[i] = parseClassValue(buf, constPool, container);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseEnumArray(int length, Class enumType,
+                                         ByteBuffer buf,
+                                         ConstantPool constPool,
+                                         Class container) {
+        Object[] result = (Object[]) Array.newInstance(enumType, length);
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == 'e') {
+                result[i] = parseEnumValue(enumType, buf, constPool, container);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    private static Object parseAnnotationArray(int length,
+                                               Class annotationType,
+                                               ByteBuffer buf,
+                                               ConstantPool constPool,
+                                               Class container) {
+        Object[] result = (Object[]) Array.newInstance(annotationType, length);
+        boolean typeMismatch = false;
+        int tag = 0;
+
+        for (int i = 0; i < length; i++) {
+            tag = buf.get();
+            if (tag == '@') {
+                result[i] = parseAnnotation(buf, constPool, container, true);
+            } else {
+                skipMemberValue(tag, buf);
+                typeMismatch = true;
+            }
+        }
+        return typeMismatch ? exceptionProxy(tag) : result;
+    }
+
+    /**
+     * Return an appropriate exception proxy for a mismatching array
+     * annotation where the erroneous array has the specified tag.
+     */
+    private static ExceptionProxy exceptionProxy(int tag) {
+        return new AnnotationTypeMismatchExceptionProxy(
+            "Array with component tag: " + tag);
+    }
+
+    /**
+     * Skips the annotation at the current position in the specified
+     * byte buffer.  The cursor of the byte buffer must point to 
+     * an "annotation structure" OR two bytes into an annotation
+     * structure (i.e., after the type index).
+     * 
+     * @parameter complete true if the byte buffer points to the beginning
+     *     of an annotation structure (rather than two bytes in).
+     */
+    private static void skipAnnotation(ByteBuffer buf, boolean complete) {
+        if (complete)
+            buf.getShort();   // Skip type index
+        int numMembers = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < numMembers; i++) {
+            buf.getShort();   // Skip memberNameIndex
+            skipMemberValue(buf);
+        }
+    }
+
+    /**
+     * Skips the annotation member value at the current position in the
+     * specified byte buffer.  The cursor of the byte buffer must point to a
+     * "member_value structure."
+     */
+    private static void skipMemberValue(ByteBuffer buf) {
+        int tag = buf.get();
+        skipMemberValue(tag, buf);
+    }
+
+    /**
+     * Skips the annotation member value at the current position in the
+     * specified byte buffer.  The cursor of the byte buffer must point
+     * immediately after the tag in a "member_value structure."
+     */
+    private static void skipMemberValue(int tag, ByteBuffer buf) {
+        switch(tag) {
+          case 'e': // Enum value
+            buf.getInt();  // (Two shorts, actually.)
+            break;
+          case '@':
+            skipAnnotation(buf, true);
+            break;
+          case '[':
+            skipArray(buf);
+            break;
+          default:
+            // Class, primitive, or String
+            buf.getShort();
+        }
+    }
+
+    /**
+     * Skips the array value at the current position in the specified byte
+     * buffer.  The cursor of the byte buffer must point to an array value
+     * struct.
+     */
+    private static void skipArray(ByteBuffer buf) {
+        int length = buf.getShort() & 0xFFFF;
+        for (int i = 0; i < length; i++)
+            skipMemberValue(buf);
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java
new file mode 100644 (file)
index 0000000..ea559bb
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Represents an annotation type at run time.  Used to type-check annotations
+ * and apply member defaults.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class AnnotationType {
+    /**
+     * Annotation class -> AnnotationType mapping. This emulates
+     * sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and
+     * sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType() so
+     * this class can be used with gnu classpath.
+     *
+     * @author Mathias Panzenböck
+     */
+    private static Map<Class, AnnotationType> annotationTypes =
+        new HashMap<Class, AnnotationType>();
+
+    /**
+     * Member name -> type mapping. Note that primitive types
+     * are represented by the class objects for the corresponding wrapper
+     * types.  This matches the return value that must be used for a
+     * dynamic proxy, allowing for a simple isInstance test.
+     */
+    private final Map<String, Class> memberTypes = new HashMap<String,Class>();
+
+    /**
+     * Member name -> default value mapping.
+     */
+    private final Map<String, Object> memberDefaults =
+        new HashMap<String, Object>();
+
+    /**
+     * Member name -> Method object mapping. This (and its assoicated
+     * accessor) are used only to generate AnnotationTypeMismatchExceptions.
+     */
+    private final Map<String, Method> members = new HashMap<String, Method>();
+
+    /**
+     * The retention policy for this annotation type.
+     */
+    private RetentionPolicy retention = RetentionPolicy.RUNTIME;;
+
+    /**
+     * Whether this annotation type is inherited.
+     */
+    private boolean inherited = false;
+
+    /**
+     * Returns an AnnotationType instance for the specified annotation type.
+     *
+     * @throw IllegalArgumentException if the specified class object for
+     *     does not represent a valid annotation type
+     */
+    public static synchronized AnnotationType getInstance(
+        Class annotationClass)
+    {
+        /*
+       AnnotationType result = sun.misc.SharedSecrets.getJavaLangAccess(). 
+            getAnnotationType(annotationClass); 
+        */
+       // emulating OpenJDKs SharedSecrets in GNU Classpath:
+       AnnotationType result = annotationTypes.get(annotationClass); 
+       if (result == null)
+            result = new AnnotationType((Class<?>) annotationClass);
+
+        return result;
+    }
+
+    /**
+     * Sole constructor.
+     *
+     * @param annotationClass the class object for the annotation type
+     * @throw IllegalArgumentException if the specified class object for
+     *     does not represent a valid annotation type
+     */
+    private AnnotationType(final Class<?> annotationClass) {
+        if (!annotationClass.isAnnotation())
+            throw new IllegalArgumentException("Not an annotation type");
+
+       Method[] methods =      
+           AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+               public Method[] run() {
+                   // Initialize memberTypes and defaultValues
+                   return annotationClass.getDeclaredMethods();
+               }
+           });
+
+
+       for (Method method :  methods) {
+           if (method.getParameterTypes().length != 0)
+               throw new IllegalArgumentException(method + " has params");
+           String name = method.getName();
+           Class type = method.getReturnType();
+           memberTypes.put(name, invocationHandlerReturnType(type));
+           members.put(name, method);
+                   
+           Object defaultValue = method.getDefaultValue();
+           if (defaultValue != null)
+               memberDefaults.put(name, defaultValue);
+
+           members.put(name, method);
+       }
+
+       /*
+        sun.misc.SharedSecrets.getJavaLangAccess(). 
+            setAnnotationType(annotationClass, this); 
+        */
+       // emulating OpenJDKs SharedSecrets in GNU Classpath:
+       annotationTypes.put(annotationClass, this);
+
+        // Initialize retention, & inherited fields.  Special treatment
+        // of the corresponding annotation types breaks infinite recursion.
+        if (annotationClass != Retention.class &&
+            annotationClass != Inherited.class) {
+            Retention ret = annotationClass.getAnnotation(Retention.class);
+            retention = (ret == null ? RetentionPolicy.CLASS : ret.value());
+            inherited = annotationClass.isAnnotationPresent(Inherited.class);
+        }
+    }
+
+    /**
+     * Returns the type that must be returned by the invocation handler
+     * of a dynamic proxy in order to have the dynamic proxy return
+     * the specified type (which is assumed to be a legal member type
+     * for an annotation).
+     */
+    public static Class invocationHandlerReturnType(Class type) {
+        // Translate primitives to wrappers
+        if (type == byte.class)
+            return Byte.class;
+        if (type == char.class)
+            return Character.class;
+        if (type == double.class)
+            return Double.class;
+        if (type == float.class)
+            return Float.class;
+        if (type == int.class)
+            return Integer.class;
+        if (type == long.class)
+            return Long.class;
+        if (type == short.class)
+            return Short.class;
+        if (type == boolean.class)
+            return Boolean.class;
+
+        // Otherwise, just return declared type
+        return type;
+    }
+
+    /**
+     * Returns member types for this annotation type
+     * (member name -> type mapping).
+     */
+    public Map<String, Class> memberTypes() {
+        return memberTypes;
+    }
+
+    /**
+     * Returns members of this annotation type
+     * (member name -> associated Method object mapping).
+     */
+    public Map<String, Method> members() {
+        return members;
+    }
+
+    /**
+     * Returns the default values for this annotation type
+     * (Member name -> default value mapping).
+     */
+    public Map<String, Object> memberDefaults() {
+        return memberDefaults;
+    }
+
+    /**
+     * Returns the retention policy for this annotation type.
+     */
+    public RetentionPolicy retention() {
+        return retention;
+    }
+
+    /**
+     * Returns true if this this annotation type is inherited.
+     */
+    public boolean isInherited() {
+        return inherited;
+    }
+
+    /**
+     * For debugging.
+     */
+    public String toString() {
+        StringBuffer s = new StringBuffer("Annotation Type:" + "\n");
+        s.append("   Member types: " + memberTypes + "\n");
+        s.append("   Member defaults: " + memberDefaults + "\n");
+        s.append("   Retention policy: " + retention + "\n");
+        s.append("   Inherited: " + inherited);
+        return s.toString();
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
new file mode 100644 (file)
index 0000000..a7f434f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+import java.lang.annotation.*;
+import java.lang.reflect.Method;
+
+/**
+ * ExceptionProxy for AnnotationTypeMismatchException.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
+    private Method member;
+    private String foundType;
+
+    /**
+     * It turns out to be convenient to construct these proxies in
+     * two stages.  Since this is a private implementation class, we
+     * permit ourselves this liberty even though it's normally a very
+     * bad idea.
+     */
+    AnnotationTypeMismatchExceptionProxy(String foundType) {
+        this.foundType = foundType;
+    }
+
+    AnnotationTypeMismatchExceptionProxy setMember(Method member) {
+        this.member = member;
+        return this;
+    }
+
+    protected RuntimeException generateException() {
+        return new AnnotationTypeMismatchException(member, foundType);
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
new file mode 100644 (file)
index 0000000..6049a3f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+import java.lang.annotation.*;
+
+/**
+ * ExceptionProxy for EnumConstantNotPresentException.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
+    Class<? extends Enum> enumType;
+    String constName;
+
+    public EnumConstantNotPresentExceptionProxy(Class<? extends Enum> enumType,
+                                                String constName) {
+        this.enumType = enumType;
+        this.constName = constName;
+    }
+
+    protected RuntimeException generateException() {
+        return new EnumConstantNotPresentException(enumType, constName);
+    }
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java
new file mode 100644 (file)
index 0000000..e9cda0b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+
+/**
+ * An instance of this class is stored in an AnnotationInvocationHandler's
+ * "memberValues" map in lieu of a value for an annotation member that
+ * cannot be returned due to some exceptional condition (typically some
+ * form of illegal evolution of the annotation class).  The ExceptionProxy
+ * instance describes the exception that the dynamic proxy should throw if
+ * it is queried for this member.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public abstract class ExceptionProxy implements java.io.Serializable {
+    protected abstract RuntimeException generateException();
+}
diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java b/src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
new file mode 100644 (file)
index 0000000..22cab5d
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.reflect.annotation;
+import java.lang.annotation.*;
+
+/**
+ * ExceptionProxy for TypeNotPresentException.
+ *
+ * @author  Josh Bloch
+ * @since   1.5
+ */
+public class TypeNotPresentExceptionProxy extends ExceptionProxy {
+    String typeName;
+    Throwable cause;
+
+    public TypeNotPresentExceptionProxy(String typeName, Throwable cause) {
+        this.typeName = typeName;
+        this.cause = cause;
+    }
+
+    protected RuntimeException generateException() {
+        return new TypeNotPresentException(typeName, cause);
+    }
+}
index 7c8e33edf607799566b05cf627639bc55ea2b7cd..25282402efea2a07b837b411ac43b56eec3a338f 100644 (file)
@@ -149,9 +149,6 @@ void GC_suspend_handler(int sig, siginfo_t *info, void *uctx)
 {
    int old_errno = errno;
 
-/*    if (cacao_suspendhandler(uctx)) */
-/*      return; */
-
    GC_suspend_handler_inner((ptr_t)(word)sig);
    errno = old_errno;
 }
@@ -394,8 +391,6 @@ void GC_stop_world()
     GC_printf1("Stopping the world from 0x%lx\n", pthread_self());
     #endif
 
-    lock_stopworld(1);
-       
     /* Make sure all free list construction has stopped before we start. */
     /* No new construction can start, since free list construction is  */
     /* required to acquire and release the GC lock before it starts,   */
@@ -505,8 +500,6 @@ void GC_start_world()
            }
 #endif
 
-       unlock_stopworld();
-
     #if DEBUG_THREADS
       GC_printf0("World started\n");
     #endif
index 6e3c1279df22f54310ee7ea25f8d3bb9c82e49ee..bdecd1eef2815c7ba5229abb617756eb74931e8c 100644 (file)
@@ -63,7 +63,7 @@ JAVASE_HEADER_FILES = \
        java_util_concurrent_atomic_AtomicLong.h \
        sun_misc_Unsafe.h
 
-if WITH_CLASSPATH_GNU
+if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
 JAVASE_HEADER_FILES += \
        java_lang_VMThread.h \
        java_lang_VMThrowable.h \
@@ -84,7 +84,7 @@ JAVASE_HEADER_FILES += \
 endif
 endif
 
-if WITH_CLASSPATH_SUN
+if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
 JAVASE_HEADER_FILES += \
        java_lang_AssertionStatusDirectives.h \
        java_nio_ByteBuffer.h \
@@ -108,7 +108,7 @@ JVMTI_HEADER_FILES = \
        gnu_classpath_jdwp_event_EventRequest.h \
        gnu_classpath_jdwp_util_VariableTable.h
 
-if WITH_CLASSPATH_GNU
+if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
 ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
        gnu_classpath_VMStackWalker.h \
        gnu_classpath_VMSystemProperties.h \
@@ -150,11 +150,11 @@ DO_HEADER_FILES += \
        $(GEN_JVMTI_HEADER_FILES)
 endif
 
-if WITH_CLASSPATH_GNU
+if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
 VM_ZIP = $(top_builddir)/src/classes/vm.zip
 endif
 
-if WITH_CLASSPATH_CLDC1_1
+if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
 VM_ZIP = $(top_builddir)/src/classes/vm.zip
 endif
 
index 77f02a3868a1553ca573be0d85df2ed6a0903e71..6cfd983f9c98d085ffe1014f5446f508db004f7d 100644 (file)
@@ -40,7 +40,7 @@
 #include "native/native.h"
 
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 #  include "native/include/gnu_classpath_Pointer.h"
 
 #  if SIZEOF_VOID_P == 8
@@ -57,7 +57,7 @@
 
 #if defined(ENABLE_JAVASE)
 
-# if defined(WITH_CLASSPATH_SUN)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 #  include "native/include/java_nio_ByteBuffer.h"       /* required by j.l.CL */
 # endif
 
@@ -76,7 +76,7 @@ struct java_lang_ClassLoader;
 
 # include "native/include/java_nio_Buffer.h"
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 #  include "native/include/java_lang_reflect_VMConstructor.h"
 #  include "native/include/java_lang_reflect_VMField.h"
 #  include "native/include/java_lang_reflect_VMMethod.h"
@@ -150,7 +150,7 @@ static hashtable *hashtable_global_ref; /* hashtable for globalrefs           */
 #if defined(ENABLE_JAVASE)
 static classinfo *class_java_nio_Buffer;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
 static classinfo *class_java_nio_DirectByteBufferImpl;
 static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
@@ -163,7 +163,7 @@ static classinfo *class_gnu_classpath_Pointer32;
 
 static methodinfo *dbbirw_init;
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
 static classinfo *class_sun_nio_ch_DirectBuffer;
 static classinfo *class_java_nio_DirectByteBuffer;
@@ -204,7 +204,7 @@ bool jni_init(void)
                !link_class(class_java_nio_Buffer))
                return false;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        if (!(class_java_nio_DirectByteBufferImpl =
                  load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
@@ -234,7 +234,7 @@ bool jni_init(void)
                return false;
 #  endif
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        if (!(class_sun_nio_ch_DirectBuffer =
                  load_class_bootstrap(utf_new_char("sun/nio/ch/DirectBuffer"))))
@@ -1480,7 +1480,7 @@ jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
        methodinfo                      *m;
        int32_t                          slot;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_reflect_VMMethod      *rvmm;
        java_lang_reflect_VMConstructor *rvmc;
 #endif
@@ -1495,13 +1495,13 @@ jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
        if (o->vftbl->clazz == class_java_lang_reflect_Constructor) {
                rc = (java_lang_reflect_Constructor *) method;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
                LLNI_field_get_ref(rc,   cons , rvmc);
                LLNI_field_get_cls(rvmc, clazz, c);
                LLNI_field_get_val(rvmc, slot , slot);
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
                LLNI_field_get_cls(rc, clazz, c);
                LLNI_field_get_val(rc, slot , slot);
@@ -1515,13 +1515,13 @@ jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
 
                rm = (java_lang_reflect_Method *) method;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
                LLNI_field_get_ref(rm,   m ,    rvmm);
                LLNI_field_get_cls(rvmm, clazz, c);
                LLNI_field_get_val(rvmm, slot , slot);
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
                LLNI_field_get_cls(rm, clazz, c);
                LLNI_field_get_val(rm, slot , slot);
@@ -1558,7 +1558,7 @@ jfieldID jni_FromReflectedField(JNIEnv* env, jobject field)
        fieldinfo                 *f;
        int32_t                    slot;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_reflect_VMField *rvmf;
 #endif
 
@@ -1569,13 +1569,13 @@ jfieldID jni_FromReflectedField(JNIEnv* env, jobject field)
        if (rf == NULL)
                return NULL;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        LLNI_field_get_ref(rf,   f,     rvmf);
        LLNI_field_get_cls(rvmf, clazz, c);
        LLNI_field_get_val(rvmf, slot , slot);
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        LLNI_field_get_cls(rf, clazz, c);
        LLNI_field_get_val(rf, slot , slot);
@@ -3566,7 +3566,7 @@ jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
 jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
 {
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_handle_t           *nbuf;
 
 # if SIZEOF_VOID_P == 8
@@ -3602,7 +3602,7 @@ jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
 
        return _Jv_JNI_NewLocalRef(env, nbuf);
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        jobject o;
        int64_t addr;
@@ -3648,7 +3648,7 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 #if defined(ENABLE_JAVASE)
        java_handle_t                 *h;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        java_nio_DirectByteBufferImpl *nbuf;
        gnu_classpath_Pointer         *po;
@@ -3689,7 +3689,7 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 
        return p;
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        java_nio_Buffer *o;
        int64_t          address;
@@ -3737,7 +3737,7 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 
 jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
 {
-#if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
+#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_handle_t   *o;
        java_nio_Buffer *nbuf;
        jlong            capacity;
index be2aea2f5bac0a89ea44c16a311f92fc827da93b..9a4cd343f55d984a39cd2b519d419967c23e6e34 100644 (file)
@@ -514,7 +514,7 @@ functionptr native_method_resolve(methodinfo *m)
        u4                              key;    /* hashkey                        */
        u4                              slot;   /* slot in hashtable              */
 #endif
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        methodinfo                     *method_findNative;
        java_handle_t                  *s;
 #endif
@@ -572,7 +572,7 @@ functionptr native_method_resolve(methodinfo *m)
                le = le->hashlink;
        }
 
-# if defined(WITH_CLASSPATH_SUN)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        if (f == NULL) {
                /* We can resolve the function directly from
                   java.lang.ClassLoader as it's a static function. */
index 74cce363f2434752df10b1e0b4c318eea314d0b9..70d401e344d2d2535952352380e3d77fbf0af077 100644 (file)
@@ -27,10 +27,10 @@ LIBS =
 
 DIST_SUBDIRS = \
        cldc1.1 \
-       gnu \
-       sun
+       gnuclasspath \
+       openjdk
 
-if WITH_CLASSPATH_CLDC1_1
+if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
 SUBDIRS = \
        cldc1.1
 
@@ -38,20 +38,20 @@ NATIVEVM_LIB = \
        cldc1.1/libnativevmcore.la
 endif
 
-if WITH_CLASSPATH_GNU
+if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
 SUBDIRS = \
-       gnu
+       gnuclasspath
 
 NATIVEVM_LIB = \
-       gnu/libnativevmcore.la
+       gnuclasspath/libnativevmcore.la
 endif
 
-if WITH_CLASSPATH_SUN
+if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
 SUBDIRS = \
-       sun
+       openjdk
 
 NATIVEVM_LIB = \
-       sun/libnativevmcore.la
+       openjdk/libnativevmcore.la
 endif
 
 if ENABLE_JAVASE
diff --git a/src/native/vm/gnu/Makefile.am b/src/native/vm/gnu/Makefile.am
deleted file mode 100644 (file)
index 219f88d..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-## src/native/vm/gnu/Makefile.am
-##
-## Copyright (C) 1996-2005, 2006, 2008
-## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-##
-## 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.
-
-
-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 = \
-       libnativevmcore.la
-
-if ENABLE_JVMTI
-lib_LTLIBRARIES = \
-       libjdwp.la
-endif
-
-if ENABLE_ANNOTATIONS
-SUN_REFLECT_SOURCES = \
-       sun_reflect_ConstantPool.c
-endif
-
-libnativevmcore_la_SOURCES = \
-       gnu_classpath_VMStackWalker.c \
-       gnu_classpath_VMSystemProperties.c \
-       gnu_java_lang_VMCPStringBuilder.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_VMConstructor.c \
-       java_lang_reflect_VMField.c \
-       java_lang_reflect_VMMethod.c \
-       java_lang_reflect_VMProxy.c \
-       java_security_VMAccessController.c \
-       java_util_concurrent_atomic_AtomicLong.c \
-       $(SUN_REFLECT_SOURCES)
-
-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
deleted file mode 100644 (file)
index cc8aefd..0000000
+++ /dev/null
@@ -1,530 +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:
-
-*/
-
-#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
deleted file mode 100644 (file)
index 42016ae..0000000
+++ /dev/null
@@ -1,45 +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:
-
-*/
-
-#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
deleted file mode 100644 (file)
index eca8f53..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* src/native/vm/gnu/gnu_classpath_VMStackWalker.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#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 "native/include/gnu_classpath_VMStackWalker.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getClassContext",         "()[Ljava/lang/Class;",      (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getClassContext         },
-       { "getCallingClass",         "()Ljava/lang/Class;",       (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClass         },
-       { "getCallingClassLoader",   "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader   },
-       { "firstNonNullClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
-};
-
-
-/* _Jv_gnu_classpath_VMStackWalker_init ****************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_classpath_VMStackWalker_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/classpath/VMStackWalker");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getClassContext
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *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)
-{
-       classinfo *c;
-
-       c = stacktrace_get_caller_class(2);
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * Class:     gnu/classpath/VMStackWalker
- * Method:    getCallingClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
-{
-       classinfo     *c;
-       classloader_t *cl;
-
-       c  = stacktrace_get_caller_class(2);
-       cl = class_get_classloader(c);
-
-       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)
-{
-       classloader_t *cl;
-
-       cl = stacktrace_first_nonnull_classloader();
-
-       return (java_lang_ClassLoader *) cl;
-}
-
-
-/*
- * 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
deleted file mode 100644 (file)
index 5517c6c..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/* src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_util_Properties.h"
-
-#include "native/include/gnu_classpath_VMSystemProperties.h"
-
-#include "vm/exceptions.h"
-#include "vm/properties.h"
-#include "vm/vm.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "preInit",  "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_preInit  },
-       { "postInit", "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_postInit },
-};
-
-
-/* _Jv_gnu_classpat_VMSystemProperties_init ************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_classpath_VMSystemProperties_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/classpath/VMSystemProperties");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * 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 *properties)
-{
-       java_handle_t *p;
-
-       p = (java_handle_t *) properties;
-
-       if (p == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* fill the java.util.Properties object */
-
-       properties_system_add_all(p);
-}
-
-
-/*
- * Class:     gnu/classpath/VMSystemProperties
- * Method:    postInit
- * Signature: (Ljava/util/Properties;)V
- */
-JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
-{
-       java_handle_t *p;
-#if defined(ENABLE_JRE_LAYOUT)
-       char *java_home;
-       char *path;
-       s4    len;
-#endif
-
-       p = (java_handle_t *) properties;
-
-       if (p == NULL) {
-               exceptions_throw_nullpointerexception();
-               return;
-       }
-
-       /* post-set some properties */
-
-#if defined(ENABLE_JRE_LAYOUT)
-       /* XXX when we do it that way, we can't set these properties on
-          commandline */
-
-       java_home = properties_get("java.home");
-
-       properties_system_add(p, "gnu.classpath.home", java_home);
-
-       len =
-               strlen("file://") +
-               strlen(java_home) +
-               strlen("/lib") +
-               strlen("0");
-
-       path = MNEW(char, len);
-
-       strcpy(path, "file://");
-       strcat(path, java_home);
-       strcat(path, "/lib");
-
-       properties_system_add(p, "gnu.classpath.home.url", path);
-
-       MFREE(path, char, len);
-#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/gnu_classpath_jdwp_VMFrame.c b/src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c
deleted file mode 100644 (file)
index e647e4d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c - jdwp->jvmti interface
-
-   Copyright (C) 1996-2005, 2006, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/gnu_classpath_jdwp_VMFrame.h"
-
-#include "toolbox/logging.h"
-
-
-/*
- * Class:     gnu/classpath/jdwp/VMFrame
- * Method:    getValue
- * Signature: (I)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_gnu_classpath_jdwp_VMFrame_getValue(JNIEnv *env, gnu_classpath_jdwp_VMFrame* this, int32_t 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, gnu_classpath_jdwp_VMFrame* this, int32_t par1, java_lang_Object* par2)
-{
-       log_text ("JVMTI-Call: IMPLEMENT ME!!!");
-       return 0;
-}
-
-
-/*
- * 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_jdwp_VMMethod.c b/src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c
deleted file mode 100644 (file)
index 54ff534..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-/* src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c - jdwp->jvmti interface
-
-   Copyright (C) 1996-2005, 2006, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#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, 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, 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 int32_t JNICALL Java_gnu_classpath_jdwp_VMMethod_getModifiers(JNIEnv *env, 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
deleted file mode 100644 (file)
index 9e06a6b..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-/* src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c - jdwp->jvmti interface
-
-   Copyright (C) 1996-2005, 2006, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-#include <string.h>
-
-#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"
-
-
-/*
- * 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 int32_t 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 int32_t 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 int32_t 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, int32_t par2, int32_t 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 int32_t 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 int32_t 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, int32_t 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, int32_t 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_VMCPStringBuilder.c b/src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c
deleted file mode 100644 (file)
index 0511085..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "native/include/gnu_java_lang_VMCPStringBuilder.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "toString", "([CII)Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_VMCPStringBuilder_toString },
-};
-
-
-/* _Jv_gnu_java_lang_VMCPStringBuilder *****************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_VMCPStringBuilder_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/VMCPStringBuilder");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/VMCPStringBuilder
- * Method:    toString
- * Signature: ([CII)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, java_handle_chararray_t *value, int32_t startIndex, int32_t count)
-{
-       int32_t          length;
-       java_handle_t    *o;
-       java_lang_String *s;
-
-       /* This is a native version of
-          java.lang.String.<init>([CIIZ)Ljava/lang/String; */
-
-    if (startIndex < 0) {
-/*             exceptions_throw_stringindexoutofboundsexception("offset: " + offset); */
-               exceptions_throw_stringindexoutofboundsexception();
-               return NULL;
-       }
-
-    if (count < 0) {
-/*             exceptions_throw_stringindexoutofboundsexception("count: " + count); */
-               exceptions_throw_stringindexoutofboundsexception();
-               return NULL;
-       }
-
-    /* equivalent to: offset + count < 0 || offset + count > data.length */
-
-       LLNI_CRITICAL_START;
-       length = LLNI_array_size(value);
-       LLNI_CRITICAL_END;
-
-    if (length - startIndex < count) {
-/*             exceptions_throw_stringindexoutofboundsexception("offset + count: " + (offset + count)); */
-               exceptions_throw_stringindexoutofboundsexception();
-               return NULL;
-       }
-
-       o = builtin_new(class_java_lang_String);
-
-       if (o == NULL)
-               return NULL;
-
-       s = (java_lang_String *) o;
-
-       LLNI_field_set_ref(s, value,  value);
-       LLNI_field_set_val(s, count,  count);
-       LLNI_field_set_val(s, offset, startIndex);
-
-       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/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c b/src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
deleted file mode 100644 (file)
index ce3b6b4..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 2006, 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getLoadedClassCount",   "()I",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount   },
-       { "getUnloadedClassCount", "()J",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount },
-       { "isVerbose",             "()Z",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose             },
-       { "setVerbose",            "(Z)V", (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose            },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init ******************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMClassLoadingMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    getLoadedClassCount
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
-{
-       int32_t count;
-
-       count = classcache_get_loaded_class_count();
-
-       return count;
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
- * Method:    getUnloadedClassCount
- * Signature: ()J
- */
-JNIEXPORT int64_t 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 int32_t 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, int32_t 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
deleted file mode 100644 (file)
index 4c05838..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/* src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_management_MemoryUsage.h"
-
-#include "native/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/vm.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"               /* XXX only for load_class_bootstrap */
-#include "vmcore/options.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getHeapMemoryUsage",                "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage                },
-       { "getNonHeapMemoryUsage",             "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage             },
-       { "getObjectPendingFinalizationCount", "()I",                                  (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
-       { "isVerbose",                         "()Z",                                  (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose                         },
-       { "setVerbose",                        "(Z)V",                                 (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose                        },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * 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_handle_t                    *o;
-       java_lang_management_MemoryUsage *mu;
-       methodinfo                       *m;
-       int64_t                           init;
-       int64_t                           used;
-       int64_t                           commited;
-       int64_t                           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 int32_t 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 int32_t 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, int32_t 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
deleted file mode 100644 (file)
index cbd1e96..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/* src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
-
-   Copyright (C) 1996-2005, 2006, 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/vm.h"
-
-#include "vmcore/class.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getInputArguments", "()[Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments },
-       { "getStartTime",      "()J",                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime      },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init ***********************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMRuntimeMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
- * Method:    getInputArguments
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* 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 int64_t 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
deleted file mode 100644 (file)
index 862ed07..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/* src/native/vm/gnu/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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_management_ThreadInfo.h"
-
-#include "native/include/gnu_java_lang_management_VMThreadMXBeanImpl.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "findMonitorDeadlockedThreads", "()[J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads },
-       { "getCurrentThreadCpuTime",      "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime      },
-       { "getCurrentThreadUserTime",     "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime     },
-       { "getPeakThreadCount",           "()I",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount           },
-       { "getThreadCpuTime",             "(J)J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime             },
-       { "getThreadInfoForId",           "(JI)Ljava/lang/management/ThreadInfo;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId           },
-       { "getThreadUserTime",            "(J)J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime            },
-       { "getTotalStartedThreadCount",   "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount   },
-       { "resetPeakThreadCount",         "()V",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount         },
-};
-
-
-/* _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init ************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("gnu/java/lang/management/VMThreadMXBeanImpl");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
- * Method:    findMonitorDeadlockedThreads
- * Signature: ()[J
- */
-JNIEXPORT java_handle_longarray_t* 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 int64_t 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 int64_t 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 int32_t 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 int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, int64_t 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, int64_t id, int32_t 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 int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, int64_t 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 int64_t 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
deleted file mode 100644 (file)
index 886a3ce..0000000
+++ /dev/null
@@ -1,654 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMClass.c
-
-   Copyright (C) 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.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_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"
-
-#include "native/include/java_lang_VMClass.h"
-
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/class.h"
-
-#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
-#include "native/include/sun_reflect_ConstantPool.h"
-
-#include "vm/vm.h"
-
-#include "vmcore/annotation.h"
-#endif
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "isInstance",              "(Ljava/lang/Class;Ljava/lang/Object;)Z",                        (void *) (uintptr_t) &Java_java_lang_VMClass_isInstance              },
-       { "isAssignableFrom",        "(Ljava/lang/Class;Ljava/lang/Class;)Z",                         (void *) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom        },
-       { "isInterface",             "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isInterface             },
-       { "isPrimitive",             "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isPrimitive             },
-       { "getName",                 "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getName                 },
-       { "getSuperclass",           "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getSuperclass           },
-       { "getInterfaces",           "(Ljava/lang/Class;)[Ljava/lang/Class;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getInterfaces           },
-       { "getComponentType",        "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getComponentType        },
-       { "getModifiers",            "(Ljava/lang/Class;Z)I",                                         (void *) (uintptr_t) &Java_java_lang_VMClass_getModifiers            },
-       { "getDeclaringClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass       },
-       { "getDeclaredClasses",      "(Ljava/lang/Class;Z)[Ljava/lang/Class;",                        (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses      },
-       { "getDeclaredFields",       "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;",                (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields       },
-       { "getDeclaredMethods",      "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;",               (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods      },
-       { "getDeclaredConstructors", "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;",          (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors },
-       { "getClassLoader",          "(Ljava/lang/Class;)Ljava/lang/ClassLoader;",                    (void *) (uintptr_t) &Java_java_lang_VMClass_getClassLoader          },
-       { "forName",                 "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_forName                 },
-       { "isArray",                 "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isArray                 },
-       { "throwException",          "(Ljava/lang/Throwable;)V",                                      (void *) (uintptr_t) &Java_java_lang_VMClass_throwException          },
-#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
-       { "getDeclaredAnnotations",  "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;",         (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations  },
-#endif
-       { "getEnclosingClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass       },
-       { "getEnclosingConstructor", "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;",            (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor },
-       { "getEnclosingMethod",      "(Ljava/lang/Class;)Ljava/lang/reflect/Method;",                 (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod      },
-       { "getClassSignature",       "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getClassSignature       },
-       { "isAnonymousClass",        "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass        },
-       { "isLocalClass",            "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isLocalClass            },
-       { "isMemberClass",           "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isMemberClass           },
-};
-
-
-/* _Jv_java_lang_VMClass_init **************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMClass_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMClass");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isInstance
- * Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o)
-{
-       classinfo     *c;
-       java_handle_t *h;
-
-       c = LLNI_classinfo_unwrap(klass);
-       h = (java_handle_t *) o;
-
-       return class_is_instance(c, h);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isAssignableFrom
- * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
-{
-       classinfo *to;
-       classinfo *from;
-
-       to   = LLNI_classinfo_unwrap(klass);
-       from = LLNI_classinfo_unwrap(c);
-
-       if (from == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       return class_is_assignable_from(to, from);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isInterface
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return class_is_interface(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isPrimitive
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return class_is_primitive(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getName
- * Signature: (Ljava/lang/Class;)Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo* c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return (java_lang_String*) class_get_classname(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getSuperclass
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *super;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       super = class_get_superclass(c);
-
-       return LLNI_classinfo_wrap(super);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getInterfaces
- * Signature: (Ljava/lang/Class;)[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_interfaces(c);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getComponentType
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *component;
-       
-       c = LLNI_classinfo_unwrap(klass);
-       
-       component = class_get_componenttype(c);
-
-       return LLNI_classinfo_wrap(component);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getModifiers
- * Signature: (Ljava/lang/Class;Z)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t ignoreInnerClassesAttrib)
-{
-       classinfo *c;
-       int32_t    flags;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       flags = class_get_modifiers(c, ignoreInnerClassesAttrib);
-
-       return flags;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaringClass
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *dc;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       dc = class_get_declaringclass(c);
-
-       return LLNI_classinfo_wrap(dc);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredClasses
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredclasses(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredFields
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredfields(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredMethods
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredmethods(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredConstructors
- * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       oa = class_get_declaredconstructors(c, publicOnly);
-
-       return oa;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    getClassLoader
- * Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader;
- */
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo     *c;
-       classloader_t *cl;
-
-       c  = LLNI_classinfo_unwrap(klass);
-       cl = class_get_classloader(c);
-
-       return (java_lang_ClassLoader *) cl;
-}
-
-
-/*
- * 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, int32_t initialize, java_lang_ClassLoader *loader)
-{
-       classloader_t *cl;
-       utf           *ufile;
-       utf           *uname;
-       classinfo     *c;
-       u2            *pos;
-       int32_t        i;
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* illegal argument */
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       ufile = javastring_toutf((java_handle_t *) name, true);
-       uname = javastring_toutf((java_handle_t *) name, false);
-
-       /* name must not contain '/' (mauve test) */
-
-       for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) {
-               if (*pos == '/') {
-                       exceptions_throw_classnotfoundexception(uname);
-                       return NULL;
-               }
-       }
-
-       /* try to load, ... */
-
-       c = load_class_from_classloader(ufile, cl);
-
-       if (c == NULL)
-           return NULL;
-
-       /* link, ... */
-
-       if (!link_class(c))
-               return NULL;
-       
-       /* ...and initialize it, if required */
-
-       if (initialize)
-               if (!initialize_class(c))
-                       return NULL;
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isArray
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return class_is_array(c);
-}
-
-
-/*
- * 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)
-{
-       java_handle_t *o;
-
-       o = (java_handle_t *) t;
-
-       exceptions_set_exception(o);
-}
-
-
-#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/VMClass
- * Method:    getDeclaredAnnotations
- * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass)
-{
-       classinfo                *c               = NULL; /* classinfo for the java.lang.Class object 'klass'       */
-       static methodinfo        *m_parseAnnotationsIntoArray   = NULL; /* parser method (cached, therefore static) */
-       utf                      *utf_parseAnnotationsIntoArray = NULL; /* parser method name     */
-       utf                      *utf_desc        = NULL;               /* parser method descriptor (signature)     */
-       java_handle_bytearray_t  *annotations     = NULL;               /* unparsed annotations   */
-       sun_reflect_ConstantPool *constantPool    = NULL;               /* constant pool of klass */
-       java_lang_Object         *constantPoolOop = (java_lang_Object*)klass; /* constantPoolOop field of */
-                                                                             /* sun.reflect.ConstantPool */
-
-       if (klass == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-       
-       c = LLNI_classinfo_unwrap(klass);
-
-       /* get annotations: */
-       annotations = class_get_annotations(c);
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-       
-       if (constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-
-       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-
-       /* only resolve the parser method the first time */
-       if (m_parseAnnotationsIntoArray == NULL) {
-               utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray");
-               utf_desc = utf_new_char(
-                       "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
-                       "[Ljava/lang/annotation/Annotation;");
-
-               if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) {
-                       /* out of memory */
-                       return NULL;
-               }
-
-               m_parseAnnotationsIntoArray = class_resolveclassmethod(
-                       class_sun_reflect_annotation_AnnotationParser,
-                       utf_parseAnnotationsIntoArray,
-                       utf_desc,
-                       class_java_lang_Class,
-                       true);
-
-               if (m_parseAnnotationsIntoArray == NULL) {
-                       /* method not found */
-                       return NULL;
-               }
-       }
-
-       return (java_handle_objectarray_t*)vm_call_method(
-               m_parseAnnotationsIntoArray, NULL,
-               annotations, constantPool, 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)
-{
-       classinfo *c;
-       classinfo *result;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       result = class_get_enclosingclass(c);
-
-       return LLNI_classinfo_wrap(result);
-}
-
-
-/*
- * 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)
-{
-       classinfo*     c;
-       java_handle_t* h;
-
-       c = LLNI_classinfo_unwrap(klass);
-       h = class_get_enclosingconstructor(c);
-
-       return (java_lang_reflect_Constructor*) h;
-}
-
-
-/*
- * 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)
-{
-       classinfo*     c;
-       java_handle_t* h;
-
-       c = LLNI_classinfo_unwrap(klass);
-       h = class_get_enclosingmethod(c);
-
-       return (java_lang_reflect_Method*) h;
-}
-
-
-/*
- * 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;
-       utf           *u;
-       java_handle_t *s;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       u = class_get_signature(c);
-
-       if (u == NULL)
-               return NULL;
-
-       s = javastring_new(u);
-
-       /* in error case s is NULL */
-
-       return (java_lang_String *) s;
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isAnonymousClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       return class_is_anonymousclass(LLNI_classinfo_unwrap(klass));
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isLocalClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       return class_is_localclass(LLNI_classinfo_unwrap(klass));
-}
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isMemberClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
-{
-       return class_is_memberclass(LLNI_classinfo_unwrap(klass));
-}
-
-
-/*
- * 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
deleted file mode 100644 (file)
index 7df215c..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMClassLoader.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-#include <sys/stat.h>
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_security_ProtectionDomain.h"  /* required by... */
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_util_Vector.h"
-#include "native/include/java_util_HashMap.h"
-#include "native/include/java_util_Map.h"
-#include "native/include/java_lang_Boolean.h"
-
-#include "native/include/java_lang_VMClassLoader.h"
-
-#include "toolbox/logging.h"
-#include "toolbox/list.h"
-
-#if defined(ENABLE_ASSERTION)
-#include "vm/assertion.h"
-#endif
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/primitive.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/linker.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-#include "vmcore/suck.h"
-#include "vmcore/zip.h"
-
-#if defined(ENABLE_JVMTI)
-#include "native/jvmti/cacaodbg.h"
-#endif
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "defineClass",                "(Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defineClass                },
-       { "getPrimitiveClass",          "(C)Ljava/lang/Class;",                                                                             (void *) (uintptr_t) &Java_java_lang_VMClassLoader_getPrimitiveClass          },
-       { "resolveClass",               "(Ljava/lang/Class;)V",                                                                             (void *) (uintptr_t) &Java_java_lang_VMClassLoader_resolveClass               },
-       { "loadClass",                  "(Ljava/lang/String;Z)Ljava/lang/Class;",                                                           (void *) (uintptr_t) &Java_java_lang_VMClassLoader_loadClass                  },
-       { "nativeGetResources",         "(Ljava/lang/String;)Ljava/util/Vector;",                                                           (void *) (uintptr_t) &Java_java_lang_VMClassLoader_nativeGetResources         },
-       { "defaultAssertionStatus",     "()Z",                                                                                              (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultAssertionStatus     },
-       { "defaultUserAssertionStatus", "()Z",                                                                                              (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultUserAssertionStatus },
-       { "packageAssertionStatus0",    "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void *) (uintptr_t) &Java_java_lang_VMClassLoader_packageAssertionStatus0    },
-       { "classAssertionStatus0",      "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void *) (uintptr_t) &Java_java_lang_VMClassLoader_classAssertionStatus0      },
-       { "findLoadedClass",            "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;",                                     (void *) (uintptr_t) &Java_java_lang_VMClassLoader_findLoadedClass            },
-};
-
-
-/* _Jv_java_lang_VMClassLoader_init ********************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMClassLoader_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMClassLoader");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * 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_handle_bytearray_t *data, int32_t offset, int32_t len, java_security_ProtectionDomain *pd)
-{
-       utf             *utfname;
-       classinfo       *c;
-       classloader_t   *loader;
-       java_lang_Class *o;
-
-#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) > LLNI_array_size(data))) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       /* add classloader to classloader hashtable */
-
-       loader = loader_hashtable_classloader_add((java_handle_t *) cl);
-
-       if (name != NULL) {
-               /* convert '.' to '/' in java string */
-
-               utfname = javastring_toutf((java_handle_t *) name, true);
-       } 
-       else {
-               utfname = NULL;
-       }
-
-#if defined(ENABLE_JVMTI)
-       /* XXX again this will not work because of the indirection cell for classloaders */
-       assert(0);
-       /* fire Class File Load Hook JVMTI event */
-
-       if (jvmti)
-               jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data, 
-                                                               loader, (java_handle_t *) pd, 
-                                                               &new_class_data_len, &new_class_data);
-#endif
-
-       /* define the class */
-
-#if defined(ENABLE_JVMTI)
-       /* check if the JVMTI wants to modify the class */
-
-       if (new_class_data == NULL)
-               c = class_define(utfname, loader, new_class_data_len, new_class_data, pd); 
-       else
-#endif
-               c = class_define(utfname, loader, len, (uint8_t *) &LLNI_array_direct(data, offset), (java_handle_t *) pd);
-
-       if (c == NULL)
-               return NULL;
-
-       /* for convenience */
-
-       o = LLNI_classinfo_wrap(c);
-
-#if defined(WITH_CLASSPATH_GNU)
-       /* set ProtectionDomain */
-
-       LLNI_field_set_ref(o, pd, pd);
-#endif
-
-       return o;
-}
-
-
-/*
- * 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, int32_t type)
-{
-       classinfo *c;
-
-       c = primitive_class_get_by_char(type);
-
-       if (c == NULL) {
-               exceptions_throw_classnotfoundexception(utf_null);
-               return NULL;
-       }
-
-       return LLNI_classinfo_wrap(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 = LLNI_classinfo_unwrap(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, int32_t resolve)
-{
-       classinfo *c;
-       utf       *u;
-
-       if (name == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* create utf string in which '.' is replaced by '/' */
-
-       u = javastring_toutf((java_handle_t *) name, true);
-
-       /* load class */
-
-       c = load_class_bootstrap(u);
-
-       if (c == NULL)
-               return NULL;
-
-       /* resolve class -- if requested */
-
-/*     if (resolve) */
-               if (!link_class(c))
-                       return NULL;
-
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * 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)
-{
-       java_handle_t        *o;         /* vector being created     */
-       methodinfo           *m;         /* "add" method of vector   */
-       java_handle_t        *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         */
-       int32_t               namelen;   /* length of name to use    */
-       int32_t               searchlen; /* length of name to search */
-       int32_t               bufsize;   /* size of buffer allocated */
-       int32_t               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((java_handle_t *) name, false);
-
-       if (utfname == NULL)
-               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 == NULL)
-               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 == NULL)
-               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 != NULL) {
-                       ret = vm_call_method_int(m, o, path);
-
-                       if (exceptions_get_exception() != NULL)
-                               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 int32_t JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_ASSERTION)
-       return assertion_system_enabled;
-#else
-       return false;
-#endif
-}
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    userAssertionStatus
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_ASSERTION)
-       return assertion_user_enabled;
-#else
-       return false;
-#endif
-}
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    packageAssertionStatus
- * Signature: ()Ljava_util_Map;
- */
-JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
-{
-       java_handle_t     *hm;
-#if defined(ENABLE_ASSERTION)
-       java_handle_t     *js;
-       methodinfo        *m;
-       assertion_name_t  *item;
-#endif
-
-       /* new HashMap() */
-
-       hm = native_new_and_init(class_java_util_HashMap);
-       if (hm == NULL) {
-               return NULL;
-       }
-
-#if defined(ENABLE_ASSERTION)
-       /* if nothing todo, return now */
-
-       if (assertion_package_count == 0) {
-               return (java_util_Map *) hm;
-       }
-
-       /* get HashMap.put method */
-
-       m = class_resolveclassmethod(class_java_util_HashMap,
-                                 utf_put,
-                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
-                                 NULL,
-                                 true);
-
-       if (m == NULL) {
-               return NULL;
-       }
-
-       item = (assertion_name_t *)list_first(list_assertion_names);
-
-       while (item != NULL) {
-               if (item->package == false) {
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-                       continue;
-               }
-               
-               if (strcmp(item->name, "") == 0) {
-                       /* unnamed package wanted */
-                       js = NULL;
-               }
-               else {
-                       js = javastring_new_from_ascii(item->name);
-                       if (js == NULL) {
-                               return NULL;
-                       }
-               }
-
-               if (item->enabled == true) {
-                       vm_call_method(m, hm, js, jtrue);
-               }
-               else {
-                       vm_call_method(m, hm, js, jfalse);
-               }
-
-               item = (assertion_name_t *)list_next(list_assertion_names, item);
-       }
-#endif
-
-       return (java_util_Map *) hm;
-}
-
-/*
- * Class:     java/lang/VMClassLoader
- * Method:    classAssertionStatus
- * Signature: ()Ljava_util_Map;
- */
-JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
-{
-       java_handle_t     *hm;
-#if defined(ENABLE_ASSERTION)
-       java_handle_t     *js;
-       methodinfo        *m;
-       assertion_name_t  *item;
-#endif
-
-       /* new HashMap() */
-
-       hm = native_new_and_init(class_java_util_HashMap);
-       if (hm == NULL) {
-               return NULL;
-       }
-
-#if defined(ENABLE_ASSERTION)
-       /* if nothing todo, return now */
-
-       if (assertion_class_count == 0) {
-               return (java_util_Map *) hm;
-       }
-
-       /* get HashMap.put method */
-
-       m = class_resolveclassmethod(class_java_util_HashMap,
-                                 utf_put,
-                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
-                                 NULL,
-                                 true);
-
-       if (m == NULL) {
-               return NULL;
-       }
-
-       item = (assertion_name_t *)list_first(list_assertion_names);
-
-       while (item != NULL) {
-               if (item->package == true) {
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-                       continue;
-               }
-
-               js = javastring_new_from_ascii(item->name);
-               if (js == NULL) {
-                       return NULL;
-               }
-
-               if (item->enabled == true) {
-                       vm_call_method(m, hm, js, jtrue);
-               }
-               else {
-                       vm_call_method(m, hm, js, jfalse);
-               }
-
-               item = (assertion_name_t *)list_next(list_assertion_names, item);
-       }
-#endif
-
-       return (java_util_Map *) hm;
-}
-
-
-/*
- * 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 *loader, java_lang_String *name)
-{
-       classloader_t *cl;
-       classinfo     *c;
-       utf           *u;
-
-       /* XXX is it correct to add the classloader to the hashtable here? */
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* replace `.' by `/', this is required by the classcache */
-
-       u = javastring_toutf((java_handle_t *) name, true);
-
-       /* lookup for defining classloader */
-
-       c = classcache_lookup_defined(cl, u);
-
-       /* if not found, lookup for initiating classloader */
-
-       if (c == NULL)
-               c = classcache_lookup(cl, u);
-
-       return LLNI_classinfo_wrap(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
deleted file mode 100644 (file)
index ea0ba0e..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMObject.c - java/lang/VMObject
-
-   Copyright (C) 1996-2005, 2006, 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Class.h"            /* required by j.l.VMO */
-#include "native/include/java_lang_Cloneable.h"        /* required by j.l.VMO */
-#include "native/include/java_lang_Object.h"           /* required by j.l.VMO */
-
-#include "native/include/java_lang_VMObject.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getClass",  "(Ljava/lang/Object;)Ljava/lang/Class;",     (void *) (intptr_t) &Java_java_lang_VMObject_getClass  },
-       { "clone",     "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void *) (intptr_t) &Java_java_lang_VMObject_clone     },
-       { "notify",    "(Ljava/lang/Object;)V",                     (void *) (intptr_t) &Java_java_lang_VMObject_notify    },
-       { "notifyAll", "(Ljava/lang/Object;)V",                     (void *) (intptr_t) &Java_java_lang_VMObject_notifyAll },
-       { "wait",      "(Ljava/lang/Object;JI)V",                   (void *) (intptr_t) &Java_java_lang_VMObject_wait      },
-};
-
-
-/* _Jv_java_lang_VMObject_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMObject_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMObject");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * 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 == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       LLNI_class_get(obj, c);
-
-       return LLNI_classinfo_wrap(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_handle_t *o;
-       java_handle_t *co;
-
-       o = (java_handle_t *) this;
-
-       co = builtin_clone(NULL, o);
-
-       return (java_lang_Object *) co;
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    notify
- * Signature: (Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this)
-{
-#if defined(ENABLE_THREADS)
-       lock_notify_object((java_handle_t *) this);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMObject
- * Method:    notifyAll
- * Signature: (Ljava/lang/Object;)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((java_handle_t *) this);
-#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, int64_t ms, int32_t ns)
-{
-#if defined(ENABLE_JVMTI)
-       /* Monitor Wait */
-       if (jvmti) jvmti_MonitorWaiting(true, o, ms);
-#endif
-
-#if defined(ENABLE_THREADS)
-       lock_wait_for_object((java_handle_t *) o, 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
deleted file mode 100644 (file)
index 25be0db..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMRuntime.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/utsname.h>
-
-#if defined(__DARWIN__)
-# if defined(__POWERPC__)
-#  define OS_INLINE    /* required for <libkern/ppc/OSByteOrder.h> */
-# endif
-# include <mach/mach.h>
-#endif
-
-#include "mm/dumpmemory.h"
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_io_File.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Process.h"
-
-#include "native/include/java_lang_VMRuntime.h"
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vmcore/system.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "exit",                   "(I)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_exit                   },
-       { "freeMemory",             "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_freeMemory             },
-       { "totalMemory",            "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_totalMemory            },
-       { "maxMemory",              "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_maxMemory              },
-       { "gc",                     "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_gc                     },
-       { "runFinalization",        "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalization        },
-       { "runFinalizersOnExit",    "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizersOnExit    },
-       { "runFinalizationForExit", "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizationForExit },
-       { "traceInstructions",      "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_traceInstructions      },
-       { "traceMethodCalls",       "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_traceMethodCalls       },
-       { "availableProcessors",    "()I",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_availableProcessors    },
-       { "nativeLoad",             "(Ljava/lang/String;Ljava/lang/ClassLoader;)I", (void *) (intptr_t) &Java_java_lang_VMRuntime_nativeLoad             },
-       { "mapLibraryName",         "(Ljava/lang/String;)Ljava/lang/String;",       (void *) (intptr_t) &Java_java_lang_VMRuntime_mapLibraryName         },
-};
-
-
-/* _Jv_java_lang_VMRuntime_init ************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMRuntime_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMRuntime");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-static bool finalizeOnExit = false;
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    exit
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, int32_t status)
-{
-       if (finalizeOnExit)
-               gc_finalize_all();
-
-       vm_shutdown(status);
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    freeMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_free_bytes();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    totalMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
-{
-       return gc_get_heap_size();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    maxMemory
- * Signature: ()J
- */
-JNIEXPORT int64_t 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, int32_t 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, int32_t par1)
-{
-       /* not supported */
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    traceMethodCalls
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, int32_t par1)
-{
-       /* not supported */
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    availableProcessors
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
-{
-       return system_processors_online();
-}
-
-
-/*
- * Class:     java/lang/VMRuntime
- * Method:    nativeLoad
- * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *libname, java_lang_ClassLoader *loader)
-{
-       classloader_t *cl;
-       utf           *name;
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* REMOVEME When we use Java-strings internally. */
-
-       if (libname == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       name = javastring_toutf((java_handle_t *) libname, false);
-
-       return native_library_load(env, name, cl);
-}
-
-
-/*
- * 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;
-       int32_t        buffer_len;
-       java_handle_t *o;
-       int32_t        dumpmarker;
-
-       if (libname == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       u = javastring_toutf((java_handle_t *) libname, false);
-
-       /* 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");
-
-       DMARKER;
-
-       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
-
-       o = javastring_new_from_utf_string(buffer);
-
-       /* release memory */
-
-       DRELEASE;
-
-       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:
- * 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
deleted file mode 100644 (file)
index 993b661..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMString.c - java/lang/VMString
-
-   Copyright (C) 1996-2005, 2006, 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdlib.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_VMString.h"
-
-#include "vm/stringlocal.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "intern", "(Ljava/lang/String;)Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_VMString_intern },
-};
-
-
-/* _Jv_java_lang_VMString_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMString_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMString");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * 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)
-{
-       if (str == NULL)
-               return NULL;
-
-       return (java_lang_String *) javastring_intern((java_handle_t *) str);
-}
-
-
-/*
- * 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
deleted file mode 100644 (file)
index 40c978c..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMSystem.c - java/lang/VMSystem
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-#include <string.h>
-
-#include "mm/gc-common.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_io_InputStream.h"        /* required by j.l.VMS */
-#include "native/include/java_io_PrintStream.h"        /* required by j.l.VMS */
-
-#include "native/include/java_lang_VMSystem.h"
-
-#include "vm/builtin.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "arraycopy",        "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void *) (uintptr_t) &Java_java_lang_VMSystem_arraycopy },
-       { "identityHashCode", "(Ljava/lang/Object;)I",                      (void *) (uintptr_t) &Java_java_lang_VMSystem_identityHashCode },
-};
-
-
-/* _Jv_java_lang_VMSystem_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMSystem_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMSystem");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * 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, int32_t srcStart, java_lang_Object *dest, int32_t destStart, int32_t len)
-{
-       builtin_arraycopy((java_handle_t *) src, srcStart,
-                                         (java_handle_t *) dest, destStart, len);
-}
-
-
-/*
- * Class:     java/lang/VMSystem
- * Method:    identityHashCode
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, java_lang_Object *o)
-{
-       int32_t hashcode;
-
-       LLNI_CRITICAL_START;
-
-       hashcode = heap_hashcode(LLNI_UNWRAP((java_handle_t *) o));
-
-       LLNI_CRITICAL_END;
-
-       return hashcode;
-}
-
-
-/*
- * 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
deleted file mode 100644 (file)
index 178bd41..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMThread.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.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_String.h"
-#include "native/include/java_lang_Thread.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "countStackFrames",  "()I",                      (void *) (intptr_t) &Java_java_lang_VMThread_countStackFrames  },
-       { "start",             "(J)V",                     (void *) (intptr_t) &Java_java_lang_VMThread_start             },
-       { "interrupt",         "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_interrupt         },
-       { "isInterrupted",     "()Z",                      (void *) (intptr_t) &Java_java_lang_VMThread_isInterrupted     },
-       { "suspend",           "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_suspend           },
-       { "resume",            "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_resume            },
-       { "nativeSetPriority", "(I)V",                     (void *) (intptr_t) &Java_java_lang_VMThread_nativeSetPriority },
-       { "nativeStop",        "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeStop        },
-       { "currentThread",     "()Ljava/lang/Thread;",     (void *) (intptr_t) &Java_java_lang_VMThread_currentThread     },
-       { "yield",             "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_yield             },
-       { "interrupted",       "()Z",                      (void *) (intptr_t) &Java_java_lang_VMThread_interrupted       },
-       { "holdsLock",         "(Ljava/lang/Object;)Z",    (void *) (intptr_t) &Java_java_lang_VMThread_holdsLock         },
-       { "getState",          "()Ljava/lang/String;",     (void *) (intptr_t) &Java_java_lang_VMThread_getState          },
-};
-
-
-/* _Jv_java_lang_VMThread_init *************************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMThread_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMThread");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    countStackFrames
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
-{
-       java_lang_Thread *thread;
-
-       LLNI_field_get_ref(this, thread, thread);
-
-    log_println("Java_java_lang_VMThread_countStackFrames: IMPLEMENT ME!");
-
-    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, int64_t stacksize)
-{
-       java_lang_Thread *thread;
-
-       LLNI_field_get_ref(this, thread, thread);
-
-#if defined(ENABLE_THREADS)
-       threads_thread_start((java_handle_t *) thread);
-#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)
-       java_handle_t *h;
-       threadobject  *t;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       threads_thread_interrupt(t);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    isInterrupted
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-       threadobject  *t;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       return thread_is_interrupted(t);
-#else
-       return 0;
-#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)
-       /* TODO Should we implement this or is it obsolete? */
-#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)
-       /* TODO Should we implement this or is it obsolete? */
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    nativeSetPriority
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-       threadobject  *t;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       threads_set_thread_priority(t->tid, priority);
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    nativeStop
- * Signature: (Ljava/lang/Throwable;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
-{
-#if defined(ENABLE_THREADS)
-       /* TODO Should we implement this or is it obsolete? */
-#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 *to;
-
-       to = (java_lang_Thread *) thread_get_current_object();
-
-       return to;
-}
-
-
-/*
- * 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 int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
-{
-#if defined(ENABLE_THREADS)
-       threadobject *t;
-       int32_t       interrupted;
-
-       t = thread_get_current();
-
-       interrupted = thread_is_interrupted(t);
-
-       if (interrupted)
-               thread_set_interrupted(t, false);
-
-       return interrupted;
-#else
-       return 0;
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    holdsLock
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-
-       h = (java_handle_t *) o;
-
-       if (h == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       return lock_is_held_by_current_thread(h);
-#else
-       return 0;
-#endif
-}
-
-
-/*
- * Class:     java/lang/VMThread
- * Method:    getState
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *h;
-       threadobject  *t;
-       int            state;
-       utf           *u;
-       java_handle_t *o;
-
-       h = (java_handle_t *) this;
-       t = thread_get_thread(h);
-
-       state = cacaothread_get_state(t);
-       
-       switch (state) {
-       case THREAD_STATE_NEW:
-               u = utf_new_char("NEW");
-               break;
-       case THREAD_STATE_RUNNABLE:
-               u = utf_new_char("RUNNABLE");
-               break;
-       case THREAD_STATE_BLOCKED:
-               u = utf_new_char("BLOCKED");
-               break;
-       case THREAD_STATE_WAITING:
-               u = utf_new_char("WAITING");
-               break;
-       case THREAD_STATE_TIMED_WAITING:
-               u = utf_new_char("TIMED_WAITING");
-               break;
-       case THREAD_STATE_TERMINATED:
-               u = utf_new_char("TERMINATED");
-               break;
-       default:
-               vm_abort("Java_java_lang_VMThread_getState: unknown thread state %d", state);
-
-               /* Keep compiler happy. */
-
-               u = NULL;
-       }
-
-       o = javastring_new(u);
-
-       return (java_lang_String *) o;
-#else
-       return NULL;
-#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
deleted file mode 100644 (file)
index 29d6f65..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/* src/native/vm/gnu/java_lang_VMThrowable.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_StackTraceElement.h"
-#include "native/include/java_lang_Throwable.h"
-
-#include "native/include/java_lang_VMThrowable.h"
-
-#include "vm/array.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/code.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "fillInStackTrace", "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;",        (void *) (ptrint) &Java_java_lang_VMThrowable_fillInStackTrace },
-       { "getStackTrace",    "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void *) (ptrint) &Java_java_lang_VMThrowable_getStackTrace    },
-};
-
-
-/* _Jv_java_lang_VMThrowable_init **********************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_VMThrowable_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/VMThrowable");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * 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   *vmto;
-       java_handle_bytearray_t *ba;
-       java_lang_Object        *o;
-
-       vmto = (java_lang_VMThrowable *)
-               native_new_and_init(class_java_lang_VMThrowable);
-
-       if (vmto == NULL)
-               return NULL;
-
-       ba = stacktrace_get_current();
-
-       if (ba == NULL)
-               return NULL;
-
-       o = (java_lang_Object *) ba;
-
-       LLNI_field_set_ref(vmto, vmdata, o);
-
-       return vmto;
-}
-
-
-/*
- * Class:     java/lang/VMThrowable
- * Method:    getStackTrace
- * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *this, java_lang_Throwable *t)
-{
-       java_lang_Object            *o;
-       java_handle_bytearray_t     *ba;
-       stacktrace_t                *st;
-       stacktrace_entry_t          *ste;
-       java_handle_objectarray_t   *oa;
-       java_lang_StackTraceElement *steo;
-       codeinfo                    *code;
-       methodinfo                  *m;
-       java_lang_String            *filename;
-       s4                           linenumber;
-       java_handle_t               *declaringclass;
-       int                          i;
-
-       /* Get the stacktrace from the VMThrowable object. */
-
-       LLNI_field_get_ref(this, vmdata, o);
-
-       ba = (java_handle_bytearray_t *) o;
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       assert(st != NULL);
-
-       ste = st->entries;
-
-       /* Create the stacktrace element array. */
-
-       oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement);
-
-       if (oa == NULL)
-               return NULL;
-
-       for (i = 0; i < st->length; i++, ste++) {
-               /* allocate a new stacktrace element */
-
-               steo = (java_lang_StackTraceElement *)
-                       builtin_new(class_java_lang_StackTraceElement);
-
-               if (steo == NULL)
-                       return NULL;
-
-               /* Get the codeinfo and methodinfo. */
-
-               code = ste->code;
-               m    = code->m;
-
-               /* Get filename. */
-
-               if (!(m->flags & ACC_NATIVE)) {
-                       if (m->clazz->sourcefile)
-                               filename = (java_lang_String *) javastring_new(m->clazz->sourcefile);
-                       else
-                               filename = NULL;
-               }
-               else
-                       filename = NULL;
-
-               /* get line number */
-
-               if (m->flags & ACC_NATIVE) {
-                       linenumber = -1;
-               }
-               else {
-                       /* FIXME The linenumbertable_linenumber_for_pc could
-                          change the methodinfo pointer when hitting an inlined
-                          method. */
-
-                       linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc);
-                       linenumber = (linenumber == 0) ? -1 : linenumber;
-               }
-
-               /* get declaring class name */
-
-               declaringclass = class_get_classname(m->clazz);
-
-               /* Fill the java.lang.StackTraceElement object. */
-
-               LLNI_field_set_ref(steo, fileName      , filename);
-               LLNI_field_set_val(steo, lineNumber    , linenumber);
-               LLNI_field_set_ref(steo, declaringClass, (java_lang_String*) declaringclass);
-               LLNI_field_set_ref(steo, methodName    , (java_lang_String *) javastring_new(m->name));
-               LLNI_field_set_val(steo, isNative      , (m->flags & ACC_NATIVE) ? 1 : 0);
-
-               array_objectarray_element_set(oa, i, (java_handle_t *) steo);
-       }
-
-       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
deleted file mode 100644 (file)
index 62e1a8f..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* src/native/vm/gnu/java_lang_management_VMManagementFactory.c
-
-   Copyright (C) 1996-2005, 2006, 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdlib.h>
-
-#include "vm/types.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_management_VMManagementFactory.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-
-#include "vmcore/class.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getMemoryPoolNames",       "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames       },
-       { "getMemoryManagerNames",    "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames    },
-       { "getGarbageCollectorNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames },
-};
-
-
-/* _Jv_java_lang_management_VMManagementFactory_init ***************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_management_VMManagementFactory_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/management/VMManagementFactory");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/management/VMManagementFactory
- * Method:    getMemoryPoolNames
- * Signature: ()[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *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_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *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_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
-{
-       java_handle_objectarray_t *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_VMConstructor.c b/src/native/vm/gnu/java_lang_reflect_VMConstructor.c
deleted file mode 100644 (file)
index db90cf9..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdlib.h>
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "vm/vm.h"
-#include "vm/exceptions.h"
-#endif
-
-#include "native/jni.h"
-#include "native/llni.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"
-
-#if defined(ENABLE_ANNOTATIONS)
-# include "native/include/java_util_Map.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_VMConstructor.h"
-
-#include "native/vm/reflect.h"
-
-#include "vm/stringlocal.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getModifiersInternal",    "()I",                                                       (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal    },
-       { "getParameterTypes",       "()[Ljava/lang/Class;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes       },
-       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes       },
-       { "construct",               "([Ljava/lang/Object;)Ljava/lang/Object;",                   (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_construct               },
-       { "getSignature",            "()Ljava/lang/String;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getSignature            },
-#if defined(ENABLE_ANNOTATIONS)
-       { "declaredAnnotations",     "()Ljava/util/Map;",                                         (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations     },
-       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                     (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMConstructor_init ************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_reflect_VMConstructor_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/reflect/VMConstructor");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       return m->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getParameterTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       return method_get_parametertypearray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       return method_get_exceptionarray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    construct
- * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, java_lang_reflect_VMConstructor *this, java_handle_objectarray_t *args)
-{
-       classinfo                     *c;
-       int32_t                        slot;
-       java_lang_reflect_Constructor *rc;
-       int32_t                        override;
-       methodinfo                    *m;
-       java_handle_t                 *o;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       LLNI_field_get_ref(this, cons,  rc);
-       LLNI_field_get_val(rc,   flag,  override);
-
-       m = &(c->methods[slot]);
-
-       o = reflect_constructor_newinstance(m, args, override);
-
-       return (java_lang_Object *) o;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *o;
-       int32_t        slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       m = &(c->methods[slot]);
-
-       if (m->signature == NULL)
-               return NULL;
-
-       o = javastring_new(m->signature);
-
-       /* In error case o is NULL. */
-
-       return (java_lang_String *) o;
-}
-
-
-#if defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    declaredAnnotations
- * Signature: ()Ljava/util/Map;
- *
- * Parses the annotations (if they aren't parsed yet) and stores them into
- * the declaredAnnotations map and return this map.
- */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
-       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
-       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
-                                                            /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
-
-       /* are the annotations parsed yet? */
-       if (declaredAnnotations == NULL) {
-               LLNI_field_get_ref(this, annotations, annotations);
-               LLNI_field_get_ref(this, clazz, declaringClass);
-               LLNI_class_get(this, referer);
-
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
-
-               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
-       }
-
-       return declaredAnnotations;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMConstructor
- * Method:    getParameterAnnotations
- * Signature: ()[[Ljava/lang/annotation/Annotation;
- *
- * Parses the parameter annotations and returns them in an 2 dimensional array.
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this)
-{
-       java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations                    */
-       int32_t                  slot                 = -1;   /* slot of the method                                */
-       java_lang_Class         *declaringClass       = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer              = NULL; /* class, which calles the annotation parser         */
-                                                             /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
-       LLNI_field_get_val(this, slot, slot);
-       LLNI_field_get_ref(this, clazz, declaringClass);
-       LLNI_class_get(this, referer);
-
-       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
-}
-#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_reflect_VMField.c b/src/native/vm/gnu/java_lang_reflect_VMField.c
deleted file mode 100644 (file)
index b3da621..0000000
+++ /dev/null
@@ -1,1345 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMField.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/llni.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_String.h"
-
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_reflect_VMField.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/java_util_Map.h"
-#include "native/include/sun_reflect_ConstantPool.h"
-#include "native/vm/reflect.h"
-#endif
-
-#include "vm/access.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/primitive.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getModifiersInternal", "()I",                                     (void *) (intptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal },
-       { "getType",              "()Ljava/lang/Class;",                     (void *) (intptr_t) &Java_java_lang_reflect_VMField_getType              },
-       { "get",                  "(Ljava/lang/Object;)Ljava/lang/Object;",  (void *) (intptr_t) &Java_java_lang_reflect_VMField_get                  },
-       { "getBoolean",           "(Ljava/lang/Object;)Z",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getBoolean           },
-       { "getByte",              "(Ljava/lang/Object;)B",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getByte              },
-       { "getChar",              "(Ljava/lang/Object;)C",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getChar              },
-       { "getShort",             "(Ljava/lang/Object;)S",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getShort             },
-       { "getInt",               "(Ljava/lang/Object;)I",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getInt               },
-       { "getLong",              "(Ljava/lang/Object;)J",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getLong              },
-       { "getFloat",             "(Ljava/lang/Object;)F",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getFloat             },
-       { "getDouble",            "(Ljava/lang/Object;)D",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getDouble            },
-       { "set",                  "(Ljava/lang/Object;Ljava/lang/Object;)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_set                  },
-       { "setBoolean",           "(Ljava/lang/Object;Z)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setBoolean           },
-       { "setByte",              "(Ljava/lang/Object;B)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setByte              },
-       { "setChar",              "(Ljava/lang/Object;C)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setChar              },
-       { "setShort",             "(Ljava/lang/Object;S)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setShort             },
-       { "setInt",               "(Ljava/lang/Object;I)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setInt               },
-       { "setLong",              "(Ljava/lang/Object;J)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setLong              },
-       { "setFloat",             "(Ljava/lang/Object;F)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setFloat             },
-       { "setDouble",            "(Ljava/lang/Object;D)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setDouble            },
-       { "getSignature",         "()Ljava/lang/String;",                    (void *) (intptr_t) &Java_java_lang_reflect_VMField_getSignature         },
-#if defined(ENABLE_ANNOTATIONS)
-       { "declaredAnnotations",  "()Ljava/util/Map;",                       (void *) (intptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations  },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMField_init ******************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_reflect_VMField_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/reflect/VMField");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/* _field_access_check *********************************************************
-
-   Checks if the field can be accessed.
-
-   RETURN VALUE:
-      true......field can be accessed, or
-      false.....otherwise (maybe an Exception was thrown).
-
-*******************************************************************************/
-
-static bool _field_access_check(java_lang_reflect_VMField *this,
-                                                               fieldinfo *f, classinfo *c, java_handle_t *o)
-{
-       java_lang_reflect_Field *rf;
-       int32_t                  flag;
-
-       /* check if we should bypass security checks (AccessibleObject) */
-
-       LLNI_field_get_ref(this, f, rf);
-       LLNI_field_get_val(rf, flag, flag);
-
-       if (flag == false) {
-               /* This function is always called like this:
-                      [0] java.lang.reflect.VMField.xxx (Native Method)
-                      [1] java.lang.reflect.Field.xxx
-                      [2] <caller>
-               */
-
-               if (!access_check_field(f, 2))
-                       return false;
-       }
-
-       /* some general checks */
-
-       if (f->flags & ACC_STATIC) {
-               /* initialize class if required */
-
-               if (!(c->state & CLASS_INITIALIZED))
-                       if (!initialize_class(c))
-                               return false;
-
-               /* everything is ok */
-
-               return true;
-       }
-       else {
-               /* obj is required for not-static fields */
-
-               if (o == NULL) {
-                       exceptions_throw_nullpointerexception();
-                       return false;
-               }
-       
-               if (builtin_instanceof(o, c))
-                       return true;
-       }
-
-       /* exception path */
-
-       exceptions_throw_illegalargumentexception();
-       return false;
-}
-
-
-/* _field_get_type *************************************************************
-
-   Returns the content of the given field.
-
-*******************************************************************************/
-
-#define _FIELD_GET_TYPE(name, type, uniontype) \
-static inline type _field_get_##name(fieldinfo *f, java_lang_Object *o) \
-{ \
-       type ret; \
-       if (f->flags & ACC_STATIC) { \
-               ret = f->value->uniontype; \
-       } else { \
-               LLNI_CRITICAL_START; \
-               ret = *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset); \
-               LLNI_CRITICAL_END; \
-       } \
-       return ret; \
-}
-
-static inline java_handle_t *_field_get_handle(fieldinfo *f, java_lang_Object *o)
-{
-       java_object_t *obj;
-       java_handle_t *hdl;
-
-       LLNI_CRITICAL_START;
-
-       if (f->flags & ACC_STATIC) {
-               obj = f->value->a;
-       } else {
-               obj = *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset);
-       }
-
-       hdl = LLNI_WRAP(obj);
-
-       LLNI_CRITICAL_END;
-
-       return hdl;
-}
-
-_FIELD_GET_TYPE(int,    int32_t, i)
-_FIELD_GET_TYPE(long,   int64_t, l)
-_FIELD_GET_TYPE(float,  float,   f)
-_FIELD_GET_TYPE(double, double,  d)
-
-
-/* _field_set_type *************************************************************
-
-   Sets the content of the given field to the given value.
-
-*******************************************************************************/
-
-#define _FIELD_SET_TYPE(name, type, uniontype) \
-static inline void _field_set_##name(fieldinfo *f, java_lang_Object *o, type value) \
-{ \
-       if (f->flags & ACC_STATIC) { \
-               f->value->uniontype = value; \
-       } else { \
-               LLNI_CRITICAL_START; \
-               *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = value; \
-               LLNI_CRITICAL_END; \
-       } \
-}
-
-static inline void _field_set_handle(fieldinfo *f, java_lang_Object *o, java_handle_t *value)
-{
-       LLNI_CRITICAL_START;
-
-       if (f->flags & ACC_STATIC) {
-               f->value->a = LLNI_DIRECT(value);
-       } else {
-               *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = LLNI_DIRECT(value);
-       }
-
-       LLNI_CRITICAL_END;
-}
-
-_FIELD_SET_TYPE(int,    int32_t, i)
-_FIELD_SET_TYPE(long,   int64_t, l)
-_FIELD_SET_TYPE(float,  float,   f)
-_FIELD_SET_TYPE(double, double,  d)
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMField *this)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &(c->fields[slot]);
-
-       return f->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getType
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, java_lang_reflect_VMField *this)
-{
-       classinfo *c;
-       typedesc  *desc;
-       classinfo *ret;
-       int32_t    slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       desc = c->fields[slot].parseddesc;
-
-       if (desc == NULL)
-               return NULL;
-
-       if (!resolve_class_from_typedesc(desc, true, false, &ret))
-               return NULL;
-       
-       return LLNI_classinfo_wrap(ret);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    get
- * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-       imm_union  value;
-       java_handle_t *object;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return NULL;
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               value.i = _field_get_int(f, o);
-               break;
-
-       case PRIMITIVETYPE_LONG:
-               value.l = _field_get_long(f, o);
-               break;
-
-       case PRIMITIVETYPE_FLOAT:
-               value.f = _field_get_float(f, o);
-               break;
-
-       case PRIMITIVETYPE_DOUBLE:
-               value.d = _field_get_double(f, o);
-               break;
-
-       case TYPE_ADR:
-               return (java_lang_Object *) _field_get_handle(f, o);
-       }
-
-       /* Now box the primitive types. */
-
-       object = primitive_box(f->parseddesc->decltype, value);
-
-       return (java_lang_Object *) object;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getBoolean
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getByte
- * Signature: (Ljava/lang/Object;)B
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getChar
- * Signature: (Ljava/lang/Object;)C
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_CHAR:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getShort
- * Signature: (Ljava/lang/Object;)S
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return 0;
-
-       /* check the field type and return the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_SHORT:
-               return (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getInt
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               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 (int32_t) _field_get_int(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getLong
- * Signature: (Ljava/lang/Object;)J
- */
-JNIEXPORT int64_t JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               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 (int64_t) _field_get_int(f, o);
-       case PRIMITIVETYPE_LONG:
-               return (int64_t) _field_get_long(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getFloat
- * Signature: (Ljava/lang/Object;)F
- */
-JNIEXPORT float JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               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) _field_get_int(f, o);
-       case PRIMITIVETYPE_LONG:
-               return (float) _field_get_long(f, o);
-       case PRIMITIVETYPE_FLOAT:
-               return (float) _field_get_float(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getDouble
- * Signature: (Ljava/lang/Object;)D
- */
-JNIEXPORT double JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               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) _field_get_int(f, o);
-       case PRIMITIVETYPE_LONG:
-               return (double) _field_get_long(f, o);
-       case PRIMITIVETYPE_FLOAT:
-               return (double) _field_get_float(f, o);
-       case PRIMITIVETYPE_DOUBLE:
-               return (double) _field_get_double(f, o);
-       default:
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    set
- * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, java_lang_Object *value)
-{
-       classinfo *sc;
-       classinfo *dc;
-       fieldinfo *sf;
-       fieldinfo *df;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, dc);
-       LLNI_field_get_val(this, slot , slot);
-       df = &dc->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, df, dc, (java_handle_t *) o))
-               return;
-
-       /* get the source classinfo from the object */
-
-       if (value == NULL)
-               sc = NULL;
-       else
-               LLNI_class_get(value, sc);
-
-       /* 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: {
-               int32_t 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:
-                       LLNI_field_get_val((java_lang_Boolean *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_BYTE: {
-               int32_t val;
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B)))
-                       break;
-
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_BYTE:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               default:        
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_CHAR: {
-               int32_t val;
-
-               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C)))
-                       break;
-                                  
-               switch (sf->parseddesc->decltype) {
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_SHORT: {
-               int32_t 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:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_INT: {
-               int32_t 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:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_int(df, o, val);
-               return;
-       }
-
-       case PRIMITIVETYPE_LONG: {
-               int64_t 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:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       LLNI_field_get_val((java_lang_Long *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_long(df, o, 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:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       LLNI_field_get_val((java_lang_Long *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_FLOAT:
-                       LLNI_field_get_val((java_lang_Float *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_float(df, o, 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:
-                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_CHAR:
-                       LLNI_field_get_val((java_lang_Character *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_SHORT:
-                       LLNI_field_get_val((java_lang_Short *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_INT:
-                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_LONG:
-                       LLNI_field_get_val((java_lang_Long *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_FLOAT:
-                       LLNI_field_get_val((java_lang_Float *) value, value, val);
-                       break;
-               case PRIMITIVETYPE_DOUBLE:
-                       LLNI_field_get_val((java_lang_Double *) value, value, val);
-                       break;
-               default:
-                       exceptions_throw_illegalargumentexception();
-                       return;
-               }
-
-               _field_set_double(df, o, val);
-               return;
-       }
-
-       case TYPE_ADR:
-               /* check if value is an instance of the destination class */
-
-               /* XXX TODO */
-               /*                      if (!builtin_instanceof((java_handle_t *) value, df->class)) */
-               /*                              break; */
-
-               _field_set_handle(df, o, (java_handle_t *) value);
-               return;
-       }
-
-       /* raise exception */
-
-       exceptions_throw_illegalargumentexception();
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setBoolean
- * Signature: (Ljava/lang/Object;Z)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BOOLEAN:
-               _field_set_int(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setByte
- * Signature: (Ljava/lang/Object;B)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_BYTE:
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setChar
- * Signature: (Ljava/lang/Object;C)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_CHAR:
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setShort
- * Signature: (Ljava/lang/Object;S)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_SHORT:
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setInt
- * Signature: (Ljava/lang/Object;I)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_INT:
-               _field_set_int(f, o, value);
-               break;
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setLong
- * Signature: (Ljava/lang/Object;J)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int64_t value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_LONG:
-               _field_set_long(f, o, value);
-               break;
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setFloat
- * Signature: (Ljava/lang/Object;F)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, float value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_FLOAT:
-               _field_set_float(f, o, value);
-               break;
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    setDouble
- * Signature: (Ljava/lang/Object;D)V
- */
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, double value)
-{
-       classinfo *c;
-       fieldinfo *f;
-       int32_t    slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       /* check if the field can be accessed */
-
-       if (!_field_access_check(this, f, c, (java_handle_t *) o))
-               return;
-
-       /* check the field type and set the value */
-
-       switch (f->parseddesc->decltype) {
-       case PRIMITIVETYPE_DOUBLE:
-               _field_set_double(f, o, value);
-               break;
-       default:
-               exceptions_throw_illegalargumentexception();
-       }
-
-       return;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, java_lang_reflect_VMField* this)
-{
-       classinfo     *c;
-       fieldinfo     *f;
-       java_handle_t *o;
-       int32_t        slot;
-
-       /* get the class and the field */
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       f = &c->fields[slot];
-
-       if (f->signature == NULL)
-               return NULL;
-
-       o = javastring_new(f->signature);
-
-       /* in error case o is NULL */
-
-       return (java_lang_String *) o;
-}
-
-
-#if defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/reflect/VMField
- * Method:    declaredAnnotations
- * Signature: ()Ljava/util/Map;
- */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMField *this)
-{
-       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
-       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
-       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
-                                                            /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
-
-       /* are the annotations parsed yet? */
-       if (declaredAnnotations == NULL) {
-               LLNI_field_get_ref(this, annotations, annotations);
-               LLNI_field_get_ref(this, clazz, declaringClass);
-               LLNI_class_get(this, referer);
-
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
-
-               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
-       }
-
-       return declaredAnnotations;
-}
-#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_reflect_VMMethod.c b/src/native/vm/gnu/java_lang_reflect_VMMethod.c
deleted file mode 100644 (file)
index 8b1853f..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMMethod.c
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "vm/vm.h"
-#endif
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-# include "native/include/java_util_Map.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/include/java_lang_reflect_Method.h"
-#include "native/include/java_lang_reflect_VMMethod.h"
-
-#include "native/vm/reflect.h"
-
-#include "vm/access.h"
-#include "vm/global.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/method.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getModifiersInternal",    "()I",                                                       (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal    },
-       { "getReturnType",           "()Ljava/lang/Class;",                                       (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType           },
-       { "getParameterTypes",       "()[Ljava/lang/Class;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes       },
-       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes       },
-       { "invoke",                  "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke                  },
-       { "getSignature",            "()Ljava/lang/String;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature            },
-#if defined(ENABLE_ANNOTATIONS)
-       { "getDefaultValue",         "()Ljava/lang/Object;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue         },
-       { "declaredAnnotations",     "()Ljava/util/Map;",                                         (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations     },
-       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                     (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMMethod_init *******************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_reflect_VMMethod_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/lang/reflect/VMMethod");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       return m->flags;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getReturnType
- * Signature: ()Ljava/lang/Class;
- */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       classinfo  *result;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       result = method_returntype_get(m);
-
-       return LLNI_classinfo_wrap(result);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getParameterTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       return method_get_parametertypearray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-       int32_t     slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       return method_get_exceptionarray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    invoke
- * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, java_lang_reflect_VMMethod *this, java_lang_Object *o, java_handle_objectarray_t *args)
-{
-       classinfo                *c;
-       int32_t                   slot;
-       java_lang_reflect_Method *rm;
-       int32_t                   override;
-       methodinfo               *m;
-       java_handle_t            *ro;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot,  slot);
-
-       LLNI_field_get_ref(this, m,     rm);
-       LLNI_field_get_val(rm,   flag,  override);
-
-       m = &(c->methods[slot]);
-
-       ro = reflect_method_invoke(m, (java_handle_t *) o, args, override);
-
-       return (java_lang_Object *) ro;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, java_lang_reflect_VMMethod* this)
-{
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *o;
-       int32_t        slot;
-
-       LLNI_field_get_cls(this, clazz, c);
-       LLNI_field_get_val(this, slot , slot);
-       m = &(c->methods[slot]);
-
-       if (m->signature == NULL)
-               return NULL;
-
-       o = javastring_new(m->signature);
-
-       /* in error case o is NULL */
-
-       return (java_lang_String *) o;
-}
-
-#if defined(ENABLE_ANNOTATIONS)
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getDefaultValue
- * Signature: ()Ljava/lang/Object;
- *
- * Parses the annotation default value and returnes it (boxed, if it's a primitive).
- */
-JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, struct java_lang_reflect_VMMethod* this)
-{
-       java_handle_bytearray_t  *annotationDefault          = NULL; /* unparsed annotation default value                 */
-       static methodinfo        *m_parseAnnotationDefault   = NULL; /* parser method (will be chached, therefore static) */
-       utf                      *utf_parseAnnotationDefault = NULL; /* parser method name                                */
-       utf                      *utf_desc        = NULL;            /* parser method descriptor (signature)              */
-       sun_reflect_ConstantPool *constantPool    = NULL;            /* constant pool object to use                       */
-       java_lang_Class          *constantPoolOop = NULL;            /* methods declaring class                           */
-       classinfo                *referer         = NULL;            /* class, which calles the annotation parser         */
-                                                                    /* (for the parameter 'referer' of vm_call_method()) */
-       java_lang_reflect_Method* rm;
-       java_handle_t*            h;
-
-       if (this == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-       
-       if (constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-
-       LLNI_field_get_ref(this, clazz, constantPoolOop);
-       LLNI_field_set_ref(constantPool, constantPoolOop, (java_lang_Object*)constantPoolOop);
-
-       /* only resolve the parser method the first time */
-       if (m_parseAnnotationDefault == NULL) {
-               utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault");
-               utf_desc = utf_new_char(
-                       "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)"
-                       "Ljava/lang/Object;");
-
-               if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) {
-                       /* out of memory */
-                       return NULL;
-               }
-
-               LLNI_class_get(this, referer);
-
-               m_parseAnnotationDefault = class_resolveclassmethod(
-                       class_sun_reflect_annotation_AnnotationParser,
-                       utf_parseAnnotationDefault,
-                       utf_desc,
-                       referer,
-                       true);
-
-               if (m_parseAnnotationDefault == NULL) {
-                       /* method not found */
-                       return NULL;
-               }
-       }
-
-       LLNI_field_get_ref(this, m,                 rm);
-       LLNI_field_get_ref(this, annotationDefault, annotationDefault);
-
-       h = vm_call_method(m_parseAnnotationDefault, NULL, rm, annotationDefault, constantPool);
-
-       return (java_lang_Object*) h;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    declaredAnnotations
- * Signature: ()Ljava/util/Map;
- *
- * Parses the annotations (if they aren't parsed yet) and stores them into
- * the declaredAnnotations map and return this map.
- */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
-       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
-       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
-                                                            /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
-
-       /* are the annotations parsed yet? */
-       if (declaredAnnotations == NULL) {
-               LLNI_field_get_ref(this, annotations, annotations);
-               LLNI_field_get_ref(this, clazz, declaringClass);
-               LLNI_class_get(this, referer);
-
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
-
-               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
-       }
-
-       return declaredAnnotations;
-}
-
-
-/*
- * Class:     java/lang/reflect/VMMethod
- * Method:    getParameterAnnotations
- * Signature: ()[[Ljava/lang/annotation/Annotation;
- *
- * Parses the parameter annotations and returns them in an 2 dimensional array.
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this)
-{
-       java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations                    */
-       int32_t                  slot                 = -1;   /* slot of the method                                */
-       java_lang_Class         *declaringClass       = NULL; /* the constant pool of this class is used           */
-       classinfo               *referer              = NULL; /* class, which calles the annotation parser         */
-                                                             /* (for the parameter 'referer' of vm_call_method()) */
-
-       LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
-       LLNI_field_get_val(this, slot, slot);
-       LLNI_field_get_ref(this, clazz, declaringClass);
-       LLNI_class_get(this, referer);
-
-       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
-}
-#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_reflect_VMProxy.c b/src/native/vm/gnu/java_lang_reflect_VMProxy.c
deleted file mode 100644 (file)
index b213842..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* src/native/vm/gnu/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy
-
-   Copyright (C) 1996-2005, 2006, 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdlib.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_reflect_VMProxy.h"
-
-
-/* native methods implemented by this file ************************************/
-
-#if 0
-static JNINativeMethod methods[] = {
-       { "getProxyClass",      "(Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/Class;",                   (void *) (ptrint) &Java_java_lang_reflect_VMProxy_getProxyClass      },
-       { "getProxyData",       "(Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/reflect/Proxy$ProxyData;", (void *) (ptrint) &Java_java_lang_reflect_VMProxy_getProxyData       },
-       { "generateProxyClass", "(Ljava/lang/ClassLoader;Ljava/lang/reflect/Proxy$ProxyData;)Ljava/lang/Class;",  (void *) (ptrint) &Java_java_lang_reflect_VMProxy_generateProxyClass },
-};
-#endif
-
-
-/* _Jv_java_lang_reflect_VMProxy_init ******************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_reflect_VMProxy_init(void)
-{
-#if 0
-       utf *u;
-
-       u = utf_new_char("java/lang/reflect/VMProxy");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-#endif
-}
-
-
-#if 0
-/*
- * 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)
-{
-       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)
-{
-       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)
-{
-       return NULL;
-}
-#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_security_VMAccessController.c b/src/native/vm/gnu/java_security_VMAccessController.c
deleted file mode 100644 (file)
index 7e86b68..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* src/native/vm/gnu/java_security_VMAccessController.c
-
-   Copyright (C) 1996-2005, 2006, 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_security_VMAccessController.h"
-
-#include "vm/global.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getStack", "()[[Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_security_VMAccessController_getStack },
-};
-
-
-/* _Jv_java_security_VMAccessController_init ***********************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_security_VMAccessController_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/security/VMAccessController");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/security/VMAccessController
- * Method:    getStack
- * Signature: ()[[Ljava/lang/Object;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz)
-{
-       return stacktrace_get_stack();
-}
-
-
-/*
- * 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_util_concurrent_atomic_AtomicLong.c b/src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c
deleted file mode 100644 (file)
index 7105e65..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c
-
-   Copyright (C) 2007 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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "native/include/java_util_concurrent_atomic_AtomicLong.h"
-
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "VMSupportsCS8", "()Z", (void *) (intptr_t) &Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8 },
-};
-
-
-/* _Jv_java_util_concurrent_atomic_AtomicLong_init *****************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_util_concurrent_atomic_AtomicLong_init(void)
-{
-       utf *u;
-
-       u = utf_new_char("java/util/concurrent/atomic/AtomicLong");
-
-       native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
-/*
- * Class:     java/util/concurrent/atomic/AtomicLong
- * Method:    VMSupportsCS8
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz)
-{
-       /* IMPLEMENT ME */
-
-       return 0;
-}
-
-
-/*
- * 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_reflect_ConstantPool.c b/src/native/vm/gnu/sun_reflect_ConstantPool.c
deleted file mode 100644 (file)
index 66b7ac4..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-/* src/native/vm/gnu/sun_reflect_ConstantPool.c
-
-   Copyright (C) 2007 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, M. S. Panzenböck 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.
-
-*/
-
-/*******************************************************************************
-
-   XXX: The Methods in this file are very redundant to thouse in
-        src/native/vm/sun/jvm.c Unless someone has a good idea how to cover
-        such redundancy I leave it how it is.
-
-  The ConstantPool class represents an interface to the constant pool of a
-  class and is used by the annotations parser (sun.reflect.annotation.
-  AnnotationParser) to get the values of the constants refered by the
-  annotations.
-
-*******************************************************************************/
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/sun_reflect_ConstantPool.h"
-
-#include "native/vm/reflect.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/vm.h"
-#include "vm/exceptions.h"
-#include "vm/resolve.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/class.h"
-#include "vmcore/utf8.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
-       { "getSize0",             "(Ljava/lang/Object;I)I",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getSize0             },
-       { "getClassAt0",          "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAt0          },
-       { "getClassAtIfLoaded0",  "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0  },
-       { "getMethodAt0",         "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0         },
-       { "getMethodAtIfLoaded0", "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 },
-       { "getFieldAt0",          "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0          },
-       { "getFieldAtIfLoaded0",  "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0  },
-       { "getMemberRefInfoAt0",  "(Ljava/lang/Object;I)[Ljava/lang/String;",        (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0  },
-       { "getIntAt0",            "(Ljava/lang/Object;I)I",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getIntAt0            },
-       { "getLongAt0",           "(Ljava/lang/Object;I)J",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getLongAt0           },
-       { "getFloatAt0",          "(Ljava/lang/Object;I)F",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0          },
-       { "getDoubleAt0",         "(Ljava/lang/Object;I)D",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0         },
-       { "getStringAt0",         "(Ljava/lang/Object;I)Ljava/lang/String;",         (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getStringAt0         },
-       { "getUTF8At0",           "(Ljava/lang/Object;I)Ljava/lang/String;",         (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0           }, 
-};
-
-
-/* _Jv_sun_reflect_ConstantPool_init ******************************************
-
-   Register native functions.
-
-*******************************************************************************/
-
-void _Jv_sun_reflect_ConstantPool_init(void)
-{
-       native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT);
-}
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getSize0
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool)
-{
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-       return cls->cpcount;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getClassAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
- */
-JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_classref *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref*)class_getconstant(
-               cls, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       return LLNI_classinfo_wrap(resolve_classref_eager(ref));
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getClassAtIfLoaded0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
- */
-JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_classref *ref;
-       classinfo *c = NULL;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref*)class_getconstant(
-               cls, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-       
-       if (!resolve_classref(NULL,ref,resolveLazy,true,true,&c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-       
-       return LLNI_classinfo_wrap(c);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getMethodAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
- */
-JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-       
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Methodref);
-       
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: is that right? or do I have to use resolve_method_*? */
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getMethodAtIfLoaded0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
- */
-JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *c = NULL;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Methodref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getFieldAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
- */
-JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getFieldAtIfLoaded0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
- */
-JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_FMIref *ref;
-       classinfo *c;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getMemberRefInfoAt0
- * Signature: (Ljava/lang/Object;I)[Ljava/lang/String;
- */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index);
-       return NULL;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getIntAt0
- * Signature: (Ljava/lang/Object;I)I
- */
-JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_integer *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_integer*)class_getconstant(
-               cls, index, CONSTANT_Integer);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getLongAt0
- * Signature: (Ljava/lang/Object;I)J
- */
-JNIEXPORT int64_t JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_long *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_long*)class_getconstant(
-               cls, index, CONSTANT_Long);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getFloatAt0
- * Signature: (Ljava/lang/Object;I)F
- */
-JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_float *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_float*)class_getconstant(
-               cls, index, CONSTANT_Float);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getDoubleAt0
- * Signature: (Ljava/lang/Object;I)D
- */
-JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       constant_double *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_double*)class_getconstant(
-               cls, index, CONSTANT_Double);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getStringAt0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       utf *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-       
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (java_lang_String*)literalstring_new(ref);
-}
-
-
-/*
- * Class:     sun/reflect/ConstantPool
- * Method:    getUTF8At0
- * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
-{
-       utf *ref;
-       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (java_lang_String*)literalstring_new(ref);
-}
-
-
-/*
- * 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/gnuclasspath/Makefile.am b/src/native/vm/gnuclasspath/Makefile.am
new file mode 100644 (file)
index 0000000..219f88d
--- /dev/null
@@ -0,0 +1,82 @@
+## src/native/vm/gnu/Makefile.am
+##
+## Copyright (C) 1996-2005, 2006, 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+##
+## 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.
+
+
+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 = \
+       libnativevmcore.la
+
+if ENABLE_JVMTI
+lib_LTLIBRARIES = \
+       libjdwp.la
+endif
+
+if ENABLE_ANNOTATIONS
+SUN_REFLECT_SOURCES = \
+       sun_reflect_ConstantPool.c
+endif
+
+libnativevmcore_la_SOURCES = \
+       gnu_classpath_VMStackWalker.c \
+       gnu_classpath_VMSystemProperties.c \
+       gnu_java_lang_VMCPStringBuilder.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_VMConstructor.c \
+       java_lang_reflect_VMField.c \
+       java_lang_reflect_VMMethod.c \
+       java_lang_reflect_VMProxy.c \
+       java_security_VMAccessController.c \
+       java_util_concurrent_atomic_AtomicLong.c \
+       $(SUN_REFLECT_SOURCES)
+
+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/gnuclasspath/VMjdwp.c b/src/native/vm/gnuclasspath/VMjdwp.c
new file mode 100644 (file)
index 0000000..cc8aefd
--- /dev/null
@@ -0,0 +1,530 @@
+/* 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:
+
+*/
+
+#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/gnuclasspath/VMjdwp.h b/src/native/vm/gnuclasspath/VMjdwp.h
new file mode 100644 (file)
index 0000000..42016ae
--- /dev/null
@@ -0,0 +1,45 @@
+/* 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:
+
+*/
+
+#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/gnuclasspath/gnu_classpath_VMStackWalker.c b/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c
new file mode 100644 (file)
index 0000000..eca8f53
--- /dev/null
@@ -0,0 +1,144 @@
+/* src/native/vm/gnu/gnu_classpath_VMStackWalker.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#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 "native/include/gnu_classpath_VMStackWalker.h"
+
+#include "vm/global.h"
+
+#include "vm/jit/stacktrace.h"
+
+#include "vmcore/class.h"
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getClassContext",         "()[Ljava/lang/Class;",      (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getClassContext         },
+       { "getCallingClass",         "()Ljava/lang/Class;",       (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClass         },
+       { "getCallingClassLoader",   "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader   },
+       { "firstNonNullClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
+};
+
+
+/* _Jv_gnu_classpath_VMStackWalker_init ****************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_classpath_VMStackWalker_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("gnu/classpath/VMStackWalker");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getClassContext
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *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)
+{
+       classinfo *c;
+
+       c = stacktrace_get_caller_class(2);
+
+       return (java_lang_Class *) c;
+}
+
+
+/*
+ * Class:     gnu/classpath/VMStackWalker
+ * Method:    getCallingClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
+{
+       classinfo     *c;
+       classloader_t *cl;
+
+       c  = stacktrace_get_caller_class(2);
+       cl = class_get_classloader(c);
+
+       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)
+{
+       classloader_t *cl;
+
+       cl = stacktrace_first_nonnull_classloader();
+
+       return (java_lang_ClassLoader *) cl;
+}
+
+
+/*
+ * 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/gnuclasspath/gnu_classpath_VMSystemProperties.c b/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c
new file mode 100644 (file)
index 0000000..5517c6c
--- /dev/null
@@ -0,0 +1,154 @@
+/* src/native/vm/gnu/gnu_classpath_VMSystemProperties.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_util_Properties.h"
+
+#include "native/include/gnu_classpath_VMSystemProperties.h"
+
+#include "vm/exceptions.h"
+#include "vm/properties.h"
+#include "vm/vm.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "preInit",  "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_preInit  },
+       { "postInit", "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_postInit },
+};
+
+
+/* _Jv_gnu_classpat_VMSystemProperties_init ************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_classpath_VMSystemProperties_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("gnu/classpath/VMSystemProperties");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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 *properties)
+{
+       java_handle_t *p;
+
+       p = (java_handle_t *) properties;
+
+       if (p == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* fill the java.util.Properties object */
+
+       properties_system_add_all(p);
+}
+
+
+/*
+ * Class:     gnu/classpath/VMSystemProperties
+ * Method:    postInit
+ * Signature: (Ljava/util/Properties;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
+{
+       java_handle_t *p;
+#if defined(ENABLE_JRE_LAYOUT)
+       char *java_home;
+       char *path;
+       s4    len;
+#endif
+
+       p = (java_handle_t *) properties;
+
+       if (p == NULL) {
+               exceptions_throw_nullpointerexception();
+               return;
+       }
+
+       /* post-set some properties */
+
+#if defined(ENABLE_JRE_LAYOUT)
+       /* XXX when we do it that way, we can't set these properties on
+          commandline */
+
+       java_home = properties_get("java.home");
+
+       properties_system_add(p, "gnu.classpath.home", java_home);
+
+       len =
+               strlen("file://") +
+               strlen(java_home) +
+               strlen("/lib") +
+               strlen("0");
+
+       path = MNEW(char, len);
+
+       strcpy(path, "file://");
+       strcat(path, java_home);
+       strcat(path, "/lib");
+
+       properties_system_add(p, "gnu.classpath.home.url", path);
+
+       MFREE(path, char, len);
+#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/gnuclasspath/gnu_classpath_jdwp_VMFrame.c b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c
new file mode 100644 (file)
index 0000000..e647e4d
--- /dev/null
@@ -0,0 +1,74 @@
+/* src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c - jdwp->jvmti interface
+
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+
+#include "native/include/java_lang_Object.h"
+#include "native/include/gnu_classpath_jdwp_VMFrame.h"
+
+#include "toolbox/logging.h"
+
+
+/*
+ * Class:     gnu/classpath/jdwp/VMFrame
+ * Method:    getValue
+ * Signature: (I)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_gnu_classpath_jdwp_VMFrame_getValue(JNIEnv *env, gnu_classpath_jdwp_VMFrame* this, int32_t 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, gnu_classpath_jdwp_VMFrame* this, int32_t par1, java_lang_Object* par2)
+{
+       log_text ("JVMTI-Call: IMPLEMENT ME!!!");
+       return 0;
+}
+
+
+/*
+ * 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/gnuclasspath/gnu_classpath_jdwp_VMMethod.c b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c
new file mode 100644 (file)
index 0000000..54ff534
--- /dev/null
@@ -0,0 +1,324 @@
+/* src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c - jdwp->jvmti interface
+
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#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, 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, 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 int32_t JNICALL Java_gnu_classpath_jdwp_VMMethod_getModifiers(JNIEnv *env, 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/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c
new file mode 100644 (file)
index 0000000..9e06a6b
--- /dev/null
@@ -0,0 +1,437 @@
+/* src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c - jdwp->jvmti interface
+
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#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"
+
+
+/*
+ * 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 int32_t 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 int32_t 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 int32_t 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, int32_t par2, int32_t 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 int32_t 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 int32_t 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, int32_t 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, int32_t 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/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c b/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c
new file mode 100644 (file)
index 0000000..0511085
--- /dev/null
@@ -0,0 +1,129 @@
+/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_String.h"
+
+#include "native/include/gnu_java_lang_VMCPStringBuilder.h"
+
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "toString", "([CII)Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_VMCPStringBuilder_toString },
+};
+
+
+/* _Jv_gnu_java_lang_VMCPStringBuilder *****************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_VMCPStringBuilder_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("gnu/java/lang/VMCPStringBuilder");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     gnu/java/lang/VMCPStringBuilder
+ * Method:    toString
+ * Signature: ([CII)Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, java_handle_chararray_t *value, int32_t startIndex, int32_t count)
+{
+       int32_t          length;
+       java_handle_t    *o;
+       java_lang_String *s;
+
+       /* This is a native version of
+          java.lang.String.<init>([CIIZ)Ljava/lang/String; */
+
+    if (startIndex < 0) {
+/*             exceptions_throw_stringindexoutofboundsexception("offset: " + offset); */
+               exceptions_throw_stringindexoutofboundsexception();
+               return NULL;
+       }
+
+    if (count < 0) {
+/*             exceptions_throw_stringindexoutofboundsexception("count: " + count); */
+               exceptions_throw_stringindexoutofboundsexception();
+               return NULL;
+       }
+
+    /* equivalent to: offset + count < 0 || offset + count > data.length */
+
+       LLNI_CRITICAL_START;
+       length = LLNI_array_size(value);
+       LLNI_CRITICAL_END;
+
+    if (length - startIndex < count) {
+/*             exceptions_throw_stringindexoutofboundsexception("offset + count: " + (offset + count)); */
+               exceptions_throw_stringindexoutofboundsexception();
+               return NULL;
+       }
+
+       o = builtin_new(class_java_lang_String);
+
+       if (o == NULL)
+               return NULL;
+
+       s = (java_lang_String *) o;
+
+       LLNI_field_set_ref(s, value,  value);
+       LLNI_field_set_val(s, count,  count);
+       LLNI_field_set_val(s, offset, startIndex);
+
+       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/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
new file mode 100644 (file)
index 0000000..ce3b6b4
--- /dev/null
@@ -0,0 +1,135 @@
+/* src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c
+
+   Copyright (C) 1996-2005, 2006, 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/vm.h"
+
+#include "vmcore/classcache.h"
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getLoadedClassCount",   "()I",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount   },
+       { "getUnloadedClassCount", "()J",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount },
+       { "isVerbose",             "()Z",  (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose             },
+       { "setVerbose",            "(Z)V", (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose            },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init ******************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("gnu/java/lang/management/VMClassLoadingMXBeanImpl");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    getLoadedClassCount
+ * Signature: ()I
+ */
+JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
+{
+       int32_t count;
+
+       count = classcache_get_loaded_class_count();
+
+       return count;
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMClassLoadingMXBeanImpl
+ * Method:    getUnloadedClassCount
+ * Signature: ()J
+ */
+JNIEXPORT int64_t 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 int32_t 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, int32_t 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/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c
new file mode 100644 (file)
index 0000000..4c05838
--- /dev/null
@@ -0,0 +1,194 @@
+/* src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_management_MemoryUsage.h"
+
+#include "native/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
+
+#include "vm/builtin.h"
+#include "vm/global.h"
+#include "vm/vm.h"
+
+#include "vmcore/class.h"
+#include "vmcore/loader.h"               /* XXX only for load_class_bootstrap */
+#include "vmcore/options.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getHeapMemoryUsage",                "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage                },
+       { "getNonHeapMemoryUsage",             "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage             },
+       { "getObjectPendingFinalizationCount", "()I",                                  (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
+       { "isVerbose",                         "()Z",                                  (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose                         },
+       { "setVerbose",                        "(Z)V",                                 (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose                        },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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_handle_t                    *o;
+       java_lang_management_MemoryUsage *mu;
+       methodinfo                       *m;
+       int64_t                           init;
+       int64_t                           used;
+       int64_t                           commited;
+       int64_t                           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 int32_t 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 int32_t 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, int32_t 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/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
new file mode 100644 (file)
index 0000000..cbd1e96
--- /dev/null
@@ -0,0 +1,104 @@
+/* src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c
+
+   Copyright (C) 1996-2005, 2006, 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
+
+#include "vm/builtin.h"
+#include "vm/global.h"
+#include "vm/vm.h"
+
+#include "vmcore/class.h"
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getInputArguments", "()[Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments },
+       { "getStartTime",      "()J",                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime      },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init ***********************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("gnu/java/lang/management/VMRuntimeMXBeanImpl");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMRuntimeMXBeanImpl
+ * Method:    getInputArguments
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_handle_objectarray_t* 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 int64_t 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/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c
new file mode 100644 (file)
index 0000000..862ed07
--- /dev/null
@@ -0,0 +1,205 @@
+/* src/native/vm/gnu/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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_Throwable.h"
+#include "native/include/java_lang_management_ThreadInfo.h"
+
+#include "native/include/gnu_java_lang_management_VMThreadMXBeanImpl.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/vm.h"
+
+#include "vmcore/classcache.h"
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "findMonitorDeadlockedThreads", "()[J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads },
+       { "getCurrentThreadCpuTime",      "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime      },
+       { "getCurrentThreadUserTime",     "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime     },
+       { "getPeakThreadCount",           "()I",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount           },
+       { "getThreadCpuTime",             "(J)J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime             },
+       { "getThreadInfoForId",           "(JI)Ljava/lang/management/ThreadInfo;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId           },
+       { "getThreadUserTime",            "(J)J",                                  (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime            },
+       { "getTotalStartedThreadCount",   "()J",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount   },
+       { "resetPeakThreadCount",         "()V",                                   (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount         },
+};
+
+
+/* _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init ************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("gnu/java/lang/management/VMThreadMXBeanImpl");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     gnu/java/lang/management/VMThreadMXBeanImpl
+ * Method:    findMonitorDeadlockedThreads
+ * Signature: ()[J
+ */
+JNIEXPORT java_handle_longarray_t* 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 int64_t 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 int64_t 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 int32_t 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 int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, int64_t 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, int64_t id, int32_t 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 int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, int64_t 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 int64_t 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/gnuclasspath/java_lang_VMClass.c b/src/native/vm/gnuclasspath/java_lang_VMClass.c
new file mode 100644 (file)
index 0000000..c61e4cc
--- /dev/null
@@ -0,0 +1,654 @@
+/* src/native/vm/gnuclasspath/java_lang_VMClass.c
+
+   Copyright (C) 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/llni.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_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"
+
+#include "native/include/java_lang_VMClass.h"
+
+#include "vm/exceptions.h"
+#include "vm/initialize.h"
+#include "vm/stringlocal.h"
+
+#include "vmcore/class.h"
+
+#if defined(ENABLE_ANNOTATIONS)
+#include "native/include/sun_reflect_ConstantPool.h"
+
+#include "vm/vm.h"
+
+#include "vmcore/annotation.h"
+#endif
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "isInstance",              "(Ljava/lang/Class;Ljava/lang/Object;)Z",                        (void *) (uintptr_t) &Java_java_lang_VMClass_isInstance              },
+       { "isAssignableFrom",        "(Ljava/lang/Class;Ljava/lang/Class;)Z",                         (void *) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom        },
+       { "isInterface",             "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isInterface             },
+       { "isPrimitive",             "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isPrimitive             },
+       { "getName",                 "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getName                 },
+       { "getSuperclass",           "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getSuperclass           },
+       { "getInterfaces",           "(Ljava/lang/Class;)[Ljava/lang/Class;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getInterfaces           },
+       { "getComponentType",        "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getComponentType        },
+       { "getModifiers",            "(Ljava/lang/Class;Z)I",                                         (void *) (uintptr_t) &Java_java_lang_VMClass_getModifiers            },
+       { "getDeclaringClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass       },
+       { "getDeclaredClasses",      "(Ljava/lang/Class;Z)[Ljava/lang/Class;",                        (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses      },
+       { "getDeclaredFields",       "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;",                (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields       },
+       { "getDeclaredMethods",      "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;",               (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods      },
+       { "getDeclaredConstructors", "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;",          (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors },
+       { "getClassLoader",          "(Ljava/lang/Class;)Ljava/lang/ClassLoader;",                    (void *) (uintptr_t) &Java_java_lang_VMClass_getClassLoader          },
+       { "forName",                 "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_forName                 },
+       { "isArray",                 "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isArray                 },
+       { "throwException",          "(Ljava/lang/Throwable;)V",                                      (void *) (uintptr_t) &Java_java_lang_VMClass_throwException          },
+#if defined(ENABLE_ANNOTATIONS)
+       { "getDeclaredAnnotations",  "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;",         (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations  },
+#endif
+       { "getEnclosingClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass       },
+       { "getEnclosingConstructor", "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;",            (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor },
+       { "getEnclosingMethod",      "(Ljava/lang/Class;)Ljava/lang/reflect/Method;",                 (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod      },
+       { "getClassSignature",       "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (uintptr_t) &Java_java_lang_VMClass_getClassSignature       },
+       { "isAnonymousClass",        "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass        },
+       { "isLocalClass",            "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isLocalClass            },
+       { "isMemberClass",           "(Ljava/lang/Class;)Z",                                          (void *) (uintptr_t) &Java_java_lang_VMClass_isMemberClass           },
+};
+
+
+/* _Jv_java_lang_VMClass_init **************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMClass_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMClass");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isInstance
+ * Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o)
+{
+       classinfo     *c;
+       java_handle_t *h;
+
+       c = LLNI_classinfo_unwrap(klass);
+       h = (java_handle_t *) o;
+
+       return class_is_instance(c, h);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isAssignableFrom
+ * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
+{
+       classinfo *to;
+       classinfo *from;
+
+       to   = LLNI_classinfo_unwrap(klass);
+       from = LLNI_classinfo_unwrap(c);
+
+       if (from == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       return class_is_assignable_from(to, from);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isInterface
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return class_is_interface(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isPrimitive
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return class_is_primitive(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getName
+ * Signature: (Ljava/lang/Class;)Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo* c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return (java_lang_String*) class_get_classname(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getSuperclass
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo *c;
+       classinfo *super;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       super = class_get_superclass(c);
+
+       return LLNI_classinfo_wrap(super);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getInterfaces
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/Class;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_interfaces(c);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getComponentType
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo *c;
+       classinfo *component;
+       
+       c = LLNI_classinfo_unwrap(klass);
+       
+       component = class_get_componenttype(c);
+
+       return LLNI_classinfo_wrap(component);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getModifiers
+ * Signature: (Ljava/lang/Class;Z)I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t ignoreInnerClassesAttrib)
+{
+       classinfo *c;
+       int32_t    flags;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       flags = class_get_modifiers(c, ignoreInnerClassesAttrib);
+
+       return flags;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaringClass
+ * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo *c;
+       classinfo *dc;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       dc = class_get_declaringclass(c);
+
+       return LLNI_classinfo_wrap(dc);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredClasses
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredclasses(c, publicOnly);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredFields
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredfields(c, publicOnly);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredMethods
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredmethods(c, publicOnly);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredConstructors
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       oa = class_get_declaredconstructors(c, publicOnly);
+
+       return oa;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getClassLoader
+ * Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader;
+ */
+JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo     *c;
+       classloader_t *cl;
+
+       c  = LLNI_classinfo_unwrap(klass);
+       cl = class_get_classloader(c);
+
+       return (java_lang_ClassLoader *) cl;
+}
+
+
+/*
+ * 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, int32_t initialize, java_lang_ClassLoader *loader)
+{
+       classloader_t *cl;
+       utf           *ufile;
+       utf           *uname;
+       classinfo     *c;
+       u2            *pos;
+       int32_t        i;
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* illegal argument */
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       ufile = javastring_toutf((java_handle_t *) name, true);
+       uname = javastring_toutf((java_handle_t *) name, false);
+
+       /* name must not contain '/' (mauve test) */
+
+       for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) {
+               if (*pos == '/') {
+                       exceptions_throw_classnotfoundexception(uname);
+                       return NULL;
+               }
+       }
+
+       /* try to load, ... */
+
+       c = load_class_from_classloader(ufile, cl);
+
+       if (c == NULL)
+           return NULL;
+
+       /* link, ... */
+
+       if (!link_class(c))
+               return NULL;
+       
+       /* ...and initialize it, if required */
+
+       if (initialize)
+               if (!initialize_class(c))
+                       return NULL;
+
+       return LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isArray
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       classinfo *c;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       return class_is_array(c);
+}
+
+
+/*
+ * 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)
+{
+       java_handle_t *o;
+
+       o = (java_handle_t *) t;
+
+       exceptions_set_exception(o);
+}
+
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/VMClass
+ * Method:    getDeclaredAnnotations
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass)
+{
+       classinfo                *c               = NULL; /* classinfo for the java.lang.Class object 'klass'       */
+       static methodinfo        *m_parseAnnotationsIntoArray   = NULL; /* parser method (cached, therefore static) */
+       utf                      *utf_parseAnnotationsIntoArray = NULL; /* parser method name     */
+       utf                      *utf_desc        = NULL;               /* parser method descriptor (signature)     */
+       java_handle_bytearray_t  *annotations     = NULL;               /* unparsed annotations   */
+       sun_reflect_ConstantPool *constantPool    = NULL;               /* constant pool of klass */
+       java_lang_Object         *constantPoolOop = (java_lang_Object*)klass; /* constantPoolOop field of */
+                                                                             /* sun.reflect.ConstantPool */
+
+       if (klass == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+       
+       c = LLNI_classinfo_unwrap(klass);
+
+       /* get annotations: */
+       annotations = class_get_annotations(c);
+
+       constantPool = 
+               (sun_reflect_ConstantPool*)native_new_and_init(
+                       class_sun_reflect_ConstantPool);
+       
+       if (constantPool == NULL) {
+               /* out of memory */
+               return NULL;
+       }
+
+       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
+
+       /* only resolve the parser method the first time */
+       if (m_parseAnnotationsIntoArray == NULL) {
+               utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray");
+               utf_desc = utf_new_char(
+                       "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
+                       "[Ljava/lang/annotation/Annotation;");
+
+               if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) {
+                       /* out of memory */
+                       return NULL;
+               }
+
+               m_parseAnnotationsIntoArray = class_resolveclassmethod(
+                       class_sun_reflect_annotation_AnnotationParser,
+                       utf_parseAnnotationsIntoArray,
+                       utf_desc,
+                       class_java_lang_Class,
+                       true);
+
+               if (m_parseAnnotationsIntoArray == NULL) {
+                       /* method not found */
+                       return NULL;
+               }
+       }
+
+       return (java_handle_objectarray_t*)vm_call_method(
+               m_parseAnnotationsIntoArray, NULL,
+               annotations, constantPool, 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)
+{
+       classinfo *c;
+       classinfo *result;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       result = class_get_enclosingclass(c);
+
+       return LLNI_classinfo_wrap(result);
+}
+
+
+/*
+ * 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)
+{
+       classinfo*     c;
+       java_handle_t* h;
+
+       c = LLNI_classinfo_unwrap(klass);
+       h = class_get_enclosingconstructor(c);
+
+       return (java_lang_reflect_Constructor*) h;
+}
+
+
+/*
+ * 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)
+{
+       classinfo*     c;
+       java_handle_t* h;
+
+       c = LLNI_classinfo_unwrap(klass);
+       h = class_get_enclosingmethod(c);
+
+       return (java_lang_reflect_Method*) h;
+}
+
+
+/*
+ * 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;
+       utf           *u;
+       java_handle_t *s;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       u = class_get_signature(c);
+
+       if (u == NULL)
+               return NULL;
+
+       s = javastring_new(u);
+
+       /* in error case s is NULL */
+
+       return (java_lang_String *) s;
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isAnonymousClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return class_is_anonymousclass(LLNI_classinfo_unwrap(klass));
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isLocalClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return class_is_localclass(LLNI_classinfo_unwrap(klass));
+}
+
+
+/*
+ * Class:     java/lang/VMClass
+ * Method:    isMemberClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return class_is_memberclass(LLNI_classinfo_unwrap(klass));
+}
+
+
+/*
+ * 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/gnuclasspath/java_lang_VMClassLoader.c b/src/native/vm/gnuclasspath/java_lang_VMClassLoader.c
new file mode 100644 (file)
index 0000000..6f6547b
--- /dev/null
@@ -0,0 +1,628 @@
+/* src/native/vm/gnu/java_lang_VMClassLoader.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+#include <sys/stat.h>
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_String.h"
+#include "native/include/java_security_ProtectionDomain.h"  /* required by... */
+#include "native/include/java_lang_ClassLoader.h"
+#include "native/include/java_util_Vector.h"
+#include "native/include/java_util_HashMap.h"
+#include "native/include/java_util_Map.h"
+#include "native/include/java_lang_Boolean.h"
+
+#include "native/include/java_lang_VMClassLoader.h"
+
+#include "toolbox/logging.h"
+#include "toolbox/list.h"
+
+#if defined(ENABLE_ASSERTION)
+#include "vm/assertion.h"
+#endif
+
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/initialize.h"
+#include "vm/primitive.h"
+#include "vm/stringlocal.h"
+#include "vm/vm.h"
+
+#include "vm/jit/asmpart.h"
+
+#include "vmcore/class.h"
+#include "vmcore/classcache.h"
+#include "vmcore/linker.h"
+#include "vmcore/loader.h"
+#include "vmcore/options.h"
+#include "vmcore/statistics.h"
+#include "vmcore/suck.h"
+#include "vmcore/zip.h"
+
+#if defined(ENABLE_JVMTI)
+#include "native/jvmti/cacaodbg.h"
+#endif
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "defineClass",                "(Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defineClass                },
+       { "getPrimitiveClass",          "(C)Ljava/lang/Class;",                                                                             (void *) (uintptr_t) &Java_java_lang_VMClassLoader_getPrimitiveClass          },
+       { "resolveClass",               "(Ljava/lang/Class;)V",                                                                             (void *) (uintptr_t) &Java_java_lang_VMClassLoader_resolveClass               },
+       { "loadClass",                  "(Ljava/lang/String;Z)Ljava/lang/Class;",                                                           (void *) (uintptr_t) &Java_java_lang_VMClassLoader_loadClass                  },
+       { "nativeGetResources",         "(Ljava/lang/String;)Ljava/util/Vector;",                                                           (void *) (uintptr_t) &Java_java_lang_VMClassLoader_nativeGetResources         },
+       { "defaultAssertionStatus",     "()Z",                                                                                              (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultAssertionStatus     },
+       { "defaultUserAssertionStatus", "()Z",                                                                                              (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultUserAssertionStatus },
+       { "packageAssertionStatus0",    "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void *) (uintptr_t) &Java_java_lang_VMClassLoader_packageAssertionStatus0    },
+       { "classAssertionStatus0",      "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;",                                          (void *) (uintptr_t) &Java_java_lang_VMClassLoader_classAssertionStatus0      },
+       { "findLoadedClass",            "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;",                                     (void *) (uintptr_t) &Java_java_lang_VMClassLoader_findLoadedClass            },
+};
+
+
+/* _Jv_java_lang_VMClassLoader_init ********************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMClassLoader_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMClassLoader");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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_handle_bytearray_t *data, int32_t offset, int32_t len, java_security_ProtectionDomain *pd)
+{
+       utf             *utfname;
+       classinfo       *c;
+       classloader_t   *loader;
+       java_lang_Class *o;
+
+#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) > LLNI_array_size(data))) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       /* add classloader to classloader hashtable */
+
+       loader = loader_hashtable_classloader_add((java_handle_t *) cl);
+
+       if (name != NULL) {
+               /* convert '.' to '/' in java string */
+
+               utfname = javastring_toutf((java_handle_t *) name, true);
+       } 
+       else {
+               utfname = NULL;
+       }
+
+#if defined(ENABLE_JVMTI)
+       /* XXX again this will not work because of the indirection cell for classloaders */
+       assert(0);
+       /* fire Class File Load Hook JVMTI event */
+
+       if (jvmti)
+               jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data, 
+                                                               loader, (java_handle_t *) pd, 
+                                                               &new_class_data_len, &new_class_data);
+#endif
+
+       /* define the class */
+
+#if defined(ENABLE_JVMTI)
+       /* check if the JVMTI wants to modify the class */
+
+       if (new_class_data == NULL)
+               c = class_define(utfname, loader, new_class_data_len, new_class_data, pd); 
+       else
+#endif
+               c = class_define(utfname, loader, len, (uint8_t *) &LLNI_array_direct(data, offset), (java_handle_t *) pd);
+
+       if (c == NULL)
+               return NULL;
+
+       /* for convenience */
+
+       o = LLNI_classinfo_wrap(c);
+
+       /* set ProtectionDomain */
+
+       LLNI_field_set_ref(o, pd, pd);
+
+       return o;
+}
+
+
+/*
+ * 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, int32_t type)
+{
+       classinfo *c;
+
+       c = primitive_class_get_by_char(type);
+
+       if (c == NULL) {
+               exceptions_throw_classnotfoundexception(utf_null);
+               return NULL;
+       }
+
+       return LLNI_classinfo_wrap(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 = LLNI_classinfo_unwrap(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, int32_t resolve)
+{
+       classinfo *c;
+       utf       *u;
+
+       if (name == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* create utf string in which '.' is replaced by '/' */
+
+       u = javastring_toutf((java_handle_t *) name, true);
+
+       /* load class */
+
+       c = load_class_bootstrap(u);
+
+       if (c == NULL)
+               return NULL;
+
+       /* resolve class -- if requested */
+
+/*     if (resolve) */
+               if (!link_class(c))
+                       return NULL;
+
+       return LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * 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)
+{
+       java_handle_t        *o;         /* vector being created     */
+       methodinfo           *m;         /* "add" method of vector   */
+       java_handle_t        *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         */
+       int32_t               namelen;   /* length of name to use    */
+       int32_t               searchlen; /* length of name to search */
+       int32_t               bufsize;   /* size of buffer allocated */
+       int32_t               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((java_handle_t *) name, false);
+
+       if (utfname == NULL)
+               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 == NULL)
+               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 == NULL)
+               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 != NULL) {
+                       ret = vm_call_method_int(m, o, path);
+
+                       if (exceptions_get_exception() != NULL)
+                               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 int32_t JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_ASSERTION)
+       return assertion_system_enabled;
+#else
+       return false;
+#endif
+}
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    userAssertionStatus
+ * Signature: ()Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_ASSERTION)
+       return assertion_user_enabled;
+#else
+       return false;
+#endif
+}
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    packageAssertionStatus
+ * Signature: ()Ljava_util_Map;
+ */
+JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
+{
+       java_handle_t     *hm;
+#if defined(ENABLE_ASSERTION)
+       java_handle_t     *js;
+       methodinfo        *m;
+       assertion_name_t  *item;
+#endif
+
+       /* new HashMap() */
+
+       hm = native_new_and_init(class_java_util_HashMap);
+       if (hm == NULL) {
+               return NULL;
+       }
+
+#if defined(ENABLE_ASSERTION)
+       /* if nothing todo, return now */
+
+       if (assertion_package_count == 0) {
+               return (java_util_Map *) hm;
+       }
+
+       /* get HashMap.put method */
+
+       m = class_resolveclassmethod(class_java_util_HashMap,
+                                 utf_put,
+                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
+                                 NULL,
+                                 true);
+
+       if (m == NULL) {
+               return NULL;
+       }
+
+       item = (assertion_name_t *)list_first(list_assertion_names);
+
+       while (item != NULL) {
+               if (item->package == false) {
+                       item = (assertion_name_t *)list_next(list_assertion_names, item);
+                       continue;
+               }
+               
+               if (strcmp(item->name, "") == 0) {
+                       /* unnamed package wanted */
+                       js = NULL;
+               }
+               else {
+                       js = javastring_new_from_ascii(item->name);
+                       if (js == NULL) {
+                               return NULL;
+                       }
+               }
+
+               if (item->enabled == true) {
+                       vm_call_method(m, hm, js, jtrue);
+               }
+               else {
+                       vm_call_method(m, hm, js, jfalse);
+               }
+
+               item = (assertion_name_t *)list_next(list_assertion_names, item);
+       }
+#endif
+
+       return (java_util_Map *) hm;
+}
+
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    classAssertionStatus
+ * Signature: ()Ljava_util_Map;
+ */
+JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
+{
+       java_handle_t     *hm;
+#if defined(ENABLE_ASSERTION)
+       java_handle_t     *js;
+       methodinfo        *m;
+       assertion_name_t  *item;
+#endif
+
+       /* new HashMap() */
+
+       hm = native_new_and_init(class_java_util_HashMap);
+       if (hm == NULL) {
+               return NULL;
+       }
+
+#if defined(ENABLE_ASSERTION)
+       /* if nothing todo, return now */
+
+       if (assertion_class_count == 0) {
+               return (java_util_Map *) hm;
+       }
+
+       /* get HashMap.put method */
+
+       m = class_resolveclassmethod(class_java_util_HashMap,
+                                 utf_put,
+                                 utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
+                                 NULL,
+                                 true);
+
+       if (m == NULL) {
+               return NULL;
+       }
+
+       item = (assertion_name_t *)list_first(list_assertion_names);
+
+       while (item != NULL) {
+               if (item->package == true) {
+                       item = (assertion_name_t *)list_next(list_assertion_names, item);
+                       continue;
+               }
+
+               js = javastring_new_from_ascii(item->name);
+               if (js == NULL) {
+                       return NULL;
+               }
+
+               if (item->enabled == true) {
+                       vm_call_method(m, hm, js, jtrue);
+               }
+               else {
+                       vm_call_method(m, hm, js, jfalse);
+               }
+
+               item = (assertion_name_t *)list_next(list_assertion_names, item);
+       }
+#endif
+
+       return (java_util_Map *) hm;
+}
+
+
+/*
+ * 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 *loader, java_lang_String *name)
+{
+       classloader_t *cl;
+       classinfo     *c;
+       utf           *u;
+
+       /* XXX is it correct to add the classloader to the hashtable here? */
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* replace `.' by `/', this is required by the classcache */
+
+       u = javastring_toutf((java_handle_t *) name, true);
+
+       /* lookup for defining classloader */
+
+       c = classcache_lookup_defined(cl, u);
+
+       /* if not found, lookup for initiating classloader */
+
+       if (c == NULL)
+               c = classcache_lookup(cl, u);
+
+       return LLNI_classinfo_wrap(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/gnuclasspath/java_lang_VMObject.c b/src/native/vm/gnuclasspath/java_lang_VMObject.c
new file mode 100644 (file)
index 0000000..ea0ba0e
--- /dev/null
@@ -0,0 +1,176 @@
+/* src/native/vm/gnu/java_lang_VMObject.c - java/lang/VMObject
+
+   Copyright (C) 1996-2005, 2006, 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_Class.h"            /* required by j.l.VMO */
+#include "native/include/java_lang_Cloneable.h"        /* required by j.l.VMO */
+#include "native/include/java_lang_Object.h"           /* required by j.l.VMO */
+
+#include "native/include/java_lang_VMObject.h"
+
+#include "threads/lock-common.h"
+
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getClass",  "(Ljava/lang/Object;)Ljava/lang/Class;",     (void *) (intptr_t) &Java_java_lang_VMObject_getClass  },
+       { "clone",     "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void *) (intptr_t) &Java_java_lang_VMObject_clone     },
+       { "notify",    "(Ljava/lang/Object;)V",                     (void *) (intptr_t) &Java_java_lang_VMObject_notify    },
+       { "notifyAll", "(Ljava/lang/Object;)V",                     (void *) (intptr_t) &Java_java_lang_VMObject_notifyAll },
+       { "wait",      "(Ljava/lang/Object;JI)V",                   (void *) (intptr_t) &Java_java_lang_VMObject_wait      },
+};
+
+
+/* _Jv_java_lang_VMObject_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMObject_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMObject");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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 == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       LLNI_class_get(obj, c);
+
+       return LLNI_classinfo_wrap(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_handle_t *o;
+       java_handle_t *co;
+
+       o = (java_handle_t *) this;
+
+       co = builtin_clone(NULL, o);
+
+       return (java_lang_Object *) co;
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    notify
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this)
+{
+#if defined(ENABLE_THREADS)
+       lock_notify_object((java_handle_t *) this);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMObject
+ * Method:    notifyAll
+ * Signature: (Ljava/lang/Object;)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((java_handle_t *) this);
+#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, int64_t ms, int32_t ns)
+{
+#if defined(ENABLE_JVMTI)
+       /* Monitor Wait */
+       if (jvmti) jvmti_MonitorWaiting(true, o, ms);
+#endif
+
+#if defined(ENABLE_THREADS)
+       lock_wait_for_object((java_handle_t *) o, 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/gnuclasspath/java_lang_VMRuntime.c b/src/native/vm/gnuclasspath/java_lang_VMRuntime.c
new file mode 100644 (file)
index 0000000..25be0db
--- /dev/null
@@ -0,0 +1,331 @@
+/* src/native/vm/gnu/java_lang_VMRuntime.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+
+#if defined(__DARWIN__)
+# if defined(__POWERPC__)
+#  define OS_INLINE    /* required for <libkern/ppc/OSByteOrder.h> */
+# endif
+# include <mach/mach.h>
+#endif
+
+#include "mm/dumpmemory.h"
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_io_File.h"
+#include "native/include/java_lang_ClassLoader.h"
+#include "native/include/java_lang_String.h"
+#include "native/include/java_lang_Process.h"
+
+#include "native/include/java_lang_VMRuntime.h"
+
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/stringlocal.h"
+#include "vm/vm.h"
+
+#include "vmcore/system.h"
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "exit",                   "(I)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_exit                   },
+       { "freeMemory",             "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_freeMemory             },
+       { "totalMemory",            "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_totalMemory            },
+       { "maxMemory",              "()J",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_maxMemory              },
+       { "gc",                     "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_gc                     },
+       { "runFinalization",        "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalization        },
+       { "runFinalizersOnExit",    "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizersOnExit    },
+       { "runFinalizationForExit", "()V",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizationForExit },
+       { "traceInstructions",      "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_traceInstructions      },
+       { "traceMethodCalls",       "(Z)V",                                         (void *) (intptr_t) &Java_java_lang_VMRuntime_traceMethodCalls       },
+       { "availableProcessors",    "()I",                                          (void *) (intptr_t) &Java_java_lang_VMRuntime_availableProcessors    },
+       { "nativeLoad",             "(Ljava/lang/String;Ljava/lang/ClassLoader;)I", (void *) (intptr_t) &Java_java_lang_VMRuntime_nativeLoad             },
+       { "mapLibraryName",         "(Ljava/lang/String;)Ljava/lang/String;",       (void *) (intptr_t) &Java_java_lang_VMRuntime_mapLibraryName         },
+};
+
+
+/* _Jv_java_lang_VMRuntime_init ************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMRuntime_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMRuntime");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+static bool finalizeOnExit = false;
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    exit
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, int32_t status)
+{
+       if (finalizeOnExit)
+               gc_finalize_all();
+
+       vm_shutdown(status);
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    freeMemory
+ * Signature: ()J
+ */
+JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_free_bytes();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
+{
+       return gc_get_heap_size();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    maxMemory
+ * Signature: ()J
+ */
+JNIEXPORT int64_t 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, int32_t 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, int32_t par1)
+{
+       /* not supported */
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    traceMethodCalls
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, int32_t par1)
+{
+       /* not supported */
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    availableProcessors
+ * Signature: ()I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
+{
+       return system_processors_online();
+}
+
+
+/*
+ * Class:     java/lang/VMRuntime
+ * Method:    nativeLoad
+ * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *libname, java_lang_ClassLoader *loader)
+{
+       classloader_t *cl;
+       utf           *name;
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* REMOVEME When we use Java-strings internally. */
+
+       if (libname == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       name = javastring_toutf((java_handle_t *) libname, false);
+
+       return native_library_load(env, name, cl);
+}
+
+
+/*
+ * 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;
+       int32_t        buffer_len;
+       java_handle_t *o;
+       int32_t        dumpmarker;
+
+       if (libname == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       u = javastring_toutf((java_handle_t *) libname, false);
+
+       /* 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");
+
+       DMARKER;
+
+       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
+
+       o = javastring_new_from_utf_string(buffer);
+
+       /* release memory */
+
+       DRELEASE;
+
+       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:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/native/vm/gnuclasspath/java_lang_VMString.c b/src/native/vm/gnuclasspath/java_lang_VMString.c
new file mode 100644 (file)
index 0000000..993b661
--- /dev/null
@@ -0,0 +1,89 @@
+/* src/native/vm/gnu/java_lang_VMString.c - java/lang/VMString
+
+   Copyright (C) 1996-2005, 2006, 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_String.h"
+#include "native/include/java_lang_VMString.h"
+
+#include "vm/stringlocal.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "intern", "(Ljava/lang/String;)Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_VMString_intern },
+};
+
+
+/* _Jv_java_lang_VMString_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMString_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMString");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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)
+{
+       if (str == NULL)
+               return NULL;
+
+       return (java_lang_String *) javastring_intern((java_handle_t *) str);
+}
+
+
+/*
+ * 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/gnuclasspath/java_lang_VMSystem.c b/src/native/vm/gnuclasspath/java_lang_VMSystem.c
new file mode 100644 (file)
index 0000000..40c978c
--- /dev/null
@@ -0,0 +1,112 @@
+/* src/native/vm/gnu/java_lang_VMSystem.c - java/lang/VMSystem
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "mm/gc-common.h"
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_io_InputStream.h"        /* required by j.l.VMS */
+#include "native/include/java_io_PrintStream.h"        /* required by j.l.VMS */
+
+#include "native/include/java_lang_VMSystem.h"
+
+#include "vm/builtin.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "arraycopy",        "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void *) (uintptr_t) &Java_java_lang_VMSystem_arraycopy },
+       { "identityHashCode", "(Ljava/lang/Object;)I",                      (void *) (uintptr_t) &Java_java_lang_VMSystem_identityHashCode },
+};
+
+
+/* _Jv_java_lang_VMSystem_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMSystem_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMSystem");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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, int32_t srcStart, java_lang_Object *dest, int32_t destStart, int32_t len)
+{
+       builtin_arraycopy((java_handle_t *) src, srcStart,
+                                         (java_handle_t *) dest, destStart, len);
+}
+
+
+/*
+ * Class:     java/lang/VMSystem
+ * Method:    identityHashCode
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, java_lang_Object *o)
+{
+       int32_t hashcode;
+
+       LLNI_CRITICAL_START;
+
+       hashcode = heap_hashcode(LLNI_UNWRAP((java_handle_t *) o));
+
+       LLNI_CRITICAL_END;
+
+       return hashcode;
+}
+
+
+/*
+ * 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/gnuclasspath/java_lang_VMThread.c b/src/native/vm/gnuclasspath/java_lang_VMThread.c
new file mode 100644 (file)
index 0000000..178bd41
--- /dev/null
@@ -0,0 +1,360 @@
+/* src/native/vm/gnu/java_lang_VMThread.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/llni.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_String.h"
+#include "native/include/java_lang_Thread.h"
+
+#include "threads/lock-common.h"
+#include "threads/thread.h"
+
+#include "vm/exceptions.h"
+#include "vm/stringlocal.h"
+
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "countStackFrames",  "()I",                      (void *) (intptr_t) &Java_java_lang_VMThread_countStackFrames  },
+       { "start",             "(J)V",                     (void *) (intptr_t) &Java_java_lang_VMThread_start             },
+       { "interrupt",         "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_interrupt         },
+       { "isInterrupted",     "()Z",                      (void *) (intptr_t) &Java_java_lang_VMThread_isInterrupted     },
+       { "suspend",           "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_suspend           },
+       { "resume",            "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_resume            },
+       { "nativeSetPriority", "(I)V",                     (void *) (intptr_t) &Java_java_lang_VMThread_nativeSetPriority },
+       { "nativeStop",        "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeStop        },
+       { "currentThread",     "()Ljava/lang/Thread;",     (void *) (intptr_t) &Java_java_lang_VMThread_currentThread     },
+       { "yield",             "()V",                      (void *) (intptr_t) &Java_java_lang_VMThread_yield             },
+       { "interrupted",       "()Z",                      (void *) (intptr_t) &Java_java_lang_VMThread_interrupted       },
+       { "holdsLock",         "(Ljava/lang/Object;)Z",    (void *) (intptr_t) &Java_java_lang_VMThread_holdsLock         },
+       { "getState",          "()Ljava/lang/String;",     (void *) (intptr_t) &Java_java_lang_VMThread_getState          },
+};
+
+
+/* _Jv_java_lang_VMThread_init *************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMThread_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMThread");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    countStackFrames
+ * Signature: ()I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
+{
+       java_lang_Thread *thread;
+
+       LLNI_field_get_ref(this, thread, thread);
+
+    log_println("Java_java_lang_VMThread_countStackFrames: IMPLEMENT ME!");
+
+    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, int64_t stacksize)
+{
+       java_lang_Thread *thread;
+
+       LLNI_field_get_ref(this, thread, thread);
+
+#if defined(ENABLE_THREADS)
+       threads_thread_start((java_handle_t *) thread);
+#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)
+       java_handle_t *h;
+       threadobject  *t;
+
+       h = (java_handle_t *) this;
+       t = thread_get_thread(h);
+
+       threads_thread_interrupt(t);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    isInterrupted
+ * Signature: ()Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+       threadobject  *t;
+
+       h = (java_handle_t *) this;
+       t = thread_get_thread(h);
+
+       return thread_is_interrupted(t);
+#else
+       return 0;
+#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)
+       /* TODO Should we implement this or is it obsolete? */
+#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)
+       /* TODO Should we implement this or is it obsolete? */
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    nativeSetPriority
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+       threadobject  *t;
+
+       h = (java_handle_t *) this;
+       t = thread_get_thread(h);
+
+       threads_set_thread_priority(t->tid, priority);
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    nativeStop
+ * Signature: (Ljava/lang/Throwable;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
+{
+#if defined(ENABLE_THREADS)
+       /* TODO Should we implement this or is it obsolete? */
+#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 *to;
+
+       to = (java_lang_Thread *) thread_get_current_object();
+
+       return to;
+}
+
+
+/*
+ * 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 int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
+{
+#if defined(ENABLE_THREADS)
+       threadobject *t;
+       int32_t       interrupted;
+
+       t = thread_get_current();
+
+       interrupted = thread_is_interrupted(t);
+
+       if (interrupted)
+               thread_set_interrupted(t, false);
+
+       return interrupted;
+#else
+       return 0;
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    holdsLock
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+
+       h = (java_handle_t *) o;
+
+       if (h == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       return lock_is_held_by_current_thread(h);
+#else
+       return 0;
+#endif
+}
+
+
+/*
+ * Class:     java/lang/VMThread
+ * Method:    getState
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *h;
+       threadobject  *t;
+       int            state;
+       utf           *u;
+       java_handle_t *o;
+
+       h = (java_handle_t *) this;
+       t = thread_get_thread(h);
+
+       state = cacaothread_get_state(t);
+       
+       switch (state) {
+       case THREAD_STATE_NEW:
+               u = utf_new_char("NEW");
+               break;
+       case THREAD_STATE_RUNNABLE:
+               u = utf_new_char("RUNNABLE");
+               break;
+       case THREAD_STATE_BLOCKED:
+               u = utf_new_char("BLOCKED");
+               break;
+       case THREAD_STATE_WAITING:
+               u = utf_new_char("WAITING");
+               break;
+       case THREAD_STATE_TIMED_WAITING:
+               u = utf_new_char("TIMED_WAITING");
+               break;
+       case THREAD_STATE_TERMINATED:
+               u = utf_new_char("TERMINATED");
+               break;
+       default:
+               vm_abort("Java_java_lang_VMThread_getState: unknown thread state %d", state);
+
+               /* Keep compiler happy. */
+
+               u = NULL;
+       }
+
+       o = javastring_new(u);
+
+       return (java_lang_String *) o;
+#else
+       return NULL;
+#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/gnuclasspath/java_lang_VMThrowable.c b/src/native/vm/gnuclasspath/java_lang_VMThrowable.c
new file mode 100644 (file)
index 0000000..29d6f65
--- /dev/null
@@ -0,0 +1,219 @@
+/* src/native/vm/gnu/java_lang_VMThrowable.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_String.h"
+#include "native/include/java_lang_StackTraceElement.h"
+#include "native/include/java_lang_Throwable.h"
+
+#include "native/include/java_lang_VMThrowable.h"
+
+#include "vm/array.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/stringlocal.h"
+
+#include "vm/jit/code.h"
+#include "vm/jit/linenumbertable.h"
+#include "vm/jit/stacktrace.h"
+
+#include "vmcore/class.h"
+#include "vmcore/loader.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "fillInStackTrace", "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;",        (void *) (ptrint) &Java_java_lang_VMThrowable_fillInStackTrace },
+       { "getStackTrace",    "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void *) (ptrint) &Java_java_lang_VMThrowable_getStackTrace    },
+};
+
+
+/* _Jv_java_lang_VMThrowable_init **********************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_VMThrowable_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/VMThrowable");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * 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   *vmto;
+       java_handle_bytearray_t *ba;
+       java_lang_Object        *o;
+
+       vmto = (java_lang_VMThrowable *)
+               native_new_and_init(class_java_lang_VMThrowable);
+
+       if (vmto == NULL)
+               return NULL;
+
+       ba = stacktrace_get_current();
+
+       if (ba == NULL)
+               return NULL;
+
+       o = (java_lang_Object *) ba;
+
+       LLNI_field_set_ref(vmto, vmdata, o);
+
+       return vmto;
+}
+
+
+/*
+ * Class:     java/lang/VMThrowable
+ * Method:    getStackTrace
+ * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *this, java_lang_Throwable *t)
+{
+       java_lang_Object            *o;
+       java_handle_bytearray_t     *ba;
+       stacktrace_t                *st;
+       stacktrace_entry_t          *ste;
+       java_handle_objectarray_t   *oa;
+       java_lang_StackTraceElement *steo;
+       codeinfo                    *code;
+       methodinfo                  *m;
+       java_lang_String            *filename;
+       s4                           linenumber;
+       java_handle_t               *declaringclass;
+       int                          i;
+
+       /* Get the stacktrace from the VMThrowable object. */
+
+       LLNI_field_get_ref(this, vmdata, o);
+
+       ba = (java_handle_bytearray_t *) o;
+
+       st = (stacktrace_t *) LLNI_array_data(ba);
+
+       assert(st != NULL);
+
+       ste = st->entries;
+
+       /* Create the stacktrace element array. */
+
+       oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement);
+
+       if (oa == NULL)
+               return NULL;
+
+       for (i = 0; i < st->length; i++, ste++) {
+               /* allocate a new stacktrace element */
+
+               steo = (java_lang_StackTraceElement *)
+                       builtin_new(class_java_lang_StackTraceElement);
+
+               if (steo == NULL)
+                       return NULL;
+
+               /* Get the codeinfo and methodinfo. */
+
+               code = ste->code;
+               m    = code->m;
+
+               /* Get filename. */
+
+               if (!(m->flags & ACC_NATIVE)) {
+                       if (m->clazz->sourcefile)
+                               filename = (java_lang_String *) javastring_new(m->clazz->sourcefile);
+                       else
+                               filename = NULL;
+               }
+               else
+                       filename = NULL;
+
+               /* get line number */
+
+               if (m->flags & ACC_NATIVE) {
+                       linenumber = -1;
+               }
+               else {
+                       /* FIXME The linenumbertable_linenumber_for_pc could
+                          change the methodinfo pointer when hitting an inlined
+                          method. */
+
+                       linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc);
+                       linenumber = (linenumber == 0) ? -1 : linenumber;
+               }
+
+               /* get declaring class name */
+
+               declaringclass = class_get_classname(m->clazz);
+
+               /* Fill the java.lang.StackTraceElement object. */
+
+               LLNI_field_set_ref(steo, fileName      , filename);
+               LLNI_field_set_val(steo, lineNumber    , linenumber);
+               LLNI_field_set_ref(steo, declaringClass, (java_lang_String*) declaringclass);
+               LLNI_field_set_ref(steo, methodName    , (java_lang_String *) javastring_new(m->name));
+               LLNI_field_set_val(steo, isNative      , (m->flags & ACC_NATIVE) ? 1 : 0);
+
+               array_objectarray_element_set(oa, i, (java_handle_t *) steo);
+       }
+
+       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/gnuclasspath/java_lang_management_VMManagementFactory.c b/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c
new file mode 100644 (file)
index 0000000..62e1a8f
--- /dev/null
@@ -0,0 +1,134 @@
+/* src/native/vm/gnu/java_lang_management_VMManagementFactory.c
+
+   Copyright (C) 1996-2005, 2006, 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_management_VMManagementFactory.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/builtin.h"
+
+#include "vmcore/class.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getMemoryPoolNames",       "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames       },
+       { "getMemoryManagerNames",    "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames    },
+       { "getGarbageCollectorNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames },
+};
+
+
+/* _Jv_java_lang_management_VMManagementFactory_init ***************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_management_VMManagementFactory_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/management/VMManagementFactory");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     java/lang/management/VMManagementFactory
+ * Method:    getMemoryPoolNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *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_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *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_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
+{
+       java_handle_objectarray_t *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/gnuclasspath/java_lang_reflect_VMConstructor.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c
new file mode 100644 (file)
index 0000000..db90cf9
--- /dev/null
@@ -0,0 +1,275 @@
+/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#if defined(ENABLE_ANNOTATIONS)
+#include "vm/vm.h"
+#include "vm/exceptions.h"
+#endif
+
+#include "native/jni.h"
+#include "native/llni.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"
+
+#if defined(ENABLE_ANNOTATIONS)
+# include "native/include/java_util_Map.h"
+# include "native/include/sun_reflect_ConstantPool.h"
+#endif
+
+#include "native/include/java_lang_reflect_Constructor.h"
+#include "native/include/java_lang_reflect_VMConstructor.h"
+
+#include "native/vm/reflect.h"
+
+#include "vm/stringlocal.h"
+
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getModifiersInternal",    "()I",                                                       (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal    },
+       { "getParameterTypes",       "()[Ljava/lang/Class;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes       },
+       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes       },
+       { "construct",               "([Ljava/lang/Object;)Ljava/lang/Object;",                   (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_construct               },
+       { "getSignature",            "()Ljava/lang/String;",                                      (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getSignature            },
+#if defined(ENABLE_ANNOTATIONS)
+       { "declaredAnnotations",     "()Ljava/util/Map;",                                         (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations     },
+       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                     (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMConstructor_init ************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMConstructor_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/VMConstructor");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMConstructor *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+       int32_t     slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot,  slot);
+
+       m = &(c->methods[slot]);
+
+       return m->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getParameterTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+       int32_t     slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot,  slot);
+
+       m = &(c->methods[slot]);
+
+       return method_get_parametertypearray(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getExceptionTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+       int32_t     slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot,  slot);
+
+       m = &(c->methods[slot]);
+
+       return method_get_exceptionarray(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    construct
+ * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, java_lang_reflect_VMConstructor *this, java_handle_objectarray_t *args)
+{
+       classinfo                     *c;
+       int32_t                        slot;
+       java_lang_reflect_Constructor *rc;
+       int32_t                        override;
+       methodinfo                    *m;
+       java_handle_t                 *o;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot,  slot);
+
+       LLNI_field_get_ref(this, cons,  rc);
+       LLNI_field_get_val(rc,   flag,  override);
+
+       m = &(c->methods[slot]);
+
+       o = reflect_constructor_newinstance(m, args, override);
+
+       return (java_lang_Object *) o;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, java_lang_reflect_VMConstructor *this)
+{
+       classinfo     *c;
+       methodinfo    *m;
+       java_handle_t *o;
+       int32_t        slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot,  slot);
+
+       m = &(c->methods[slot]);
+
+       if (m->signature == NULL)
+               return NULL;
+
+       o = javastring_new(m->signature);
+
+       /* In error case o is NULL. */
+
+       return (java_lang_String *) o;
+}
+
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ *
+ * Parses the annotations (if they aren't parsed yet) and stores them into
+ * the declaredAnnotations map and return this map.
+ */
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this)
+{
+       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
+       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
+       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
+       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
+                                                            /* (for the parameter 'referer' of vm_call_method()) */
+
+       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
+
+       /* are the annotations parsed yet? */
+       if (declaredAnnotations == NULL) {
+               LLNI_field_get_ref(this, annotations, annotations);
+               LLNI_field_get_ref(this, clazz, declaringClass);
+               LLNI_class_get(this, referer);
+
+               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
+
+               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
+       }
+
+       return declaredAnnotations;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMConstructor
+ * Method:    getParameterAnnotations
+ * Signature: ()[[Ljava/lang/annotation/Annotation;
+ *
+ * Parses the parameter annotations and returns them in an 2 dimensional array.
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this)
+{
+       java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations                    */
+       int32_t                  slot                 = -1;   /* slot of the method                                */
+       java_lang_Class         *declaringClass       = NULL; /* the constant pool of this class is used           */
+       classinfo               *referer              = NULL; /* class, which calles the annotation parser         */
+                                                             /* (for the parameter 'referer' of vm_call_method()) */
+
+       LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
+       LLNI_field_get_val(this, slot, slot);
+       LLNI_field_get_ref(this, clazz, declaringClass);
+       LLNI_class_get(this, referer);
+
+       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
+}
+#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/gnuclasspath/java_lang_reflect_VMField.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMField.c
new file mode 100644 (file)
index 0000000..b3da621
--- /dev/null
@@ -0,0 +1,1345 @@
+/* src/native/vm/gnu/java_lang_reflect_VMField.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/llni.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_String.h"
+
+#include "native/include/java_lang_reflect_Field.h"
+#include "native/include/java_lang_reflect_VMField.h"
+
+#if defined(ENABLE_ANNOTATIONS)
+#include "native/include/java_util_Map.h"
+#include "native/include/sun_reflect_ConstantPool.h"
+#include "native/vm/reflect.h"
+#endif
+
+#include "vm/access.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/global.h"
+#include "vm/initialize.h"
+#include "vm/primitive.h"
+#include "vm/resolve.h"
+#include "vm/stringlocal.h"
+
+#include "vm/jit/stacktrace.h"
+
+#include "vmcore/loader.h"
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getModifiersInternal", "()I",                                     (void *) (intptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal },
+       { "getType",              "()Ljava/lang/Class;",                     (void *) (intptr_t) &Java_java_lang_reflect_VMField_getType              },
+       { "get",                  "(Ljava/lang/Object;)Ljava/lang/Object;",  (void *) (intptr_t) &Java_java_lang_reflect_VMField_get                  },
+       { "getBoolean",           "(Ljava/lang/Object;)Z",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getBoolean           },
+       { "getByte",              "(Ljava/lang/Object;)B",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getByte              },
+       { "getChar",              "(Ljava/lang/Object;)C",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getChar              },
+       { "getShort",             "(Ljava/lang/Object;)S",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getShort             },
+       { "getInt",               "(Ljava/lang/Object;)I",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getInt               },
+       { "getLong",              "(Ljava/lang/Object;)J",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getLong              },
+       { "getFloat",             "(Ljava/lang/Object;)F",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getFloat             },
+       { "getDouble",            "(Ljava/lang/Object;)D",                   (void *) (intptr_t) &Java_java_lang_reflect_VMField_getDouble            },
+       { "set",                  "(Ljava/lang/Object;Ljava/lang/Object;)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_set                  },
+       { "setBoolean",           "(Ljava/lang/Object;Z)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setBoolean           },
+       { "setByte",              "(Ljava/lang/Object;B)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setByte              },
+       { "setChar",              "(Ljava/lang/Object;C)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setChar              },
+       { "setShort",             "(Ljava/lang/Object;S)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setShort             },
+       { "setInt",               "(Ljava/lang/Object;I)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setInt               },
+       { "setLong",              "(Ljava/lang/Object;J)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setLong              },
+       { "setFloat",             "(Ljava/lang/Object;F)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setFloat             },
+       { "setDouble",            "(Ljava/lang/Object;D)V",                  (void *) (intptr_t) &Java_java_lang_reflect_VMField_setDouble            },
+       { "getSignature",         "()Ljava/lang/String;",                    (void *) (intptr_t) &Java_java_lang_reflect_VMField_getSignature         },
+#if defined(ENABLE_ANNOTATIONS)
+       { "declaredAnnotations",  "()Ljava/util/Map;",                       (void *) (intptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations  },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMField_init ******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMField_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/VMField");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/* _field_access_check *********************************************************
+
+   Checks if the field can be accessed.
+
+   RETURN VALUE:
+      true......field can be accessed, or
+      false.....otherwise (maybe an Exception was thrown).
+
+*******************************************************************************/
+
+static bool _field_access_check(java_lang_reflect_VMField *this,
+                                                               fieldinfo *f, classinfo *c, java_handle_t *o)
+{
+       java_lang_reflect_Field *rf;
+       int32_t                  flag;
+
+       /* check if we should bypass security checks (AccessibleObject) */
+
+       LLNI_field_get_ref(this, f, rf);
+       LLNI_field_get_val(rf, flag, flag);
+
+       if (flag == false) {
+               /* This function is always called like this:
+                      [0] java.lang.reflect.VMField.xxx (Native Method)
+                      [1] java.lang.reflect.Field.xxx
+                      [2] <caller>
+               */
+
+               if (!access_check_field(f, 2))
+                       return false;
+       }
+
+       /* some general checks */
+
+       if (f->flags & ACC_STATIC) {
+               /* initialize class if required */
+
+               if (!(c->state & CLASS_INITIALIZED))
+                       if (!initialize_class(c))
+                               return false;
+
+               /* everything is ok */
+
+               return true;
+       }
+       else {
+               /* obj is required for not-static fields */
+
+               if (o == NULL) {
+                       exceptions_throw_nullpointerexception();
+                       return false;
+               }
+       
+               if (builtin_instanceof(o, c))
+                       return true;
+       }
+
+       /* exception path */
+
+       exceptions_throw_illegalargumentexception();
+       return false;
+}
+
+
+/* _field_get_type *************************************************************
+
+   Returns the content of the given field.
+
+*******************************************************************************/
+
+#define _FIELD_GET_TYPE(name, type, uniontype) \
+static inline type _field_get_##name(fieldinfo *f, java_lang_Object *o) \
+{ \
+       type ret; \
+       if (f->flags & ACC_STATIC) { \
+               ret = f->value->uniontype; \
+       } else { \
+               LLNI_CRITICAL_START; \
+               ret = *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset); \
+               LLNI_CRITICAL_END; \
+       } \
+       return ret; \
+}
+
+static inline java_handle_t *_field_get_handle(fieldinfo *f, java_lang_Object *o)
+{
+       java_object_t *obj;
+       java_handle_t *hdl;
+
+       LLNI_CRITICAL_START;
+
+       if (f->flags & ACC_STATIC) {
+               obj = f->value->a;
+       } else {
+               obj = *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset);
+       }
+
+       hdl = LLNI_WRAP(obj);
+
+       LLNI_CRITICAL_END;
+
+       return hdl;
+}
+
+_FIELD_GET_TYPE(int,    int32_t, i)
+_FIELD_GET_TYPE(long,   int64_t, l)
+_FIELD_GET_TYPE(float,  float,   f)
+_FIELD_GET_TYPE(double, double,  d)
+
+
+/* _field_set_type *************************************************************
+
+   Sets the content of the given field to the given value.
+
+*******************************************************************************/
+
+#define _FIELD_SET_TYPE(name, type, uniontype) \
+static inline void _field_set_##name(fieldinfo *f, java_lang_Object *o, type value) \
+{ \
+       if (f->flags & ACC_STATIC) { \
+               f->value->uniontype = value; \
+       } else { \
+               LLNI_CRITICAL_START; \
+               *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = value; \
+               LLNI_CRITICAL_END; \
+       } \
+}
+
+static inline void _field_set_handle(fieldinfo *f, java_lang_Object *o, java_handle_t *value)
+{
+       LLNI_CRITICAL_START;
+
+       if (f->flags & ACC_STATIC) {
+               f->value->a = LLNI_DIRECT(value);
+       } else {
+               *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = LLNI_DIRECT(value);
+       }
+
+       LLNI_CRITICAL_END;
+}
+
+_FIELD_SET_TYPE(int,    int32_t, i)
+_FIELD_SET_TYPE(long,   int64_t, l)
+_FIELD_SET_TYPE(float,  float,   f)
+_FIELD_SET_TYPE(double, double,  d)
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMField *this)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &(c->fields[slot]);
+
+       return f->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, java_lang_reflect_VMField *this)
+{
+       classinfo *c;
+       typedesc  *desc;
+       classinfo *ret;
+       int32_t    slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       desc = c->fields[slot].parseddesc;
+
+       if (desc == NULL)
+               return NULL;
+
+       if (!resolve_class_from_typedesc(desc, true, false, &ret))
+               return NULL;
+       
+       return LLNI_classinfo_wrap(ret);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    get
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+       imm_union  value;
+       java_handle_t *object;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return NULL;
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BOOLEAN:
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               value.i = _field_get_int(f, o);
+               break;
+
+       case PRIMITIVETYPE_LONG:
+               value.l = _field_get_long(f, o);
+               break;
+
+       case PRIMITIVETYPE_FLOAT:
+               value.f = _field_get_float(f, o);
+               break;
+
+       case PRIMITIVETYPE_DOUBLE:
+               value.d = _field_get_double(f, o);
+               break;
+
+       case TYPE_ADR:
+               return (java_lang_Object *) _field_get_handle(f, o);
+       }
+
+       /* Now box the primitive types. */
+
+       object = primitive_box(f->parseddesc->decltype, value);
+
+       return (java_lang_Object *) object;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BOOLEAN:
+               return (int32_t) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;)B
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+               return (int32_t) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;)C
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_CHAR:
+               return (int32_t) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;)S
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return 0;
+
+       /* check the field type and return the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_SHORT:
+               return (int32_t) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               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 (int32_t) _field_get_int(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;)J
+ */
+JNIEXPORT int64_t JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               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 (int64_t) _field_get_int(f, o);
+       case PRIMITIVETYPE_LONG:
+               return (int64_t) _field_get_long(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               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) _field_get_int(f, o);
+       case PRIMITIVETYPE_LONG:
+               return (float) _field_get_long(f, o);
+       case PRIMITIVETYPE_FLOAT:
+               return (float) _field_get_float(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               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) _field_get_int(f, o);
+       case PRIMITIVETYPE_LONG:
+               return (double) _field_get_long(f, o);
+       case PRIMITIVETYPE_FLOAT:
+               return (double) _field_get_float(f, o);
+       case PRIMITIVETYPE_DOUBLE:
+               return (double) _field_get_double(f, o);
+       default:
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    set
+ * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, java_lang_Object *value)
+{
+       classinfo *sc;
+       classinfo *dc;
+       fieldinfo *sf;
+       fieldinfo *df;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, dc);
+       LLNI_field_get_val(this, slot , slot);
+       df = &dc->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, df, dc, (java_handle_t *) o))
+               return;
+
+       /* get the source classinfo from the object */
+
+       if (value == NULL)
+               sc = NULL;
+       else
+               LLNI_class_get(value, sc);
+
+       /* 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: {
+               int32_t 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:
+                       LLNI_field_get_val((java_lang_Boolean *) value, value, val);
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_BYTE: {
+               int32_t val;
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B)))
+                       break;
+
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_BYTE:
+                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
+                       break;
+               default:        
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_CHAR: {
+               int32_t val;
+
+               if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C)))
+                       break;
+                                  
+               switch (sf->parseddesc->decltype) {
+               case PRIMITIVETYPE_CHAR:
+                       LLNI_field_get_val((java_lang_Character *) value, value, val);
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_SHORT: {
+               int32_t 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:
+                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       LLNI_field_get_val((java_lang_Short *) value, value, val);
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_INT: {
+               int32_t 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:
+                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       LLNI_field_get_val((java_lang_Character *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       LLNI_field_get_val((java_lang_Short *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_INT:
+                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_int(df, o, val);
+               return;
+       }
+
+       case PRIMITIVETYPE_LONG: {
+               int64_t 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:
+                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       LLNI_field_get_val((java_lang_Character *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       LLNI_field_get_val((java_lang_Short *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_INT:
+                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       LLNI_field_get_val((java_lang_Long *) value, value, val);
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_long(df, o, 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:
+                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       LLNI_field_get_val((java_lang_Character *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       LLNI_field_get_val((java_lang_Short *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_INT:
+                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       LLNI_field_get_val((java_lang_Long *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_FLOAT:
+                       LLNI_field_get_val((java_lang_Float *) value, value, val);
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_float(df, o, 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:
+                       LLNI_field_get_val((java_lang_Byte *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_CHAR:
+                       LLNI_field_get_val((java_lang_Character *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_SHORT:
+                       LLNI_field_get_val((java_lang_Short *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_INT:
+                       LLNI_field_get_val((java_lang_Integer *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_LONG:
+                       LLNI_field_get_val((java_lang_Long *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_FLOAT:
+                       LLNI_field_get_val((java_lang_Float *) value, value, val);
+                       break;
+               case PRIMITIVETYPE_DOUBLE:
+                       LLNI_field_get_val((java_lang_Double *) value, value, val);
+                       break;
+               default:
+                       exceptions_throw_illegalargumentexception();
+                       return;
+               }
+
+               _field_set_double(df, o, val);
+               return;
+       }
+
+       case TYPE_ADR:
+               /* check if value is an instance of the destination class */
+
+               /* XXX TODO */
+               /*                      if (!builtin_instanceof((java_handle_t *) value, df->class)) */
+               /*                              break; */
+
+               _field_set_handle(df, o, (java_handle_t *) value);
+               return;
+       }
+
+       /* raise exception */
+
+       exceptions_throw_illegalargumentexception();
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BOOLEAN:
+               _field_set_int(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;B)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;C)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;S)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_INT:
+               _field_set_int(f, o, value);
+               break;
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int64_t value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_LONG:
+               _field_set_long(f, o, value);
+               break;
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;F)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, float value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_FLOAT:
+               _field_set_float(f, o, value);
+               break;
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;D)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, double value)
+{
+       classinfo *c;
+       fieldinfo *f;
+       int32_t    slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       /* check if the field can be accessed */
+
+       if (!_field_access_check(this, f, c, (java_handle_t *) o))
+               return;
+
+       /* check the field type and set the value */
+
+       switch (f->parseddesc->decltype) {
+       case PRIMITIVETYPE_DOUBLE:
+               _field_set_double(f, o, value);
+               break;
+       default:
+               exceptions_throw_illegalargumentexception();
+       }
+
+       return;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, java_lang_reflect_VMField* this)
+{
+       classinfo     *c;
+       fieldinfo     *f;
+       java_handle_t *o;
+       int32_t        slot;
+
+       /* get the class and the field */
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       f = &c->fields[slot];
+
+       if (f->signature == NULL)
+               return NULL;
+
+       o = javastring_new(f->signature);
+
+       /* in error case o is NULL */
+
+       return (java_lang_String *) o;
+}
+
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/VMField
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ */
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMField *this)
+{
+       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
+       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
+       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
+       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
+                                                            /* (for the parameter 'referer' of vm_call_method()) */
+
+       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
+
+       /* are the annotations parsed yet? */
+       if (declaredAnnotations == NULL) {
+               LLNI_field_get_ref(this, annotations, annotations);
+               LLNI_field_get_ref(this, clazz, declaringClass);
+               LLNI_class_get(this, referer);
+
+               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
+
+               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
+       }
+
+       return declaredAnnotations;
+}
+#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/gnuclasspath/java_lang_reflect_VMMethod.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c
new file mode 100644 (file)
index 0000000..8b1853f
--- /dev/null
@@ -0,0 +1,372 @@
+/* src/native/vm/gnu/java_lang_reflect_VMMethod.c
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#if defined(ENABLE_ANNOTATIONS)
+#include "vm/vm.h"
+#endif
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_String.h"
+
+#if defined(ENABLE_ANNOTATIONS)
+# include "native/include/java_util_Map.h"
+# include "native/include/sun_reflect_ConstantPool.h"
+#endif
+
+#include "native/include/java_lang_reflect_Method.h"
+#include "native/include/java_lang_reflect_VMMethod.h"
+
+#include "native/vm/reflect.h"
+
+#include "vm/access.h"
+#include "vm/global.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/initialize.h"
+#include "vm/resolve.h"
+#include "vm/stringlocal.h"
+
+#include "vmcore/method.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getModifiersInternal",    "()I",                                                       (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal    },
+       { "getReturnType",           "()Ljava/lang/Class;",                                       (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType           },
+       { "getParameterTypes",       "()[Ljava/lang/Class;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes       },
+       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes       },
+       { "invoke",                  "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke                  },
+       { "getSignature",            "()Ljava/lang/String;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature            },
+#if defined(ENABLE_ANNOTATIONS)
+       { "getDefaultValue",         "()Ljava/lang/Object;",                                      (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue         },
+       { "declaredAnnotations",     "()Ljava/util/Map;",                                         (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations     },
+       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                     (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMMethod_init *******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMMethod_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/VMMethod");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getModifiersInternal
+ * Signature: ()I
+ */
+JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMMethod *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+       int32_t     slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       m = &(c->methods[slot]);
+
+       return m->flags;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getReturnType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, java_lang_reflect_VMMethod *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+       classinfo  *result;
+       int32_t     slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       m = &(c->methods[slot]);
+
+       result = method_returntype_get(m);
+
+       return LLNI_classinfo_wrap(result);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getParameterTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, java_lang_reflect_VMMethod *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+       int32_t     slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       m = &(c->methods[slot]);
+
+       return method_get_parametertypearray(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getExceptionTypes
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMMethod *this)
+{
+       classinfo  *c;
+       methodinfo *m;
+       int32_t     slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       m = &(c->methods[slot]);
+
+       return method_get_exceptionarray(m);
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    invoke
+ * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, java_lang_reflect_VMMethod *this, java_lang_Object *o, java_handle_objectarray_t *args)
+{
+       classinfo                *c;
+       int32_t                   slot;
+       java_lang_reflect_Method *rm;
+       int32_t                   override;
+       methodinfo               *m;
+       java_handle_t            *ro;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot,  slot);
+
+       LLNI_field_get_ref(this, m,     rm);
+       LLNI_field_get_val(rm,   flag,  override);
+
+       m = &(c->methods[slot]);
+
+       ro = reflect_method_invoke(m, (java_handle_t *) o, args, override);
+
+       return (java_lang_Object *) ro;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getSignature
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, java_lang_reflect_VMMethod* this)
+{
+       classinfo     *c;
+       methodinfo    *m;
+       java_handle_t *o;
+       int32_t        slot;
+
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
+       m = &(c->methods[slot]);
+
+       if (m->signature == NULL)
+               return NULL;
+
+       o = javastring_new(m->signature);
+
+       /* in error case o is NULL */
+
+       return (java_lang_String *) o;
+}
+
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getDefaultValue
+ * Signature: ()Ljava/lang/Object;
+ *
+ * Parses the annotation default value and returnes it (boxed, if it's a primitive).
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, struct java_lang_reflect_VMMethod* this)
+{
+       java_handle_bytearray_t  *annotationDefault          = NULL; /* unparsed annotation default value                 */
+       static methodinfo        *m_parseAnnotationDefault   = NULL; /* parser method (will be chached, therefore static) */
+       utf                      *utf_parseAnnotationDefault = NULL; /* parser method name                                */
+       utf                      *utf_desc        = NULL;            /* parser method descriptor (signature)              */
+       sun_reflect_ConstantPool *constantPool    = NULL;            /* constant pool object to use                       */
+       java_lang_Class          *constantPoolOop = NULL;            /* methods declaring class                           */
+       classinfo                *referer         = NULL;            /* class, which calles the annotation parser         */
+                                                                    /* (for the parameter 'referer' of vm_call_method()) */
+       java_lang_reflect_Method* rm;
+       java_handle_t*            h;
+
+       if (this == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       constantPool = 
+               (sun_reflect_ConstantPool*)native_new_and_init(
+                       class_sun_reflect_ConstantPool);
+       
+       if (constantPool == NULL) {
+               /* out of memory */
+               return NULL;
+       }
+
+       LLNI_field_get_ref(this, clazz, constantPoolOop);
+       LLNI_field_set_ref(constantPool, constantPoolOop, (java_lang_Object*)constantPoolOop);
+
+       /* only resolve the parser method the first time */
+       if (m_parseAnnotationDefault == NULL) {
+               utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault");
+               utf_desc = utf_new_char(
+                       "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)"
+                       "Ljava/lang/Object;");
+
+               if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) {
+                       /* out of memory */
+                       return NULL;
+               }
+
+               LLNI_class_get(this, referer);
+
+               m_parseAnnotationDefault = class_resolveclassmethod(
+                       class_sun_reflect_annotation_AnnotationParser,
+                       utf_parseAnnotationDefault,
+                       utf_desc,
+                       referer,
+                       true);
+
+               if (m_parseAnnotationDefault == NULL) {
+                       /* method not found */
+                       return NULL;
+               }
+       }
+
+       LLNI_field_get_ref(this, m,                 rm);
+       LLNI_field_get_ref(this, annotationDefault, annotationDefault);
+
+       h = vm_call_method(m_parseAnnotationDefault, NULL, rm, annotationDefault, constantPool);
+
+       return (java_lang_Object*) h;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ *
+ * Parses the annotations (if they aren't parsed yet) and stores them into
+ * the declaredAnnotations map and return this map.
+ */
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this)
+{
+       java_util_Map           *declaredAnnotations = NULL; /* parsed annotations                                */
+       java_handle_bytearray_t *annotations         = NULL; /* unparsed annotations                              */
+       java_lang_Class         *declaringClass      = NULL; /* the constant pool of this class is used           */
+       classinfo               *referer             = NULL; /* class, which calles the annotation parser         */
+                                                            /* (for the parameter 'referer' of vm_call_method()) */
+
+       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
+
+       /* are the annotations parsed yet? */
+       if (declaredAnnotations == NULL) {
+               LLNI_field_get_ref(this, annotations, annotations);
+               LLNI_field_get_ref(this, clazz, declaringClass);
+               LLNI_class_get(this, referer);
+
+               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
+
+               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
+       }
+
+       return declaredAnnotations;
+}
+
+
+/*
+ * Class:     java/lang/reflect/VMMethod
+ * Method:    getParameterAnnotations
+ * Signature: ()[[Ljava/lang/annotation/Annotation;
+ *
+ * Parses the parameter annotations and returns them in an 2 dimensional array.
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this)
+{
+       java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations                    */
+       int32_t                  slot                 = -1;   /* slot of the method                                */
+       java_lang_Class         *declaringClass       = NULL; /* the constant pool of this class is used           */
+       classinfo               *referer              = NULL; /* class, which calles the annotation parser         */
+                                                             /* (for the parameter 'referer' of vm_call_method()) */
+
+       LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
+       LLNI_field_get_val(this, slot, slot);
+       LLNI_field_get_ref(this, clazz, declaringClass);
+       LLNI_class_get(this, referer);
+
+       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
+}
+#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/gnuclasspath/java_lang_reflect_VMProxy.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c
new file mode 100644 (file)
index 0000000..b213842
--- /dev/null
@@ -0,0 +1,116 @@
+/* src/native/vm/gnu/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy
+
+   Copyright (C) 1996-2005, 2006, 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdlib.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_reflect_VMProxy.h"
+
+
+/* native methods implemented by this file ************************************/
+
+#if 0
+static JNINativeMethod methods[] = {
+       { "getProxyClass",      "(Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/Class;",                   (void *) (ptrint) &Java_java_lang_reflect_VMProxy_getProxyClass      },
+       { "getProxyData",       "(Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/reflect/Proxy$ProxyData;", (void *) (ptrint) &Java_java_lang_reflect_VMProxy_getProxyData       },
+       { "generateProxyClass", "(Ljava/lang/ClassLoader;Ljava/lang/reflect/Proxy$ProxyData;)Ljava/lang/Class;",  (void *) (ptrint) &Java_java_lang_reflect_VMProxy_generateProxyClass },
+};
+#endif
+
+
+/* _Jv_java_lang_reflect_VMProxy_init ******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMProxy_init(void)
+{
+#if 0
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/VMProxy");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+#endif
+}
+
+
+#if 0
+/*
+ * 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)
+{
+       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)
+{
+       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)
+{
+       return NULL;
+}
+#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/gnuclasspath/java_security_VMAccessController.c b/src/native/vm/gnuclasspath/java_security_VMAccessController.c
new file mode 100644 (file)
index 0000000..7e86b68
--- /dev/null
@@ -0,0 +1,89 @@
+/* src/native/vm/gnu/java_security_VMAccessController.c
+
+   Copyright (C) 1996-2005, 2006, 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_security_VMAccessController.h"
+
+#include "vm/global.h"
+
+#include "vm/jit/stacktrace.h"
+
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getStack", "()[[Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_security_VMAccessController_getStack },
+};
+
+
+/* _Jv_java_security_VMAccessController_init ***********************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_security_VMAccessController_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/security/VMAccessController");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     java/security/VMAccessController
+ * Method:    getStack
+ * Signature: ()[[Ljava/lang/Object;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz)
+{
+       return stacktrace_get_stack();
+}
+
+
+/*
+ * 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/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c b/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c
new file mode 100644 (file)
index 0000000..7105e65
--- /dev/null
@@ -0,0 +1,87 @@
+/* src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c
+
+   Copyright (C) 2007 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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_util_concurrent_atomic_AtomicLong.h"
+
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "VMSupportsCS8", "()Z", (void *) (intptr_t) &Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8 },
+};
+
+
+/* _Jv_java_util_concurrent_atomic_AtomicLong_init *****************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_util_concurrent_atomic_AtomicLong_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/util/concurrent/atomic/AtomicLong");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * Class:     java/util/concurrent/atomic/AtomicLong
+ * Method:    VMSupportsCS8
+ * Signature: ()Z
+ */
+JNIEXPORT int32_t JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz)
+{
+       /* IMPLEMENT ME */
+
+       return 0;
+}
+
+
+/*
+ * 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/gnuclasspath/sun_reflect_ConstantPool.c b/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c
new file mode 100644 (file)
index 0000000..66b7ac4
--- /dev/null
@@ -0,0 +1,427 @@
+/* src/native/vm/gnu/sun_reflect_ConstantPool.c
+
+   Copyright (C) 2007 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, M. S. Panzenböck 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.
+
+*/
+
+/*******************************************************************************
+
+   XXX: The Methods in this file are very redundant to thouse in
+        src/native/vm/sun/jvm.c Unless someone has a good idea how to cover
+        such redundancy I leave it how it is.
+
+  The ConstantPool class represents an interface to the constant pool of a
+  class and is used by the annotations parser (sun.reflect.annotation.
+  AnnotationParser) to get the values of the constants refered by the
+  annotations.
+
+*******************************************************************************/
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Class.h"
+#include "native/include/sun_reflect_ConstantPool.h"
+
+#include "native/vm/reflect.h"
+
+#include "toolbox/logging.h"
+
+#include "vm/vm.h"
+#include "vm/exceptions.h"
+#include "vm/resolve.h"
+#include "vm/stringlocal.h"
+
+#include "vmcore/class.h"
+#include "vmcore/utf8.h"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getSize0",             "(Ljava/lang/Object;I)I",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getSize0             },
+       { "getClassAt0",          "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAt0          },
+       { "getClassAtIfLoaded0",  "(Ljava/lang/Object;I)Ljava/lang/Class;",          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0  },
+       { "getMethodAt0",         "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0         },
+       { "getMethodAtIfLoaded0", "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 },
+       { "getFieldAt0",          "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0          },
+       { "getFieldAtIfLoaded0",  "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;",  (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0  },
+       { "getMemberRefInfoAt0",  "(Ljava/lang/Object;I)[Ljava/lang/String;",        (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0  },
+       { "getIntAt0",            "(Ljava/lang/Object;I)I",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getIntAt0            },
+       { "getLongAt0",           "(Ljava/lang/Object;I)J",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getLongAt0           },
+       { "getFloatAt0",          "(Ljava/lang/Object;I)F",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0          },
+       { "getDoubleAt0",         "(Ljava/lang/Object;I)D",                          (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0         },
+       { "getStringAt0",         "(Ljava/lang/Object;I)Ljava/lang/String;",         (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getStringAt0         },
+       { "getUTF8At0",           "(Ljava/lang/Object;I)Ljava/lang/String;",         (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0           }, 
+};
+
+
+/* _Jv_sun_reflect_ConstantPool_init ******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_sun_reflect_ConstantPool_init(void)
+{
+       native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT);
+}
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getSize0
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool)
+{
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+       return cls->cpcount;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getClassAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_classref *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref*)class_getconstant(
+               cls, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       return LLNI_classinfo_wrap(resolve_classref_eager(ref));
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getClassAtIfLoaded0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_classref *ref;
+       classinfo *c = NULL;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref*)class_getconstant(
+               cls, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+       
+       if (!resolve_classref(NULL,ref,resolveLazy,true,true,&c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+       
+       return LLNI_classinfo_wrap(c);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getMethodAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
+ */
+JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_FMIref *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+       
+       ref = (constant_FMIref*)class_getconstant(
+               cls, index, CONSTANT_Methodref);
+       
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: is that right? or do I have to use resolve_method_*? */
+       return (jobject)reflect_method_new(ref->p.method);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getMethodAtIfLoaded0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
+ */
+JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_FMIref *ref;
+       classinfo *c = NULL;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_FMIref*)class_getconstant(
+               cls, index, CONSTANT_Methodref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       return (jobject)reflect_method_new(ref->p.method);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getFieldAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
+ */
+JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_FMIref *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_FMIref*)class_getconstant(
+               cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       return (jobject)reflect_field_new(ref->p.field);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getFieldAtIfLoaded0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
+ */
+JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_FMIref *ref;
+       classinfo *c;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_FMIref*)class_getconstant(
+               cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       return (jobject)reflect_field_new(ref->p.field);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getMemberRefInfoAt0
+ * Signature: (Ljava/lang/Object;I)[Ljava/lang/String;
+ */
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index);
+       return NULL;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getIntAt0
+ * Signature: (Ljava/lang/Object;I)I
+ */
+JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_integer *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_integer*)class_getconstant(
+               cls, index, CONSTANT_Integer);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getLongAt0
+ * Signature: (Ljava/lang/Object;I)J
+ */
+JNIEXPORT int64_t JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_long *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_long*)class_getconstant(
+               cls, index, CONSTANT_Long);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getFloatAt0
+ * Signature: (Ljava/lang/Object;I)F
+ */
+JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_float *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_float*)class_getconstant(
+               cls, index, CONSTANT_Float);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getDoubleAt0
+ * Signature: (Ljava/lang/Object;I)D
+ */
+JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       constant_double *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_double*)class_getconstant(
+               cls, index, CONSTANT_Double);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getStringAt0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       utf *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+       
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (java_lang_String*)literalstring_new(ref);
+}
+
+
+/*
+ * Class:     sun/reflect/ConstantPool
+ * Method:    getUTF8At0
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
+{
+       utf *ref;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (java_lang_String*)literalstring_new(ref);
+}
+
+
+/*
+ * 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:
+ */
index e6e2369d0668b2dcc918a6a50ded41df068586fe..ed3806ec081924a00224b8718dff76103c5718c5 100644 (file)
 #include "vmcore/options.h"
 #include "vmcore/system.h"
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 # include "mm/memory.h"
 
 # include "native/native.h"
 
-# include "native/vm/sun/hpi.h"
+# include "native/vm/openjdk/hpi.h"
 
 # include "vm/properties.h"
 # include "vm/vm.h"
@@ -61,7 +61,7 @@ void nativevm_preinit(void)
        /* Register native methods of all classes implemented. */
 
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        TRACESUBSYSTEMINITIALIZATION("nativevm_preinit");
 
@@ -93,7 +93,7 @@ void nativevm_preinit(void)
        _Jv_sun_reflect_ConstantPool_init();
 #endif
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        char        *boot_library_path;
        int          len;
@@ -173,13 +173,13 @@ void nativevm_init(void)
 {
 #if defined(ENABLE_JAVASE)
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        TRACESUBSYSTEMINITIALIZATION("nativevm_init");
 
        /* nothing to do */
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        methodinfo *m;
 
index 6ed7acbfcc842ef391aa72675fff137e15a33ae5..db22ee65070d08d2d8d3a432e363a8fa296d9ac7 100644 (file)
@@ -38,7 +38,7 @@ void nativevm_preinit(void);
 void nativevm_init(void);
 
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
 void _Jv_gnu_classpath_VMStackWalker_init();
 void _Jv_gnu_classpath_VMSystemProperties_init();
@@ -68,7 +68,7 @@ void _Jv_sun_misc_Unsafe_init();
 void _Jv_sun_reflect_ConstantPool_init();
 #endif
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
 void _Jv_sun_misc_Unsafe_init();
 
diff --git a/src/native/vm/openjdk/Makefile.am b/src/native/vm/openjdk/Makefile.am
new file mode 100644 (file)
index 0000000..1f17531
--- /dev/null
@@ -0,0 +1,43 @@
+## src/native/vm/sun/Makefile.am
+##
+## Copyright (C) 2007, 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+##
+## 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.
+
+
+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 = \
+       libnativevmcore.la
+
+libnativevmcore_la_SOURCES = \
+       hpi.c \
+       hpi.h \
+       jvm.c
+
+
+## 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/openjdk/hpi.c b/src/native/vm/openjdk/hpi.c
new file mode 100644 (file)
index 0000000..87f0a7d
--- /dev/null
@@ -0,0 +1,199 @@
+/* src/native/vm/openjdk/hpi.c - HotSpot HPI interface functions
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+/* We include hpi_md.h before hpi.h as the latter includes the
+   former. */
+
+#include INCLUDE_HPI_MD_H
+#include INCLUDE_HPI_H
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "vm/properties.h"
+#include "vm/vm.h"
+
+#include "vmcore/options.h"
+#include "vmcore/system.h"
+#include "vmcore/utf8.h"
+
+
+/* VM callback functions ******************************************************/
+
+static vm_calls_t callbacks = {
+       /* TODO What should we use here? */
+/*   jio_fprintf, */
+/*   unimplemented_panic, */
+/*   unimplemented_monitorRegister, */
+       NULL,
+       NULL,
+       NULL,
+       
+       NULL, /* unused */
+       NULL, /* unused */
+       NULL  /* unused */
+};
+
+
+/* HPI interfaces *************************************************************/
+
+GetInterfaceFunc      hpi_get_interface = NULL;
+HPI_FileInterface    *hpi_file          = NULL;
+HPI_SocketInterface  *hpi_socket        = NULL;
+HPI_LibraryInterface *hpi_library       = NULL;
+HPI_SystemInterface  *hpi_system        = NULL;
+
+
+/* hpi_initialize **************************************************************
+
+   Initialize the Host Porting Interface (HPI).
+
+*******************************************************************************/
+
+void hpi_initialize(void)
+{
+       char        *boot_library_path;
+       int          len;
+       char        *p;
+       utf         *u;
+       lt_dlhandle  handle;
+       lt_ptr       dll_initialize;
+       int          result;
+    jint (JNICALL * DLL_Initialize)(GetInterfaceFunc *, void *);
+
+       TRACESUBSYSTEMINITIALIZATION("hpi_init");
+
+       /* Load libhpi.so */
+
+       boot_library_path = properties_get("sun.boot.library.path");
+
+       len =
+               system_strlen(boot_library_path) +
+               system_strlen("/native_threads/libhpi.so") +
+               system_strlen("0");
+
+       p = MNEW(char, len);
+
+       system_strcpy(p, boot_library_path);
+       system_strcat(p, "/native_threads/libhpi.so");
+
+       u = utf_new_char(p);
+
+    if (opt_TraceHPI)
+               log_println("hpi_init: Loading HPI %s ", p);
+
+       MFREE(p, char, len);
+
+       handle = native_library_open(u);
+
+       if (handle == NULL)
+               if (opt_TraceHPI)
+                       vm_abort("hpi_init: HPI open failed");
+
+       /* Resolve the DLL_Initialize function from the library. */
+
+       dll_initialize = lt_dlsym(handle, "DLL_Initialize");
+
+    DLL_Initialize = (jint (JNICALL *)(GetInterfaceFunc *, void *)) (intptr_t) dll_initialize;
+
+    if (opt_TraceHPI && DLL_Initialize == NULL)
+               log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", lt_dlerror());
+
+    if (DLL_Initialize == NULL ||
+        (*DLL_Initialize)(&hpi_get_interface, &callbacks) < 0) {
+
+        if (opt_TraceHPI)
+                       vm_abort("hpi_init: HPI DLL_Initialize failed");
+    }
+
+       native_library_add(u, NULL, handle);
+
+    if (opt_TraceHPI)
+               log_println("hpi_init: HPI loaded successfully");
+
+       /* Resolve the interfaces. */
+       /* NOTE: The intptr_t-case is only to prevent the a compiler
+          warning with -O2: warning: dereferencing type-punned pointer
+          will break strict-aliasing rules */
+
+       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_file, "File", 1);
+
+       if (result != 0)
+               vm_abort("hpi_init: Can't find HPI_FileInterface");
+
+       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_library, "Library", 1);
+
+       if (result != 0)
+               vm_abort("hpi_init: Can't find HPI_LibraryInterface");
+
+       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_system, "System", 1);
+
+       if (result != 0)
+               vm_abort("hpi_init: Can't find HPI_SystemInterface");
+}
+
+
+/* hpi_initialize_socket_library ***********************************************
+
+   Initialize the library Host Porting Interface (HPI).
+
+*******************************************************************************/
+
+int hpi_initialize_socket_library(void)
+{
+       int result;
+
+       /* Resolve the socket library interface. */
+
+       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_socket, "Socket", 1);
+
+       if (result != 0) {
+               if (opt_TraceHPI)
+                       log_println("hpi_initialize_socket_library: Can't find HPI_SocketInterface");
+
+               return JNI_ERR;
+       }
+
+       return JNI_OK;
+}
+
+
+/*
+ * 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/openjdk/hpi.h b/src/native/vm/openjdk/hpi.h
new file mode 100644 (file)
index 0000000..03880e6
--- /dev/null
@@ -0,0 +1,74 @@
+/* src/native/vm/openjdk/hpi.h - HotSpot HPI interface functions
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#ifndef _HPI_H
+#define _HPI_H
+
+#include "config.h"
+
+/* HPI headers *****************************************************************
+
+   We include hpi_md.h before hpi.h as the latter includes the former.
+
+   These includes define:
+
+   #define _JAVASOFT_HPI_MD_H_
+   #define _JAVASOFT_HPI_H_
+
+*******************************************************************************/
+
+#include INCLUDE_HPI_MD_H
+#include INCLUDE_HPI_H
+
+
+/* HPI interfaces *************************************************************/
+
+extern HPI_FileInterface    *hpi_file;
+extern HPI_SocketInterface  *hpi_socket;
+extern HPI_LibraryInterface *hpi_library;
+extern HPI_SystemInterface  *hpi_system;
+
+
+/* functions ******************************************************************/
+
+void hpi_initialize(void);
+int  hpi_initialize_socket_library(void);
+
+#endif /* _HPI_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/openjdk/jvm.c b/src/native/vm/openjdk/jvm.c
new file mode 100644 (file)
index 0000000..4723b5c
--- /dev/null
@@ -0,0 +1,3738 @@
+/* src/native/vm/openjdk/jvm.c - HotSpot JVM interface functions
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <ltdl.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#if defined(HAVE_SYS_IOCTL_H)
+#define BSD_COMP /* Get FIONREAD on Solaris2 */
+#include <sys/ioctl.h>
+#endif
+
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_AssertionStatusDirectives.h"
+#include "native/include/java_lang_String.h"            /* required by j.l.CL */
+#include "native/include/java_nio_ByteBuffer.h"         /* required by j.l.CL */
+#include "native/include/java_lang_ClassLoader.h"        /* required by j.l.C */
+#include "native/include/java_lang_StackTraceElement.h"
+#include "native/include/java_lang_Throwable.h"
+#include "native/include/java_security_ProtectionDomain.h"
+
+#if defined(ENABLE_ANNOTATIONS)
+#include "native/include/sun_reflect_ConstantPool.h"
+#endif
+
+#include "native/vm/reflect.h"
+
+#include "native/vm/openjdk/hpi.h"
+
+#include "threads/lock-common.h"
+#include "threads/thread.h"
+
+#include "toolbox/logging.h"
+#include "toolbox/list.h"
+
+#include "vm/array.h"
+
+#if defined(ENABLE_ASSERTION)
+#include "vm/assertion.h"
+#endif
+
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/global.h"
+#include "vm/initialize.h"
+#include "vm/package.h"
+#include "vm/primitive.h"
+#include "vm/properties.h"
+#include "vm/resolve.h"
+#include "vm/signallocal.h"
+#include "vm/stringlocal.h"
+#include "vm/vm.h"
+
+#include "vm/jit/stacktrace.h"
+
+#include "vmcore/classcache.h"
+#include "vmcore/options.h"
+#include "vmcore/system.h"
+
+
+/* debugging macros ***********************************************************/
+
+#if !defined(NDEBUG)
+
+# define TRACEJVMCALLS(x)                                                                              \
+    do {                                                                                                               \
+        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
+            log_println x;                                                                             \
+        }                                                                                                              \
+    } while (0)
+
+# define TRACEJVMCALLSENTER(x)                                                                 \
+    do {                                                                                                               \
+        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
+                       log_start();                                                                            \
+            log_print x;                                                                               \
+        }                                                                                                              \
+    } while (0)
+
+# define TRACEJVMCALLSEXIT(x)                                                                  \
+    do {                                                                                                               \
+        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
+                       log_print x;                                                                            \
+                       log_finish();                                                                           \
+        }                                                                                                              \
+    } while (0)
+
+# define TRACEJVMCALLSVERBOSE(x)                               \
+    do {                                                                               \
+        if (opt_TraceJVMCallsVerbose) {                        \
+            log_println x;                                             \
+        }                                                                              \
+    } while (0)
+
+# define PRINTJVMWARNINGS(x)
+/*     do { \ */
+/*         if (opt_PrintJVMWarnings) { \ */
+/*             log_println x; \ */
+/*         } \ */
+/*     } while (0) */
+
+#else
+
+# define TRACEJVMCALLS(x)
+# define TRACEJVMCALLSENTER(x)
+# define TRACEJVMCALLSEXIT(x)
+# define TRACEJVMCALLSVERBOSE(x)
+# define PRINTJVMWARNINGS(x)
+
+#endif
+
+
+typedef struct {
+    /* Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx */
+    unsigned int jvm_version;   /* Consists of major, minor, micro (n.n.n) */
+                                /* and build number (xx) */
+    unsigned int update_version : 8;         /* Update release version (uu) */
+    unsigned int special_update_version : 8; /* Special update release version (c) */
+    unsigned int reserved1 : 16; 
+    unsigned int reserved2; 
+
+    /* The following bits represents JVM supports that JDK has dependency on.
+     * JDK can use these bits to determine which JVM version
+     * and support it has to maintain runtime compatibility.
+     *
+     * When a new bit is added in a minor or update release, make sure
+     * the new bit is also added in the main/baseline.
+     */
+    unsigned int is_attachable : 1;
+    unsigned int : 31;
+    unsigned int : 32;
+    unsigned int : 32;
+} jvm_version_info;
+
+
+/*
+ * A structure used to a capture exception table entry in a Java method.
+ */
+typedef struct {
+    jint start_pc;
+    jint end_pc;
+    jint handler_pc;
+    jint catchType;
+} JVM_ExceptionTableEntryType;
+
+
+int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
+{
+       if ((intptr_t) count <= 0)
+               return -1;
+
+       return vsnprintf(str, count, fmt, args);
+}
+
+
+int jio_snprintf(char *str, size_t count, const char *fmt, ...)
+{
+       va_list ap;
+       int     len;
+
+       va_start(ap, fmt);
+       len = jio_vsnprintf(str, count, fmt, ap);
+       va_end(ap);
+
+       return len;
+}
+
+
+int jio_fprintf(FILE* f, const char *fmt, ...)
+{
+       log_println("jio_fprintf: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+int jio_vfprintf(FILE* f, const char *fmt, va_list args)
+{
+       log_println("jio_vfprintf: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+int jio_printf(const char *fmt, ...)
+{
+       log_println("jio_printf: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetInterfaceVersion */
+
+jint JVM_GetInterfaceVersion()
+{
+       /* This is defined in hotspot/src/share/vm/prims/jvm.h */
+
+#define JVM_INTERFACE_VERSION 4
+
+       return JVM_INTERFACE_VERSION;
+}
+
+
+/* JVM_CurrentTimeMillis */
+
+jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored)
+{
+       TRACEJVMCALLS(("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored));
+
+       return (jlong) builtin_currenttimemillis();
+}
+
+
+/* JVM_NanoTime */
+
+jlong JVM_NanoTime(JNIEnv *env, jclass ignored)
+{
+       TRACEJVMCALLS(("JVM_NanoTime(env=%p, ignored=%p)", env, ignored));
+
+       return (jlong) builtin_nanotime();
+}
+
+
+/* JVM_ArrayCopy */
+
+void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length)
+{
+       java_handle_t *s;
+       java_handle_t *d;
+
+       s = (java_handle_t *) src;
+       d = (java_handle_t *) dst;
+
+       TRACEJVMCALLSVERBOSE(("JVM_ArrayCopy(env=%p, ignored=%p, src=%p, src_pos=%d, dst=%p, dst_pos=%d, length=%d)", env, ignored, src, src_pos, dst, dst_pos, length));
+
+       builtin_arraycopy(s, src_pos, d, dst_pos, length);
+}
+
+
+/* JVM_InitProperties */
+
+jobject JVM_InitProperties(JNIEnv *env, jobject properties)
+{
+       java_handle_t *h;
+       char           buf[256];
+
+       TRACEJVMCALLS(("JVM_InitProperties(env=%p, properties=%p)", env, properties));
+
+       h = (java_handle_t *) properties;
+
+       /* Convert the -XX:MaxDirectMemorySize= command line flag to the
+          sun.nio.MaxDirectMemorySize property.  Do this after setting
+          user properties to prevent people from setting the value with a
+          -D option, as requested. */
+
+       jio_snprintf(buf, sizeof(buf), PRINTF_FORMAT_INT64_T, opt_MaxDirectMemorySize);
+       properties_add("sun.nio.MaxDirectMemorySize", buf);
+
+       /* Add all properties. */
+
+       properties_system_add_all(h);
+
+       return properties;
+}
+
+
+/* JVM_Exit */
+
+void JVM_Exit(jint code)
+{
+       log_println("JVM_Exit: IMPLEMENT ME!");
+}
+
+
+/* JVM_Halt */
+
+void JVM_Halt(jint code)
+{
+       TRACEJVMCALLS(("JVM_Halt(code=%d)", code));
+
+/*     vm_exit(code); */
+       vm_shutdown(code);
+}
+
+
+/* JVM_OnExit(void (*func)) */
+
+void JVM_OnExit(void (*func)(void))
+{
+       log_println("JVM_OnExit(void (*func): IMPLEMENT ME!");
+}
+
+
+/* JVM_GC */
+
+void JVM_GC(void)
+{
+       TRACEJVMCALLS(("JVM_GC()"));
+
+       gc_call();
+}
+
+
+/* JVM_MaxObjectInspectionAge */
+
+jlong JVM_MaxObjectInspectionAge(void)
+{
+       log_println("JVM_MaxObjectInspectionAge: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_TraceInstructions */
+
+void JVM_TraceInstructions(jboolean on)
+{
+       log_println("JVM_TraceInstructions: IMPLEMENT ME!");
+}
+
+
+/* JVM_TraceMethodCalls */
+
+void JVM_TraceMethodCalls(jboolean on)
+{
+       log_println("JVM_TraceMethodCalls: IMPLEMENT ME!");
+}
+
+
+/* JVM_TotalMemory */
+
+jlong JVM_TotalMemory(void)
+{
+       TRACEJVMCALLS(("JVM_TotalMemory()"));
+
+       return gc_get_heap_size();
+}
+
+
+/* JVM_FreeMemory */
+
+jlong JVM_FreeMemory(void)
+{
+       TRACEJVMCALLS(("JVM_FreeMemory()"));
+
+       return gc_get_free_bytes();
+}
+
+
+/* JVM_MaxMemory */
+
+jlong JVM_MaxMemory(void)
+{
+       TRACEJVMCALLS(("JVM_MaxMemory()"));
+
+       return gc_get_max_heap_size();
+}
+
+
+/* JVM_ActiveProcessorCount */
+
+jint JVM_ActiveProcessorCount(void)
+{
+       TRACEJVMCALLS(("JVM_ActiveProcessorCount()"));
+
+       return system_processors_online();
+}
+
+
+/* JVM_FillInStackTrace */
+
+void JVM_FillInStackTrace(JNIEnv *env, jobject receiver)
+{
+       java_lang_Throwable     *o;
+       java_handle_bytearray_t *ba;
+
+       TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver));
+
+       o = (java_lang_Throwable *) receiver;
+
+       ba = stacktrace_get_current();
+
+       if (ba == NULL)
+               return;
+
+       LLNI_field_set_ref(o, backtrace, (java_lang_Object *) ba);
+}
+
+
+/* JVM_PrintStackTrace */
+
+void JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable)
+{
+       log_println("JVM_PrintStackTrace: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetStackTraceDepth */
+
+jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
+{
+       java_lang_Throwable     *to;
+       java_lang_Object        *o;
+       java_handle_bytearray_t *ba;
+       stacktrace_t            *st;
+       int32_t                  depth;
+
+       TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable));
+
+       if (throwable == NULL) {
+               exceptions_throw_nullpointerexception();
+               return 0;
+       }
+
+       to = (java_lang_Throwable *) throwable;
+
+       LLNI_field_get_ref(to, backtrace, o);
+
+       ba = (java_handle_bytearray_t *) o;
+
+       if (ba == NULL)
+               return 0;
+
+       /* We need a critical section here as the stacktrace structure is
+          mapped onto a Java byte-array. */
+
+       LLNI_CRITICAL_START;
+
+       st = (stacktrace_t *) LLNI_array_data(ba);
+
+       depth = st->length;
+
+       LLNI_CRITICAL_END;
+
+       return depth;
+}
+
+
+/* JVM_GetStackTraceElement */
+
+jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
+{
+       java_lang_Throwable         *to;
+       java_lang_Object            *o;
+       java_handle_bytearray_t     *ba;
+       stacktrace_t                *st;
+       stacktrace_entry_t          *ste;
+       codeinfo                    *code;
+       methodinfo                  *m;
+       classinfo                   *c;
+       java_lang_StackTraceElement *steo;
+       java_handle_t*               declaringclass;
+       java_lang_String            *filename;
+       int32_t                      linenumber;
+
+       TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index));
+
+       to = (java_lang_Throwable *) throwable;
+
+       LLNI_field_get_ref(to, backtrace, o);
+
+       ba = (java_handle_bytearray_t *) o;
+
+       /* FIXME critical section */
+
+       st = (stacktrace_t *) LLNI_array_data(ba);
+
+       if ((index < 0) || (index >= st->length)) {
+               /* XXX This should be an IndexOutOfBoundsException (check this
+                  again). */
+
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       /* Get the stacktrace entry. */
+
+       ste = &(st->entries[index]);
+
+       /* Get the codeinfo, methodinfo and classinfo. */
+
+       code = ste->code;
+       m    = code->m;
+       c    = m->clazz;
+
+       /* allocate a new StackTraceElement */
+
+       steo = (java_lang_StackTraceElement *)
+               builtin_new(class_java_lang_StackTraceElement);
+
+       if (steo == NULL)
+               return NULL;
+
+       /* get filename */
+
+       if (!(m->flags & ACC_NATIVE)) {
+               if (c->sourcefile != NULL)
+                       filename = (java_lang_String *) javastring_new(c->sourcefile);
+               else
+                       filename = NULL;
+       }
+       else
+               filename = NULL;
+
+       /* get line number */
+
+       if (m->flags & ACC_NATIVE) {
+               linenumber = -2;
+       }
+       else {
+               /* FIXME The linenumbertable_linenumber_for_pc could change
+                  the methodinfo pointer when hitting an inlined method. */
+
+               linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc);
+               linenumber = (linenumber == 0) ? -1 : linenumber;
+       }
+
+       /* get declaring class name */
+
+       declaringclass = class_get_classname(c);
+
+       /* fill the java.lang.StackTraceElement element */
+
+       /* FIXME critical section */
+
+       steo->declaringClass = (java_lang_String*) declaringclass;
+       steo->methodName     = (java_lang_String*) javastring_new(m->name);
+       steo->fileName       = filename;
+       steo->lineNumber     = linenumber;
+
+       return (jobject) steo;
+}
+
+
+/* JVM_IHashCode */
+
+jint JVM_IHashCode(JNIEnv* env, jobject handle)
+{
+       TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle));
+
+       return (jint) ((ptrint) handle);
+}
+
+
+/* JVM_MonitorWait */
+
+void JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *o;
+#endif
+
+       TRACEJVMCALLS(("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms));
+    if (ms < 0) {
+/*             exceptions_throw_illegalargumentexception("argument out of range"); */
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
+#if defined(ENABLE_THREADS)
+       o = (java_handle_t *) handle;
+
+       lock_wait_for_object(o, ms, 0);
+#endif
+}
+
+
+/* JVM_MonitorNotify */
+
+void JVM_MonitorNotify(JNIEnv* env, jobject handle)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *o;
+#endif
+
+       TRACEJVMCALLS(("JVM_MonitorNotify(env=%p, handle=%p)", env, handle));
+
+#if defined(ENABLE_THREADS)
+       o = (java_handle_t *) handle;
+
+       lock_notify_object(o);
+#endif
+}
+
+
+/* JVM_MonitorNotifyAll */
+
+void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)
+{
+#if defined(ENABLE_THREADS)
+       java_handle_t *o;
+#endif
+
+       TRACEJVMCALLS(("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle));
+
+#if defined(ENABLE_THREADS)
+       o = (java_handle_t *) handle;
+
+       lock_notify_all_object(o);
+#endif
+}
+
+
+/* JVM_Clone */
+
+jobject JVM_Clone(JNIEnv* env, jobject handle)
+{
+       TRACEJVMCALLS(("JVM_Clone(env=%p, handle=%p)", env, handle));
+
+       return (jobject) builtin_clone(env, (java_handle_t *) handle);
+}
+
+
+/* JVM_InitializeCompiler  */
+
+void JVM_InitializeCompiler (JNIEnv *env, jclass compCls)
+{
+       log_println("JVM_InitializeCompiler : IMPLEMENT ME!");
+}
+
+
+/* JVM_IsSilentCompiler */
+
+jboolean JVM_IsSilentCompiler(JNIEnv *env, jclass compCls)
+{
+       log_println("JVM_IsSilentCompiler: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_CompileClass */
+
+jboolean JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls)
+{
+       log_println("JVM_CompileClass: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_CompileClasses */
+
+jboolean JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname)
+{
+       log_println("JVM_CompileClasses: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_CompilerCommand */
+
+jobject JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg)
+{
+       log_println("JVM_CompilerCommand: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_EnableCompiler */
+
+void JVM_EnableCompiler(JNIEnv *env, jclass compCls)
+{
+       TRACEJVMCALLS(("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls));
+       PRINTJVMWARNINGS(("JVM_EnableCompiler not supported"));
+}
+
+
+/* JVM_DisableCompiler */
+
+void JVM_DisableCompiler(JNIEnv *env, jclass compCls)
+{
+       TRACEJVMCALLS(("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls));
+       PRINTJVMWARNINGS(("JVM_DisableCompiler not supported"));
+}
+
+
+/* JVM_GetLastErrorString */
+
+jint JVM_GetLastErrorString(char *buf, int len)
+{
+       TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len));
+
+       return hpi_system->GetLastErrorString(buf, len);
+}
+
+
+/* JVM_NativePath */
+
+char *JVM_NativePath(char *path)
+{
+       TRACEJVMCALLS(("JVM_NativePath(path=%s)", path));
+
+       return hpi_file->NativePath(path);
+}
+
+
+/* JVM_GetCallerClass */
+
+jclass JVM_GetCallerClass(JNIEnv* env, int depth)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_GetCallerClass(env=%p, depth=%d)", env, depth));
+
+       c = stacktrace_get_caller_class(depth);
+
+       return (jclass) c;
+}
+
+
+/* JVM_FindPrimitiveClass */
+
+jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* s)
+{
+       classinfo *c;
+       utf       *u;
+
+       TRACEJVMCALLS(("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s));
+
+       u = utf_new_char(s);
+       c = primitive_class_get_by_name(u);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_ResolveClass */
+
+void JVM_ResolveClass(JNIEnv* env, jclass cls)
+{
+       TRACEJVMCALLS(("JVM_ResolveClass(env=%p, cls=%p)", env, cls));
+       PRINTJVMWARNINGS(("JVM_ResolveClass not implemented"));
+}
+
+
+/* JVM_FindClassFromClassLoader */
+
+jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError)
+{
+       classinfo     *c;
+       utf           *u;
+       classloader_t *cl;
+
+       TRACEJVMCALLS(("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError));
+
+       /* As of now, OpenJDK does not call this function with throwError
+          is true. */
+
+       assert(throwError == false);
+
+       u  = utf_new_char(name);
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       c = load_class_from_classloader(u, cl);
+
+       if (c == NULL)
+               return NULL;
+
+       if (init)
+               if (!(c->state & CLASS_INITIALIZED))
+                       if (!initialize_class(c))
+                               return NULL;
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_FindClassFromClass */
+
+jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from)
+{
+       log_println("JVM_FindClassFromClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_DefineClass */
+
+jclass JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)
+{
+       log_println("JVM_DefineClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_DefineClassWithSource */
+
+jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)
+{
+       classinfo     *c;
+       utf           *u;
+       classloader_t *cl;
+
+       TRACEJVMCALLS(("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source));
+
+       if (name != NULL)
+               u = utf_new_char(name);
+       else
+               u = NULL;
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       /* XXX do something with source */
+
+       c = class_define(u, cl, len, (uint8_t *) buf, (java_handle_t *) pd);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_FindLoadedClass */
+
+jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
+{
+       classloader_t *cl;
+       utf           *u;
+       classinfo     *c;
+
+       TRACEJVMCALLS(("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name));
+
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
+
+       u = javastring_toutf((java_handle_t *) name, true);
+       c = classcache_lookup(cl, u);
+
+       return (jclass) LLNI_classinfo_wrap(c);
+}
+
+
+/* JVM_GetClassName */
+
+jstring JVM_GetClassName(JNIEnv *env, jclass cls)
+{
+       classinfo* c;
+
+       TRACEJVMCALLS(("JVM_GetClassName(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return (jstring) class_get_classname(c);
+}
+
+
+/* JVM_GetClassInterfaces */
+
+jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       oa = class_get_interfaces(c);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassLoader */
+
+jobject JVM_GetClassLoader(JNIEnv *env, jclass cls)
+{
+       classinfo     *c;
+       classloader_t *cl;
+
+       TRACEJVMCALLSENTER(("JVM_GetClassLoader(env=%p, cls=%p)", env, cls));
+
+       c  = LLNI_classinfo_unwrap(cls);
+       cl = class_get_classloader(c);
+
+       TRACEJVMCALLSEXIT(("->%p", cl));
+
+       return (jobject) cl;
+}
+
+
+/* JVM_IsInterface */
+
+jboolean JVM_IsInterface(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_IsInterface(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return class_is_interface(c);
+}
+
+
+/* JVM_GetClassSigners */
+
+jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassSigners: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_SetClassSigners */
+
+void JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *hoa;
+
+       TRACEJVMCALLS(("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       hoa = (java_handle_objectarray_t *) signers;
+
+    /* This call is ignored for primitive types and arrays.  Signers
+          are only set once, ClassLoader.java, and thus shouldn't be
+          called with an array.  Only the bootstrap loader creates
+          arrays. */
+
+       if (class_is_primitive(c) || class_is_array(c))
+               return;
+
+       LLNI_classinfo_field_set(c, signers, hoa);
+}
+
+
+/* JVM_GetProtectionDomain */
+
+jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       if (c == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+    /* Primitive types do not have a protection domain. */
+
+       if (class_is_primitive(c))
+               return NULL;
+
+       return (jobject) c->protectiondomain;
+}
+
+
+/* JVM_SetProtectionDomain */
+
+void JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain)
+{
+       log_println("JVM_SetProtectionDomain: IMPLEMENT ME!");
+}
+
+
+/* JVM_DoPrivileged */
+
+jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException)
+{
+       java_handle_t *h;
+       classinfo     *c;
+       methodinfo    *m;
+       java_handle_t *result;
+       java_handle_t *e;
+
+       TRACEJVMCALLS(("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException));
+
+       h = (java_handle_t *) action;
+       LLNI_class_get(h, c);
+
+       if (action == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* lookup run() method (throw no exceptions) */
+
+       m = class_resolveclassmethod(c, utf_run, utf_void__java_lang_Object, c,
+                                                                false);
+
+       if ((m == NULL) || !(m->flags & ACC_PUBLIC) || (m->flags & ACC_STATIC)) {
+               exceptions_throw_internalerror("No run method");
+               return NULL;
+       }
+
+       /* XXX It seems something with a privileged stack needs to be done
+          here. */
+
+       result = vm_call_method(m, h);
+
+       e = exceptions_get_exception();
+
+       if (e != NULL) {
+               if ( builtin_instanceof(e, class_java_lang_Exception) &&
+                       !builtin_instanceof(e, class_java_lang_RuntimeException)) {
+                       exceptions_clear_exception();
+                       exceptions_throw_privilegedactionexception(e);
+               }
+
+               return NULL;
+       }
+
+       return (jobject) result;
+}
+
+
+/* JVM_GetInheritedAccessControlContext */
+
+jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetInheritedAccessControlContext: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetStackAccessControlContext */
+
+jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)
+{
+       TRACEJVMCALLS(("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls));
+
+       /* XXX All stuff I tested so far works without that function.  At
+          some point we have to implement it, but I disable the output
+          for now to make IcedTea happy. */
+
+       return NULL;
+}
+
+
+/* JVM_IsArrayClass */
+
+jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_IsArrayClass(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return class_is_array(c);
+}
+
+
+/* JVM_IsPrimitiveClass */
+
+jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       return class_is_primitive(c);
+}
+
+
+/* JVM_GetComponentType */
+
+jclass JVM_GetComponentType(JNIEnv *env, jclass cls)
+{
+       classinfo *component;
+       classinfo *c;
+       
+       TRACEJVMCALLS(("JVM_GetComponentType(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+       
+       component = class_get_componenttype(c);
+
+       return (jclass) LLNI_classinfo_wrap(component);
+}
+
+
+/* JVM_GetClassModifiers */
+
+jint JVM_GetClassModifiers(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+       int32_t    flags;
+
+       TRACEJVMCALLS(("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       flags = class_get_modifiers(c, false);
+
+       return flags;
+}
+
+
+/* JVM_GetDeclaredClasses */
+
+jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       oa = class_get_declaredclasses(c, false);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetDeclaringClass */
+
+jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)
+{
+       classinfo *c;
+       classinfo *dc;
+
+       TRACEJVMCALLS(("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       dc = class_get_declaringclass(c);
+
+       return (jclass) LLNI_classinfo_wrap(dc);
+}
+
+
+/* JVM_GetClassSignature */
+
+jstring JVM_GetClassSignature(JNIEnv *env, jclass cls)
+{
+       classinfo     *c;
+       utf           *u;
+       java_handle_t *s;
+
+       TRACEJVMCALLS(("JVM_GetClassSignature(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       /* Get the signature of the class. */
+
+       u = class_get_signature(c);
+
+       if (u == NULL)
+               return NULL;
+
+       /* Convert UTF-string to a Java-string. */
+
+       s = javastring_new(u);
+
+       return (jstring) s;
+}
+
+
+/* JVM_GetClassAnnotations */
+
+jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
+{
+       classinfo               *c           = NULL; /* classinfo for 'cls'  */
+       java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
+
+       TRACEJVMCALLS(("JVM_GetClassAnnotations: cls=%p", cls));
+
+       if (cls == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+       
+       c = LLNI_classinfo_unwrap(cls);
+
+       /* get annotations: */
+       annotations = class_get_annotations(c);
+
+       return (jbyteArray)annotations;
+}
+
+
+/* JVM_GetFieldAnnotations */
+
+jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
+{
+       java_lang_reflect_Field *rf = NULL; /* java.lang.reflect.Field for 'field' */
+       java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
+
+       TRACEJVMCALLS(("JVM_GetFieldAnnotations: field=%p", field));
+
+       if (field == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       rf = (java_lang_reflect_Field*)field;
+
+       LLNI_field_get_ref(rf, annotations, ba);
+
+       return (jbyteArray)ba;
+}
+
+
+/* JVM_GetMethodAnnotations */
+
+jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
+{
+       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
+       java_handle_bytearray_t  *ba = NULL; /* unparsed annotations */
+
+       TRACEJVMCALLS(("JVM_GetMethodAnnotations: method=%p", method));
+
+       if (method == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       rm = (java_lang_reflect_Method*)method;
+
+       LLNI_field_get_ref(rm, annotations, ba);
+
+       return (jbyteArray)ba;
+}
+
+
+/* JVM_GetMethodDefaultAnnotationValue */
+
+jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
+{
+       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
+       java_handle_bytearray_t  *ba = NULL; /* unparsed annotation default value */
+
+       TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue: method=%p", method));
+
+       if (method == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       rm = (java_lang_reflect_Method*)method;
+
+       LLNI_field_get_ref(rm, annotationDefault, ba);
+
+       return (jbyteArray)ba;
+}
+
+
+/* JVM_GetMethodParameterAnnotations */
+
+jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
+{
+       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
+       java_handle_bytearray_t  *ba = NULL; /* unparsed parameter annotations */
+
+       TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations: method=%p", method));
+
+       if (method == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       rm = (java_lang_reflect_Method*)method;
+
+       LLNI_field_get_ref(rm, parameterAnnotations, ba);
+
+       return (jbyteArray)ba;
+}
+
+
+/* JVM_GetClassDeclaredFields */
+
+jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       oa = class_get_declaredfields(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassDeclaredMethods */
+
+jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       oa = class_get_declaredmethods(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassDeclaredConstructors */
+
+jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly)
+{
+       classinfo                 *c;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       oa = class_get_declaredconstructors(c, publicOnly);
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetClassAccessFlags */
+
+jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)
+{
+       classinfo *c;
+
+       TRACEJVMCALLS(("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       /* Primitive type classes have the correct access flags. */
+
+       return c->flags & ACC_CLASS_REFLECT_MASK;
+}
+
+
+/* JVM_GetClassConstantPool */
+
+jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
+{
+#if defined(ENABLE_ANNOTATIONS)
+       sun_reflect_ConstantPool *constantPool    = NULL;
+                     /* constant pool object for the class refered by 'cls' */
+       java_lang_Object         *constantPoolOop = (java_lang_Object*)cls;
+                     /* constantPoolOop field of the constant pool object   */
+
+       TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls));
+
+       constantPool = 
+               (sun_reflect_ConstantPool*)native_new_and_init(
+                       class_sun_reflect_ConstantPool);
+       
+       if (constantPool == NULL) {
+               /* out of memory */
+               return NULL;
+       }
+       
+       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
+
+       return (jobject)constantPool;
+#else
+       log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls);
+       return NULL;
+#endif
+}
+
+
+/* JVM_ConstantPoolGetSize */
+
+jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
+{
+       classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool));
+
+       c = LLNI_classinfo_unwrap(jcpool);
+
+       return c->cpcount;
+}
+
+
+/* JVM_ConstantPoolGetClassAt */
+
+jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
+       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
+       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index));
+
+       c = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       result = resolve_classref_eager(ref);
+
+       return (jclass) LLNI_classinfo_wrap(result);
+}
+
+
+/* JVM_ConstantPoolGetClassAtIfLoaded */
+
+jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
+       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
+       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index));
+
+       c = LLNI_classinfo_unwrap(jcpool);
+
+       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+       
+       if (!resolve_classref(NULL, ref, resolveLazy, true, true, &result)) {
+               return NULL;
+       }
+
+       if ((result == NULL) || !(result->state & CLASS_LOADED)) {
+               return NULL;
+       }
+       
+       return (jclass) LLNI_classinfo_wrap(result);
+}
+
+
+/* JVM_ConstantPoolGetMethodAt */
+
+jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+       
+       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index));
+       
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
+       
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: is that right? or do I have to use resolve_method_*? */
+       return (jobject)reflect_method_new(ref->p.method);
+}
+
+
+/* JVM_ConstantPoolGetMethodAtIfLoaded */
+
+jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
+       classinfo *c = NULL;  /* resolved declaring class of the method */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       return (jobject)reflect_method_new(ref->p.method);
+}
+
+
+/* JVM_ConstantPoolGetFieldAt */
+
+jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+       
+       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       return (jobject)reflect_field_new(ref->p.field);
+}
+
+
+/* JVM_ConstantPoolGetFieldAtIfLoaded */
+
+jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
+       classinfo *c;         /* resolved declaring class for the field */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
+               return NULL;
+       }
+
+       if (c == NULL || !(c->state & CLASS_LOADED)) {
+               return NULL;
+       }
+
+       return (jobject)reflect_field_new(ref->p.field);
+}
+
+
+/* JVM_ConstantPoolGetMemberRefInfoAt */
+
+jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       log_println("JVM_ConstantPoolGetMemberRefInfoAt: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index);
+
+       /* TODO: implement. (this is yet unused be OpenJDK but, so very low priority) */
+
+       return NULL;
+}
+
+
+/* JVM_ConstantPoolGetIntAt */
+
+jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_integer *ref; /* reference to the int value in constant pool at index 'index' */
+       classinfo *cls;        /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetLongAt */
+
+jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_long *ref; /* reference to the long value in constant pool at index 'index' */
+       classinfo *cls;     /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetFloatAt */
+
+jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_float *ref; /* reference to the float value in constant pool at index 'index' */
+       classinfo *cls;      /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetDoubleAt */
+
+jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       constant_double *ref; /* reference to the double value in constant pool at index 'index' */
+       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return 0;
+       }
+
+       return ref->value;
+}
+
+
+/* JVM_ConstantPoolGetStringAt */
+
+jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       utf *ref;       /* utf object for the string in constant pool at index 'index' */
+       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index));
+       
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (jstring)literalstring_new(ref);
+}
+
+
+/* JVM_ConstantPoolGetUTF8At */
+
+jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)
+{
+       utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */
+       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
+
+       TRACEJVMCALLS(("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index));
+
+       cls = LLNI_classinfo_unwrap(jcpool);
+       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
+
+       if (ref == NULL) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX: I hope literalstring_new is the right Function. */
+       return (jstring)literalstring_new(ref);
+}
+
+
+/* JVM_DesiredAssertionStatus */
+
+jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)
+{
+#if defined(ENABLE_ASSERTION)
+       assertion_name_t  *item;
+       classinfo         *c;
+       jboolean           status;
+       utf               *name;
+
+       TRACEJVMCALLS(("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls));
+
+       c = LLNI_classinfo_unwrap(cls);
+
+       if (c->classloader == NULL) {
+               status = (jboolean)assertion_system_enabled;
+       }
+       else {
+               status = (jboolean)assertion_user_enabled;
+       }
+
+       if (list_assertion_names != NULL) {
+               item = (assertion_name_t *)list_first(list_assertion_names);
+               while (item != NULL) {
+                       name = utf_new_char(item->name);
+                       if (name == c->packagename) {
+                               status = (jboolean)item->enabled;
+                       }
+                       else if (name == c->name) {
+                               status = (jboolean)item->enabled;
+                       }
+
+                       item = (assertion_name_t *)list_next(list_assertion_names, item);
+               }
+       }
+
+       return status;
+#else
+       return (jboolean)false;
+#endif
+}
+
+
+/* JVM_AssertionStatusDirectives */
+
+jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
+{
+       classinfo                             *c;
+       java_lang_AssertionStatusDirectives   *o;
+       java_handle_objectarray_t             *classes;
+       java_handle_objectarray_t             *packages;
+       java_booleanarray_t                   *classEnabled;
+       java_booleanarray_t                   *packageEnabled;
+#if defined(ENABLE_ASSERTION)
+       assertion_name_t                      *item;
+       java_handle_t                         *js;
+       s4                                     i, j;
+#endif
+
+       TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused));
+
+       c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
+
+       if (c == NULL)
+               return NULL;
+
+       o = (java_lang_AssertionStatusDirectives *) builtin_new(c);
+
+       if (o == NULL)
+               return NULL;
+
+#if defined(ENABLE_ASSERTION)
+       classes = builtin_anewarray(assertion_class_count, class_java_lang_Object);
+#else
+       classes = builtin_anewarray(0, class_java_lang_Object);
+#endif
+       if (classes == NULL)
+               return NULL;
+
+#if defined(ENABLE_ASSERTION)
+       packages = builtin_anewarray(assertion_package_count, class_java_lang_Object);
+#else
+       packages = builtin_anewarray(0, class_java_lang_Object);
+#endif
+       if (packages == NULL)
+               return NULL;
+       
+#if defined(ENABLE_ASSERTION)
+       classEnabled = builtin_newarray_boolean(assertion_class_count);
+#else
+       classEnabled = builtin_newarray_boolean(0);
+#endif
+       if (classEnabled == NULL)
+               return NULL;
+
+#if defined(ENABLE_ASSERTION)
+       packageEnabled = builtin_newarray_boolean(assertion_package_count);
+#else
+       packageEnabled = builtin_newarray_boolean(0);
+#endif
+       if (packageEnabled == NULL)
+               return NULL;
+
+#if defined(ENABLE_ASSERTION)
+       /* initialize arrays */
+
+       if (list_assertion_names != NULL) {
+               i = 0;
+               j = 0;
+               
+               item = (assertion_name_t *)list_first(list_assertion_names);
+               while (item != NULL) {
+                       js = javastring_new_from_ascii(item->name);
+                       if (js == NULL) {
+                               return NULL;
+                       }
+
+                       if (item->package == false) {
+                               classes->data[i] = js;
+                               classEnabled->data[i] = (jboolean) item->enabled;
+                               i += 1;
+                       }
+                       else {
+                               packages->data[j] = js;
+                               packageEnabled->data[j] = (jboolean) item->enabled;
+                               j += 1;
+                       }
+
+                       item = (assertion_name_t *)list_next(list_assertion_names, item);
+               }
+       }
+#endif
+
+       /* set instance fields */
+
+       o->classes  = classes;
+       o->packages = packages;
+       o->classEnabled = classEnabled;
+       o->packageEnabled = packageEnabled;
+
+       return (jobject) o;
+}
+
+
+/* JVM_GetClassNameUTF */
+
+const char *JVM_GetClassNameUTF(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassCPTypes */
+
+void JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)
+{
+       log_println("JVM_GetClassCPTypes: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetClassCPEntriesCount */
+
+jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassCPEntriesCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetClassFieldsCount */
+
+jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassFieldsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetClassMethodsCount */
+
+jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_GetClassMethodsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxExceptionIndexes */
+
+void JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)
+{
+       log_println("JVM_GetMethodIxExceptionIndexes: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetMethodIxExceptionsCount */
+
+jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxExceptionsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxByteCode */
+
+void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)
+{
+       log_println("JVM_GetMethodIxByteCode: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetMethodIxByteCodeLength */
+
+jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxByteCodeLength: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxExceptionTableEntry */
+
+void JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)
+{
+       log_println("JVM_GetMethodIxExceptionTableEntry: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetMethodIxExceptionTableLength */
+
+jint JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxExceptionTableLength: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxModifiers */
+
+jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetFieldIxModifiers */
+
+jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)
+{
+       log_println("JVM_GetFieldIxModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxLocalsCount */
+
+jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxLocalsCount: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxArgsSize */
+
+jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxArgsSize: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxMaxStack */
+
+jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_GetMethodIxMaxStack: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_IsConstructorIx */
+
+jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)
+{
+       log_println("JVM_IsConstructorIx: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetMethodIxNameUTF */
+
+const char *JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetMethodIxSignatureUTF */
+
+const char *JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)
+{
+       log_println("JVM_GetMethodIxSignatureUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldNameUTF */
+
+const char *JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPFieldNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPMethodNameUTF */
+
+const char *JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPMethodNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPMethodSignatureUTF */
+
+const char *JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPMethodSignatureUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldSignatureUTF */
+
+const char *JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPFieldSignatureUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPClassNameUTF */
+
+const char *JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldClassNameUTF */
+
+const char *JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPFieldClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPMethodClassNameUTF */
+
+const char *JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
+{
+       log_println("JVM_GetCPMethodClassNameUTF: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetCPFieldModifiers */
+
+jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
+{
+       log_println("JVM_GetCPFieldModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetCPMethodModifiers */
+
+jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
+{
+       log_println("JVM_GetCPMethodModifiers: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_ReleaseUTF */
+
+void JVM_ReleaseUTF(const char *utf)
+{
+       log_println("JVM_ReleaseUTF: IMPLEMENT ME!");
+}
+
+
+/* JVM_IsSameClassPackage */
+
+jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)
+{
+       log_println("JVM_IsSameClassPackage: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Open */
+
+/* Taken from: hotspot/src/share/vm/prims/jvm.h */
+
+/*
+ * JVM I/O error codes
+ */
+#define JVM_EEXIST       -100
+
+jint JVM_Open(const char *fname, jint flags, jint mode)
+{
+       int result;
+
+       TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode));
+
+       result = hpi_file->Open(fname, flags, mode);
+
+       if (result >= 0) {
+               return result;
+       }
+       else {
+               switch (errno) {
+               case EEXIST:
+                       return JVM_EEXIST;
+               default:
+                       return -1;
+               }
+       }
+}
+
+
+/* JVM_Close */
+
+jint JVM_Close(jint fd)
+{
+       TRACEJVMCALLS(("JVM_Close(fd=%d)", fd));
+
+       return hpi_file->Close(fd);
+}
+
+
+/* JVM_Read */
+
+jint JVM_Read(jint fd, char *buf, jint nbytes)
+{
+       TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes));
+
+       return (jint) hpi_file->Read(fd, buf, nbytes);
+}
+
+
+/* JVM_Write */
+
+jint JVM_Write(jint fd, char *buf, jint nbytes)
+{
+       TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes));
+
+       return (jint) hpi_file->Write(fd, buf, nbytes);
+}
+
+
+/* JVM_Available */
+
+jint JVM_Available(jint fd, jlong *pbytes)
+{
+       TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes));
+
+       return hpi_file->Available(fd, pbytes);
+}
+
+
+/* JVM_Lseek */
+
+jlong JVM_Lseek(jint fd, jlong offset, jint whence)
+{
+       TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence));
+
+       return hpi_file->Seek(fd, (off_t) offset, whence);
+}
+
+
+/* JVM_SetLength */
+
+jint JVM_SetLength(jint fd, jlong length)
+{
+       TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length));
+
+       return hpi_file->SetLength(fd, length);
+}
+
+
+/* JVM_Sync */
+
+jint JVM_Sync(jint fd)
+{
+       TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd));
+
+       return hpi_file->Sync(fd);
+}
+
+
+/* JVM_StartThread */
+
+void JVM_StartThread(JNIEnv* env, jobject jthread)
+{
+       TRACEJVMCALLS(("JVM_StartThread(env=%p, jthread=%p)", env, jthread));
+
+       threads_thread_start((java_handle_t *) jthread);
+}
+
+
+/* JVM_StopThread */
+
+void JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable)
+{
+       log_println("JVM_StopThread: IMPLEMENT ME!");
+}
+
+
+/* JVM_IsThreadAlive */
+
+jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread)
+{
+       java_handle_t *h;
+       threadobject  *t;
+       bool           result;
+
+       TRACEJVMCALLS(("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       /* The threadobject is null when a thread is created in Java. The
+          priority is set later during startup. */
+
+       if (t == NULL)
+               return 0;
+
+       result = threads_thread_is_alive(t);
+
+       return result;
+}
+
+
+/* JVM_SuspendThread */
+
+void JVM_SuspendThread(JNIEnv* env, jobject jthread)
+{
+       log_println("JVM_SuspendThread: IMPLEMENT ME!");
+}
+
+
+/* JVM_ResumeThread */
+
+void JVM_ResumeThread(JNIEnv* env, jobject jthread)
+{
+       log_println("JVM_ResumeThread: IMPLEMENT ME!");
+}
+
+
+/* JVM_SetThreadPriority */
+
+void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)
+{
+       java_handle_t *h;
+       threadobject  *t;
+
+       TRACEJVMCALLS(("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       /* The threadobject is null when a thread is created in Java. The
+          priority is set later during startup. */
+
+       if (t == NULL)
+               return;
+
+       threads_set_thread_priority(t->tid, prio);
+}
+
+
+/* JVM_Yield */
+
+void JVM_Yield(JNIEnv *env, jclass threadClass)
+{
+       TRACEJVMCALLS(("JVM_Yield(env=%p, threadClass=%p)", env, threadClass));
+
+       threads_yield();
+}
+
+
+/* JVM_Sleep */
+
+void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)
+{
+       TRACEJVMCALLS(("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis));
+
+       threads_sleep(millis, 0);
+}
+
+
+/* JVM_CurrentThread */
+
+jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass)
+{
+       java_object_t *o;
+
+       TRACEJVMCALLSVERBOSE(("JVM_CurrentThread(env=%p, threadClass=%p)", env, threadClass));
+
+       o = thread_get_current_object();
+
+       return (jobject) o;
+}
+
+
+/* JVM_CountStackFrames */
+
+jint JVM_CountStackFrames(JNIEnv* env, jobject jthread)
+{
+       log_println("JVM_CountStackFrames: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Interrupt */
+
+void JVM_Interrupt(JNIEnv* env, jobject jthread)
+{
+       java_handle_t *h;
+       threadobject  *t;
+
+       TRACEJVMCALLS(("JVM_Interrupt(env=%p, jthread=%p)", env, jthread));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       if (t == NULL)
+               return;
+
+       threads_thread_interrupt(t);
+}
+
+
+/* JVM_IsInterrupted */
+
+jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)
+{
+       java_handle_t *h;
+       threadobject  *t;
+       jboolean       interrupted;
+
+       TRACEJVMCALLS(("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted));
+
+       h = (java_handle_t *) jthread;
+       t = thread_get_thread(h);
+
+       interrupted = thread_is_interrupted(t);
+
+       if (interrupted && clear_interrupted)
+               thread_set_interrupted(t, false);
+
+       return interrupted;
+}
+
+
+/* JVM_HoldsLock */
+
+jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj)
+{
+       java_handle_t *h;
+       bool           result;
+
+       TRACEJVMCALLS(("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj));
+
+       h = (java_handle_t *) obj;
+
+       if (h == NULL) {
+               exceptions_throw_nullpointerexception();
+               return JNI_FALSE;
+       }
+
+       result = lock_is_held_by_current_thread(h);
+
+       return result;
+}
+
+
+/* JVM_DumpAllStacks */
+
+void JVM_DumpAllStacks(JNIEnv* env, jclass unused)
+{
+       log_println("JVM_DumpAllStacks: IMPLEMENT ME!");
+}
+
+
+/* JVM_CurrentLoadedClass */
+
+jclass JVM_CurrentLoadedClass(JNIEnv *env)
+{
+       log_println("JVM_CurrentLoadedClass: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_CurrentClassLoader */
+
+jobject JVM_CurrentClassLoader(JNIEnv *env)
+{
+    /* XXX if a method in a class in a trusted loader is in a
+          doPrivileged, return NULL */
+
+       log_println("JVM_CurrentClassLoader: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassContext */
+
+jobjectArray JVM_GetClassContext(JNIEnv *env)
+{
+       TRACEJVMCALLS(("JVM_GetClassContext(env=%p)", env));
+
+       return (jobjectArray) stacktrace_getClassContext();
+}
+
+
+/* JVM_ClassDepth */
+
+jint JVM_ClassDepth(JNIEnv *env, jstring name)
+{
+       log_println("JVM_ClassDepth: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_ClassLoaderDepth */
+
+jint JVM_ClassLoaderDepth(JNIEnv *env)
+{
+       log_println("JVM_ClassLoaderDepth: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetSystemPackage */
+
+jstring JVM_GetSystemPackage(JNIEnv *env, jstring name)
+{
+       java_handle_t *s;
+       utf *u;
+       utf *result;
+
+       TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name));
+
+/*     s = package_find(name); */
+       u = javastring_toutf((java_handle_t *) name, false);
+
+       result = package_find(u);
+
+       if (result != NULL)
+               s = javastring_new(result);
+       else
+               s = NULL;
+
+       return (jstring) s;
+}
+
+
+/* JVM_GetSystemPackages */
+
+jobjectArray JVM_GetSystemPackages(JNIEnv *env)
+{
+       log_println("JVM_GetSystemPackages: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_AllocateNewObject */
+
+jobject JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)
+{
+       log_println("JVM_AllocateNewObject: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_AllocateNewArray */
+
+jobject JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length)
+{
+       log_println("JVM_AllocateNewArray: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_LatestUserDefinedLoader */
+
+jobject JVM_LatestUserDefinedLoader(JNIEnv *env)
+{
+       classloader_t *cl;
+
+       TRACEJVMCALLS(("JVM_LatestUserDefinedLoader(env=%p)", env));
+
+       cl = stacktrace_first_nonnull_classloader();
+
+       return (jobject) cl;
+}
+
+
+/* JVM_LoadClass0 */
+
+jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring currClassName)
+{
+       log_println("JVM_LoadClass0: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetArrayLength */
+
+jint JVM_GetArrayLength(JNIEnv *env, jobject arr)
+{
+       java_handle_t *a;
+
+       TRACEJVMCALLS(("JVM_GetArrayLength(arr=%p)", arr));
+
+       a = (java_handle_t *) arr;
+
+       return array_length_get(a);
+}
+
+
+/* JVM_GetArrayElement */
+
+jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
+{
+       java_handle_t *a;
+       java_handle_t *o;
+
+       TRACEJVMCALLS(("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index));
+
+       a = (java_handle_t *) arr;
+
+/*     if (!class_is_array(a->objheader.vftbl->class)) { */
+/*             exceptions_throw_illegalargumentexception(); */
+/*             return NULL; */
+/*     } */
+
+       o = array_element_get(a, index);
+
+       return (jobject) o;
+}
+
+
+/* JVM_GetPrimitiveArrayElement */
+
+jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode)
+{
+       jvalue jv;
+
+       log_println("JVM_GetPrimitiveArrayElement: IMPLEMENT ME!");
+
+       jv.l = NULL;
+
+       return jv;
+}
+
+
+/* JVM_SetArrayElement */
+
+void JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val)
+{
+       java_handle_t *a;
+       java_handle_t *value;
+
+       TRACEJVMCALLS(("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val));
+
+       a     = (java_handle_t *) arr;
+       value = (java_handle_t *) val;
+
+       array_element_set(a, index, value);
+}
+
+
+/* JVM_SetPrimitiveArrayElement */
+
+void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode)
+{
+       log_println("JVM_SetPrimitiveArrayElement: IMPLEMENT ME!");
+}
+
+
+/* JVM_NewArray */
+
+jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length)
+{
+       classinfo                 *c;
+       classinfo                 *pc;
+       java_handle_t             *a;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length));
+
+       if (eltClass == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* NegativeArraySizeException is checked in builtin_newarray. */
+
+       c = LLNI_classinfo_unwrap(eltClass);
+
+       /* Create primitive or object array. */
+
+       if (class_is_primitive(c)) {
+               pc = primitive_arrayclass_get_by_name(c->name);
+
+               /* void arrays are not allowed. */
+
+               if (pc == NULL) {
+                       exceptions_throw_illegalargumentexception();
+                       return NULL;
+               }
+
+               a = builtin_newarray(length, pc);
+
+               return (jobject) a;
+       }
+       else {
+               oa = builtin_anewarray(length, c);
+
+               return (jobject) oa;
+       }
+}
+
+
+/* JVM_NewMultiArray */
+
+jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)
+{
+       classinfo                 *c;
+       java_handle_intarray_t    *ia;
+       int32_t                    length;
+       long                      *dims;
+       int32_t                    value;
+       int32_t                    i;
+       classinfo                 *ac;
+       java_handle_objectarray_t *a;
+
+       TRACEJVMCALLS(("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim));
+
+       if (eltClass == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* NegativeArraySizeException is checked in builtin_newarray. */
+
+       c = LLNI_classinfo_unwrap(eltClass);
+
+       ia = (java_handle_intarray_t *) dim;
+
+       length = array_length_get((java_handle_t *) ia);
+
+       /* We check here for exceptions thrown in array_length_get,
+          otherwise these exceptions get overwritten by the following
+          IllegalArgumentException. */
+
+       if (length < 0)
+               return NULL;
+
+       if ((length <= 0) || (length > /* MAX_DIM */ 255)) {
+               exceptions_throw_illegalargumentexception();
+               return NULL;
+       }
+
+       /* XXX This is just a quick hack to get it working. */
+
+       dims = MNEW(long, length);
+
+       for (i = 0; i < length; i++) {
+               value = LLNI_array_direct(ia, i);
+               dims[i] = (long) value;
+       }
+
+       /* Create an array-class if necessary. */
+
+       if (class_is_primitive(c))
+               ac = primitive_arrayclass_get_by_name(c->name);
+       else
+               ac = class_array_of(c, true);
+
+       if (ac == NULL)
+               return NULL;
+
+       a = builtin_multianewarray(length, (java_handle_t *) ac, dims);
+
+       return (jobject) a;
+}
+
+
+/* JVM_InitializeSocketLibrary */
+
+jint JVM_InitializeSocketLibrary()
+{
+       TRACEJVMCALLS(("JVM_InitializeSocketLibrary()"));
+
+       return hpi_initialize_socket_library();
+}
+
+
+/* JVM_Socket */
+
+jint JVM_Socket(jint domain, jint type, jint protocol)
+{
+       TRACEJVMCALLS(("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol));
+
+       return system_socket(domain, type, protocol);
+}
+
+
+/* JVM_SocketClose */
+
+jint JVM_SocketClose(jint fd)
+{
+       TRACEJVMCALLS(("JVM_SocketClose(fd=%d)", fd));
+
+       return system_close(fd);
+}
+
+
+/* JVM_SocketShutdown */
+
+jint JVM_SocketShutdown(jint fd, jint howto)
+{
+       TRACEJVMCALLS(("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto));
+
+       return system_shutdown(fd, howto);
+}
+
+
+/* JVM_Recv */
+
+jint JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)
+{
+       log_println("JVM_Recv: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Send */
+
+jint JVM_Send(jint fd, char *buf, jint nBytes, jint flags)
+{
+       log_println("JVM_Send: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Timeout */
+
+jint JVM_Timeout(int fd, long timeout)
+{
+       log_println("JVM_Timeout: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Listen */
+
+jint JVM_Listen(jint fd, jint count)
+{
+       TRACEJVMCALLS(("JVM_Listen(fd=%d, count=%d)", fd, count));
+
+       return system_listen(fd, count);
+}
+
+
+/* JVM_Connect */
+
+jint JVM_Connect(jint fd, struct sockaddr *him, jint len)
+{
+       TRACEJVMCALLS(("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len));
+
+       return system_connect(fd, him, len);
+}
+
+
+/* JVM_Bind */
+
+jint JVM_Bind(jint fd, struct sockaddr *him, jint len)
+{
+       log_println("JVM_Bind: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_Accept */
+
+jint JVM_Accept(jint fd, struct sockaddr *him, jint *len)
+{
+       TRACEJVMCALLS(("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len));
+
+       return system_accept(fd, him, (socklen_t *) len);
+}
+
+
+/* JVM_RecvFrom */
+
+jint JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)
+{
+       log_println("JVM_RecvFrom: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetSockName */
+
+jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len)
+{
+       TRACEJVMCALLS(("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len));
+
+       return system_getsockname(fd, him, (socklen_t *) len);
+}
+
+
+/* JVM_SendTo */
+
+jint JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)
+{
+       log_println("JVM_SendTo: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_SocketAvailable */
+
+jint JVM_SocketAvailable(jint fd, jint *pbytes)
+{
+#if defined(FIONREAD)
+       int bytes;
+       int result;
+
+       TRACEJVMCALLS(("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes));
+
+       *pbytes = 0;
+
+       result = ioctl(fd, FIONREAD, &bytes);
+
+       if (result < 0)
+               return 0;
+
+       *pbytes = bytes;
+
+       return 1;
+#else
+# error FIONREAD not defined
+#endif
+}
+
+
+/* JVM_GetSockOpt */
+
+jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)
+{
+       TRACEJVMCALLS(("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen));
+
+       return system_getsockopt(fd, level, optname, optval, (socklen_t *) optlen);
+}
+
+
+/* JVM_SetSockOpt */
+
+jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)
+{
+       TRACEJVMCALLS(("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen));
+
+       return system_setsockopt(fd, level, optname, optval, optlen);
+}
+
+
+/* JVM_GetHostName */
+
+int JVM_GetHostName(char *name, int namelen)
+{
+       int result;
+
+       TRACEJVMCALLSENTER(("JVM_GetHostName(name=%s, namelen=%d)", name, namelen));
+
+       result = system_gethostname(name, namelen);
+
+       TRACEJVMCALLSEXIT(("->%d (name=%s)", result, name));
+
+       return result;
+}
+
+
+/* JVM_GetHostByAddr */
+
+struct hostent *JVM_GetHostByAddr(const char* name, int len, int type)
+{
+       log_println("JVM_GetHostByAddr: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetHostByName */
+
+struct hostent *JVM_GetHostByName(char* name)
+{
+       log_println("JVM_GetHostByName: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetProtoByName */
+
+struct protoent *JVM_GetProtoByName(char* name)
+{
+       log_println("JVM_GetProtoByName: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_LoadLibrary */
+
+void *JVM_LoadLibrary(const char *name)
+{
+       utf*  u;
+       void* handle;
+
+       TRACEJVMCALLSENTER(("JVM_LoadLibrary(name=%s)", name));
+
+       u = utf_new_char(name);
+
+       handle = native_library_open(u);
+
+       TRACEJVMCALLSEXIT(("->%p", handle));
+
+       return handle;
+}
+
+
+/* JVM_UnloadLibrary */
+
+void JVM_UnloadLibrary(void* handle)
+{
+       TRACEJVMCALLS(("JVM_UnloadLibrary(handle=%p)", handle));
+
+       native_library_close(handle);
+}
+
+
+/* JVM_FindLibraryEntry */
+
+void *JVM_FindLibraryEntry(void *handle, const char *name)
+{
+       lt_ptr symbol;
+
+       TRACEJVMCALLSENTER(("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name));
+
+       symbol = lt_dlsym(handle, name);
+
+       TRACEJVMCALLSEXIT(("->%p", symbol));
+
+       return symbol;
+}
+
+
+/* JVM_IsNaN */
+
+jboolean JVM_IsNaN(jdouble a)
+{
+       log_println("JVM_IsNaN: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_IsSupportedJNIVersion */
+
+jboolean JVM_IsSupportedJNIVersion(jint version)
+{
+       TRACEJVMCALLS(("JVM_IsSupportedJNIVersion(version=%d)", version));
+
+       return jni_version_check(version);
+}
+
+
+/* JVM_InternString */
+
+jstring JVM_InternString(JNIEnv *env, jstring str)
+{
+       TRACEJVMCALLS(("JVM_InternString(env=%p, str=%p)", env, str));
+
+       return (jstring) javastring_intern((java_handle_t *) str);
+}
+
+
+/* JVM_RawMonitorCreate */
+
+JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void)
+{
+       java_object_t *o;
+
+       TRACEJVMCALLS(("JVM_RawMonitorCreate()"));
+
+       o = NEW(java_object_t);
+
+       lock_init_object_lock(o);
+
+       return o;
+}
+
+
+/* JVM_RawMonitorDestroy */
+
+JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon)
+{
+       TRACEJVMCALLS(("JVM_RawMonitorDestroy(mon=%p)", mon));
+
+       FREE(mon, java_object_t);
+}
+
+
+/* JVM_RawMonitorEnter */
+
+JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon)
+{
+       TRACEJVMCALLS(("JVM_RawMonitorEnter(mon=%p)", mon));
+
+       (void) lock_monitor_enter((java_object_t *) mon);
+
+       return 0;
+}
+
+
+/* JVM_RawMonitorExit */
+
+JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon)
+{
+       TRACEJVMCALLS(("JVM_RawMonitorExit(mon=%p)", mon));
+
+       (void) lock_monitor_exit((java_object_t *) mon);
+}
+
+
+/* JVM_SetPrimitiveFieldValues */
+
+void JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
+{
+       log_println("JVM_SetPrimitiveFieldValues: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetPrimitiveFieldValues */
+
+void JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
+{
+       log_println("JVM_GetPrimitiveFieldValues: IMPLEMENT ME!");
+}
+
+
+/* JVM_AccessVMBooleanFlag */
+
+jboolean JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)
+{
+       log_println("JVM_AccessVMBooleanFlag: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_AccessVMIntFlag */
+
+jboolean JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)
+{
+       log_println("JVM_AccessVMIntFlag: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_VMBreakPoint */
+
+void JVM_VMBreakPoint(JNIEnv *env, jobject obj)
+{
+       log_println("JVM_VMBreakPoint: IMPLEMENT ME!");
+}
+
+
+/* JVM_GetClassFields */
+
+jobjectArray JVM_GetClassFields(JNIEnv *env, jclass cls, jint which)
+{
+       log_println("JVM_GetClassFields: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassMethods */
+
+jobjectArray JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which)
+{
+       log_println("JVM_GetClassMethods: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassConstructors */
+
+jobjectArray JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which)
+{
+       log_println("JVM_GetClassConstructors: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassField */
+
+jobject JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which)
+{
+       log_println("JVM_GetClassField: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassMethod */
+
+jobject JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which)
+{
+       log_println("JVM_GetClassMethod: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetClassConstructor */
+
+jobject JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which)
+{
+       log_println("JVM_GetClassConstructor: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_NewInstance */
+
+jobject JVM_NewInstance(JNIEnv *env, jclass cls)
+{
+       log_println("JVM_NewInstance: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetField */
+
+jobject JVM_GetField(JNIEnv *env, jobject field, jobject obj)
+{
+       log_println("JVM_GetField: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetPrimitiveField */
+
+jvalue JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode)
+{
+       jvalue jv;
+
+       log_println("JVM_GetPrimitiveField: IMPLEMENT ME!");
+
+       jv.l = NULL;
+
+       return jv;
+}
+
+
+/* JVM_SetField */
+
+void JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val)
+{
+       log_println("JVM_SetField: IMPLEMENT ME!");
+}
+
+
+/* JVM_SetPrimitiveField */
+
+void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode)
+{
+       log_println("JVM_SetPrimitiveField: IMPLEMENT ME!");
+}
+
+
+/* JVM_InvokeMethod */
+
+jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
+{
+       java_lang_reflect_Method *rm;
+       classinfo     *c;
+       int32_t        slot;
+       int32_t        override;
+       methodinfo    *m;
+       java_handle_t *ro;
+
+       TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0));
+
+       rm = (java_lang_reflect_Method *) method;
+
+       LLNI_field_get_cls(rm, clazz,    c);
+       LLNI_field_get_val(rm, slot,     slot);
+       LLNI_field_get_val(rm, override, override);
+
+       m = &(c->methods[slot]);
+
+       ro = reflect_method_invoke(m, (java_handle_t *) obj, (java_handle_objectarray_t *) args0, override);
+
+       return (jobject) ro;
+}
+
+
+/* JVM_NewInstanceFromConstructor */
+
+jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0)
+{
+       java_lang_reflect_Constructor *rc;
+       classinfo                     *c;
+       int32_t                        slot;
+       int32_t                        override;
+       methodinfo                    *m;
+       java_handle_t                 *o;
+
+       TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0));
+
+       rc = (java_lang_reflect_Constructor *) con;
+
+       LLNI_field_get_cls(rc, clazz,    c);
+       LLNI_field_get_val(rc, slot,     slot);
+       LLNI_field_get_val(rc, override, override);
+
+       m = &(c->methods[slot]);
+
+       o = reflect_constructor_newinstance(m, (java_handle_objectarray_t *) args0, override);
+
+       return (jobject) o;
+}
+
+
+/* JVM_SupportsCX8 */
+
+jboolean JVM_SupportsCX8()
+{
+       TRACEJVMCALLS(("JVM_SupportsCX8()"));
+
+       /* IMPLEMENT ME */
+
+       return 0;
+}
+
+
+/* JVM_CX8Field */
+
+jboolean JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal)
+{
+       log_println("JVM_CX8Field: IMPLEMENT ME!");
+
+       return 0;
+}
+
+
+/* JVM_GetAllThreads */
+
+jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy)
+{
+       log_println("JVM_GetAllThreads: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_DumpThreads */
+
+jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads)
+{
+       log_println("JVM_DumpThreads: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetManagement */
+
+void *JVM_GetManagement(jint version)
+{
+       TRACEJVMCALLS(("JVM_GetManagement(version=%d)", version));
+
+       /* TODO We current don't support the management interface. */
+
+       return NULL;
+}
+
+
+/* JVM_InitAgentProperties */
+
+jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties)
+{
+       log_println("JVM_InitAgentProperties: IMPLEMENT ME!");
+
+       return NULL;
+}
+
+
+/* JVM_GetEnclosingMethodInfo */
+
+jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)
+{
+       classinfo                 *c;
+       methodinfo                *m;
+       java_handle_objectarray_t *oa;
+
+       TRACEJVMCALLS(("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass));
+
+       c = LLNI_classinfo_unwrap(ofClass);
+
+       if ((c == NULL) || class_is_primitive(c))
+               return NULL;
+
+       m = class_get_enclosingmethod_raw(c);
+
+       if (m == NULL)
+               return NULL;
+
+       oa = builtin_anewarray(3, class_java_lang_Object);
+
+       if (oa == NULL)
+               return NULL;
+
+       array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->clazz));
+       array_objectarray_element_set(oa, 1, javastring_new(m->name));
+       array_objectarray_element_set(oa, 2, javastring_new(m->descriptor));
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetThreadStateValues */
+
+jintArray JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState)
+{
+       java_handle_intarray_t *ia;
+
+       TRACEJVMCALLS(("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)",
+                                 env, javaThreadState));
+
+       /* If new thread states are added in future JDK and VM versions,
+          this should check if the JDK version is compatible with thread
+          states supported by the VM.  Return NULL if not compatible.
+       
+          This function must map the VM java_lang_Thread::ThreadStatus
+          to the Java thread state that the JDK supports. */
+
+       switch (javaThreadState) {
+    case THREAD_STATE_NEW:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_NEW);
+               break; 
+
+    case THREAD_STATE_RUNNABLE:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_RUNNABLE);
+               break; 
+
+    case THREAD_STATE_BLOCKED:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_BLOCKED);
+               break; 
+
+    case THREAD_STATE_WAITING:
+               ia = builtin_newarray_int(2);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_WAITING);
+               /* XXX Implement parked stuff. */
+/*             array_intarray_element_set(ia, 1, PARKED); */
+               break; 
+
+    case THREAD_STATE_TIMED_WAITING:
+               ia = builtin_newarray_int(3);
+
+               if (ia == NULL)
+                       return NULL;
+
+               /* XXX Not sure about that one. */
+/*             array_intarray_element_set(ia, 0, SLEEPING); */
+               array_intarray_element_set(ia, 0, THREAD_STATE_TIMED_WAITING);
+               /* XXX Implement parked stuff. */
+/*             array_intarray_element_set(ia, 2, PARKED); */
+               break; 
+
+    case THREAD_STATE_TERMINATED:
+               ia = builtin_newarray_int(1);
+
+               if (ia == NULL)
+                       return NULL;
+
+               array_intarray_element_set(ia, 0, THREAD_STATE_TERMINATED);
+               break; 
+
+    default:
+               /* Unknown state - probably incompatible JDK version */
+               return NULL;
+       }
+
+       return (jintArray) ia;
+}
+
+
+/* JVM_GetThreadStateNames */
+
+jobjectArray JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values)
+{
+       java_handle_intarray_t    *ia;
+       java_handle_objectarray_t *oa;
+       java_object_t             *s;
+
+       TRACEJVMCALLS(("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)",
+                                 env, javaThreadState, values));
+
+       ia = (java_handle_intarray_t *) values;
+
+       /* If new thread states are added in future JDK and VM versions,
+          this should check if the JDK version is compatible with thread
+          states supported by the VM.  Return NULL if not compatible.
+       
+          This function must map the VM java_lang_Thread::ThreadStatus
+          to the Java thread state that the JDK supports. */
+
+       if (values == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       switch (javaThreadState) {
+    case THREAD_STATE_NEW:
+               assert(ia->header.size == 1 && ia->data[0] == THREAD_STATE_NEW);
+
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("NEW"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+    case THREAD_STATE_RUNNABLE:
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("RUNNABLE"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+    case THREAD_STATE_BLOCKED:
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("BLOCKED"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+    case THREAD_STATE_WAITING:
+               oa = builtin_anewarray(2, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("WAITING.OBJECT_WAIT"));
+/*             s = javastring_new(utf_new_char("WAITING.PARKED")); */
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+/*             array_objectarray_element_set(oa, 1, s); */
+               break; 
+
+    case THREAD_STATE_TIMED_WAITING:
+               oa = builtin_anewarray(3, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+/*             s = javastring_new(utf_new_char("TIMED_WAITING.SLEEPING")); */
+               s = javastring_new(utf_new_char("TIMED_WAITING.OBJECT_WAIT"));
+/*             s = javastring_new(utf_new_char("TIMED_WAITING.PARKED")); */
+
+               if (s == NULL)
+                       return NULL;
+
+/*             array_objectarray_element_set(oa, 0, s); */
+               array_objectarray_element_set(oa, 0, s);
+/*             array_objectarray_element_set(oa, 2, s); */
+               break; 
+
+    case THREAD_STATE_TERMINATED:
+               oa = builtin_anewarray(1, class_java_lang_String);
+
+               if (oa == NULL)
+                       return NULL;
+
+               s = javastring_new(utf_new_char("TERMINATED"));
+
+               if (s == NULL)
+                       return NULL;
+
+               array_objectarray_element_set(oa, 0, s);
+               break; 
+
+       default:
+               /* Unknown state - probably incompatible JDK version */
+               return NULL;
+       }
+
+       return (jobjectArray) oa;
+}
+
+
+/* JVM_GetVersionInfo */
+
+void JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)
+{
+       log_println("JVM_GetVersionInfo: IMPLEMENT ME!");
+}
+
+
+/* OS: JVM_RegisterSignal */
+
+void *JVM_RegisterSignal(jint sig, void *handler)
+{
+       functionptr newHandler;
+
+       TRACEJVMCALLS(("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler));
+
+       if (handler == (void *) 2)
+               newHandler = (functionptr) signal_thread_handler;
+       else
+               newHandler = (functionptr) (uintptr_t) handler;
+
+       switch (sig) {
+    case SIGILL:
+    case SIGFPE:
+    case SIGUSR1:
+    case SIGSEGV:
+               /* These signals are already used by the VM. */
+               return (void *) -1;
+
+    case SIGQUIT:
+               /* This signal is used by the VM to dump thread stacks unless
+                  ReduceSignalUsage is set, in which case the user is allowed
+                  to set his own _native_ handler for this signal; thus, in
+                  either case, we do not allow JVM_RegisterSignal to change
+                  the handler. */
+               return (void *) -1;
+
+       case SIGHUP:
+       case SIGINT:
+       case SIGTERM:
+               break;
+       }
+
+       signal_register_signal(sig, newHandler, 0);
+
+       /* XXX Should return old handler. */
+
+       return (void *) 2;
+}
+
+
+/* OS: JVM_RaiseSignal */
+
+jboolean JVM_RaiseSignal(jint sig)
+{
+       log_println("JVM_RaiseSignal: IMPLEMENT ME! sig=%s", sig);
+
+       return false;
+}
+
+
+/* OS: JVM_FindSignal */
+
+jint JVM_FindSignal(const char *name)
+{
+       TRACEJVMCALLS(("JVM_FindSignal(name=%s)", name));
+
+#if defined(__LINUX__)
+       if (strcmp(name, "HUP") == 0)
+               return SIGHUP;
+
+       if (strcmp(name, "INT") == 0)
+               return SIGINT;
+
+       if (strcmp(name, "TERM") == 0)
+               return SIGTERM;
+#else
+# error not implemented for this OS
+#endif
+
+       return -1;
+}
+
+
+/*
+ * 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 156bc097fa0fe2dbeb23355e55f969374f8f19f9..90b172989589c29a7e474872285117ec347e497d 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "native/include/java_lang_String.h"
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 # include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
 #endif
 #include "native/include/java_lang_ClassLoader.h"
 #include "native/include/java_lang_reflect_Field.h"
 #include "native/include/java_lang_reflect_Method.h"
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 # include "native/include/java_lang_reflect_VMConstructor.h"
 # include "native/include/java_lang_reflect_VMField.h"
 # include "native/include/java_lang_reflect_VMMethod.h"
 #endif
 
-#if defined(ENABLE_ANNOTATIONS) && defined(WITH_CLASSPATH_GNU)
+#if defined(ENABLE_ANNOTATIONS) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 # include "vm/vm.h"
 # include "native/include/sun_reflect_ConstantPool.h"
 #endif
@@ -82,7 +82,7 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
        java_lang_reflect_Constructor   *rc;
        int32_t                          slot;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_reflect_VMConstructor *rvmc;
 #endif
 
@@ -101,7 +101,7 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
 
        slot = m - m->clazz->methods;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Allocate a java.lang.reflect.VMConstructor object. */
 
@@ -124,7 +124,7 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
        LLNI_field_set_ref(rvmc, annotations,          method_get_annotations(m));
        LLNI_field_set_ref(rvmc, parameterAnnotations, method_get_parameterannotations(m));
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        /* Set Java object instance fields. */
 
@@ -158,7 +158,7 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
        java_lang_reflect_Field   *rf;
        int32_t                    slot;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_reflect_VMField *rvmf;
 #endif
 
@@ -177,7 +177,7 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
 
        slot = f - f->clazz->fields;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Allocate a java.lang.reflect.VMField object. */
 
@@ -204,7 +204,7 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
        LLNI_field_set_val(rvmf, slot,        slot);
        LLNI_field_set_ref(rvmf, annotations, field_get_annotations(f));
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        /* Set the Java object fields. */
 
@@ -241,7 +241,7 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
        java_lang_reflect_Method   *rm;
        int32_t                     slot;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_reflect_VMMethod *rvmm;
 #endif
 
@@ -260,7 +260,7 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
 
        slot = m - m->clazz->methods;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Allocate a java.lang.reflect.VMMethod object. */
 
@@ -289,7 +289,7 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
        LLNI_field_set_ref(rvmm, parameterAnnotations, method_get_parameterannotations(m));
        LLNI_field_set_ref(rvmm, annotationDefault,    method_get_annotationdefault(m));
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        LLNI_field_set_cls(rm, clazz,                m->clazz);
 
@@ -457,7 +457,7 @@ java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handl
        /* Should we bypass security the checks (AccessibleObject)? */
 
        if (override == false) {
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                /* This method is always called like this:
                       [0] java.lang.reflect.Method.invokeNative (Native Method)
                       [1] java.lang.reflect.Method.invoke (Method.java:329)
@@ -466,13 +466,15 @@ java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handl
 
                if (!access_check_method(m, 2))
                        return NULL;
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
                /* We only pass 1 here as stacktrace_get_caller_class, which
                   is called from access_check_method, skips
                   java.lang.reflect.Method.invoke(). */
 
                if (!access_check_method(m, 1))
                        return NULL;
+#else
+# error unknown classpath configuration
 #endif
        }
 
@@ -490,7 +492,7 @@ java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handl
 }
 
 
-#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
 /* reflect_get_declaredannotatios *********************************************
 
    Calls the annotation parser with the unparsed annotations and returnes
index f0abceb77ad1ec491a5f3f3a6102c9fc9d11adc9..6c6b45182425741dec3466f95dda6e5effcc01f8 100644 (file)
@@ -38,7 +38,7 @@
 #include "native/include/java_lang_String.h"
 
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_SUN)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 #  include "native/include/java_nio_ByteBuffer.h"       /* required by j.l.CL */
 # endif
 # include "native/include/java_lang_ClassLoader.h"
@@ -65,7 +65,7 @@ java_lang_reflect_Method      *reflect_method_new(methodinfo *m);
 java_handle_t                 *reflect_constructor_newinstance(methodinfo *m, java_handle_objectarray_t *args, bool override);
 java_handle_t                 *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override);
 
-#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
 struct java_util_Map* reflect_get_declaredannotatios(
        java_handle_bytearray_t *annotations,
        java_lang_Class         *declaringClass,
diff --git a/src/native/vm/sun/Makefile.am b/src/native/vm/sun/Makefile.am
deleted file mode 100644 (file)
index 1f17531..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-## src/native/vm/sun/Makefile.am
-##
-## Copyright (C) 2007, 2008
-## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-##
-## 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.
-
-
-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 = \
-       libnativevmcore.la
-
-libnativevmcore_la_SOURCES = \
-       hpi.c \
-       hpi.h \
-       jvm.c
-
-
-## 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/sun/hpi.c b/src/native/vm/sun/hpi.c
deleted file mode 100644 (file)
index 9b97c30..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/* src/native/vm/sun/hpi.c - HotSpot HPI interface functions
-
-   Copyright (C) 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-/* We include hpi_md.h before hpi.h as the latter includes the
-   former. */
-
-#include INCLUDE_HPI_MD_H
-#include INCLUDE_HPI_H
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/native.h"
-
-#include "vm/properties.h"
-#include "vm/vm.h"
-
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-#include "vmcore/utf8.h"
-
-
-/* VM callback functions ******************************************************/
-
-static vm_calls_t callbacks = {
-       /* TODO What should we use here? */
-/*   jio_fprintf, */
-/*   unimplemented_panic, */
-/*   unimplemented_monitorRegister, */
-       NULL,
-       NULL,
-       NULL,
-       
-       NULL, /* unused */
-       NULL, /* unused */
-       NULL  /* unused */
-};
-
-
-/* HPI interfaces *************************************************************/
-
-GetInterfaceFunc      hpi_get_interface = NULL;
-HPI_FileInterface    *hpi_file          = NULL;
-HPI_SocketInterface  *hpi_socket        = NULL;
-HPI_LibraryInterface *hpi_library       = NULL;
-HPI_SystemInterface  *hpi_system        = NULL;
-
-
-/* hpi_initialize **************************************************************
-
-   Initialize the Host Porting Interface (HPI).
-
-*******************************************************************************/
-
-void hpi_initialize(void)
-{
-       char        *boot_library_path;
-       int          len;
-       char        *p;
-       utf         *u;
-       lt_dlhandle  handle;
-       lt_ptr       dll_initialize;
-       int          result;
-    jint (JNICALL * DLL_Initialize)(GetInterfaceFunc *, void *);
-
-       TRACESUBSYSTEMINITIALIZATION("hpi_init");
-
-       /* Load libhpi.so */
-
-       boot_library_path = properties_get("sun.boot.library.path");
-
-       len =
-               system_strlen(boot_library_path) +
-               system_strlen("/native_threads/libhpi.so") +
-               system_strlen("0");
-
-       p = MNEW(char, len);
-
-       system_strcpy(p, boot_library_path);
-       system_strcat(p, "/native_threads/libhpi.so");
-
-       u = utf_new_char(p);
-
-    if (opt_TraceHPI)
-               log_println("hpi_init: Loading HPI %s ", p);
-
-       MFREE(p, char, len);
-
-       handle = native_library_open(u);
-
-       if (handle == NULL)
-               if (opt_TraceHPI)
-                       vm_abort("hpi_init: HPI open failed");
-
-       /* Resolve the DLL_Initialize function from the library. */
-
-       dll_initialize = lt_dlsym(handle, "DLL_Initialize");
-
-    DLL_Initialize = (jint (JNICALL *)(GetInterfaceFunc *, void *)) (intptr_t) dll_initialize;
-
-    if (opt_TraceHPI && DLL_Initialize == NULL)
-               log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", lt_dlerror());
-
-    if (DLL_Initialize == NULL ||
-        (*DLL_Initialize)(&hpi_get_interface, &callbacks) < 0) {
-
-        if (opt_TraceHPI)
-                       vm_abort("hpi_init: HPI DLL_Initialize failed");
-    }
-
-       native_library_add(u, NULL, handle);
-
-    if (opt_TraceHPI)
-               log_println("hpi_init: HPI loaded successfully");
-
-       /* Resolve the interfaces. */
-       /* NOTE: The intptr_t-case is only to prevent the a compiler
-          warning with -O2: warning: dereferencing type-punned pointer
-          will break strict-aliasing rules */
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_file, "File", 1);
-
-       if (result != 0)
-               vm_abort("hpi_init: Can't find HPI_FileInterface");
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_library, "Library", 1);
-
-       if (result != 0)
-               vm_abort("hpi_init: Can't find HPI_LibraryInterface");
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_system, "System", 1);
-
-       if (result != 0)
-               vm_abort("hpi_init: Can't find HPI_SystemInterface");
-}
-
-
-/* hpi_initialize_socket_library ***********************************************
-
-   Initialize the library Host Porting Interface (HPI).
-
-*******************************************************************************/
-
-int hpi_initialize_socket_library(void)
-{
-       int result;
-
-       /* Resolve the socket library interface. */
-
-       result = (*hpi_get_interface)((void **) (intptr_t) &hpi_socket, "Socket", 1);
-
-       if (result != 0) {
-               if (opt_TraceHPI)
-                       log_println("hpi_initialize_socket_library: Can't find HPI_SocketInterface");
-
-               return JNI_ERR;
-       }
-
-       return JNI_OK;
-}
-
-
-/*
- * 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/sun/hpi.h b/src/native/vm/sun/hpi.h
deleted file mode 100644 (file)
index 9b0b19f..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* src/native/vm/sun/hpi.h - HotSpot HPI interface functions
-
-   Copyright (C) 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#ifndef _HPI_H
-#define _HPI_H
-
-#include "config.h"
-
-/* HPI headers *****************************************************************
-
-   We include hpi_md.h before hpi.h as the latter includes the former.
-
-   These includes define:
-
-   #define _JAVASOFT_HPI_MD_H_
-   #define _JAVASOFT_HPI_H_
-
-*******************************************************************************/
-
-#include INCLUDE_HPI_MD_H
-#include INCLUDE_HPI_H
-
-
-/* HPI interfaces *************************************************************/
-
-extern HPI_FileInterface    *hpi_file;
-extern HPI_SocketInterface  *hpi_socket;
-extern HPI_LibraryInterface *hpi_library;
-extern HPI_SystemInterface  *hpi_system;
-
-
-/* functions ******************************************************************/
-
-void hpi_initialize(void);
-int  hpi_initialize_socket_library(void);
-
-#endif /* _HPI_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/sun/jvm.c b/src/native/vm/sun/jvm.c
deleted file mode 100644 (file)
index be21f58..0000000
+++ /dev/null
@@ -1,3738 +0,0 @@
-/* src/native/vm/sun/jvm.c - HotSpot JVM interface functions
-
-   Copyright (C) 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <ltdl.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#if defined(HAVE_SYS_IOCTL_H)
-#define BSD_COMP /* Get FIONREAD on Solaris2 */
-#include <sys/ioctl.h>
-#endif
-
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-#include "native/include/java_lang_AssertionStatusDirectives.h"
-#include "native/include/java_lang_String.h"            /* required by j.l.CL */
-#include "native/include/java_nio_ByteBuffer.h"         /* required by j.l.CL */
-#include "native/include/java_lang_ClassLoader.h"        /* required by j.l.C */
-#include "native/include/java_lang_StackTraceElement.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_security_ProtectionDomain.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/vm/reflect.h"
-
-#include "native/vm/sun/hpi.h"
-
-#include "threads/lock-common.h"
-#include "threads/thread.h"
-
-#include "toolbox/logging.h"
-#include "toolbox/list.h"
-
-#include "vm/array.h"
-
-#if defined(ENABLE_ASSERTION)
-#include "vm/assertion.h"
-#endif
-
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/package.h"
-#include "vm/primitive.h"
-#include "vm/properties.h"
-#include "vm/resolve.h"
-#include "vm/signallocal.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/classcache.h"
-#include "vmcore/options.h"
-#include "vmcore/system.h"
-
-
-/* debugging macros ***********************************************************/
-
-#if !defined(NDEBUG)
-
-# define TRACEJVMCALLS(x)                                                                              \
-    do {                                                                                                               \
-        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
-            log_println x;                                                                             \
-        }                                                                                                              \
-    } while (0)
-
-# define TRACEJVMCALLSENTER(x)                                                                 \
-    do {                                                                                                               \
-        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
-                       log_start();                                                                            \
-            log_print x;                                                                               \
-        }                                                                                                              \
-    } while (0)
-
-# define TRACEJVMCALLSEXIT(x)                                                                  \
-    do {                                                                                                               \
-        if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) {   \
-                       log_print x;                                                                            \
-                       log_finish();                                                                           \
-        }                                                                                                              \
-    } while (0)
-
-# define TRACEJVMCALLSVERBOSE(x)                               \
-    do {                                                                               \
-        if (opt_TraceJVMCallsVerbose) {                        \
-            log_println x;                                             \
-        }                                                                              \
-    } while (0)
-
-# define PRINTJVMWARNINGS(x)
-/*     do { \ */
-/*         if (opt_PrintJVMWarnings) { \ */
-/*             log_println x; \ */
-/*         } \ */
-/*     } while (0) */
-
-#else
-
-# define TRACEJVMCALLS(x)
-# define TRACEJVMCALLSENTER(x)
-# define TRACEJVMCALLSEXIT(x)
-# define TRACEJVMCALLSVERBOSE(x)
-# define PRINTJVMWARNINGS(x)
-
-#endif
-
-
-typedef struct {
-    /* Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx */
-    unsigned int jvm_version;   /* Consists of major, minor, micro (n.n.n) */
-                                /* and build number (xx) */
-    unsigned int update_version : 8;         /* Update release version (uu) */
-    unsigned int special_update_version : 8; /* Special update release version (c) */
-    unsigned int reserved1 : 16; 
-    unsigned int reserved2; 
-
-    /* The following bits represents JVM supports that JDK has dependency on.
-     * JDK can use these bits to determine which JVM version
-     * and support it has to maintain runtime compatibility.
-     *
-     * When a new bit is added in a minor or update release, make sure
-     * the new bit is also added in the main/baseline.
-     */
-    unsigned int is_attachable : 1;
-    unsigned int : 31;
-    unsigned int : 32;
-    unsigned int : 32;
-} jvm_version_info;
-
-
-/*
- * A structure used to a capture exception table entry in a Java method.
- */
-typedef struct {
-    jint start_pc;
-    jint end_pc;
-    jint handler_pc;
-    jint catchType;
-} JVM_ExceptionTableEntryType;
-
-
-int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
-{
-       if ((intptr_t) count <= 0)
-               return -1;
-
-       return vsnprintf(str, count, fmt, args);
-}
-
-
-int jio_snprintf(char *str, size_t count, const char *fmt, ...)
-{
-       va_list ap;
-       int     len;
-
-       va_start(ap, fmt);
-       len = jio_vsnprintf(str, count, fmt, ap);
-       va_end(ap);
-
-       return len;
-}
-
-
-int jio_fprintf(FILE* f, const char *fmt, ...)
-{
-       log_println("jio_fprintf: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-int jio_vfprintf(FILE* f, const char *fmt, va_list args)
-{
-       log_println("jio_vfprintf: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-int jio_printf(const char *fmt, ...)
-{
-       log_println("jio_printf: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetInterfaceVersion */
-
-jint JVM_GetInterfaceVersion()
-{
-       /* This is defined in hotspot/src/share/vm/prims/jvm.h */
-
-#define JVM_INTERFACE_VERSION 4
-
-       return JVM_INTERFACE_VERSION;
-}
-
-
-/* JVM_CurrentTimeMillis */
-
-jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored)
-{
-       TRACEJVMCALLS(("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored));
-
-       return (jlong) builtin_currenttimemillis();
-}
-
-
-/* JVM_NanoTime */
-
-jlong JVM_NanoTime(JNIEnv *env, jclass ignored)
-{
-       TRACEJVMCALLS(("JVM_NanoTime(env=%p, ignored=%p)", env, ignored));
-
-       return (jlong) builtin_nanotime();
-}
-
-
-/* JVM_ArrayCopy */
-
-void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length)
-{
-       java_handle_t *s;
-       java_handle_t *d;
-
-       s = (java_handle_t *) src;
-       d = (java_handle_t *) dst;
-
-       TRACEJVMCALLSVERBOSE(("JVM_ArrayCopy(env=%p, ignored=%p, src=%p, src_pos=%d, dst=%p, dst_pos=%d, length=%d)", env, ignored, src, src_pos, dst, dst_pos, length));
-
-       builtin_arraycopy(s, src_pos, d, dst_pos, length);
-}
-
-
-/* JVM_InitProperties */
-
-jobject JVM_InitProperties(JNIEnv *env, jobject properties)
-{
-       java_handle_t *h;
-       char           buf[256];
-
-       TRACEJVMCALLS(("JVM_InitProperties(env=%p, properties=%p)", env, properties));
-
-       h = (java_handle_t *) properties;
-
-       /* Convert the -XX:MaxDirectMemorySize= command line flag to the
-          sun.nio.MaxDirectMemorySize property.  Do this after setting
-          user properties to prevent people from setting the value with a
-          -D option, as requested. */
-
-       jio_snprintf(buf, sizeof(buf), PRINTF_FORMAT_INT64_T, opt_MaxDirectMemorySize);
-       properties_add("sun.nio.MaxDirectMemorySize", buf);
-
-       /* Add all properties. */
-
-       properties_system_add_all(h);
-
-       return properties;
-}
-
-
-/* JVM_Exit */
-
-void JVM_Exit(jint code)
-{
-       log_println("JVM_Exit: IMPLEMENT ME!");
-}
-
-
-/* JVM_Halt */
-
-void JVM_Halt(jint code)
-{
-       TRACEJVMCALLS(("JVM_Halt(code=%d)", code));
-
-/*     vm_exit(code); */
-       vm_shutdown(code);
-}
-
-
-/* JVM_OnExit(void (*func)) */
-
-void JVM_OnExit(void (*func)(void))
-{
-       log_println("JVM_OnExit(void (*func): IMPLEMENT ME!");
-}
-
-
-/* JVM_GC */
-
-void JVM_GC(void)
-{
-       TRACEJVMCALLS(("JVM_GC()"));
-
-       gc_call();
-}
-
-
-/* JVM_MaxObjectInspectionAge */
-
-jlong JVM_MaxObjectInspectionAge(void)
-{
-       log_println("JVM_MaxObjectInspectionAge: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_TraceInstructions */
-
-void JVM_TraceInstructions(jboolean on)
-{
-       log_println("JVM_TraceInstructions: IMPLEMENT ME!");
-}
-
-
-/* JVM_TraceMethodCalls */
-
-void JVM_TraceMethodCalls(jboolean on)
-{
-       log_println("JVM_TraceMethodCalls: IMPLEMENT ME!");
-}
-
-
-/* JVM_TotalMemory */
-
-jlong JVM_TotalMemory(void)
-{
-       TRACEJVMCALLS(("JVM_TotalMemory()"));
-
-       return gc_get_heap_size();
-}
-
-
-/* JVM_FreeMemory */
-
-jlong JVM_FreeMemory(void)
-{
-       TRACEJVMCALLS(("JVM_FreeMemory()"));
-
-       return gc_get_free_bytes();
-}
-
-
-/* JVM_MaxMemory */
-
-jlong JVM_MaxMemory(void)
-{
-       TRACEJVMCALLS(("JVM_MaxMemory()"));
-
-       return gc_get_max_heap_size();
-}
-
-
-/* JVM_ActiveProcessorCount */
-
-jint JVM_ActiveProcessorCount(void)
-{
-       TRACEJVMCALLS(("JVM_ActiveProcessorCount()"));
-
-       return system_processors_online();
-}
-
-
-/* JVM_FillInStackTrace */
-
-void JVM_FillInStackTrace(JNIEnv *env, jobject receiver)
-{
-       java_lang_Throwable     *o;
-       java_handle_bytearray_t *ba;
-
-       TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver));
-
-       o = (java_lang_Throwable *) receiver;
-
-       ba = stacktrace_get_current();
-
-       if (ba == NULL)
-               return;
-
-       LLNI_field_set_ref(o, backtrace, (java_lang_Object *) ba);
-}
-
-
-/* JVM_PrintStackTrace */
-
-void JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable)
-{
-       log_println("JVM_PrintStackTrace: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetStackTraceDepth */
-
-jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
-{
-       java_lang_Throwable     *to;
-       java_lang_Object        *o;
-       java_handle_bytearray_t *ba;
-       stacktrace_t            *st;
-       int32_t                  depth;
-
-       TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable));
-
-       if (throwable == NULL) {
-               exceptions_throw_nullpointerexception();
-               return 0;
-       }
-
-       to = (java_lang_Throwable *) throwable;
-
-       LLNI_field_get_ref(to, backtrace, o);
-
-       ba = (java_handle_bytearray_t *) o;
-
-       if (ba == NULL)
-               return 0;
-
-       /* We need a critical section here as the stacktrace structure is
-          mapped onto a Java byte-array. */
-
-       LLNI_CRITICAL_START;
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       depth = st->length;
-
-       LLNI_CRITICAL_END;
-
-       return depth;
-}
-
-
-/* JVM_GetStackTraceElement */
-
-jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
-{
-       java_lang_Throwable         *to;
-       java_lang_Object            *o;
-       java_handle_bytearray_t     *ba;
-       stacktrace_t                *st;
-       stacktrace_entry_t          *ste;
-       codeinfo                    *code;
-       methodinfo                  *m;
-       classinfo                   *c;
-       java_lang_StackTraceElement *steo;
-       java_handle_t*               declaringclass;
-       java_lang_String            *filename;
-       int32_t                      linenumber;
-
-       TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index));
-
-       to = (java_lang_Throwable *) throwable;
-
-       LLNI_field_get_ref(to, backtrace, o);
-
-       ba = (java_handle_bytearray_t *) o;
-
-       /* FIXME critical section */
-
-       st = (stacktrace_t *) LLNI_array_data(ba);
-
-       if ((index < 0) || (index >= st->length)) {
-               /* XXX This should be an IndexOutOfBoundsException (check this
-                  again). */
-
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       /* Get the stacktrace entry. */
-
-       ste = &(st->entries[index]);
-
-       /* Get the codeinfo, methodinfo and classinfo. */
-
-       code = ste->code;
-       m    = code->m;
-       c    = m->clazz;
-
-       /* allocate a new StackTraceElement */
-
-       steo = (java_lang_StackTraceElement *)
-               builtin_new(class_java_lang_StackTraceElement);
-
-       if (steo == NULL)
-               return NULL;
-
-       /* get filename */
-
-       if (!(m->flags & ACC_NATIVE)) {
-               if (c->sourcefile != NULL)
-                       filename = (java_lang_String *) javastring_new(c->sourcefile);
-               else
-                       filename = NULL;
-       }
-       else
-               filename = NULL;
-
-       /* get line number */
-
-       if (m->flags & ACC_NATIVE) {
-               linenumber = -2;
-       }
-       else {
-               /* FIXME The linenumbertable_linenumber_for_pc could change
-                  the methodinfo pointer when hitting an inlined method. */
-
-               linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc);
-               linenumber = (linenumber == 0) ? -1 : linenumber;
-       }
-
-       /* get declaring class name */
-
-       declaringclass = class_get_classname(c);
-
-       /* fill the java.lang.StackTraceElement element */
-
-       /* FIXME critical section */
-
-       steo->declaringClass = (java_lang_String*) declaringclass;
-       steo->methodName     = (java_lang_String*) javastring_new(m->name);
-       steo->fileName       = filename;
-       steo->lineNumber     = linenumber;
-
-       return (jobject) steo;
-}
-
-
-/* JVM_IHashCode */
-
-jint JVM_IHashCode(JNIEnv* env, jobject handle)
-{
-       TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle));
-
-       return (jint) ((ptrint) handle);
-}
-
-
-/* JVM_MonitorWait */
-
-void JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *o;
-#endif
-
-       TRACEJVMCALLS(("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms));
-    if (ms < 0) {
-/*             exceptions_throw_illegalargumentexception("argument out of range"); */
-               exceptions_throw_illegalargumentexception();
-               return;
-       }
-
-#if defined(ENABLE_THREADS)
-       o = (java_handle_t *) handle;
-
-       lock_wait_for_object(o, ms, 0);
-#endif
-}
-
-
-/* JVM_MonitorNotify */
-
-void JVM_MonitorNotify(JNIEnv* env, jobject handle)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *o;
-#endif
-
-       TRACEJVMCALLS(("JVM_MonitorNotify(env=%p, handle=%p)", env, handle));
-
-#if defined(ENABLE_THREADS)
-       o = (java_handle_t *) handle;
-
-       lock_notify_object(o);
-#endif
-}
-
-
-/* JVM_MonitorNotifyAll */
-
-void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)
-{
-#if defined(ENABLE_THREADS)
-       java_handle_t *o;
-#endif
-
-       TRACEJVMCALLS(("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle));
-
-#if defined(ENABLE_THREADS)
-       o = (java_handle_t *) handle;
-
-       lock_notify_all_object(o);
-#endif
-}
-
-
-/* JVM_Clone */
-
-jobject JVM_Clone(JNIEnv* env, jobject handle)
-{
-       TRACEJVMCALLS(("JVM_Clone(env=%p, handle=%p)", env, handle));
-
-       return (jobject) builtin_clone(env, (java_handle_t *) handle);
-}
-
-
-/* JVM_InitializeCompiler  */
-
-void JVM_InitializeCompiler (JNIEnv *env, jclass compCls)
-{
-       log_println("JVM_InitializeCompiler : IMPLEMENT ME!");
-}
-
-
-/* JVM_IsSilentCompiler */
-
-jboolean JVM_IsSilentCompiler(JNIEnv *env, jclass compCls)
-{
-       log_println("JVM_IsSilentCompiler: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_CompileClass */
-
-jboolean JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls)
-{
-       log_println("JVM_CompileClass: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_CompileClasses */
-
-jboolean JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname)
-{
-       log_println("JVM_CompileClasses: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_CompilerCommand */
-
-jobject JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg)
-{
-       log_println("JVM_CompilerCommand: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_EnableCompiler */
-
-void JVM_EnableCompiler(JNIEnv *env, jclass compCls)
-{
-       TRACEJVMCALLS(("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls));
-       PRINTJVMWARNINGS(("JVM_EnableCompiler not supported"));
-}
-
-
-/* JVM_DisableCompiler */
-
-void JVM_DisableCompiler(JNIEnv *env, jclass compCls)
-{
-       TRACEJVMCALLS(("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls));
-       PRINTJVMWARNINGS(("JVM_DisableCompiler not supported"));
-}
-
-
-/* JVM_GetLastErrorString */
-
-jint JVM_GetLastErrorString(char *buf, int len)
-{
-       TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len));
-
-       return hpi_system->GetLastErrorString(buf, len);
-}
-
-
-/* JVM_NativePath */
-
-char *JVM_NativePath(char *path)
-{
-       TRACEJVMCALLS(("JVM_NativePath(path=%s)", path));
-
-       return hpi_file->NativePath(path);
-}
-
-
-/* JVM_GetCallerClass */
-
-jclass JVM_GetCallerClass(JNIEnv* env, int depth)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_GetCallerClass(env=%p, depth=%d)", env, depth));
-
-       c = stacktrace_get_caller_class(depth);
-
-       return (jclass) c;
-}
-
-
-/* JVM_FindPrimitiveClass */
-
-jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* s)
-{
-       classinfo *c;
-       utf       *u;
-
-       TRACEJVMCALLS(("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s));
-
-       u = utf_new_char(s);
-       c = primitive_class_get_by_name(u);
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_ResolveClass */
-
-void JVM_ResolveClass(JNIEnv* env, jclass cls)
-{
-       TRACEJVMCALLS(("JVM_ResolveClass(env=%p, cls=%p)", env, cls));
-       PRINTJVMWARNINGS(("JVM_ResolveClass not implemented"));
-}
-
-
-/* JVM_FindClassFromClassLoader */
-
-jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError)
-{
-       classinfo     *c;
-       utf           *u;
-       classloader_t *cl;
-
-       TRACEJVMCALLS(("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError));
-
-       /* As of now, OpenJDK does not call this function with throwError
-          is true. */
-
-       assert(throwError == false);
-
-       u  = utf_new_char(name);
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       c = load_class_from_classloader(u, cl);
-
-       if (c == NULL)
-               return NULL;
-
-       if (init)
-               if (!(c->state & CLASS_INITIALIZED))
-                       if (!initialize_class(c))
-                               return NULL;
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_FindClassFromClass */
-
-jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from)
-{
-       log_println("JVM_FindClassFromClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_DefineClass */
-
-jclass JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)
-{
-       log_println("JVM_DefineClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_DefineClassWithSource */
-
-jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)
-{
-       classinfo     *c;
-       utf           *u;
-       classloader_t *cl;
-
-       TRACEJVMCALLS(("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source));
-
-       if (name != NULL)
-               u = utf_new_char(name);
-       else
-               u = NULL;
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       /* XXX do something with source */
-
-       c = class_define(u, cl, len, (uint8_t *) buf, (java_handle_t *) pd);
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_FindLoadedClass */
-
-jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
-{
-       classloader_t *cl;
-       utf           *u;
-       classinfo     *c;
-
-       TRACEJVMCALLS(("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name));
-
-       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
-
-       u = javastring_toutf((java_handle_t *) name, true);
-       c = classcache_lookup(cl, u);
-
-       return (jclass) LLNI_classinfo_wrap(c);
-}
-
-
-/* JVM_GetClassName */
-
-jstring JVM_GetClassName(JNIEnv *env, jclass cls)
-{
-       classinfo* c;
-
-       TRACEJVMCALLS(("JVM_GetClassName(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return (jstring) class_get_classname(c);
-}
-
-
-/* JVM_GetClassInterfaces */
-
-jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       oa = class_get_interfaces(c);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassLoader */
-
-jobject JVM_GetClassLoader(JNIEnv *env, jclass cls)
-{
-       classinfo     *c;
-       classloader_t *cl;
-
-       TRACEJVMCALLSENTER(("JVM_GetClassLoader(env=%p, cls=%p)", env, cls));
-
-       c  = LLNI_classinfo_unwrap(cls);
-       cl = class_get_classloader(c);
-
-       TRACEJVMCALLSEXIT(("->%p", cl));
-
-       return (jobject) cl;
-}
-
-
-/* JVM_IsInterface */
-
-jboolean JVM_IsInterface(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_IsInterface(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return class_is_interface(c);
-}
-
-
-/* JVM_GetClassSigners */
-
-jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassSigners: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_SetClassSigners */
-
-void JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *hoa;
-
-       TRACEJVMCALLS(("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       hoa = (java_handle_objectarray_t *) signers;
-
-    /* This call is ignored for primitive types and arrays.  Signers
-          are only set once, ClassLoader.java, and thus shouldn't be
-          called with an array.  Only the bootstrap loader creates
-          arrays. */
-
-       if (class_is_primitive(c) || class_is_array(c))
-               return;
-
-       LLNI_classinfo_field_set(c, signers, hoa);
-}
-
-
-/* JVM_GetProtectionDomain */
-
-jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       if (c == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-    /* Primitive types do not have a protection domain. */
-
-       if (class_is_primitive(c))
-               return NULL;
-
-       return (jobject) c->protectiondomain;
-}
-
-
-/* JVM_SetProtectionDomain */
-
-void JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain)
-{
-       log_println("JVM_SetProtectionDomain: IMPLEMENT ME!");
-}
-
-
-/* JVM_DoPrivileged */
-
-jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException)
-{
-       java_handle_t *h;
-       classinfo     *c;
-       methodinfo    *m;
-       java_handle_t *result;
-       java_handle_t *e;
-
-       TRACEJVMCALLS(("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException));
-
-       h = (java_handle_t *) action;
-       LLNI_class_get(h, c);
-
-       if (action == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* lookup run() method (throw no exceptions) */
-
-       m = class_resolveclassmethod(c, utf_run, utf_void__java_lang_Object, c,
-                                                                false);
-
-       if ((m == NULL) || !(m->flags & ACC_PUBLIC) || (m->flags & ACC_STATIC)) {
-               exceptions_throw_internalerror("No run method");
-               return NULL;
-       }
-
-       /* XXX It seems something with a privileged stack needs to be done
-          here. */
-
-       result = vm_call_method(m, h);
-
-       e = exceptions_get_exception();
-
-       if (e != NULL) {
-               if ( builtin_instanceof(e, class_java_lang_Exception) &&
-                       !builtin_instanceof(e, class_java_lang_RuntimeException)) {
-                       exceptions_clear_exception();
-                       exceptions_throw_privilegedactionexception(e);
-               }
-
-               return NULL;
-       }
-
-       return (jobject) result;
-}
-
-
-/* JVM_GetInheritedAccessControlContext */
-
-jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetInheritedAccessControlContext: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetStackAccessControlContext */
-
-jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)
-{
-       TRACEJVMCALLS(("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls));
-
-       /* XXX All stuff I tested so far works without that function.  At
-          some point we have to implement it, but I disable the output
-          for now to make IcedTea happy. */
-
-       return NULL;
-}
-
-
-/* JVM_IsArrayClass */
-
-jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_IsArrayClass(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return class_is_array(c);
-}
-
-
-/* JVM_IsPrimitiveClass */
-
-jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       return class_is_primitive(c);
-}
-
-
-/* JVM_GetComponentType */
-
-jclass JVM_GetComponentType(JNIEnv *env, jclass cls)
-{
-       classinfo *component;
-       classinfo *c;
-       
-       TRACEJVMCALLS(("JVM_GetComponentType(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-       
-       component = class_get_componenttype(c);
-
-       return (jclass) LLNI_classinfo_wrap(component);
-}
-
-
-/* JVM_GetClassModifiers */
-
-jint JVM_GetClassModifiers(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-       int32_t    flags;
-
-       TRACEJVMCALLS(("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       flags = class_get_modifiers(c, false);
-
-       return flags;
-}
-
-
-/* JVM_GetDeclaredClasses */
-
-jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredclasses(c, false);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetDeclaringClass */
-
-jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)
-{
-       classinfo *c;
-       classinfo *dc;
-
-       TRACEJVMCALLS(("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       dc = class_get_declaringclass(c);
-
-       return (jclass) LLNI_classinfo_wrap(dc);
-}
-
-
-/* JVM_GetClassSignature */
-
-jstring JVM_GetClassSignature(JNIEnv *env, jclass cls)
-{
-       classinfo     *c;
-       utf           *u;
-       java_handle_t *s;
-
-       TRACEJVMCALLS(("JVM_GetClassSignature(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       /* Get the signature of the class. */
-
-       u = class_get_signature(c);
-
-       if (u == NULL)
-               return NULL;
-
-       /* Convert UTF-string to a Java-string. */
-
-       s = javastring_new(u);
-
-       return (jstring) s;
-}
-
-
-/* JVM_GetClassAnnotations */
-
-jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
-{
-       classinfo               *c           = NULL; /* classinfo for 'cls'  */
-       java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
-
-       TRACEJVMCALLS(("JVM_GetClassAnnotations: cls=%p", cls));
-
-       if (cls == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-       
-       c = LLNI_classinfo_unwrap(cls);
-
-       /* get annotations: */
-       annotations = class_get_annotations(c);
-
-       return (jbyteArray)annotations;
-}
-
-
-/* JVM_GetFieldAnnotations */
-
-jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
-{
-       java_lang_reflect_Field *rf = NULL; /* java.lang.reflect.Field for 'field' */
-       java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
-
-       TRACEJVMCALLS(("JVM_GetFieldAnnotations: field=%p", field));
-
-       if (field == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rf = (java_lang_reflect_Field*)field;
-
-       LLNI_field_get_ref(rf, annotations, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetMethodAnnotations */
-
-jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
-{
-       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
-       java_handle_bytearray_t  *ba = NULL; /* unparsed annotations */
-
-       TRACEJVMCALLS(("JVM_GetMethodAnnotations: method=%p", method));
-
-       if (method == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rm = (java_lang_reflect_Method*)method;
-
-       LLNI_field_get_ref(rm, annotations, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetMethodDefaultAnnotationValue */
-
-jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
-{
-       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
-       java_handle_bytearray_t  *ba = NULL; /* unparsed annotation default value */
-
-       TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue: method=%p", method));
-
-       if (method == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rm = (java_lang_reflect_Method*)method;
-
-       LLNI_field_get_ref(rm, annotationDefault, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetMethodParameterAnnotations */
-
-jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
-{
-       java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
-       java_handle_bytearray_t  *ba = NULL; /* unparsed parameter annotations */
-
-       TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations: method=%p", method));
-
-       if (method == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       rm = (java_lang_reflect_Method*)method;
-
-       LLNI_field_get_ref(rm, parameterAnnotations, ba);
-
-       return (jbyteArray)ba;
-}
-
-
-/* JVM_GetClassDeclaredFields */
-
-jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredfields(c, publicOnly);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassDeclaredMethods */
-
-jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredmethods(c, publicOnly);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassDeclaredConstructors */
-
-jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly)
-{
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       oa = class_get_declaredconstructors(c, publicOnly);
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetClassAccessFlags */
-
-jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)
-{
-       classinfo *c;
-
-       TRACEJVMCALLS(("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       /* Primitive type classes have the correct access flags. */
-
-       return c->flags & ACC_CLASS_REFLECT_MASK;
-}
-
-
-/* JVM_GetClassConstantPool */
-
-jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
-{
-#if defined(ENABLE_ANNOTATIONS)
-       sun_reflect_ConstantPool *constantPool    = NULL;
-                     /* constant pool object for the class refered by 'cls' */
-       java_lang_Object         *constantPoolOop = (java_lang_Object*)cls;
-                     /* constantPoolOop field of the constant pool object   */
-
-       TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls));
-
-       constantPool = 
-               (sun_reflect_ConstantPool*)native_new_and_init(
-                       class_sun_reflect_ConstantPool);
-       
-       if (constantPool == NULL) {
-               /* out of memory */
-               return NULL;
-       }
-       
-       LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-
-       return (jobject)constantPool;
-#else
-       log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls);
-       return NULL;
-#endif
-}
-
-
-/* JVM_ConstantPoolGetSize */
-
-jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
-{
-       classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool));
-
-       c = LLNI_classinfo_unwrap(jcpool);
-
-       return c->cpcount;
-}
-
-
-/* JVM_ConstantPoolGetClassAt */
-
-jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
-       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
-       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index));
-
-       c = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       result = resolve_classref_eager(ref);
-
-       return (jclass) LLNI_classinfo_wrap(result);
-}
-
-
-/* JVM_ConstantPoolGetClassAtIfLoaded */
-
-jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_classref *ref;    /* classref to the class at constant pool index 'index' */
-       classinfo         *c;      /* classinfo of the class for which 'this' is the constant pool */
-       classinfo         *result; /* classinfo of the class at constant pool index 'index' */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index));
-
-       c = LLNI_classinfo_unwrap(jcpool);
-
-       ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-       
-       if (!resolve_classref(NULL, ref, resolveLazy, true, true, &result)) {
-               return NULL;
-       }
-
-       if ((result == NULL) || !(result->state & CLASS_LOADED)) {
-               return NULL;
-       }
-       
-       return (jclass) LLNI_classinfo_wrap(result);
-}
-
-
-/* JVM_ConstantPoolGetMethodAt */
-
-jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-       
-       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index));
-       
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
-       
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: is that right? or do I have to use resolve_method_*? */
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/* JVM_ConstantPoolGetMethodAtIfLoaded */
-
-jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
-       classinfo *c = NULL;  /* resolved declaring class of the method */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_method_new(ref->p.method);
-}
-
-
-/* JVM_ConstantPoolGetFieldAt */
-
-jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-       
-       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/* JVM_ConstantPoolGetFieldAtIfLoaded */
-
-jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
-       classinfo *c;         /* resolved declaring class for the field */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) {
-               return NULL;
-       }
-
-       if (c == NULL || !(c->state & CLASS_LOADED)) {
-               return NULL;
-       }
-
-       return (jobject)reflect_field_new(ref->p.field);
-}
-
-
-/* JVM_ConstantPoolGetMemberRefInfoAt */
-
-jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       log_println("JVM_ConstantPoolGetMemberRefInfoAt: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index);
-
-       /* TODO: implement. (this is yet unused be OpenJDK but, so very low priority) */
-
-       return NULL;
-}
-
-
-/* JVM_ConstantPoolGetIntAt */
-
-jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_integer *ref; /* reference to the int value in constant pool at index 'index' */
-       classinfo *cls;        /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetLongAt */
-
-jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_long *ref; /* reference to the long value in constant pool at index 'index' */
-       classinfo *cls;     /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetFloatAt */
-
-jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_float *ref; /* reference to the float value in constant pool at index 'index' */
-       classinfo *cls;      /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetDoubleAt */
-
-jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       constant_double *ref; /* reference to the double value in constant pool at index 'index' */
-       classinfo *cls;       /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return 0;
-       }
-
-       return ref->value;
-}
-
-
-/* JVM_ConstantPoolGetStringAt */
-
-jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       utf *ref;       /* utf object for the string in constant pool at index 'index' */
-       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index));
-       
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (jstring)literalstring_new(ref);
-}
-
-
-/* JVM_ConstantPoolGetUTF8At */
-
-jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)
-{
-       utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */
-       classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
-
-       TRACEJVMCALLS(("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index));
-
-       cls = LLNI_classinfo_unwrap(jcpool);
-       ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
-
-       if (ref == NULL) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX: I hope literalstring_new is the right Function. */
-       return (jstring)literalstring_new(ref);
-}
-
-
-/* JVM_DesiredAssertionStatus */
-
-jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)
-{
-#if defined(ENABLE_ASSERTION)
-       assertion_name_t  *item;
-       classinfo         *c;
-       jboolean           status;
-       utf               *name;
-
-       TRACEJVMCALLS(("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls));
-
-       c = LLNI_classinfo_unwrap(cls);
-
-       if (c->classloader == NULL) {
-               status = (jboolean)assertion_system_enabled;
-       }
-       else {
-               status = (jboolean)assertion_user_enabled;
-       }
-
-       if (list_assertion_names != NULL) {
-               item = (assertion_name_t *)list_first(list_assertion_names);
-               while (item != NULL) {
-                       name = utf_new_char(item->name);
-                       if (name == c->packagename) {
-                               status = (jboolean)item->enabled;
-                       }
-                       else if (name == c->name) {
-                               status = (jboolean)item->enabled;
-                       }
-
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-               }
-       }
-
-       return status;
-#else
-       return (jboolean)false;
-#endif
-}
-
-
-/* JVM_AssertionStatusDirectives */
-
-jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
-{
-       classinfo                             *c;
-       java_lang_AssertionStatusDirectives   *o;
-       java_handle_objectarray_t             *classes;
-       java_handle_objectarray_t             *packages;
-       java_booleanarray_t                   *classEnabled;
-       java_booleanarray_t                   *packageEnabled;
-#if defined(ENABLE_ASSERTION)
-       assertion_name_t                      *item;
-       java_handle_t                         *js;
-       s4                                     i, j;
-#endif
-
-       TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused));
-
-       c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
-
-       if (c == NULL)
-               return NULL;
-
-       o = (java_lang_AssertionStatusDirectives *) builtin_new(c);
-
-       if (o == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       classes = builtin_anewarray(assertion_class_count, class_java_lang_Object);
-#else
-       classes = builtin_anewarray(0, class_java_lang_Object);
-#endif
-       if (classes == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       packages = builtin_anewarray(assertion_package_count, class_java_lang_Object);
-#else
-       packages = builtin_anewarray(0, class_java_lang_Object);
-#endif
-       if (packages == NULL)
-               return NULL;
-       
-#if defined(ENABLE_ASSERTION)
-       classEnabled = builtin_newarray_boolean(assertion_class_count);
-#else
-       classEnabled = builtin_newarray_boolean(0);
-#endif
-       if (classEnabled == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       packageEnabled = builtin_newarray_boolean(assertion_package_count);
-#else
-       packageEnabled = builtin_newarray_boolean(0);
-#endif
-       if (packageEnabled == NULL)
-               return NULL;
-
-#if defined(ENABLE_ASSERTION)
-       /* initialize arrays */
-
-       if (list_assertion_names != NULL) {
-               i = 0;
-               j = 0;
-               
-               item = (assertion_name_t *)list_first(list_assertion_names);
-               while (item != NULL) {
-                       js = javastring_new_from_ascii(item->name);
-                       if (js == NULL) {
-                               return NULL;
-                       }
-
-                       if (item->package == false) {
-                               classes->data[i] = js;
-                               classEnabled->data[i] = (jboolean) item->enabled;
-                               i += 1;
-                       }
-                       else {
-                               packages->data[j] = js;
-                               packageEnabled->data[j] = (jboolean) item->enabled;
-                               j += 1;
-                       }
-
-                       item = (assertion_name_t *)list_next(list_assertion_names, item);
-               }
-       }
-#endif
-
-       /* set instance fields */
-
-       o->classes  = classes;
-       o->packages = packages;
-       o->classEnabled = classEnabled;
-       o->packageEnabled = packageEnabled;
-
-       return (jobject) o;
-}
-
-
-/* JVM_GetClassNameUTF */
-
-const char *JVM_GetClassNameUTF(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassCPTypes */
-
-void JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)
-{
-       log_println("JVM_GetClassCPTypes: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetClassCPEntriesCount */
-
-jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassCPEntriesCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetClassFieldsCount */
-
-jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassFieldsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetClassMethodsCount */
-
-jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_GetClassMethodsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxExceptionIndexes */
-
-void JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)
-{
-       log_println("JVM_GetMethodIxExceptionIndexes: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetMethodIxExceptionsCount */
-
-jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxExceptionsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxByteCode */
-
-void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)
-{
-       log_println("JVM_GetMethodIxByteCode: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetMethodIxByteCodeLength */
-
-jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxByteCodeLength: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxExceptionTableEntry */
-
-void JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)
-{
-       log_println("JVM_GetMethodIxExceptionTableEntry: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetMethodIxExceptionTableLength */
-
-jint JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxExceptionTableLength: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxModifiers */
-
-jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetFieldIxModifiers */
-
-jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)
-{
-       log_println("JVM_GetFieldIxModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxLocalsCount */
-
-jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxLocalsCount: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxArgsSize */
-
-jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxArgsSize: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxMaxStack */
-
-jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_GetMethodIxMaxStack: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_IsConstructorIx */
-
-jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)
-{
-       log_println("JVM_IsConstructorIx: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetMethodIxNameUTF */
-
-const char *JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetMethodIxSignatureUTF */
-
-const char *JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)
-{
-       log_println("JVM_GetMethodIxSignatureUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldNameUTF */
-
-const char *JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPFieldNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPMethodNameUTF */
-
-const char *JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPMethodNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPMethodSignatureUTF */
-
-const char *JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPMethodSignatureUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldSignatureUTF */
-
-const char *JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPFieldSignatureUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPClassNameUTF */
-
-const char *JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldClassNameUTF */
-
-const char *JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPFieldClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPMethodClassNameUTF */
-
-const char *JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
-{
-       log_println("JVM_GetCPMethodClassNameUTF: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetCPFieldModifiers */
-
-jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
-{
-       log_println("JVM_GetCPFieldModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetCPMethodModifiers */
-
-jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
-{
-       log_println("JVM_GetCPMethodModifiers: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_ReleaseUTF */
-
-void JVM_ReleaseUTF(const char *utf)
-{
-       log_println("JVM_ReleaseUTF: IMPLEMENT ME!");
-}
-
-
-/* JVM_IsSameClassPackage */
-
-jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)
-{
-       log_println("JVM_IsSameClassPackage: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Open */
-
-/* Taken from: hotspot/src/share/vm/prims/jvm.h */
-
-/*
- * JVM I/O error codes
- */
-#define JVM_EEXIST       -100
-
-jint JVM_Open(const char *fname, jint flags, jint mode)
-{
-       int result;
-
-       TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode));
-
-       result = hpi_file->Open(fname, flags, mode);
-
-       if (result >= 0) {
-               return result;
-       }
-       else {
-               switch (errno) {
-               case EEXIST:
-                       return JVM_EEXIST;
-               default:
-                       return -1;
-               }
-       }
-}
-
-
-/* JVM_Close */
-
-jint JVM_Close(jint fd)
-{
-       TRACEJVMCALLS(("JVM_Close(fd=%d)", fd));
-
-       return hpi_file->Close(fd);
-}
-
-
-/* JVM_Read */
-
-jint JVM_Read(jint fd, char *buf, jint nbytes)
-{
-       TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes));
-
-       return (jint) hpi_file->Read(fd, buf, nbytes);
-}
-
-
-/* JVM_Write */
-
-jint JVM_Write(jint fd, char *buf, jint nbytes)
-{
-       TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes));
-
-       return (jint) hpi_file->Write(fd, buf, nbytes);
-}
-
-
-/* JVM_Available */
-
-jint JVM_Available(jint fd, jlong *pbytes)
-{
-       TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes));
-
-       return hpi_file->Available(fd, pbytes);
-}
-
-
-/* JVM_Lseek */
-
-jlong JVM_Lseek(jint fd, jlong offset, jint whence)
-{
-       TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence));
-
-       return hpi_file->Seek(fd, (off_t) offset, whence);
-}
-
-
-/* JVM_SetLength */
-
-jint JVM_SetLength(jint fd, jlong length)
-{
-       TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length));
-
-       return hpi_file->SetLength(fd, length);
-}
-
-
-/* JVM_Sync */
-
-jint JVM_Sync(jint fd)
-{
-       TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd));
-
-       return hpi_file->Sync(fd);
-}
-
-
-/* JVM_StartThread */
-
-void JVM_StartThread(JNIEnv* env, jobject jthread)
-{
-       TRACEJVMCALLS(("JVM_StartThread(env=%p, jthread=%p)", env, jthread));
-
-       threads_thread_start((java_handle_t *) jthread);
-}
-
-
-/* JVM_StopThread */
-
-void JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable)
-{
-       log_println("JVM_StopThread: IMPLEMENT ME!");
-}
-
-
-/* JVM_IsThreadAlive */
-
-jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread)
-{
-       java_handle_t *h;
-       threadobject  *t;
-       bool           result;
-
-       TRACEJVMCALLS(("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       /* The threadobject is null when a thread is created in Java. The
-          priority is set later during startup. */
-
-       if (t == NULL)
-               return 0;
-
-       result = threads_thread_is_alive(t);
-
-       return result;
-}
-
-
-/* JVM_SuspendThread */
-
-void JVM_SuspendThread(JNIEnv* env, jobject jthread)
-{
-       log_println("JVM_SuspendThread: IMPLEMENT ME!");
-}
-
-
-/* JVM_ResumeThread */
-
-void JVM_ResumeThread(JNIEnv* env, jobject jthread)
-{
-       log_println("JVM_ResumeThread: IMPLEMENT ME!");
-}
-
-
-/* JVM_SetThreadPriority */
-
-void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)
-{
-       java_handle_t *h;
-       threadobject  *t;
-
-       TRACEJVMCALLS(("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       /* The threadobject is null when a thread is created in Java. The
-          priority is set later during startup. */
-
-       if (t == NULL)
-               return;
-
-       threads_set_thread_priority(t->tid, prio);
-}
-
-
-/* JVM_Yield */
-
-void JVM_Yield(JNIEnv *env, jclass threadClass)
-{
-       TRACEJVMCALLS(("JVM_Yield(env=%p, threadClass=%p)", env, threadClass));
-
-       threads_yield();
-}
-
-
-/* JVM_Sleep */
-
-void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)
-{
-       TRACEJVMCALLS(("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis));
-
-       threads_sleep(millis, 0);
-}
-
-
-/* JVM_CurrentThread */
-
-jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass)
-{
-       java_object_t *o;
-
-       TRACEJVMCALLSVERBOSE(("JVM_CurrentThread(env=%p, threadClass=%p)", env, threadClass));
-
-       o = thread_get_current_object();
-
-       return (jobject) o;
-}
-
-
-/* JVM_CountStackFrames */
-
-jint JVM_CountStackFrames(JNIEnv* env, jobject jthread)
-{
-       log_println("JVM_CountStackFrames: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Interrupt */
-
-void JVM_Interrupt(JNIEnv* env, jobject jthread)
-{
-       java_handle_t *h;
-       threadobject  *t;
-
-       TRACEJVMCALLS(("JVM_Interrupt(env=%p, jthread=%p)", env, jthread));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       if (t == NULL)
-               return;
-
-       threads_thread_interrupt(t);
-}
-
-
-/* JVM_IsInterrupted */
-
-jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)
-{
-       java_handle_t *h;
-       threadobject  *t;
-       jboolean       interrupted;
-
-       TRACEJVMCALLS(("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted));
-
-       h = (java_handle_t *) jthread;
-       t = thread_get_thread(h);
-
-       interrupted = thread_is_interrupted(t);
-
-       if (interrupted && clear_interrupted)
-               thread_set_interrupted(t, false);
-
-       return interrupted;
-}
-
-
-/* JVM_HoldsLock */
-
-jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj)
-{
-       java_handle_t *h;
-       bool           result;
-
-       TRACEJVMCALLS(("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj));
-
-       h = (java_handle_t *) obj;
-
-       if (h == NULL) {
-               exceptions_throw_nullpointerexception();
-               return JNI_FALSE;
-       }
-
-       result = lock_is_held_by_current_thread(h);
-
-       return result;
-}
-
-
-/* JVM_DumpAllStacks */
-
-void JVM_DumpAllStacks(JNIEnv* env, jclass unused)
-{
-       log_println("JVM_DumpAllStacks: IMPLEMENT ME!");
-}
-
-
-/* JVM_CurrentLoadedClass */
-
-jclass JVM_CurrentLoadedClass(JNIEnv *env)
-{
-       log_println("JVM_CurrentLoadedClass: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_CurrentClassLoader */
-
-jobject JVM_CurrentClassLoader(JNIEnv *env)
-{
-    /* XXX if a method in a class in a trusted loader is in a
-          doPrivileged, return NULL */
-
-       log_println("JVM_CurrentClassLoader: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassContext */
-
-jobjectArray JVM_GetClassContext(JNIEnv *env)
-{
-       TRACEJVMCALLS(("JVM_GetClassContext(env=%p)", env));
-
-       return (jobjectArray) stacktrace_getClassContext();
-}
-
-
-/* JVM_ClassDepth */
-
-jint JVM_ClassDepth(JNIEnv *env, jstring name)
-{
-       log_println("JVM_ClassDepth: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_ClassLoaderDepth */
-
-jint JVM_ClassLoaderDepth(JNIEnv *env)
-{
-       log_println("JVM_ClassLoaderDepth: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetSystemPackage */
-
-jstring JVM_GetSystemPackage(JNIEnv *env, jstring name)
-{
-       java_handle_t *s;
-       utf *u;
-       utf *result;
-
-       TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name));
-
-/*     s = package_find(name); */
-       u = javastring_toutf((java_handle_t *) name, false);
-
-       result = package_find(u);
-
-       if (result != NULL)
-               s = javastring_new(result);
-       else
-               s = NULL;
-
-       return (jstring) s;
-}
-
-
-/* JVM_GetSystemPackages */
-
-jobjectArray JVM_GetSystemPackages(JNIEnv *env)
-{
-       log_println("JVM_GetSystemPackages: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_AllocateNewObject */
-
-jobject JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)
-{
-       log_println("JVM_AllocateNewObject: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_AllocateNewArray */
-
-jobject JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length)
-{
-       log_println("JVM_AllocateNewArray: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_LatestUserDefinedLoader */
-
-jobject JVM_LatestUserDefinedLoader(JNIEnv *env)
-{
-       classloader_t *cl;
-
-       TRACEJVMCALLS(("JVM_LatestUserDefinedLoader(env=%p)", env));
-
-       cl = stacktrace_first_nonnull_classloader();
-
-       return (jobject) cl;
-}
-
-
-/* JVM_LoadClass0 */
-
-jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring currClassName)
-{
-       log_println("JVM_LoadClass0: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetArrayLength */
-
-jint JVM_GetArrayLength(JNIEnv *env, jobject arr)
-{
-       java_handle_t *a;
-
-       TRACEJVMCALLS(("JVM_GetArrayLength(arr=%p)", arr));
-
-       a = (java_handle_t *) arr;
-
-       return array_length_get(a);
-}
-
-
-/* JVM_GetArrayElement */
-
-jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
-{
-       java_handle_t *a;
-       java_handle_t *o;
-
-       TRACEJVMCALLS(("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index));
-
-       a = (java_handle_t *) arr;
-
-/*     if (!class_is_array(a->objheader.vftbl->class)) { */
-/*             exceptions_throw_illegalargumentexception(); */
-/*             return NULL; */
-/*     } */
-
-       o = array_element_get(a, index);
-
-       return (jobject) o;
-}
-
-
-/* JVM_GetPrimitiveArrayElement */
-
-jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode)
-{
-       jvalue jv;
-
-       log_println("JVM_GetPrimitiveArrayElement: IMPLEMENT ME!");
-
-       jv.l = NULL;
-
-       return jv;
-}
-
-
-/* JVM_SetArrayElement */
-
-void JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val)
-{
-       java_handle_t *a;
-       java_handle_t *value;
-
-       TRACEJVMCALLS(("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val));
-
-       a     = (java_handle_t *) arr;
-       value = (java_handle_t *) val;
-
-       array_element_set(a, index, value);
-}
-
-
-/* JVM_SetPrimitiveArrayElement */
-
-void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode)
-{
-       log_println("JVM_SetPrimitiveArrayElement: IMPLEMENT ME!");
-}
-
-
-/* JVM_NewArray */
-
-jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length)
-{
-       classinfo                 *c;
-       classinfo                 *pc;
-       java_handle_t             *a;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length));
-
-       if (eltClass == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* NegativeArraySizeException is checked in builtin_newarray. */
-
-       c = LLNI_classinfo_unwrap(eltClass);
-
-       /* Create primitive or object array. */
-
-       if (class_is_primitive(c)) {
-               pc = primitive_arrayclass_get_by_name(c->name);
-
-               /* void arrays are not allowed. */
-
-               if (pc == NULL) {
-                       exceptions_throw_illegalargumentexception();
-                       return NULL;
-               }
-
-               a = builtin_newarray(length, pc);
-
-               return (jobject) a;
-       }
-       else {
-               oa = builtin_anewarray(length, c);
-
-               return (jobject) oa;
-       }
-}
-
-
-/* JVM_NewMultiArray */
-
-jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)
-{
-       classinfo                 *c;
-       java_handle_intarray_t    *ia;
-       int32_t                    length;
-       long                      *dims;
-       int32_t                    value;
-       int32_t                    i;
-       classinfo                 *ac;
-       java_handle_objectarray_t *a;
-
-       TRACEJVMCALLS(("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim));
-
-       if (eltClass == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* NegativeArraySizeException is checked in builtin_newarray. */
-
-       c = LLNI_classinfo_unwrap(eltClass);
-
-       ia = (java_handle_intarray_t *) dim;
-
-       length = array_length_get((java_handle_t *) ia);
-
-       /* We check here for exceptions thrown in array_length_get,
-          otherwise these exceptions get overwritten by the following
-          IllegalArgumentException. */
-
-       if (length < 0)
-               return NULL;
-
-       if ((length <= 0) || (length > /* MAX_DIM */ 255)) {
-               exceptions_throw_illegalargumentexception();
-               return NULL;
-       }
-
-       /* XXX This is just a quick hack to get it working. */
-
-       dims = MNEW(long, length);
-
-       for (i = 0; i < length; i++) {
-               value = LLNI_array_direct(ia, i);
-               dims[i] = (long) value;
-       }
-
-       /* Create an array-class if necessary. */
-
-       if (class_is_primitive(c))
-               ac = primitive_arrayclass_get_by_name(c->name);
-       else
-               ac = class_array_of(c, true);
-
-       if (ac == NULL)
-               return NULL;
-
-       a = builtin_multianewarray(length, (java_handle_t *) ac, dims);
-
-       return (jobject) a;
-}
-
-
-/* JVM_InitializeSocketLibrary */
-
-jint JVM_InitializeSocketLibrary()
-{
-       TRACEJVMCALLS(("JVM_InitializeSocketLibrary()"));
-
-       return hpi_initialize_socket_library();
-}
-
-
-/* JVM_Socket */
-
-jint JVM_Socket(jint domain, jint type, jint protocol)
-{
-       TRACEJVMCALLS(("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol));
-
-       return system_socket(domain, type, protocol);
-}
-
-
-/* JVM_SocketClose */
-
-jint JVM_SocketClose(jint fd)
-{
-       TRACEJVMCALLS(("JVM_SocketClose(fd=%d)", fd));
-
-       return system_close(fd);
-}
-
-
-/* JVM_SocketShutdown */
-
-jint JVM_SocketShutdown(jint fd, jint howto)
-{
-       TRACEJVMCALLS(("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto));
-
-       return system_shutdown(fd, howto);
-}
-
-
-/* JVM_Recv */
-
-jint JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)
-{
-       log_println("JVM_Recv: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Send */
-
-jint JVM_Send(jint fd, char *buf, jint nBytes, jint flags)
-{
-       log_println("JVM_Send: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Timeout */
-
-jint JVM_Timeout(int fd, long timeout)
-{
-       log_println("JVM_Timeout: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Listen */
-
-jint JVM_Listen(jint fd, jint count)
-{
-       TRACEJVMCALLS(("JVM_Listen(fd=%d, count=%d)", fd, count));
-
-       return system_listen(fd, count);
-}
-
-
-/* JVM_Connect */
-
-jint JVM_Connect(jint fd, struct sockaddr *him, jint len)
-{
-       TRACEJVMCALLS(("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len));
-
-       return system_connect(fd, him, len);
-}
-
-
-/* JVM_Bind */
-
-jint JVM_Bind(jint fd, struct sockaddr *him, jint len)
-{
-       log_println("JVM_Bind: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_Accept */
-
-jint JVM_Accept(jint fd, struct sockaddr *him, jint *len)
-{
-       TRACEJVMCALLS(("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len));
-
-       return system_accept(fd, him, (socklen_t *) len);
-}
-
-
-/* JVM_RecvFrom */
-
-jint JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)
-{
-       log_println("JVM_RecvFrom: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetSockName */
-
-jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len)
-{
-       TRACEJVMCALLS(("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len));
-
-       return system_getsockname(fd, him, (socklen_t *) len);
-}
-
-
-/* JVM_SendTo */
-
-jint JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)
-{
-       log_println("JVM_SendTo: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_SocketAvailable */
-
-jint JVM_SocketAvailable(jint fd, jint *pbytes)
-{
-#if defined(FIONREAD)
-       int bytes;
-       int result;
-
-       TRACEJVMCALLS(("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes));
-
-       *pbytes = 0;
-
-       result = ioctl(fd, FIONREAD, &bytes);
-
-       if (result < 0)
-               return 0;
-
-       *pbytes = bytes;
-
-       return 1;
-#else
-# error FIONREAD not defined
-#endif
-}
-
-
-/* JVM_GetSockOpt */
-
-jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)
-{
-       TRACEJVMCALLS(("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen));
-
-       return system_getsockopt(fd, level, optname, optval, (socklen_t *) optlen);
-}
-
-
-/* JVM_SetSockOpt */
-
-jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)
-{
-       TRACEJVMCALLS(("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen));
-
-       return system_setsockopt(fd, level, optname, optval, optlen);
-}
-
-
-/* JVM_GetHostName */
-
-int JVM_GetHostName(char *name, int namelen)
-{
-       int result;
-
-       TRACEJVMCALLSENTER(("JVM_GetHostName(name=%s, namelen=%d)", name, namelen));
-
-       result = system_gethostname(name, namelen);
-
-       TRACEJVMCALLSEXIT(("->%d (name=%s)", result, name));
-
-       return result;
-}
-
-
-/* JVM_GetHostByAddr */
-
-struct hostent *JVM_GetHostByAddr(const char* name, int len, int type)
-{
-       log_println("JVM_GetHostByAddr: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetHostByName */
-
-struct hostent *JVM_GetHostByName(char* name)
-{
-       log_println("JVM_GetHostByName: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetProtoByName */
-
-struct protoent *JVM_GetProtoByName(char* name)
-{
-       log_println("JVM_GetProtoByName: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_LoadLibrary */
-
-void *JVM_LoadLibrary(const char *name)
-{
-       utf*  u;
-       void* handle;
-
-       TRACEJVMCALLSENTER(("JVM_LoadLibrary(name=%s)", name));
-
-       u = utf_new_char(name);
-
-       handle = native_library_open(u);
-
-       TRACEJVMCALLSEXIT(("->%p", handle));
-
-       return handle;
-}
-
-
-/* JVM_UnloadLibrary */
-
-void JVM_UnloadLibrary(void* handle)
-{
-       TRACEJVMCALLS(("JVM_UnloadLibrary(handle=%p)", handle));
-
-       native_library_close(handle);
-}
-
-
-/* JVM_FindLibraryEntry */
-
-void *JVM_FindLibraryEntry(void *handle, const char *name)
-{
-       lt_ptr symbol;
-
-       TRACEJVMCALLSENTER(("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name));
-
-       symbol = lt_dlsym(handle, name);
-
-       TRACEJVMCALLSEXIT(("->%p", symbol));
-
-       return symbol;
-}
-
-
-/* JVM_IsNaN */
-
-jboolean JVM_IsNaN(jdouble a)
-{
-       log_println("JVM_IsNaN: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_IsSupportedJNIVersion */
-
-jboolean JVM_IsSupportedJNIVersion(jint version)
-{
-       TRACEJVMCALLS(("JVM_IsSupportedJNIVersion(version=%d)", version));
-
-       return jni_version_check(version);
-}
-
-
-/* JVM_InternString */
-
-jstring JVM_InternString(JNIEnv *env, jstring str)
-{
-       TRACEJVMCALLS(("JVM_InternString(env=%p, str=%p)", env, str));
-
-       return (jstring) javastring_intern((java_handle_t *) str);
-}
-
-
-/* JVM_RawMonitorCreate */
-
-JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void)
-{
-       java_object_t *o;
-
-       TRACEJVMCALLS(("JVM_RawMonitorCreate()"));
-
-       o = NEW(java_object_t);
-
-       lock_init_object_lock(o);
-
-       return o;
-}
-
-
-/* JVM_RawMonitorDestroy */
-
-JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon)
-{
-       TRACEJVMCALLS(("JVM_RawMonitorDestroy(mon=%p)", mon));
-
-       FREE(mon, java_object_t);
-}
-
-
-/* JVM_RawMonitorEnter */
-
-JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon)
-{
-       TRACEJVMCALLS(("JVM_RawMonitorEnter(mon=%p)", mon));
-
-       (void) lock_monitor_enter((java_object_t *) mon);
-
-       return 0;
-}
-
-
-/* JVM_RawMonitorExit */
-
-JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon)
-{
-       TRACEJVMCALLS(("JVM_RawMonitorExit(mon=%p)", mon));
-
-       (void) lock_monitor_exit((java_object_t *) mon);
-}
-
-
-/* JVM_SetPrimitiveFieldValues */
-
-void JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
-{
-       log_println("JVM_SetPrimitiveFieldValues: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetPrimitiveFieldValues */
-
-void JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
-{
-       log_println("JVM_GetPrimitiveFieldValues: IMPLEMENT ME!");
-}
-
-
-/* JVM_AccessVMBooleanFlag */
-
-jboolean JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)
-{
-       log_println("JVM_AccessVMBooleanFlag: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_AccessVMIntFlag */
-
-jboolean JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)
-{
-       log_println("JVM_AccessVMIntFlag: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_VMBreakPoint */
-
-void JVM_VMBreakPoint(JNIEnv *env, jobject obj)
-{
-       log_println("JVM_VMBreakPoint: IMPLEMENT ME!");
-}
-
-
-/* JVM_GetClassFields */
-
-jobjectArray JVM_GetClassFields(JNIEnv *env, jclass cls, jint which)
-{
-       log_println("JVM_GetClassFields: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassMethods */
-
-jobjectArray JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which)
-{
-       log_println("JVM_GetClassMethods: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassConstructors */
-
-jobjectArray JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which)
-{
-       log_println("JVM_GetClassConstructors: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassField */
-
-jobject JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which)
-{
-       log_println("JVM_GetClassField: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassMethod */
-
-jobject JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which)
-{
-       log_println("JVM_GetClassMethod: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetClassConstructor */
-
-jobject JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which)
-{
-       log_println("JVM_GetClassConstructor: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_NewInstance */
-
-jobject JVM_NewInstance(JNIEnv *env, jclass cls)
-{
-       log_println("JVM_NewInstance: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetField */
-
-jobject JVM_GetField(JNIEnv *env, jobject field, jobject obj)
-{
-       log_println("JVM_GetField: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetPrimitiveField */
-
-jvalue JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode)
-{
-       jvalue jv;
-
-       log_println("JVM_GetPrimitiveField: IMPLEMENT ME!");
-
-       jv.l = NULL;
-
-       return jv;
-}
-
-
-/* JVM_SetField */
-
-void JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val)
-{
-       log_println("JVM_SetField: IMPLEMENT ME!");
-}
-
-
-/* JVM_SetPrimitiveField */
-
-void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode)
-{
-       log_println("JVM_SetPrimitiveField: IMPLEMENT ME!");
-}
-
-
-/* JVM_InvokeMethod */
-
-jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
-{
-       java_lang_reflect_Method *rm;
-       classinfo     *c;
-       int32_t        slot;
-       int32_t        override;
-       methodinfo    *m;
-       java_handle_t *ro;
-
-       TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0));
-
-       rm = (java_lang_reflect_Method *) method;
-
-       LLNI_field_get_cls(rm, clazz,    c);
-       LLNI_field_get_val(rm, slot,     slot);
-       LLNI_field_get_val(rm, override, override);
-
-       m = &(c->methods[slot]);
-
-       ro = reflect_method_invoke(m, (java_handle_t *) obj, (java_handle_objectarray_t *) args0, override);
-
-       return (jobject) ro;
-}
-
-
-/* JVM_NewInstanceFromConstructor */
-
-jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0)
-{
-       java_lang_reflect_Constructor *rc;
-       classinfo                     *c;
-       int32_t                        slot;
-       int32_t                        override;
-       methodinfo                    *m;
-       java_handle_t                 *o;
-
-       TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0));
-
-       rc = (java_lang_reflect_Constructor *) con;
-
-       LLNI_field_get_cls(rc, clazz,    c);
-       LLNI_field_get_val(rc, slot,     slot);
-       LLNI_field_get_val(rc, override, override);
-
-       m = &(c->methods[slot]);
-
-       o = reflect_constructor_newinstance(m, (java_handle_objectarray_t *) args0, override);
-
-       return (jobject) o;
-}
-
-
-/* JVM_SupportsCX8 */
-
-jboolean JVM_SupportsCX8()
-{
-       TRACEJVMCALLS(("JVM_SupportsCX8()"));
-
-       /* IMPLEMENT ME */
-
-       return 0;
-}
-
-
-/* JVM_CX8Field */
-
-jboolean JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal)
-{
-       log_println("JVM_CX8Field: IMPLEMENT ME!");
-
-       return 0;
-}
-
-
-/* JVM_GetAllThreads */
-
-jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy)
-{
-       log_println("JVM_GetAllThreads: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_DumpThreads */
-
-jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads)
-{
-       log_println("JVM_DumpThreads: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetManagement */
-
-void *JVM_GetManagement(jint version)
-{
-       TRACEJVMCALLS(("JVM_GetManagement(version=%d)", version));
-
-       /* TODO We current don't support the management interface. */
-
-       return NULL;
-}
-
-
-/* JVM_InitAgentProperties */
-
-jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties)
-{
-       log_println("JVM_InitAgentProperties: IMPLEMENT ME!");
-
-       return NULL;
-}
-
-
-/* JVM_GetEnclosingMethodInfo */
-
-jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)
-{
-       classinfo                 *c;
-       methodinfo                *m;
-       java_handle_objectarray_t *oa;
-
-       TRACEJVMCALLS(("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass));
-
-       c = LLNI_classinfo_unwrap(ofClass);
-
-       if ((c == NULL) || class_is_primitive(c))
-               return NULL;
-
-       m = class_get_enclosingmethod_raw(c);
-
-       if (m == NULL)
-               return NULL;
-
-       oa = builtin_anewarray(3, class_java_lang_Object);
-
-       if (oa == NULL)
-               return NULL;
-
-       array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->clazz));
-       array_objectarray_element_set(oa, 1, javastring_new(m->name));
-       array_objectarray_element_set(oa, 2, javastring_new(m->descriptor));
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetThreadStateValues */
-
-jintArray JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState)
-{
-       java_handle_intarray_t *ia;
-
-       TRACEJVMCALLS(("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)",
-                                 env, javaThreadState));
-
-       /* If new thread states are added in future JDK and VM versions,
-          this should check if the JDK version is compatible with thread
-          states supported by the VM.  Return NULL if not compatible.
-       
-          This function must map the VM java_lang_Thread::ThreadStatus
-          to the Java thread state that the JDK supports. */
-
-       switch (javaThreadState) {
-    case THREAD_STATE_NEW:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_NEW);
-               break; 
-
-    case THREAD_STATE_RUNNABLE:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_RUNNABLE);
-               break; 
-
-    case THREAD_STATE_BLOCKED:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_BLOCKED);
-               break; 
-
-    case THREAD_STATE_WAITING:
-               ia = builtin_newarray_int(2);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_WAITING);
-               /* XXX Implement parked stuff. */
-/*             array_intarray_element_set(ia, 1, PARKED); */
-               break; 
-
-    case THREAD_STATE_TIMED_WAITING:
-               ia = builtin_newarray_int(3);
-
-               if (ia == NULL)
-                       return NULL;
-
-               /* XXX Not sure about that one. */
-/*             array_intarray_element_set(ia, 0, SLEEPING); */
-               array_intarray_element_set(ia, 0, THREAD_STATE_TIMED_WAITING);
-               /* XXX Implement parked stuff. */
-/*             array_intarray_element_set(ia, 2, PARKED); */
-               break; 
-
-    case THREAD_STATE_TERMINATED:
-               ia = builtin_newarray_int(1);
-
-               if (ia == NULL)
-                       return NULL;
-
-               array_intarray_element_set(ia, 0, THREAD_STATE_TERMINATED);
-               break; 
-
-    default:
-               /* Unknown state - probably incompatible JDK version */
-               return NULL;
-       }
-
-       return (jintArray) ia;
-}
-
-
-/* JVM_GetThreadStateNames */
-
-jobjectArray JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values)
-{
-       java_handle_intarray_t    *ia;
-       java_handle_objectarray_t *oa;
-       java_object_t             *s;
-
-       TRACEJVMCALLS(("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)",
-                                 env, javaThreadState, values));
-
-       ia = (java_handle_intarray_t *) values;
-
-       /* If new thread states are added in future JDK and VM versions,
-          this should check if the JDK version is compatible with thread
-          states supported by the VM.  Return NULL if not compatible.
-       
-          This function must map the VM java_lang_Thread::ThreadStatus
-          to the Java thread state that the JDK supports. */
-
-       if (values == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       switch (javaThreadState) {
-    case THREAD_STATE_NEW:
-               assert(ia->header.size == 1 && ia->data[0] == THREAD_STATE_NEW);
-
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("NEW"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-    case THREAD_STATE_RUNNABLE:
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("RUNNABLE"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-    case THREAD_STATE_BLOCKED:
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("BLOCKED"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-    case THREAD_STATE_WAITING:
-               oa = builtin_anewarray(2, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("WAITING.OBJECT_WAIT"));
-/*             s = javastring_new(utf_new_char("WAITING.PARKED")); */
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-/*             array_objectarray_element_set(oa, 1, s); */
-               break; 
-
-    case THREAD_STATE_TIMED_WAITING:
-               oa = builtin_anewarray(3, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-/*             s = javastring_new(utf_new_char("TIMED_WAITING.SLEEPING")); */
-               s = javastring_new(utf_new_char("TIMED_WAITING.OBJECT_WAIT"));
-/*             s = javastring_new(utf_new_char("TIMED_WAITING.PARKED")); */
-
-               if (s == NULL)
-                       return NULL;
-
-/*             array_objectarray_element_set(oa, 0, s); */
-               array_objectarray_element_set(oa, 0, s);
-/*             array_objectarray_element_set(oa, 2, s); */
-               break; 
-
-    case THREAD_STATE_TERMINATED:
-               oa = builtin_anewarray(1, class_java_lang_String);
-
-               if (oa == NULL)
-                       return NULL;
-
-               s = javastring_new(utf_new_char("TERMINATED"));
-
-               if (s == NULL)
-                       return NULL;
-
-               array_objectarray_element_set(oa, 0, s);
-               break; 
-
-       default:
-               /* Unknown state - probably incompatible JDK version */
-               return NULL;
-       }
-
-       return (jobjectArray) oa;
-}
-
-
-/* JVM_GetVersionInfo */
-
-void JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)
-{
-       log_println("JVM_GetVersionInfo: IMPLEMENT ME!");
-}
-
-
-/* OS: JVM_RegisterSignal */
-
-void *JVM_RegisterSignal(jint sig, void *handler)
-{
-       functionptr newHandler;
-
-       TRACEJVMCALLS(("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler));
-
-       if (handler == (void *) 2)
-               newHandler = (functionptr) signal_thread_handler;
-       else
-               newHandler = (functionptr) (uintptr_t) handler;
-
-       switch (sig) {
-    case SIGILL:
-    case SIGFPE:
-    case SIGUSR1:
-    case SIGSEGV:
-               /* These signals are already used by the VM. */
-               return (void *) -1;
-
-    case SIGQUIT:
-               /* This signal is used by the VM to dump thread stacks unless
-                  ReduceSignalUsage is set, in which case the user is allowed
-                  to set his own _native_ handler for this signal; thus, in
-                  either case, we do not allow JVM_RegisterSignal to change
-                  the handler. */
-               return (void *) -1;
-
-       case SIGHUP:
-       case SIGINT:
-       case SIGTERM:
-               break;
-       }
-
-       signal_register_signal(sig, newHandler, 0);
-
-       /* XXX Should return old handler. */
-
-       return (void *) 2;
-}
-
-
-/* OS: JVM_RaiseSignal */
-
-jboolean JVM_RaiseSignal(jint sig)
-{
-       log_println("JVM_RaiseSignal: IMPLEMENT ME! sig=%s", sig);
-
-       return false;
-}
-
-
-/* OS: JVM_FindSignal */
-
-jint JVM_FindSignal(const char *name)
-{
-       TRACEJVMCALLS(("JVM_FindSignal(name=%s)", name));
-
-#if defined(__LINUX__)
-       if (strcmp(name, "HUP") == 0)
-               return SIGHUP;
-
-       if (strcmp(name, "INT") == 0)
-               return SIGINT;
-
-       if (strcmp(name, "TERM") == 0)
-               return SIGTERM;
-#else
-# error not implemented for this OS
-#endif
-
-       return -1;
-}
-
-
-/*
- * 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 34192a356a6c72ea9d60ad1becaf320bb433fc43..737559da5cafcc99ee642645f7f5c7d593e0cdcd 100644 (file)
@@ -39,7 +39,7 @@
 #include "native/include/java_lang_Object.h"                  /* before c.l.C */
 #include "native/include/java_lang_String.h"            /* required by j.l.CL */
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 # include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
 #endif
 
@@ -49,7 +49,7 @@
 #include "native/include/java_lang_Thread.h"             /* required by s.m.U */
 #include "native/include/java_lang_Throwable.h"
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 # include "native/include/java_lang_reflect_VMField.h"
 #endif
 
@@ -657,17 +657,17 @@ JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, su
        fieldinfo *f;
        int32_t    slot;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_reflect_VMField *rvmf;
 #endif
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        LLNI_field_get_ref(field, f,     rvmf);
        LLNI_field_get_cls(rvmf,  clazz, c);
        LLNI_field_get_val(rvmf,  slot , slot);
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        LLNI_field_get_cls(field, clazz, c);
        LLNI_field_get_val(field, slot , slot);
@@ -862,17 +862,17 @@ JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv
        fieldinfo *f;
        int32_t    slot;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_reflect_VMField *rvmf;
 #endif
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        LLNI_field_get_ref(rf,   f,     rvmf);
        LLNI_field_get_cls(rvmf, clazz, c);
        LLNI_field_get_val(rvmf, slot , slot);
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        LLNI_field_get_cls(rf, clazz, c);
        LLNI_field_get_val(rf, slot , slot);
@@ -1024,7 +1024,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_
 
        o = LLNI_classinfo_wrap(c);
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        /* set ProtectionDomain */
 
        LLNI_field_set_ref(o, pd, protectionDomain);
index db0b685fea0e0df5f78c96705eacd59604caa30f..cefeeacebc589cf37770ab75767c46192784ee28 100644 (file)
@@ -39,9 +39,7 @@
 
 /* define some stuff we need to no-ops ****************************************/
 
-#define THREADSPECIFIC
 #define THREADOBJECT      NULL
-#define THREADINFO        NULL
 
 #define threadobject      void
 
index 07a5362cfe4a6d93782330ee4aa05072f07ac396..4d69503ba8a2824b904c0a5d11aa26a2f872b271 100644 (file)
  *
  *     ,----------------------,-----------,---,
  *     |      thread ID       |   count   | 0 |
- *     `----------------------'-----------'---´
+ *     `----------------------'-----------'---'
  *
  *     thread ID......the 'index' of the owning thread, or 0
  *     count..........number of times the lock has been entered        minus 1
  *
  *     ,----------------------------------,---,
  *     |    lock_record_t * (without LSB) | 1 |
- *     `----------------------------------'---´
+ *     `----------------------------------'---'
  *
  *     1..............the shape bit is 1 in fat lock mode
  */
index 7d53fec3768e67b4c6b7592dcabb85b57fde77cc..af5e43c05461b101d03a431b3a975696c1c80b5e 100644 (file)
@@ -69,7 +69,7 @@
 # include "native/include/java_lang_ThreadGroup.h"
 #endif
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 # include "native/include/java_lang_VMThread.h"
 #endif
 
@@ -232,15 +232,12 @@ static mutex_t mutex_gc;
 static mutex_t mutex_join;
 static pthread_cond_t  cond_join;
 
-/* XXX We disable that whole bunch of code until we have the exact-GC
-   running. */
-
-#if 1
-
 /* this is one of the STOPWORLD_FROM_ constants, telling why the world is     */
 /* being stopped                                                              */
 static volatile int stopworldwhere;
 
+#if defined(ENABLE_GC_CACAO)
+
 /* semaphore used for acknowleding thread suspension                          */
 static sem_t suspend_ack;
 #if defined(__IRIX__)
@@ -248,7 +245,7 @@ static mutex_t suspend_ack_lock = MUTEX_INITIALIZER;
 static pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER;
 #endif
 
-#endif /* 0 */
+#endif /* ENABLE_GC_CACAO */
 
 /* mutexes used by the fake atomic instructions                               */
 #if defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
@@ -367,7 +364,8 @@ void unlock_stopworld(void)
 }
 
 /* XXX We disable that whole bunch of code until we have the exact-GC
-   running. */
+   running. Some of it may only be needed by the old Boehm-based
+   suspension handling. */
 
 #if 0
 
@@ -516,8 +514,6 @@ static void threads_sigsuspend_handler(ucontext_t *_uc)
 }
 #endif
 
-#endif
-
 
 /* threads_stopworld ***********************************************************
 
@@ -527,7 +523,6 @@ static void threads_sigsuspend_handler(ucontext_t *_uc)
 
 *******************************************************************************/
 
-#if !defined(DISABLE_GC)
 void threads_stopworld(void)
 {
 #if !defined(__DARWIN__) && !defined(__CYGWIN__)
@@ -588,7 +583,6 @@ void threads_stopworld(void)
           non-signaled NEW threads can't change their state and execute
           code. */
 }
-#endif /* !defined(DISABLE_GC) */
 
 
 /* threads_startworld **********************************************************
@@ -597,7 +591,6 @@ void threads_stopworld(void)
 
 *******************************************************************************/
 
-#if !defined(DISABLE_GC)
 void threads_startworld(void)
 {
 #if !defined(__DARWIN__) && !defined(__CYGWIN__)
@@ -657,6 +650,7 @@ void threads_startworld(void)
 
        unlock_stopworld();
 }
+
 #endif
 
 
@@ -850,9 +844,10 @@ void threads_impl_preinit(void)
                vm_abort_errnum(result, "threads_impl_preinit: pthread_cond_init failed");
 
 #if defined(ENABLE_GC_CACAO)
-       /* initialize the GC mutext */
+       /* initialize the GC mutex & suspend semaphore */
 
        mutex_init(&mutex_gc);
+       threads_sem_init(&suspend_ack, 0, 0);
 #endif
 
 #if !defined(HAVE___THREAD)
@@ -860,8 +855,6 @@ void threads_impl_preinit(void)
        if (result != 0)
                vm_abort_errnum(result, "threads_impl_preinit: pthread_key_create failed");
 #endif
-
-       threads_sem_init(&suspend_ack, 0, 0);
 }
 
 
@@ -967,7 +960,7 @@ static void *threads_startup_thread(void *arg)
        startupinfo        *startup;
        threadobject       *t;
        java_lang_Thread   *object;
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_VMThread *vmt;
 #endif
        sem_t              *psem;
@@ -1049,13 +1042,13 @@ static void *threads_startup_thread(void *arg)
        /* find and run the Thread.run()V method if no other function was passed */
 
        if (function == NULL) {
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                /* We need to start the run method of
                   java.lang.VMThread. Since this is a final class, we can use
                   the class object directly. */
 
                c = class_java_lang_VMThread;
-#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
                LLNI_class_get(object, c);
 #else
 # error unknown classpath configuration
@@ -1076,13 +1069,13 @@ static void *threads_startup_thread(void *arg)
                        _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount =
                                _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                /* we need to start the run method of java.lang.VMThread */
 
                LLNI_field_get_ref(object, vmThread, vmt);
                o = (java_handle_t *) vmt;
 
-#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
                o = (java_handle_t *) object;
 #else
 # error unknown classpath configuration
@@ -1274,9 +1267,9 @@ bool threads_detach_thread(threadobject *t)
                   to build the java_lang_Thread_UncaughtExceptionHandler
                   header file with cacaoh. */
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                LLNI_field_get_ref(object, exceptionHandler, handler);
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
                LLNI_field_get_ref(object, uncaughtExceptionHandler, handler);
 # endif
 
@@ -1311,13 +1304,13 @@ bool threads_detach_thread(threadobject *t)
        if (group != NULL) {
                LLNI_class_get(group, c);
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                m = class_resolveclassmethod(c,
                                                                         utf_removeThread,
                                                                         utf_java_lang_Thread__V,
                                                                         class_java_lang_ThreadGroup,
                                                                         true);
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
                m = class_resolveclassmethod(c,
                                                                         utf_remove,
                                                                         utf_java_lang_Thread__V,
@@ -1380,6 +1373,8 @@ bool threads_detach_thread(threadobject *t)
 }
 
 
+#if defined(ENABLE_GC_CACAO)
+
 /* threads_suspend_thread ******************************************************
 
    Suspend the passed thread. Execution stops until the thread
@@ -1436,7 +1431,6 @@ void threads_suspend_ack(u1* pc, u1* sp)
 
        /* TODO: remember dump memory size */
 
-#if defined(ENABLE_GC_CACAO)
        /* inform the GC about the suspension */
        if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD && gc_pending) {
 
@@ -1449,7 +1443,6 @@ void threads_suspend_ack(u1* pc, u1* sp)
 
                }
        }
-#endif
 
        /* mark this thread as suspended and remember the PC */
        thread->pc        = pc;
@@ -1507,6 +1500,7 @@ bool threads_resume_thread(threadobject *thread)
        return true;
 }
 
+#endif
 
 /* threads_join_all_threads ****************************************************
 
index 99e6cb092470d944f8afcb8b416f94e5855ba6bf..58f7d845c755808d73318481742cd8c8f80e1a76 100644 (file)
@@ -77,14 +77,12 @@ typedef struct {
 
 #if defined(HAVE___THREAD)
 
-#define THREADSPECIFIC    __thread
 #define THREADOBJECT      thread_current
 
 extern __thread threadobject *thread_current;
 
 #else /* defined(HAVE___THREAD) */
 
-#define THREADSPECIFIC
 #define THREADOBJECT \
        ((threadobject *) pthread_getspecific(thread_current_key))
 
@@ -275,9 +273,11 @@ void threads_set_thread_priority(pthread_t tid, int priority);
 
 bool threads_detach_thread(threadobject *thread);
 
+#if defined(ENABLE_GC_CACAO)
 bool threads_suspend_thread(threadobject *thread, s4 reason);
 void threads_suspend_ack(u1* pc, u1* sp);
 bool threads_resume_thread(threadobject *thread);
+#endif
 
 void threads_join_all_threads(void);
 
@@ -287,11 +287,6 @@ void threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos);
 
 void threads_thread_interrupt(threadobject *thread);
 
-#if !defined(DISABLE_GC)
-void threads_stopworld(void);
-void threads_startworld(void);
-#endif
-
 #endif /* _THREAD_POSIX_H */
 
 
index 1a7880f4eb239b2a62d6073f05eaa6339395bcd0..e1e0c0aa367ab78cc340591af4697654520d8a04 100644 (file)
@@ -45,7 +45,7 @@
 # include "native/include/java_lang_ThreadGroup.h"
 #endif
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 # include "native/include/java_lang_VMThread.h"
 #endif
 
@@ -175,7 +175,7 @@ void threads_init(void)
 
        /* Cache the java.lang.Thread initialization method. */
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        thread_method_init =
                class_resolveclassmethod(class_java_lang_Thread,
@@ -184,7 +184,7 @@ void threads_init(void)
                                                                 class_java_lang_Thread,
                                                                 true);
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        thread_method_init =
                class_resolveclassmethod(class_java_lang_Thread,
@@ -193,7 +193,7 @@ void threads_init(void)
                                                                 class_java_lang_Thread,
                                                                 true);
 
-#elif defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
        thread_method_init =
                class_resolveclassmethod(class_java_lang_Thread,
@@ -233,7 +233,7 @@ static bool thread_create_object(threadobject *t, java_handle_t *name, java_hand
        java_handle_t    *o;
        java_lang_Thread *to;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_VMThread    *vmto;
        classinfo             *c;
        methodinfo            *m;
@@ -254,7 +254,7 @@ static bool thread_create_object(threadobject *t, java_handle_t *name, java_hand
 
        thread_set_object(t, (java_handle_t *) to);
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Create a java.lang.VMThread Java object. */
 
@@ -304,7 +304,7 @@ static bool thread_create_object(threadobject *t, java_handle_t *name, java_hand
        if (exceptions_get_exception())
                return false;
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        /* OpenJDK's java.lang.Thread does not have a VMThread field in
           the class.  Nothing to do here. */
@@ -323,7 +323,7 @@ static bool thread_create_object(threadobject *t, java_handle_t *name, java_hand
        if (exceptions_get_exception())
                return false;
 
-#elif defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
        /* Set the thread data-structure in the Java thread object. */
 
@@ -363,7 +363,7 @@ static bool thread_create_object(threadobject *t, java_handle_t *name, java_hand
 static void thread_create_initial_threadgroups(void)
 {
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Allocate and initialize the main thread group. */
 
@@ -376,7 +376,7 @@ static void thread_create_initial_threadgroups(void)
 
        threadgroup_system = threadgroup_main;
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        java_handle_t *name;
        methodinfo    *m;
@@ -651,7 +651,7 @@ void threads_thread_start(java_handle_t *object)
 {
        java_lang_Thread   *to;
        threadobject       *t;
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_VMThread *vmto;
 #endif
 
@@ -687,7 +687,7 @@ void threads_thread_start(java_handle_t *object)
 
        thread_set_object(t, object);
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Get the java.lang.VMThread object and do some sanity checks. */
 
@@ -698,11 +698,11 @@ void threads_thread_start(java_handle_t *object)
 
        LLNI_field_set_val(vmto, vmdata, (java_lang_Object *) t);
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        /* Nothing to do. */
 
-#elif defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
        LLNI_field_set_val(to, vm_thread, (java_lang_Object *) t);
 
@@ -828,9 +828,9 @@ void thread_fprint_name(threadobject *t, FILE *stream)
 {
        java_lang_Thread *to;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_String *name;
-#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
        java_chararray_t *name;
 #endif
 
@@ -841,11 +841,11 @@ void thread_fprint_name(threadobject *t, FILE *stream)
 
        LLNI_field_get_ref(to, name, name);
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        javastring_fprint((java_handle_t *) name, stream);
 
-#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
        /* FIXME: In OpenJDK and CLDC the name is a char[]. */
        /* FIXME This prints to stdout. */
@@ -1069,15 +1069,15 @@ void thread_set_state_terminated(threadobject *t)
 threadobject *thread_get_thread(java_handle_t *h)
 {
        threadobject       *t;
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_VMThread *vmto;
        java_lang_Object   *to;
 #endif
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        bool                equal;
 #endif
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        vmto = (java_lang_VMThread *) h;
 
@@ -1085,7 +1085,7 @@ threadobject *thread_get_thread(java_handle_t *h)
 
        t = (threadobject *) to;
 
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        /* XXX This is just a quick hack. */
 
@@ -1100,7 +1100,7 @@ threadobject *thread_get_thread(java_handle_t *h)
 
        threadlist_unlock();
 
-#elif defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
        log_println("threads_get_thread: IMPLEMENT ME!");
 
index c0d1ca816a4849538b28de7c923f933b20f04aee..81ea76412329c8d74e8a2a52a876aa52d973e5b5 100644 (file)
@@ -79,7 +79,7 @@ bool access_is_accessible_class(classinfo *referer, classinfo *cls)
        if (SAME_PACKAGE(referer, cls))
                return true;
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        /* Code for Sun's OpenJDK (see
           hotspot/src/share/vm/runtime/reflection.cpp
           (Reflection::verify_class_access)): Allow all accesses from
@@ -134,7 +134,7 @@ bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
        if (memberflags & ACC_PUBLIC)
                return true;
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        /* Code for Sun's OpenJDK (see
           hotspot/src/share/vm/runtime/reflection.cpp
           (Reflection::verify_class_access)): Allow all accesses from
index afa01d4b169e30d30f9d0f914beff20d0ebf13e8..6a1f0f694f13a8132d7b82ab7010f03db88e423a 100644 (file)
@@ -83,7 +83,7 @@ void assertion_ea_da(const char *name, bool enabled)
        if ((len > 2) && (strcmp(name + (len - 3), "...") == 0)) {
                package = true;
                assertion_package_count += 1;
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
                buf[len - 2] = '\0';
                buf[len - 3] = '/';
 #else
@@ -97,7 +97,7 @@ void assertion_ea_da(const char *name, bool enabled)
        len = system_strlen(buf);
 
        for (i = 0; i < len; i++) {
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
                if (buf[i] == '.') {
                        buf[i] = '/';
                }
index 2c6ff024ddad81c18b4997484c477006380cbfe5..6e0c10838155bac944f8427877302f4069f1a282 100644 (file)
@@ -65,11 +65,11 @@ void initialize_init(void)
        TRACESUBSYSTEMINITIALIZATION("initialize_init");
 
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Nothing. */
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        if (!initialize_class(class_java_lang_String))
                vm_abort("initialize_init: Initialization failed: java.lang.String");
index bcb7b9b59310a70d9eb92950e845c2cbfa92703f..f8cbcab9dcb7ecbfe8b2922ac58528c0b57e5d1f 100644 (file)
@@ -1444,6 +1444,7 @@ static void simplereg_allocate_temporaries(jitdata *jd)
                                case ICMD_FCONST:
                                case ICMD_DCONST:
                                case ICMD_ACONST:
+                               case ICMD_GETEXCEPTION:
 
                                        /* pop 0 push 1 load */
                                        
index 9cc8260996b94c8d72d0c5268c50dcb6c524a5f1..ab74f93191916df27626a28c60fec8cb74cd87c4 100644 (file)
@@ -502,6 +502,8 @@ void cfg_add_root(jitdata *jd) {
 
 #if defined(ENABLE_SSA)
 
+static void cfg_eliminate_edges_to_unreachable(jitdata *jd);
+
 /* cfg_add_exceptional_edges ***************************************************
  
    Edges from basicblocks to their exception handlers and from exception 
@@ -518,6 +520,7 @@ void cfg_add_exceptional_edges(jitdata *jd) {
        basicblock *bptr;
        instruction *iptr;
        exception_entry *ee;
+       bool unreachable_exh = false;
 
        /* Count the number of exceptional exits for every block.
         * Every PEI is an exceptional out.
@@ -525,6 +528,9 @@ void cfg_add_exceptional_edges(jitdata *jd) {
 
        FOR_EACH_BASICBLOCK(jd, bptr) {
 
+               /* Prepare for reachability calculation. */
+               bptr->vp = NULL;
+
                if (bptr->flags == BBUNDEF) {
                        continue;
                }
@@ -552,6 +558,14 @@ void cfg_add_exceptional_edges(jitdata *jd) {
        /* Allocate and fill exception handler arrays. */
 
        for (ee = jd->exceptiontable; ee; ee = ee->down) {
+
+               if (ee->handler->expredecessorcount == 0) {
+                       /* An exception handler that is unreachable.
+                          This is inconsistent with the semantics of the CFG,
+                          we need to recalculate reachability. */
+                       unreachable_exh = true;
+               }
+
                for (bptr = ee->start; bptr != ee->end; bptr = bptr->next) {
                        if (bptr->exouts > 0) {
 
@@ -576,8 +590,109 @@ void cfg_add_exceptional_edges(jitdata *jd) {
                        }
                }
        }
+
+       if (unreachable_exh) {
+
+               /* This is rare in ``normal'' compiler generated code.
+                 
+                  The dead block [EXH] is a predecessor of [BB1],
+                  but the edge [EXH] -> [BB1] will never be traversed.
+
+                  [BB1] --[next]--> [BB2, no peis] ==[exhandler]==> [EXH] --[next]--+
+             ^                                                               |
+                    +---------------------------------------------------------------+
+               */
+
+               /*
+               fprintf(stderr, "Found unreachable exh, adjusting %s %s", 
+                       jd->m->klazz->name->text, jd->m->name->text);
+               fprintf(stderr, "<before>\n");
+               show_method(jd, 3);
+               fprintf(stderr, "</before>\n");
+               */
+
+               cfg_eliminate_edges_to_unreachable(jd);
+
+               /*
+               fprintf(stderr, "<after>\n");
+               show_method(jd, 3);
+               fprintf(stderr, "</after>\n");
+               */
+       }
 }
 
+static void cfg_calculate_reachability(basicblock *bptr) {
+       basicblock **itsucc;
+
+       /* Block not marked. */
+       assert(bptr->vp == NULL);
+
+       bptr->vp = bptr; /* Mark block */
+
+       FOR_EACH_SUCCESSOR(bptr, itsucc) {
+               if ((*itsucc)->vp == NULL) {
+                       cfg_calculate_reachability(*itsucc);
+               }
+       }
+
+       if (bptr->exouts > 0) {
+               FOR_EACH_EXHANDLER(bptr, itsucc) {
+                       if ((*itsucc)->vp == NULL) {
+                               cfg_calculate_reachability(*itsucc);
+                       }
+               }
+       }
+}
+
+static void cfg_remove_predecessors(basicblock *bptr, basicblock *pbptr) {
+       s4 i;
+
+       for (i = 0; i < bptr->predecessorcount; ++i) {
+               /* Search item. */
+               if (bptr->predecessors[i] == pbptr) {
+                       if (i != (bptr->predecessorcount - 1)) {
+                               /* If not last element, replace element with last element. */
+                               bptr->predecessors[i] = bptr->predecessors[bptr->predecessorcount - 1];
+                       }
+
+                       /* Decrease element count. */
+                       bptr->predecessorcount -= 1;
+
+                       return;
+               }
+       }
+}
+
+static void cfg_eliminate_edges_to_unreachable(jitdata *jd) {
+       basicblock *it;
+       basicblock **itsucc;
+
+       cfg_calculate_reachability(jd->basicblocks);
+
+       FOR_EACH_BASICBLOCK(jd, it) {
+               if (it->vp == NULL) {
+
+                       /* Mark as unreachable. */
+
+                       it->flags = BBUNDEF;
+
+                       /* As this block got unreachable, it is no more a predecessor
+                          of its successors. */
+
+                       FOR_EACH_SUCCESSOR(it, itsucc) {
+                               cfg_remove_predecessors(*itsucc, it);
+                       }
+
+                       /* Eliminiate all CFG edges of this block. */
+
+                       it->predecessorcount = 0;
+                       it->successorcount = 0;
+                       it->expredecessorcount = 0;
+               }
+       }
+}
+
+
 #endif
 
 /*
index 4f438809f627ab56ea1f84f9c33240d06e784ac4..045a44c86123ca17d057f1fd734cfc1e887ac31a 100644 (file)
 #include "native/localref.h"
 #include "native/native.h"
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 # include "native/include/java_lang_Object.h"
 # include "native/include/java_lang_String.h"           /* required by j.l.CL */
 # include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
 # include "native/include/java_lang_ClassLoader.h"
 #endif
 
-#if defined(WITH_CLASSPATH_CLDC1_1)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 # include "native/include/java_lang_String.h"
 #endif
 
index d909a9b1d2c9655ef93f2f9beeb2c4c2396bd305..f8507a12652c03163a02a0ed1f810a827947b318 100644 (file)
@@ -443,11 +443,13 @@ bool codegen_emit(jitdata *jd)
                                var = VAR(bptr->invars[len]);
                                if (bptr->type != BBTYPE_STD) {
                                        if (!IS_2_WORD_TYPE(var->type)) {
+#if !defined(ENABLE_SSA)
                                                if (bptr->type == BBTYPE_EXH) {
                                                        d = codegen_reg_of_var(0, var, REG_ITMP1);
                                                        M_INTMOVE(REG_ITMP1, d);
                                                        emit_store(jd, NULL, var, d);
                                                }
+#endif
                                        } 
                                        else {
                                                log_text("copy interface registers(EXH, SBR): longs \
@@ -3418,6 +3420,13 @@ gen_method:
                        emit_store_dst(jd, iptr, s1);
                        break;
 
+#if defined(ENABLE_SSA)
+               case ICMD_GETEXCEPTION:
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       M_INTMOVE(REG_ITMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+#endif
                default:
                        exceptions_throw_internalerror("Unknown ICMD %d during code generation",
                                                                                   iptr->opc);
index 23f02b0650b6fceee22fb91b43e83b1a4728cd4b..4b0639cdcacf46728e7e4f977dba6e6d24b2a534 100644 (file)
 /*246*/ {N("UNDEF246       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
 /*247*/ {N("UNDEF247       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
 /*248*/ {N("UNDEF248       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*249*/ {N("UNDEF249       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
-/*250*/ {N("UNDEF250       ") DF_0_TO_0 , CF_NORMAL, 0              /* -- ()                   */},
+/*249*/ {N("GETEXCEPTION   ") DF_0_TO_1 , CF_NORMAL, 0              /* -- ()                   */},
+/*250*/ {N("PHI            ") DF_N_TO_1 , CF_NORMAL, 0              /* -- ()                   */},
 /*251*/ {N("INLINE_START   ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
 /*252*/ {N("INLINE_END     ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
 /*253*/ {N("INLINE_BODY    ") DF_0_TO_0 , CF_NORMAL, 0              /* S+ (--)                 */},
index ea9faea507a78b555716ad3f6522c667b906743f..eaf8672745da0ed93dbe229dee54e41bec022c4c 100644 (file)
@@ -640,7 +640,7 @@ static u1 *jit_compile_intern(jitdata *jd)
 
        RT_TIMING_GET_TIME(time_checks);
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        /* Code for Sun's OpenJDK (see
           hotspot/src/share/vm/classfile/verifier.cpp
           (Verifier::is_eligible_for_verification)): Don't verify
@@ -684,12 +684,6 @@ static u1 *jit_compile_intern(jitdata *jd)
 
                DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
 
-               /* Build the CFG.  This has to be done after stack_analyse, as
-                  there happens the JSR elimination. */
-
-               if (!cfg_build(jd))
-                       return NULL;
-
 #ifdef ENABLE_VERIFIER
                if (JITDATA_HAS_FLAG_VERIFY(jd)) {
                        DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
@@ -706,6 +700,16 @@ static u1 *jit_compile_intern(jitdata *jd)
 #endif
                RT_TIMING_GET_TIME(time_typecheck);
 
+#if defined(ENABLE_SSA)
+               fix_exception_handlers(jd);
+#endif
+
+               /* Build the CFG.  This has to be done after stack_analyse, as
+                  there happens the JSR elimination. */
+
+               if (!cfg_build(jd))
+                       return NULL;
+
 #if defined(ENABLE_LOOP)
                if (opt_loops) {
                        depthFirst(jd);
@@ -763,7 +767,12 @@ static u1 *jit_compile_intern(jitdata *jd)
 # endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
 #if defined(ENABLE_SSA)
                /* allocate registers */
-               if ((opt_lsra) /*&& (strcmp(jd->m->name->text, "findClass") == 0 || jd->exceptiontablelength == 0)*/) {
+               if (
+                       (opt_lsra) 
+                       /*&& strncmp(jd->m->name->text, "banana", 6) == 0*/
+                       /*&& jd->exceptiontablelength == 0*/
+               ) {
+                       /* printf("=== %s ===\n", jd->m->name->text); */
                        jd->ls = DNEW(lsradata);
                        jd->ls = NULL;
                        ssa(jd);
index f45733fe18f76c3afaa8336e651c7a864139c727..a09c01e122e2b8a2aa703422ce3be833f8623594 100644 (file)
@@ -247,7 +247,13 @@ static inline bool var_is_prealloc(const jitdata *jd, s4 i) {
 
 static inline bool var_is_inout(const jitdata *jd, s4 i) {
        const varinfo *v = jd->var + i;
-       return ((i >= jd->localcount) && !(v->flags & PREALLOC) && (v->flags & INOUT));
+       return (
+               (i >= jd->localcount) && (
+                       (!(v->flags & PREALLOC) && (v->flags & INOUT)) ||
+                       /* special case of TYPE_RET, used with JSR */
+                       ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET))
+               )
+       );
 }
 
 static inline bool var_is_temp(const jitdata *jd, s4 i) {
@@ -294,6 +300,7 @@ typedef union {
     s4                         tablelow;         /* for TABLESWITCH           */
     u4                         lookupcount;      /* for LOOKUPSWITCH          */
        s4                         retaddrnr;        /* for ASTORE                */
+       instruction              **iargs;            /* for PHI                   */
 } s2_operand_t;
 
 /*** s3 operand ***/
@@ -522,8 +529,6 @@ struct basicblock {
        s4            expredecessorcount;
        s4            exouts;       /* Number of exceptional exits */
 
-       basicblock   *subbasicblocks;
-
        void         *vp;           /* Freely used by different passes            */
 #endif
 };
@@ -948,6 +953,9 @@ enum {
        ICMD_IMULPOW2         = 214,
        ICMD_LMULPOW2         = 215,
 
+       ICMD_GETEXCEPTION     = 249,
+       ICMD_PHI              = 250,
+
        ICMD_INLINE_START     = 251,        /* instruction before inlined method  */
        ICMD_INLINE_END       = 252,        /* instruction after inlined method   */
        ICMD_INLINE_BODY      = 253,        /* start of inlined body              */
index aa9c2f4ccd7dbd77558fa7b1f116907f08013067..721323e4bb0df7409dca7d2981c95c6da8c458c1 100644 (file)
@@ -123,15 +123,16 @@ void ssa(jitdata *jd) {
        /*dominator_tree_validate(jd, dd);*/
        /*pythonpass_run(jd, "ssa2", "main");*/
        /*pythonpass_run(jd, "alt_ssa", "main");*/
-       pythonpass_run(jd, "foo", "before");
-       if (getenv("XSSA")) {
+       /*pythonpass_run(jd, "foo", "before");*/
+       
+       /*if (getenv("XSSA")) {
                dominator_tree_build(jd);
                dominance_frontier_build(jd);
                xssa(jd);
-       } else {
+       } else */{
                yssa(jd);
        }
-       pythonpass_run(jd, "foo", "after");
+       /*pythonpass_run(jd, "foo", "after");*/
        return;
 
        ls = jd->ls;
index 05aa36fd22111a5522e977dba5e11dc2d6bb25c7..fb48421e21335dcce7765f9380b2df740c99f38d 100644 (file)
    TODO
 
    * Adapt for exception handling [done]
-   * Eliminiation of redundand PHI functions
+   * Eliminiation of redundand PHI functions. [in progress]
+   * Handle also inout variables. [done]
    * Create PHI functions lazyly, when they are used for the first time
      (I suspect that currently PHIs are created that are never used).
-   * REWRITE. The code was never designed for producion.
+   * REWRITE. The code was never designed for producion. [done]
+   * Unify access to phi args.
 */
 
 #include "vm/jit/jit.h"
 #include "mm/dumpmemory.h"
 #include "toolbox/list.h"
 
-#if 1
-static inline bool test_do_verbose(jitdata *jd) { 
-       return strcmp(jd->m->name->text, "close") == 0 &&
-               strcmp(jd->m->clazz->name->text, "antlr/PreservingFileWriter") == 0;
-}
-static bool do_verbose = 0;
-#define WHEN do_verbose
-#define printf(...) do { if (WHEN) printf(__VA_ARGS__); } while (0)
-#define show_method(...) do { if (WHEN) show_method(__VA_ARGS__); } while (0)
-#define show_basicblock(...) do { if (WHEN) show_basicblock(__VA_ARGS__); } while (0)
-#endif
+#include <limits.h>
+#include <stdio.h>
+
+#define ELIMINATE_NOP_LOAD_STORE
+#define FIXME(x) x
+#define SSA_VERIFY
+/* #define SSA_VERBOSE */
 
 /*
-TODO
-move set and get uses into jit.h
+__attribute__((always_inline))
 */
 
-#define ICMD_PHI 666
+/*** phi ********************************************************************/
 
-#define eqi(a, b) (((a) && (b) || (!(a) && !(b)))
+typedef enum {
+       PHI_FLAG_USED,
+       PHI_FLAG_REDUNDANT_ALL,
+       PHI_FLAG_REDUNDANT_ONE
+} phi_flags_t;
 
-#define nn(x) ((x) < 0 ? 0 : (x))
+static inline void phi_set_flag(instruction *iptr, phi_flags_t flag) {
+       iptr->flags.bits |= (1 << flag);        
+}
 
-#define ass(dst, src) *(dst) = *(src)
+static inline void phi_clear_flag(instruction *iptr, phi_flags_t flag) {
+       iptr->flags.bits &= ~(1 << flag);       
+}
 
-static inline const char *instruction_name(const instruction *iptr) {
-       if (iptr == NULL) {
-               return "null";
-       } else if (iptr->opc == ICMD_PHI) {
-               return "phi";
-       } else {
-               return icmd_table[iptr->opc].name;
-       }
+static inline bool phi_has_flag(const instruction *iptr, phi_flags_t flag) {
+       return (iptr->flags.bits & (1 << flag)) != 0;
 }
 
-static inline s4 instruction_line(const instruction *iptr) {
-       if (iptr == NULL) {
-               return -1;
-       } else {
-               return iptr->line;
-       }
+static inline instruction *phi_get_subst(instruction *iptr) {
+       return iptr->sx.s23.s2.iargs[-1];
 }
 
-typedef struct phi_function {
-       s4 dst;
-       s4 *args;
-       s4 local;
-       instruction instr;
-} phi_function;
+static inline bool phi_has_subst(const instruction *iptr) {
+       return (iptr->sx.s23.s2.iargs[-1] != NULL);
+}
 
-typedef struct basicblock_info {
-       bool visited;
-       bool active;
-       bool traversed;
-       unsigned backward_branches;
 
-       instruction **state_array;
+static inline void phi_init(instruction *iptr, unsigned argcount, s4 index) {
+       unsigned i;
 
-       unsigned phi_count;
-       unsigned phi_max;
-       phi_function *phi_functions;
-       unsigned complete_predecessors;
-       bool cow;
-} basicblock_info;
+       iptr->opc = ICMD_PHI;
+       iptr->flags.bits = 0;
+       iptr->dst.varindex = 0;
+       iptr->s1.argcount = argcount;
+       iptr->sx.s23.s2.iargs = DMNEW(instruction *, argcount + 1);
+       iptr->sx.s23.s2.iargs += 1;
+       iptr->sx.s23.s3.javaindex = index;
+
+       /* subst field - If non-null, the phi function shall be replaced by the 
+          value produced by the subst instruction. */
+       iptr->sx.s23.s2.iargs[-1] = NULL;
+
+#if !defined(NDEBUG)
+       for (i = 0; i < argcount; ++i) {
+               iptr->sx.s23.s2.iargs[i] = (instruction *)0x7fffffff;
+       }
+#endif
+}
 
-typedef struct ssa_info {
-       jitdata *jd;
+#define phi_assert_opc(iptr) assert(iptr->opc == ICMD_PHI)
 
-       varinfo locals[3000]; /* XXX hardcoded max */
-       unsigned max_locals;
-       unsigned locals_count;
+#define phi_assert_arg(iptr, arg) assert(arg < iptr->s1.argcount)
 
-       s4 s_buf[3];
-} ssa_info;
+static inline s4 phi_arg_count(const instruction *iptr) {
+       phi_assert_opc(iptr);
+       return iptr->s1.argcount;
+}
 
-static unsigned get_predecessor_count(basicblock *bb) {
-       unsigned ret;
-       basicblock **itpred;
+static inline instruction *phi_get_arg(const instruction *iptr, unsigned arg) {
+       phi_assert_opc(iptr);
+       phi_assert_arg(iptr, arg);
+       return iptr->sx.s23.s2.iargs[arg];
+}
 
-       ret = nn(bb->predecessorcount);
+static inline s4 phi_get_arg_var(const instruction *iptr, unsigned arg) {
+       phi_assert_opc(iptr);
+       phi_assert_arg(iptr, arg);
+       return iptr->sx.s23.s2.iargs[arg]->dst.varindex;
+}
 
-       FOR_EACH_EXPREDECESSOR(bb, itpred) {
-               ret += (*itpred)->exouts;
+static inline void phi_set_all_args(instruction *iptr, instruction *value) {
+       unsigned i;
+       phi_assert_opc(iptr);
+       for (i = 0; i < iptr->s1.argcount; ++i) {
+               iptr->sx.s23.s2.iargs[i] = value;
        }
+}
 
-       return ret;
+static inline s4 phi_get_index(const instruction *iptr) {
+       phi_assert_opc(iptr);
+       return iptr->sx.s23.s3.javaindex;
 }
 
-static unsigned get_predecessor_index(basicblock *from, basicblock *to) {
-       basicblock **itpred;
-       unsigned j = 0;
+static inline s4 phi_get_dst(const instruction *iptr) {
+       phi_assert_opc(iptr);
+       return iptr->dst.varindex;
+}
 
-       for (itpred = to->predecessors; itpred != to->predecessors + nn(to->predecessorcount); ++itpred) {
-               if (*itpred == from) break;
-               j++;
+static inline void phi_set_dst(instruction *iptr, s4 dst) {
+       phi_assert_opc(iptr);
+       iptr->dst.varindex = dst;
+}
+
+static inline bool phi_get_used(const instruction *iptr) {
+       phi_assert_opc(iptr);
+       return phi_has_flag(iptr, PHI_FLAG_USED);
+}
+
+static void phi_set_used(instruction *iptr) {
+       phi_assert_opc(iptr);
+       if (! phi_has_flag(iptr, PHI_FLAG_USED)) {
+               phi_set_flag(iptr, PHI_FLAG_USED);
+               /* TODO recurse into arguments */
        }
-       
-       if (j == nn(to->predecessorcount)) {
-               assert(j != nn(to->predecessorcount));
+}
+
+static instruction *phi_resolve_use(instruction *use) {
+       if (use != NULL) {
+               while (use->opc == ICMD_PHI) {
+                       if (phi_has_subst(use)) {
+                               use = phi_get_subst(use);
+                       } else {
+                               break;
+                       }
+               }
        }
+       return use;
+}
 
-       return j;
+static inline void phi_set_arg(instruction *iptr, unsigned arg, instruction *value) {
+       phi_assert_opc(iptr);
+       phi_assert_arg(iptr, arg);
+       assert(value != NULL);
+       iptr->sx.s23.s2.iargs[arg] = value;
 }
 
-static void phi_set_argument(basicblock *bb, instruction *phi, unsigned j, instruction *value) {
-       phi_function *pf = (phi_function *)(
-               (char *)phi - OFFSET(phi_function, instr)
+static inline bool phi_is_redundant(const instruction *iptr) {
+       return (
+               phi_has_flag(iptr, PHI_FLAG_REDUNDANT_ONE) || 
+               phi_has_flag(iptr, PHI_FLAG_REDUNDANT_ALL)
        );
-       assert(j < phi->s1.argcount);
-       if (value == NULL) {
-               pf->args[j] = pf->local;
-       } else {
-               pf->args[j] = value->dst.varindex;
-       }
-       /*phi->sx.s23.s2.args[j] = value->dst.varindex;*/
-       printf(" *** in bb%d setting phi arg %d for local %d to %s@%d (%d)\n", bb->nr, j, pf->local, instruction_name(value), instruction_line(value), value ? value->dst.varindex : -1);
 }
 
-static inline basicblock_info *bb_info(basicblock *bb) {
-       return (basicblock_info *)(bb->vp);
+static inline void phi_create_copy(instruction *iptr, unsigned arg, instruction *copy) {
+       phi_assert_opc(iptr);
+       phi_assert_arg(iptr, arg);
+       copy->dst.varindex = phi_get_dst(iptr);
+       copy->s1.varindex = phi_resolve_use(phi_get_arg(iptr, arg))->dst.varindex;
+       if (copy->dst.varindex == copy->s1.varindex || phi_is_redundant(iptr)) {
+               copy->opc = ICMD_NOP;
+       } else {
+               copy->opc = ICMD_COPY;
+       }
 }
 
-static void mark_loops(basicblock *bb) {
-       basicblock_info *bbi = bb_info(bb);
-       basicblock **itsucc;
-
-       if (! bbi->visited) {
-               bbi->visited = true;
-               bbi->active = true;
-               FOR_EACH_SUCCESSOR(bb, itsucc) {
-                       mark_loops(*itsucc);
-               }
-               FOR_EACH_EXHANDLER(bb, itsucc) {
-                       mark_loops(*itsucc);
+#if !defined(NDEBUG)
+static void phi_print(const instruction *iptr) {
+       unsigned i;
+       instruction *use;
+       printf("%d = phi(", iptr->dst.varindex);
+       for (i = 0; i < iptr->s1.argcount; ++i) {
+               use = phi_resolve_use(iptr->sx.s23.s2.iargs[i]);
+               if (use) {
+                       printf("%d, ", use->dst.varindex);
+               } else {
+                       printf("null, ");
                }
-               bbi->active = false;
-       } else if (bbi->active) {
-               bbi->backward_branches += 1;
        }
+       printf(")\n");
 }
+#endif
 
-static instruction *create_phi(ssa_info *ssa, basicblock *bb, s4 local) {
-       basicblock_info *bbi = bb_info(bb);
-       phi_function *phi;
-       s4 *itarg;
-       unsigned arg_count = get_predecessor_count(bb);
-
-       printf(" *** BB%d phi #%d for local %d\n", bb->nr, bbi->phi_count, local);
+#define FOR_EACH_PHI_USE_CAST(iptr, it, cast) \
+       for ( \
+               (it) = cast (iptr)->sx.s23.s2.iargs; \
+               (it) != cast (iptr)->sx.s23.s2.iargs + (iptr)->s1.argcount; \
+               ++(it) \
+       )
 
-       phi = bbi->phi_functions + bbi->phi_count;
-       assert(bbi->phi_count < bbi->phi_max);
-       bbi->phi_count += 1;
+#define FOR_EACH_PHI_USE(iptr, it) \
+       FOR_EACH_PHI_USE_CAST(iptr, it, )
 
+#define FOR_EACH_PHI_USE_CONST(iptr, it) \
+       FOR_EACH_PHI_USE_CAST(iptr, it, (const instruction *))
 
-       phi->local = local;
-       phi->args = DMNEW(s4, arg_count);
-       for (itarg = phi->args; itarg != phi->args + arg_count; ++itarg) {
-               /* Invalidate */
-               *itarg = 0x7fffffff;
-       }
+static void phi_calculate_redundancy(instruction *iptr) {
 
-       assert(ssa->locals_count < ssa->max_locals);
-       ssa->locals[ssa->locals_count] = ssa->jd->var[local];
-       phi->dst = ssa->locals_count;
-       ssa->locals_count += 1;
+       s4 dst = iptr->dst.varindex;
+       s4 use;
+       instruction *iuse;
+       instruction **ituse;
+       unsigned num_different = 0;
+       instruction *different;
 
-       phi->instr.opc = ICMD_PHI;
-       phi->instr.dst.varindex = phi->dst;
-       phi->instr.s1.argcount = arg_count;
-       phi->instr.sx.s23.s2.args = NULL;
+       if (phi_is_redundant(iptr)) return; /* XXX */
 
-       return &(phi->instr);
-}
+       /* x = phi(x, y, x, x) ... PHI_FLAG_REDUNDANT_ONE
+          x = phi(x, x, x, x) ... PHI_FLAG_REDUNDANT_ALL */
 
-static bool is_my_phi(basicblock *bb, instruction *iptr) {
-       basicblock_info *bbi = bb_info(bb);
-       if (iptr == NULL) {
-               return false;
-       }
-       if (iptr->opc != ICMD_PHI) {
-               return false;
-       }
-       if (    
-               ((char *)bbi->phi_functions <= (char *)iptr) &&
-               ((char *)iptr < (char *)(bbi->phi_functions + bbi->phi_count))
-       ) {
-               return true;
-       } else {
-               return false;
-       }
-}
+       FOR_EACH_PHI_USE(iptr, ituse) {
+               iuse = phi_resolve_use(*ituse);
+               assert(iuse);
 
-static void rename_def(ssa_info *ssa, basicblock *bptr, instruction *iptr) {
-       basicblock_info *bbi = bb_info(bptr);
-       assert(bbi->state_array);
+               use = iuse->dst.varindex;
 
-       bbi->state_array[iptr->dst.varindex] = iptr;
+               if (use != dst) {
+                       different = *ituse;
+                       num_different += 1;
+                       if (num_different >= 2) {
+                               phi_clear_flag(iptr, PHI_FLAG_REDUNDANT_ONE);
+                               phi_clear_flag(iptr, PHI_FLAG_REDUNDANT_ALL);
+                       }
+               }
+       }
 
-       assert(ssa->locals_count < ssa->max_locals);
+       if (num_different == 1) {
+               /* Set the subst field of the instruction.
+                  I.e. the instruction will be replaced by the value produced by y. */
+               iptr->sx.s23.s2.iargs[-1] = different;
 
-       ssa->locals[ssa->locals_count] = ssa->jd->var[iptr->dst.varindex];
-       iptr->dst.varindex = ssa->locals_count;
-       printf(" *** BB%d %s def %d => %d\n", bptr->nr, instruction_name(iptr), iptr->dst.varindex, ssa->locals_count);
+               phi_set_flag(iptr, PHI_FLAG_REDUNDANT_ONE);
+               phi_clear_flag(iptr, PHI_FLAG_REDUNDANT_ALL);
+       } else if (num_different == 0) {
+               assert(0);
+               /*iptr->sx.s23.s2.iargs[-1] = iptr->sx.s23.s2.iargs[0];*/
 
-       ssa->locals_count += 1;
+               phi_clear_flag(iptr, PHI_FLAG_REDUNDANT_ONE);
+               phi_clear_flag(iptr, PHI_FLAG_REDUNDANT_ALL);
+               /*assert(0);*/
+       }
 }
 
-static void rename_use(ssa_info *ssa, basicblock *bptr, instruction *iptr, s4 *use) {
-       basicblock_info *bbi = bb_info(bptr);
-       assert(bbi->state_array);
 
-       if (bbi->state_array[*use] != NULL) {
-               printf(" *** BB%d %s use %d => %d (%s) \n", bptr->nr, instruction_name(iptr), *use, bbi->state_array[*use]->dst.varindex, instruction_name(bbi->state_array[*use]) );
-               *use = bbi->state_array[*use]->dst.varindex;
-       } else {
-               printf(" *** BB%d %s use keep\n", bptr->nr, instruction_name(iptr));
-       }
+/*** goto *******************************************************************/
+
+static inline void goto_init(instruction *iptr, basicblock *dst) {
+       iptr->opc = ICMD_GOTO;
+       iptr->dst.block = dst;
 }
 
-static void get_uses(ssa_info *ssa, instruction *iptr, s4 **puses, unsigned *puses_count) {
+/*** instruction ***********************************************************/
+
+static void instruction_get_uses(const instruction *iptr, s4 *buf, s4 **puses, unsigned *puses_count) {
        unsigned uses_count = 0;
 
        switch (icmd_table[iptr->opc].dataflow) {
                case DF_3_TO_0:
                case DF_3_TO_1:
-                       ssa->s_buf[2] = iptr->sx.s23.s3.varindex;
+                       buf[2] = iptr->sx.s23.s3.varindex;
                        uses_count += 1;
 
                case DF_2_TO_0:
                case DF_2_TO_1:
-                       ssa->s_buf[1] = iptr->sx.s23.s2.varindex;
+                       buf[1] = iptr->sx.s23.s2.varindex;
                        uses_count += 1;
 
                case DF_1_TO_0:
                case DF_1_TO_1:
                case DF_COPY:
                case DF_MOVE:
-                       ssa->s_buf[0] = iptr->s1.varindex;
+                       buf[0] = iptr->s1.varindex;
                        uses_count += 1;
 
                        *puses_count = uses_count;
-                       *puses = ssa->s_buf;
+                       *puses = buf;
                        break;
        
                case DF_N_TO_1:
@@ -301,459 +330,1421 @@ static void get_uses(ssa_info *ssa, instruction *iptr, s4 **puses, unsigned *pus
        }
 }
 
-static void set_uses(ssa_info *ssa, instruction *iptr, s4 *uses, unsigned uses_count) {
-       if (uses == ssa->s_buf) {
+static inline void instruction_set_uses(instruction *iptr, s4 *buf, s4 *uses, unsigned uses_count) {
+       if (uses == buf) {
                switch (uses_count) {
                        case 3:
-                               iptr->sx.s23.s3.varindex = ssa->s_buf[2];
+                               iptr->sx.s23.s3.varindex = buf[2];
                        case 2:
-                               iptr->sx.s23.s2.varindex = ssa->s_buf[1];
+                               iptr->sx.s23.s2.varindex = buf[1];
                        case 1:
-                               iptr->s1.varindex = ssa->s_buf[0];
+                               iptr->s1.varindex = buf[0];
                }
        }
 }
 
-typedef void (*traverse_fun)(ssa_info *ssa, basicblock *bb);
+/*** vars *******************************************************************/
+
+#define VARS_CATEGORY_SHIFT 29
+#define VARS_INDEX_MASK 0x1FFFFFFF
+
+#define VARS_CATEGORY_LOCAL 0
+#define VARS_CATEGORY_STACK 1
+#define VARS_CATEGORY_OTHERS 2
+
+#define VAR_TYPE_SUBSTITUED 666
+
+typedef struct {
+       varinfo items[9000]; /* XXX hardcoded max */
+       unsigned max;
+       unsigned count;
+       unsigned category;
+} vars_t;
+
+static inline unsigned vars_add_item(vars_t *vs, const varinfo *item) {
+       unsigned i = vs->count;
+       assert(i < vs->max);
+       vs->count += 1;
+       vs->items[i] = *item;
+       return (vs->category << VARS_CATEGORY_SHIFT) | i;
+}
+
+static inline unsigned vars_add(vars_t *vs) {
+       unsigned i = vs->count;
+       assert(i < vs->max);
+       vs->count += 1;
+       return (vs->category << VARS_CATEGORY_SHIFT) | i;
+}
+
+static inline varinfo *vars_back(vars_t *vs) {
+       assert(vs->count > 0);
+       return vs->items + (vs->count - 1);
+}
+
+static inline void vars_init(vars_t *vs, unsigned category) {
+       vs->max = sizeof(vs->items) / sizeof(vs->items[0]);
+       vs->count = 0;
+       assert((category & 0x3) == category);
+       vs->category = category;
+}
+
+static inline unsigned vars_get_category(unsigned varindex) {
+       return (varindex >> VARS_CATEGORY_SHIFT);
+}
+
+static inline unsigned vars_get_index(unsigned varindex) {
+       return (varindex & VARS_INDEX_MASK);
+}
+
+static void vars_subst(vars_t *vs, unsigned varindex, unsigned replacementindex) {
+       varindex = vars_get_index(varindex);
+       replacementindex = vars_get_index(replacementindex);
+
+       vs->items[varindex].type = VAR_TYPE_SUBSTITUED;
+       vs->items[varindex].vv.regoff = replacementindex;
+}
+
+static unsigned vars_resolve_subst(const vars_t *vs, unsigned varindex) {
+#if !defined(NDEBUG)
+       unsigned loop_ctr = 0;
+#endif
+       varindex = vars_get_index(varindex);
+
+       if (vs->items[varindex].type == VAR_TYPE_SUBSTITUED) /*fprintf(stderr, "*")*/;
+
+       while (vs->items[varindex].type == VAR_TYPE_SUBSTITUED) {
+               assert(loop_ctr++ != vs->count);
+               varindex = vs->items[varindex].vv.regoff;
+       }
+
+       return (vs->category << VARS_CATEGORY_SHIFT) | varindex ;
+}
+
+static void vars_copy_to_final(vars_t *vs, varinfo *dst) {
+       const varinfo *it;
+       unsigned subst;
+
+       for (it = vs->items; it != vs->items + vs->count; ++it, ++dst) {
+
+               /* Copy variable. */
+
+               *dst = *it;
+
+               /* Eliminate VAR_TYPE_SUBSTITUED as it leads to problems. */
+
+               if (dst->type == VAR_TYPE_SUBSTITUED) {
+                       subst = vars_get_index(vars_resolve_subst(vs, it - vs->items));
+                       dst->type = vs->items[subst].type;
+               }
+       }
+}
+
+
+/*** phis *******************************************************************/
+
+typedef struct {
+       instruction *items;
+       unsigned max;
+       unsigned count;
+} phis_t;
+
+static inline void phis_init(phis_t *ps, unsigned max) {
+       ps->max = max;
+       ps->count = 0;
+       ps->items = DMNEW(instruction, max);
+}
+
+static inline instruction *phis_add(phis_t *ps) {
+       unsigned i = ps->count;
+       assert(i < ps->max);
+       ps->count += 1;
+       return ps->items + i;
+}
+
+static inline instruction *phis_get(const phis_t *ps, unsigned i) {
+       assert(i < ps->count);
+       return ps->items + i;
+}
+
+static inline bool phis_contains(const phis_t *ps, const instruction *phi) {
+       return (ps->items <= phi) && (phi < (ps->items + ps->max));
+}
+
+#define FOR_EACH_PHI_FUNCTION_(ps, it) \
+       for ((it) = (ps)->items; (it) != (ps)->items + (ps)->count; ++(it)) \
+
+#define FOR_EACH_PHI_FUNCTION(ps, it) \
+               FOR_EACH_PHI_FUNCTION_(ps, it) if (!phi_is_redundant((it)))
+
+#if !defined(NDEBUG)
+FIXME() inline void phis_print(const phis_t *ps) {
+       const instruction *iptr;
+       FOR_EACH_PHI_FUNCTION(ps, iptr) {
+               phi_print(iptr);
+       }
+}
+#endif
+
+/*** state_array ************************************************************/
+
+typedef struct {
+       instruction **items;
+       unsigned count;
+} state_array_t;
+
+static inline void state_array_init(state_array_t *sa, unsigned count) {
+       sa->items = NULL;
+       sa->count = count;
+}
+
+static inline bool state_array_has_items(const state_array_t *sa) {
+       return (sa->items != NULL);
+}
+
+static inline s4 state_array_get_var(const state_array_t *sa, unsigned index) {
+       assert(index < sa->count);
+       assert(sa->items[index]);
+       return sa->items[index]->dst.varindex;
+}
+
+static inline instruction *state_array_get(const state_array_t *sa, unsigned index) {
+       assert(index < sa->count);
+       return sa->items[index];
+}
+
+static inline void state_array_set(const state_array_t *sa, unsigned index, instruction *value) {
+       assert(index < sa->count);
+       sa->items[index] = value;
+}
+
+static inline void state_array_copy(state_array_t *sa, state_array_t *other) {
+       assert(sa->count == other->count);
+       MCOPY(sa->items, other->items, instruction *, sa->count);
+}
+
+#define state_array_assert_items(sa) assert(state_array_has_items(sa) || (sa->count == 0))
+#define state_array_assert_no_items(sa) assert(! state_array_has_items(sa))
+
+static inline void state_array_allocate_items(state_array_t *sa) {
+       sa->items = DMNEW(instruction *, sa->count);
+       MZERO(sa->items, instruction *, sa->count);
+}
+
+/*** basicblock_chain *******************************************************/
+
+typedef struct {
+       basicblock *first;
+       basicblock *last;
+} basicblock_chain_t;
+
+static void basicblock_chain_init(basicblock_chain_t *bbc) {
+       bbc->first = NULL;
+       bbc->last = NULL;
+}
+
+#define basicblock_chain_clear basicblock_chain_init
+
+static void basicblock_chain_add(basicblock_chain_t *bbc, basicblock *bb) {
+       if (bbc->first == NULL) {
+               assert(bbc->last == NULL);
+               assert(bb->next == NULL);
+               bbc->first = bb;
+               bbc->last = bb;
+       } else {
+               assert(bbc->last->next == NULL);
+               bbc->last->next = bb;
+               bbc->last = bb;
+       }
+}
+
+static inline basicblock *basicblock_chain_front(basicblock_chain_t *bbc) {
+       assert(bbc->first);
+       return bbc->first;
+}
+
+static inline basicblock *basicblock_chain_back(basicblock_chain_t *bbc) {
+       assert(bbc->last);
+       return bbc->last;
+}
+
+static inline bool basicblock_chain_empty(const basicblock_chain_t *bbc) {
+       return bbc->first == NULL;
+}
+
+/*** exception_entry_chain ***************************************************/
+
+typedef struct {
+       exception_entry *first;
+       exception_entry *last;
+} exception_entry_chain_t;
+
+static void exception_entry_chain_init(exception_entry_chain_t *eec) {
+       eec->first = NULL;
+       eec->last = NULL;
+}
+
+#define exception_entry_chain_clear exception_entry_chain_init
+
+static void exception_entry_chain_add(exception_entry_chain_t *eec, exception_entry *ee) {
+       if (eec->first == NULL) {
+               eec->first = ee;
+               eec->last = ee;
+       } else {
+               eec->last->next = ee;
+               eec->last->down = ee;
+               eec->last = ee;
+       }
+}
+
+static inline bool exception_entry_chain_empty(const exception_entry_chain_t *eec) {
+       return eec->first == NULL;
+}
+
+static inline exception_entry *exception_entry_chain_back(exception_entry_chain_t *eec) {
+       assert(eec->last);
+       return eec->last;
+}
+
+static inline exception_entry *exception_entry_chain_front(exception_entry_chain_t *eec) {
+       assert(eec->first);
+       return eec->first;
+}
+
+/*** traversal **************************************************************/
+
+typedef struct {
+       unsigned (*var_num_to_index)(void *vp, s4 var);
+       varinfo *(*index_to_initial_var)(void *vp, unsigned index);
+       varinfo *(*var_num_to_varinfo)(void *vp, s4 var);
+       unsigned (*variables_count)(void *vp);
+} traversal_ops_t;
+
+typedef struct {
+       phis_t *phis;
+       state_array_t *state_array;
+       void *ops_vp;
+       traversal_ops_t *ops;
+} traversal_t;
+
+/*** basicblock_info ********************************************************/
+
+typedef struct basicblock_info {
+       bool visited;
+       bool active;
+       bool traversed;
+       unsigned backward_branches;
+
+       traversal_t *locals;
+       traversal_t *stack;
+
+       basicblock_chain_t *subbasicblocks;
+
+       unsigned complete_predecessors;
+
+#if defined(SSA_VERIFY)
+       unsigned num_phi_elimination;
+#endif
+
+} basicblock_info_t;
+
+/*** traversal **************************************************************/
+
+void traversal_init(traversal_t *t, unsigned count, void *ops_vp, traversal_ops_t *ops) {
+       t->phis = DNEW(phis_t);
+       phis_init(t->phis, count);
+
+       t->state_array = DNEW(state_array_t);
+       state_array_init(t->state_array, count);
+
+       t->ops_vp = ops_vp;
+       t->ops = ops;
+}
+
+instruction *traversal_create_phi(traversal_t *t, vars_t *v, unsigned argcount, s4 index) {
+       instruction *phi = phis_add(t->phis);
+       s4 dst;
+
+       phi_init(phi, argcount, index);
+       dst = vars_add_item(v, t->ops->index_to_initial_var(t->ops_vp, index));
+       phi_set_dst(phi, dst);
+
+       state_array_set(t->state_array, index, phi);
+
+       return phi;
+}
+
+static void traversal_rename_def(traversal_t *t, vars_t *vars, instruction *iptr) {
+       const varinfo *v;
+       unsigned index;
+
+       state_array_assert_items(t->state_array);
+
+       v = t->ops->var_num_to_varinfo(t->ops_vp, iptr->dst.varindex);
+       index = t->ops->var_num_to_index(t->ops_vp, iptr->dst.varindex);
 
-static void traverse(ssa_info *ssa, basicblock *bb, traverse_fun fun) {
-       basicblock_info *bbi = bb_info(bb);
-       basicblock **itsucc, **itpred;
-       basicblock_info *succi;
-       unsigned complete_preds;
+       iptr->dst.varindex = vars_add_item(vars, v);
+       state_array_set(t->state_array, index, iptr);
+}
+
+static void traversal_rename_use(traversal_t *t, s4 *puse) {
+       unsigned index;
+
+       state_array_assert_items(t->state_array);
+
+       index = t->ops->var_num_to_index(t->ops_vp, *puse);
+
+       assert(state_array_get(t->state_array, index));
+       *puse = state_array_get_var(t->state_array, index);
+}
+
+static inline unsigned traversal_variables_count(traversal_t *t) {
+       return t->ops->variables_count(t->ops_vp);
+}
+
+unsigned local_var_num_to_index(void *vp, s4 var) {
+       return (unsigned)var;
+}
+
+varinfo *local_index_to_initial_var(void *vp, unsigned index) {
+       jitdata *jd = (jitdata *)vp;
+       return jd->var + index;
+}
+
+varinfo *local_var_num_to_varinfo(void *vp, s4 var) {
+       jitdata *jd = (jitdata *)vp;
+       return jd->var + var;
+}
+
+unsigned local_variables_count(void *vp) {
+       jitdata *jd = (jitdata *)vp;
+       return jd->localcount;
+}
+
+traversal_ops_t traversal_local_ops = {
+       local_var_num_to_index,
+       local_index_to_initial_var,
+       local_var_num_to_varinfo,
+       local_variables_count
+};
+
+unsigned inout_var_num_to_index(void *vp, s4 var) {
+       basicblock *bb = (basicblock *)vp;
+       unsigned i;
+
+       for (i = 0; i < bb->indepth; ++i) {
+               if (bb->invars[i] == var) {
+                       return i;
+               }
+       }
+
+       for (i = 0; i < bb->outdepth; ++i) {
+               if (bb->outvars[i] == var) {
+                       return i;
+               }
+       }
+
+       assert(0);
+}
+
+varinfo *inout_index_to_initial_var(void *vp, unsigned index) {
+       basicblock *bb = (basicblock *)vp;
+       jitdata *jd = (jitdata *)(((basicblock_info_t *)bb->vp)->locals->ops_vp); /* evil hack */
+       assert(index < bb->indepth);
+       return jd->var + bb->invars[index];
+}
+
+varinfo *inout_var_num_to_varinfo(void *vp, s4 var) {
+       basicblock *bb = (basicblock *)vp;
+       jitdata *jd = (jitdata *)(((basicblock_info_t *)bb->vp)->locals->ops_vp); /* evil hack */
+       return jd->var + var;
+}
+
+unsigned inout_variables_count(void *vp) {
+       basicblock *bb = (basicblock *)vp;
+       return bb->indepth;
+}
+
+traversal_ops_t traversal_inout_ops = {
+       inout_var_num_to_index,
+       inout_index_to_initial_var,
+       inout_var_num_to_varinfo,
+       inout_variables_count
+};
+
+/*** basicblock_info ********************************************************/
+
+void basicblock_info_init(basicblock_info_t *bbi, basicblock *bb, jitdata *jd) {
+       MZERO(bbi, basicblock_info_t, 1);
+
+       bbi->locals = DNEW(traversal_t);
+       traversal_init(bbi->locals, jd->localcount, jd, &traversal_local_ops);
+
+       bbi->stack = DNEW(traversal_t);
+       traversal_init(bbi->stack, jd->maxinterfaces, bb, &traversal_inout_ops);
+
+       bbi->subbasicblocks = DNEW(basicblock_chain_t);
+       basicblock_chain_init(bbi->subbasicblocks);
+}
+
+/*** basicblock *************************************************************/
+
+static inline basicblock_info_t *basicblock_info(basicblock *bb) {
+       return (basicblock_info_t *)(bb->vp);
+}
+
+#define bb_info basicblock_info
+
+static unsigned basicblock_get_predecessor_count(basicblock *bb) {
+       unsigned ret;
+       basicblock **itpred;
+
+       ret = bb->predecessorcount;
+
+       FOR_EACH_EXPREDECESSOR(bb, itpred) {
+               ret += (*itpred)->exouts;
+       }
+
+       return ret;
+}
+
+static unsigned basicblock_get_predecessor_index(basicblock *from, basicblock *to) {
+       basicblock **itpred;
+       unsigned j = 0;
+
+       FOR_EACH_PREDECESSOR(to, itpred) {      
+               if (*itpred == from) break;
+               j++;
+       }
+       
+       assert(j != to->predecessorcount);
+
+       return j;
+}
+
+static unsigned basicblock_get_ex_predecessor_index(basicblock *from, unsigned pei, basicblock *to) {
        unsigned j;
+       basicblock **itpred;
+
+       j = to->predecessorcount;
 
-       /*if (bbi->traversed) {
+       FOR_EACH_EXPREDECESSOR(to, itpred) {
+               if ((*itpred)->nr == from->nr) {
+                       j += pei;
+                       return j;
+               } else {
+                       j += (*itpred)->exouts;
+               }
+       }
+
+       assert(0);
+}
+
+/*** ssa_info ***************************************************************/
+
+typedef struct ssa_info {
+       jitdata *jd;
+
+       vars_t *locals;
+       vars_t *stack;
+       vars_t *others;
+
+       s4 s_buf[3];
+
+       basicblock_chain_t *new_blocks;
+
+} ssa_info, ssa_info_t;
+
+void ssa_info_init(ssa_info_t *ssa, jitdata *jd) {
+       ssa->jd = jd;
+
+       ssa->locals = DNEW(vars_t);
+       vars_init(ssa->locals, VARS_CATEGORY_LOCAL);
+
+       /* Initialize first version of locals, that is always available. */
+       MCOPY(ssa->locals->items, jd->var, varinfo, jd->localcount);
+       ssa->locals->count = jd->localcount;
+
+       ssa->stack = DNEW(vars_t);
+       vars_init(ssa->stack, VARS_CATEGORY_STACK);
+
+       ssa->others = DNEW(vars_t);
+       vars_init(ssa->others, VARS_CATEGORY_OTHERS);
+
+       ssa->new_blocks = DNEW(basicblock_chain_t);
+       basicblock_chain_init(ssa->new_blocks);
+}
+
+/*** others_mapping *********************************************************/
+
+static inline void others_mapping_set(ssa_info *ssa, s4 var, s4 new_var) {
+       ssa->jd->var[var].vv.regoff = new_var;
+}
+
+static inline s4 others_mapping_get(const ssa_info *ssa, s4 var) {
+       return ssa->jd->var[var].vv.regoff;
+}
+
+/*** code *******************************************************************/
+
+void fix_exception_handlers(jitdata *jd) {
+       basicblock *bptr;
+       basicblock *exh = NULL;
+       instruction *iptr;
+       exception_entry *ee;
+       size_t add_vars;
+       size_t avail_vars;
+       s4 v;
+       basicblock_chain_t chain;
+       basicblock *last = NULL;
+       basicblock *marker = NULL;
+
+       if (jd->exceptiontablelength == 0) {
                return;
-       }*/
+       }
 
-       /* Process block */
+       basicblock_chain_init(&chain);
+
+       /* We need to allocate new iovars */
+
+       avail_vars = (jd->varcount - jd->vartop);
+       add_vars = jd->exceptiontablelength;
+
+       if (add_vars > avail_vars) {
+               add_vars -= avail_vars;
+               jd->var = DMREALLOC(jd->var, varinfo, jd->varcount, jd->varcount + add_vars);
+               jd->varcount += add_vars;
+       }
+
+       /* For each exception handler block, create one block with a prologue block */
+
+       FOR_EACH_BASICBLOCK(jd, bptr) {
+               if (bptr->type == BBTYPE_EXH) {
+
+                       bptr->type = BBTYPE_STD;
+                       bptr->predecessorcount = 0; /* legacy */
+
+                       /* Create basicblock with 2 instructions */
+               
+                       exh = DNEW(basicblock);
+                       MZERO(exh, basicblock, 1);
+
+                       iptr = DMNEW(instruction, 2);
+                       MZERO(iptr, instruction, 2);
+
+                       /* Create new outvar */
+
+                       assert(jd->vartop < jd->varcount);
+                       v = jd->vartop;
+                       jd->vartop += 1;
+                       jd->var[v].type = TYPE_ADR;
+                       jd->var[v].flags = INOUT;
+
+                       exh->nr = jd->basicblockcount;
+                       jd->basicblockcount += 1;
+                       exh->mpc = -1;
+                       exh->type = BBTYPE_EXH;
+                       exh->icount = 2;
+                       exh->iinstr = iptr;
+                       exh->outdepth = 1;
+                       exh->outvars = DNEW(s4);
+                       exh->outvars[0] = v;
+                       exh->predecessorcount = -1; /* legacy */
+                       exh->flags = BBFINISHED;
+
+                       basicblock_chain_add(&chain, exh);
+
+                       /* Get exception */
+
+                       iptr->opc = ICMD_GETEXCEPTION;
+                       iptr->dst.varindex = v;
+                       iptr += 1;
+
+                       /* Goto real exception handler */
+
+                       goto_init(iptr, bptr);
+
+                       bptr->vp = exh;
+               } else {        
+                       bptr->vp = NULL;
+               }
+
+               if (bptr->next == NULL) {
+                       marker = bptr;
+               } else {
+                       last = bptr;
+               }
+       }
 
-       fun(ssa, bb);
+       /* Put the chain of exception handlers between just before the last
+          basic block (end marker). */
 
-       /*bbi->traversed = true;*/
+       if (! basicblock_chain_empty(&chain)) {
+               marker->nr = jd->basicblockcount;
+               basicblock_chain_back(&chain)->next = marker;
+               last->next = basicblock_chain_front(&chain);
+
+               assert(last->nr + 1 == basicblock_chain_front(&chain)->nr);
+               assert(marker->nr == jd->basicblockcount);
+       }
+
+       /* Replace all exception handlers in exception table with their respective
+          prologue blocks. */
+
+       for (ee = jd->exceptiontable; ee; ee = ee->down) {
+               assert(ee->handler->vp);
+               ee->handler = ee->handler->vp;
+       }
+
+}
+
+/*** ssa_enter ***************************************************************/
+
+static void ssa_enter_mark_loops_intern(basicblock *bb, unsigned num_branches) {
+       basicblock_info_t *bbi = bb_info(bb);
+       basicblock **itsucc;
+
+       if (! bbi->visited) {
+               bbi->visited = true;
+               bbi->active = true;
+               FOR_EACH_SUCCESSOR(bb, itsucc) {
+                       /* There is a single branch from bb into the successor. */
+                       ssa_enter_mark_loops_intern(*itsucc, 1);
+               }
+               FOR_EACH_EXHANDLER(bb, itsucc) {
+                       /* For exception handler type successors,
+                          we count a branch into the exception handler from every PEI. */
+                       ssa_enter_mark_loops_intern(*itsucc, bb->exouts);
+               }
+               bbi->active = false;
+       } else if (bbi->active) {
+               bbi->backward_branches += num_branches;
+       }
+}
+
+static inline void ssa_enter_mark_loops(basicblock *bb) {
+       ssa_enter_mark_loops_intern(bb, 1);
+}
+
+static void ssa_enter_merge(
+       traversal_t *src, 
+       traversal_t *dst, 
+       basicblock *bdst, 
+       unsigned predecessor_index, 
+       vars_t *vdst
+) {
+
+       basicblock_info_t *dsti = bb_info(bdst);
+       unsigned predecessor_count = basicblock_get_predecessor_count(bdst);
+       instruction *phi;
+       instruction *old;
+       s4 i;
+
+       /* We are merging for the first time into this block. */
+
+       if (! state_array_has_items(dst->state_array)) {
+
+               state_array_allocate_items(dst->state_array);
+
+               if (dsti->backward_branches > 0) {
+                       /* Loop header, create phi functions for all variables. */
+                       for (i = 0; i < traversal_variables_count(dst); ++i) {
+                               phi = traversal_create_phi(dst, vdst, predecessor_count, i);
+                               /* No need to init, they will only be filled in later. */
+                       }
+               } else {
+                       state_array_copy(dst->state_array, src->state_array);
+                       return;
+               }
+       }
+
+       /* We are merging another block. */
+
+       /* Process every variable. */
+
+       for (i = 0; i < traversal_variables_count(dst); ++i) {
+               if (dsti->traversed) {
+
+                       /* Back edge, all phi functions are already created.
+                          We only need to set their arguments. */
+
+                       phi_set_arg(
+                               phis_get(dst->phis, i), 
+                               predecessor_index, 
+                               state_array_get(src->state_array, i)
+                       );
+
+               } else if (state_array_get(dst->state_array, i) != state_array_get(src->state_array, i)) {
+
+                       /* A different definition of this var reaches the block.
+                          We need to create a phi function. */
+
+                       if (phis_contains(dst->phis, state_array_get(dst->state_array, i))) {
+                               /* There is already a phi function created for this var.
+                                  No need to create one. */
+                       } else {
+                               /* Create a new phi function. 
+                                  Set all arguments to old value in state array. */
+                               old = state_array_get(dst->state_array, i);
+                               phi = traversal_create_phi(dst, vdst, predecessor_count, i);
+                               phi_set_all_args(phi, old);
+                       }
+
+                       /* Set argument of phi function. */
+
+                       phi_set_arg(
+                               state_array_get(dst->state_array, i), 
+                               predecessor_index,
+                               state_array_get(src->state_array, i)
+                       );
+               }
+       }
+}
+
+static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb);
+static bool ssa_enter_eliminate_redundant_phis(traversal_t *t, vars_t *vs, basicblock_info_t *bbi);
+
+#if defined(SSA_VERIFY)
+static void ssa_enter_verify_no_redundant_phis(ssa_info_t *ssa) {
+       basicblock *bptr;
+       basicblock_info_t *bbi;
+       instruction *itph;
+       FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
+               if (basicblock_reached(bptr)) {
+                       bbi = bb_info(bptr);
+                       FOR_EACH_PHI_FUNCTION(bbi->locals->phis, itph) {
+                               if (! phi_is_redundant(itph)) {
+                                       phi_calculate_redundancy(itph);
+                                       assert(! phi_is_redundant(itph));
+                               }
+                       }
+                       FOR_EACH_PHI_FUNCTION(bbi->stack->phis, itph) {
+                               if (! phi_is_redundant(itph)) {
+                                       phi_calculate_redundancy(itph);
+                                       assert(! phi_is_redundant(itph));
+                               }
+                       }
+               }
+       }
+}
+#endif
+
+static void ssa_enter_traverse(ssa_info_t *ssa, basicblock *bb) {
+       basicblock **itsucc;
+       basicblock_info_t *succi;
+       basicblock_info_t *bbi = bb_info(bb);
+       unsigned predecessor_count;
+
+       /* Process block */
+
+       ssa_enter_process_block(ssa, bb);
 
        /* Recurse */
 
        FOR_EACH_SUCCESSOR(bb, itsucc) {
-               merge(ssa, bbi->state_array, *itsucc, get_predecessor_index(bb, *itsucc));
+
                succi = bb_info(*itsucc);
+
+               ssa_enter_merge(
+                       bbi->locals,
+                       succi->locals,
+                       *itsucc,
+                       basicblock_get_predecessor_index(bb, *itsucc),
+                       ssa->locals
+               );
+
+               ssa_enter_merge(
+                       bbi->stack,
+                       succi->stack,
+                       *itsucc,
+                       basicblock_get_predecessor_index(bb, *itsucc),
+                       ssa->stack
+               );
+
                succi->complete_predecessors += 1;
-               if (succi->complete_predecessors == (/*nn((*itsucc)->predecessorcount)*/ get_predecessor_count(*itsucc) - succi->backward_branches)) {
-                       printf(" *** Traverse bb%d => bb%d\n", bb->nr, (*itsucc)->nr);
-                       traverse(ssa, *itsucc, fun);
+
+               predecessor_count = basicblock_get_predecessor_count(*itsucc);
+
+               if (
+                       succi->complete_predecessors == 
+                       (predecessor_count - succi->backward_branches)
+               ) {
+                       ssa_enter_traverse(ssa, *itsucc);
+               }
+               
+               if (
+                       (succi->complete_predecessors == predecessor_count) &&
+                       (succi->backward_branches > 0)
+               ) {
+#if defined(SSA_VERIFY)
+                       assert(succi->num_phi_elimination < 2);
+                       succi->num_phi_elimination += 1;
+#endif
+                       ssa_enter_eliminate_redundant_phis(succi->locals, ssa->locals, succi);
+                       ssa_enter_eliminate_redundant_phis(succi->stack, ssa->stack, succi);
                }
        }
 
        FOR_EACH_EXHANDLER(bb, itsucc) {
+
                succi = bb_info(*itsucc);
+
                succi->complete_predecessors += bb->exouts; /* XXX this might be 0 */
-               if (succi->complete_predecessors == (/*nn((*itsucc)->predecessorcount)*/ get_predecessor_count(*itsucc) - succi->backward_branches)) {
-                       printf(" *** Traverse bb%d => bb%d\n", bb->nr, (*itsucc)->nr);
-                       traverse(ssa, *itsucc, fun);
+
+               predecessor_count = basicblock_get_predecessor_count(*itsucc);
+
+               if (
+                       succi->complete_predecessors == 
+                       (predecessor_count - succi->backward_branches)
+               ) {
+                       ssa_enter_traverse(ssa, *itsucc);
+               }
+
+               if (
+                       (succi->complete_predecessors == predecessor_count) &&
+                       (succi->backward_branches > 0)
+               ) {
+#if defined(SSA_VERIFY)
+                       assert(succi->num_phi_elimination < 2);
+                       succi->num_phi_elimination += 1;
+#endif
+                       ssa_enter_eliminate_redundant_phis(succi->locals, ssa->locals, succi);
+                       ssa_enter_eliminate_redundant_phis(succi->stack, ssa->stack, succi);
                }
+
        }
 
 }
 
-void merge(ssa_info *ssa, instruction **state_array, basicblock *succ, unsigned j) {
-       basicblock_info *succi = bb_info(succ);
-       instruction *phi;
-       unsigned i;
-       unsigned a;
+static void ssa_enter_process_pei(ssa_info *ssa, basicblock *bb, unsigned pei) {
+       basicblock_info_t *bbi = bb_info(bb);
+       basicblock_info_t *succi;
+       basicblock **itsucc;
 
-#define mprintf(fmt, ...) printf(" *** merge bb? => bb%d > " fmt, succ->nr, __VA_ARGS__)
+       FOR_EACH_EXHANDLER(bb, itsucc) {
+               succi = bb_info(*itsucc);
 
-       mprintf("(%d, %p)\n", j, succi->state_array);
+               ssa_enter_merge(
+                       bbi->locals,
+                       succi->locals,
+                       *itsucc,
+                       basicblock_get_ex_predecessor_index(bb, pei, *itsucc),
+                       ssa->locals
+               );
+       }
+}
 
-       if (succi->state_array == NULL) {
+static FIXME(bool) ssa_enter_eliminate_redundant_phis(traversal_t *t, vars_t *vs, basicblock_info_t *FIXME(bbi)) {
 
-               succi->state_array = DMNEW(instruction *, ssa->jd->localcount);
+       instruction *itph;
+       bool ret = false;
 
-               mprintf("creating state_array %p\n", succi->state_array );
+       FOR_EACH_PHI_FUNCTION(t->phis, itph) {
 
+               phi_calculate_redundancy(itph);
 
-               if (succi->backward_branches > 0) {
-                       mprintf("bb%d is loop header, creating phis\n", succ->nr);
-                       for (i = 0; i < ssa->jd->localcount; ++i) {
-                               succi->state_array[i] = create_phi(ssa, succ, i);
-                       }
-               } else {
-                       /*
-                       printf(" *** merge bb%d cow state array\n", succ->nr);
-                       succi->state_array = bbi->state_array;
-                       succi->cow = true;
-                       */
-                       MCOPY(succi->state_array, state_array, instruction *, ssa->jd->localcount);
-                       return;
-               }
-       }
+               /* If the phi function is redundant,
+                  make the variable it defines point to the value defined by the substituing
+                  instruction. */
 
-       for (i = 0; i < ssa->jd->localcount; ++i) {
-               mprintf("local %d bb: %s@%d, succ: %s@%d\n", i, instruction_name(state_array[i]), instruction_line(state_array[i]), instruction_name(succi->state_array[i]), instruction_line(succi->state_array[i]));
-
-               if (succi->traversed) {
-                       /* Back edge, all phis already created */
-                       /* Only fill in phi arguments */
-                       /* We have created phis for *ALL* locals, so there is random access */
-                       phi_set_argument(succ, &(succi->phi_functions[i].instr), j, state_array[i]);
-               } else if (state_array[i] != succi->state_array[i]) {
-                       mprintf("merge bb%d need phi for local %d\n", succ->nr, i);
-                       /* Create new state array if needed */
-
-                       /*if (succi->cow) {
-                               printf(" *** merge bb%d cloning cow state array\n", succ->nr);
-                               state_array = DMNEW(instruction *, ssa->jd->localcount);
-                               MCOPY(state_array, succi->state_array, instruction *, ssa->jd->localcount);
-                               succi->state_array = state_array;
-                               succi->cow = false;
-                       }*/
-
-                       if (is_my_phi(succ, succi->state_array[i])) {
-                               /* State array is already phi function, just need to fill in argument */
-                               phi_set_argument(succ, succi->state_array[i], j, state_array[i]);
-                       } else {
-                               /* Create phi and initialize all arguments with current state array value
-                                * (We might have already merged this value from within several blocks).
-                                */
-                               phi = create_phi(ssa, succ, i);
-                               for (a = 0; a < get_predecessor_count(succ); ++a) {
-                                       phi_set_argument(succ, phi, a, succi->state_array[i]);
-                               }
-                               phi_set_argument(succ, phi, j, state_array[i]);
-                               succi->state_array[i] = phi;
-                       }
+               if (phi_is_redundant(itph)) {
+                       vars_subst(vs, itph->dst.varindex, phi_get_subst(itph)->dst.varindex);
+                       assert(bbi->backward_branches > 0);
+                       ret = true;
                }
        }
-#undef mprintf
+
+       return ret;
 }
 
-static unsigned get_ex_predecessor_index(basicblock *from, unsigned pei, basicblock *to) {
-       unsigned i, j;
-       basicblock **itpred;
-       instruction *iti;
+#if 0
+static void ssa_enter_post_eliminate_redundand_phi(
+       ssa_info_t *ssa,
+       instruction *phi,
+       state_array *sa,
+       basicblock *bptr
+) {
+       phi_calculate_redundancy(phi);
+       phi_set_flag(PHI_FLAG_REDUNDANCY_CHECKED);
+       
+       /* if redundancy changed and phi function escapes block */
+
+       /* for each successor */
+}
 
-       j = nn(to->predecessorcount);
+static void ssa_enter_post_eliminate_redundant_phis(ssa_info_t *ssa) {
+       basicblock *bptr;
+       basicblock_info_t *bbi;
+       instruction *itph;
 
-       FOR_EACH_EXPREDECESSOR(to, itpred) {
-               if ((*itpred)->nr == from->nr) {
-                       j += pei;
-                       return j;
-               } else {
-                       j += (*itpred)->exouts;
+       FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
+               bbi = bb_info(bptr);
+
+               if (bbi->backward_branches > 0) {
+                       /* Redundant phi functions have the left hand side as operand.
+                          This can happen by definition only in loop headers. */
+
+                       FOR_EACH_PHI_FUNCTION(bbi->locals, itph) {
+                               if (! phi_has_flag(PHI_FLAG_REDUNDANCY_CHECKED)) {
+                                       /* Calculate redundancy? */
+                                       /* Changed? */
+                                       /* If yes recurse? */
+                               }
+                       }
+
+                       FOR_EACH_PHI_FUNCTION(bbi->stack, itph) {
+                       }
                }
        }
-
-       assert(0);
 }
+#endif
 
-static void handle_pei(ssa_info *ssa, basicblock *bb, unsigned pei) {
-       basicblock_info *bbi = bb_info(bb);
-       basicblock **itsucc;
+static void ssa_enter_init_locals(state_array_t *sa) {
+       unsigned i;
+       instruction *iptr;
 
-       FOR_EACH_EXHANDLER(bb, itsucc) {
-               merge(ssa, bbi->state_array, *itsucc, get_ex_predecessor_index(bb, pei, *itsucc));
+       for (i = 0; i < sa->count; ++i) {
+               iptr = DNEW(instruction);
+               iptr->opc = ICMD_NOP;
+               iptr->dst.varindex = i;
+               state_array_set(sa, i, iptr);
        }
 }
 
-static void traverse_fun_impl(ssa_info *ssa, basicblock *bb) {
-       basicblock_info *bbi = bb_info(bb), *predi;
-       basicblock **itpred, *pred;
-       unsigned i;
-       bool need_phi;
+static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb) {
+       basicblock_info_t *bbi = bb_info(bb);
        instruction *iptr;
-       unsigned uses_count;
-       s4 *uses, *ituse;
        unsigned pei = 0;
+       s4 *ituse;
+       s4 *uses;
+       unsigned uses_count;
+       s4 old;
+
+       /* Every basic block can be traversed only once. */
 
        assert(! bbi->traversed);
        bbi->traversed = true;
 
-       /*
-       if (bbi->state_array) {
-               return;
-       }
-       */
+       /* The root basicblock needs special treatment. */
 
-       /* bb 0 */
+       if (bb->predecessorcount == 0 && bb->type != BBTYPE_EXH) {
+               state_array_assert_no_items(bbi->locals->state_array);
+               state_array_allocate_items(bbi->locals->state_array);
+               ssa_enter_init_locals(bbi->locals->state_array);
 
-       if (bb->predecessorcount == 0) {
-               assert(! bbi->state_array);
-               bbi->state_array = DMNEW(instruction *, ssa->jd->localcount);
-               MZERO(bbi->state_array, instruction *, ssa->jd->localcount);
-               goto process_instructions;
+               state_array_assert_no_items(bbi->stack->state_array);
+               state_array_allocate_items(bbi->stack->state_array);
        }
 
+       /* Exception handlers have a clean stack. */
 
-       /*
-       if ((bb->predecessorcount == 1) && (bb->predecessors[0]->successorcount == 1)) {
-               bbi->state_array = bb_info(bb->predecessors[0])->state_array;
-               assert(bbi->state_array);
-               goto process_instructions;
+       if (bb->type == BBTYPE_EXH) {
+               state_array_assert_no_items(bbi->stack->state_array);
+               state_array_allocate_items(bbi->stack->state_array);
        }
-       */
-
-       /*
-       bbi->state_array = DMNEW(instruction *, ssa->jd->localcount);
-       MZERO(bbi->state_array, instruction *, ssa->jd->localcount);
-       */
-
-       /*
-       if (bbi->backward_branches > 0) {
-               for (i = 0; i < ssa->jd->localcount; ++i) {
-                       bbi->state_array[i] = create_phi(ssa, bb, i);
-               }
-       } else {
-               for (i = 0; i < ssa->jd->localcount; ++i) {
-                       need_phi = false;
-                       assert(bb_info(bb->predecessors[0])->state_array);
-
-                       FOR_EACH_PREDECESSOR(bb, itpred) {
-                               assert(bb_info(*itpred)->state_array);
-                               if (bb_info(bb->predecessors[0])->state_array[i] != bb_info(*itpred)->state_array[i]) {
-                                       need_phi = true;
-                                       break;
-                               }
-                       }
 
-                       if (need_phi) {
-                               bbi->state_array[i] = create_phi(ssa, bb, i);
-                       } else {
-                               bbi->state_array[i] = bb_info(bb->predecessors[0])->state_array[i];
-                       }
+       /* Some in/out vars get marked as INOUT in simplereg,
+          and are not marked at this point. 
+          Mark them manually. */
 
-               }
+       for (ituse = bb->invars; ituse != bb->invars + bb->indepth; ++ituse) {
+               ssa->jd->var[*ituse].flags |= INOUT;
+               ssa->jd->var[*ituse].flags &= ~PREALLOC;
        }
-       */
 
-process_instructions:
+       for (ituse = bb->outvars; ituse != bb->outvars + bb->outdepth; ++ituse) {
+               ssa->jd->var[*ituse].flags |= INOUT;
+               ssa->jd->var[*ituse].flags &= ~PREALLOC;
+       }
 
-       assert(bbi->state_array);
+       /* Process instructions */
 
+       state_array_assert_items(bbi->locals->state_array);
+       
        FOR_EACH_INSTRUCTION(bb, iptr) {
 
+#if defined(ELIMINATE_NOP_LOAD_STORE)
+
+               /* Kill NOP instructions of the form:
+                  LOAD foo => foo
+                  STORE foo => foo
+                  As they create a lot of unnecessary definitions.
+                  For performance, definitely eliminate them. However, keeping them is a
+                  good stress test.
+               */
+
+               if (
+                       (icmd_table[iptr->opc].dataflow == DF_LOAD) ||
+                       (icmd_table[iptr->opc].dataflow == DF_STORE)
+               ) {
+                       if (iptr->dst.varindex == iptr->s1.varindex) {
+                               iptr->opc = ICMD_NOP;
+                               continue;
+                       }
+               }
+#endif
+
                if (icmd_table[iptr->opc].flags & ICMDTABLE_PEI) {
-                       handle_pei(ssa, bb, pei++);
+                       ssa_enter_process_pei(ssa, bb, pei++);
                }
 
-               get_uses(ssa, iptr, &uses, &uses_count);
+               instruction_get_uses(iptr, ssa->s_buf, &uses, &uses_count);
 
                for (ituse = uses; ituse != uses + uses_count; ++ituse) {
                        if (var_is_local(ssa->jd, *ituse)) {
-                               rename_use(ssa, bb, iptr, ituse);
+                               traversal_rename_use(
+                                       bbi->locals, 
+                                       ituse
+                               );
+                       } else if (var_is_inout(ssa->jd, *ituse)) {
+                               traversal_rename_use(
+                                       bbi->stack,
+                                       ituse
+                               );
                        } else {
-                               *ituse += 0xFFFF;
+                               *ituse = others_mapping_get(ssa, *ituse);
                        }
                }
 
-               set_uses(ssa, iptr, uses, uses_count);
+               instruction_set_uses(iptr, ssa->s_buf, uses, uses_count);
 
                if (instruction_has_dst(iptr)) {
                        if (var_is_local(ssa->jd, iptr->dst.varindex)) {
-                               rename_def(ssa, bb, iptr);
+                               traversal_rename_def(
+                                       bbi->locals, 
+                                       ssa->locals, 
+                                       iptr
+                               );
+                       } else if (var_is_inout(ssa->jd, iptr->dst.varindex)) {
+                               traversal_rename_def(
+                                       bbi->stack,
+                                       ssa->stack,
+                                       iptr
+                               );
                        } else {
-                               iptr->dst.varindex += 0xFFFF;
+                               old = iptr->dst.varindex;
+                               iptr->dst.varindex = vars_add_item(
+                                       ssa->others,
+                                       ssa->jd->var + iptr->dst.varindex
+                               );
+                               others_mapping_set(ssa, old, iptr->dst.varindex);
                        }
                }
        }
 }
 
-static void ssa_rename_others(ssa_info *ssa) {
+/*
 
-       basicblock *bb;
-       instruction *iptr;
-       s4 *itinout, *uses, *ituse;
-       unsigned uses_count;
-       unsigned off = ssa->locals_count - ssa->jd->localcount;
+ [locals.........................][interaces][others]
+ [original locals][version > 1   ]
+ <--------------- new locals --------------->
+*/
 
-       FOR_EACH_BASICBLOCK(ssa->jd, bb) {
+static void ssa_enter_export_variables(ssa_info *ssa) {
+       s4 vartop;
+       varinfo *vars;
+       s4 *it;
+       unsigned i, j;
+       jitdata *jd = ssa->jd;
 
-               if (! basicblock_reached(bb)) continue;
+       vartop = ssa->locals->count + ssa->stack->count + ssa->others->count;
+       vars = DMNEW(varinfo, vartop);
 
-               for (itinout = bb->invars; itinout != bb->invars + bb->indepth; ++itinout) {
-                       *itinout += off;
-               }
+       vars_copy_to_final(ssa->locals, vars);
+       vars_copy_to_final(ssa->stack, vars + ssa->locals->count);
+       vars_copy_to_final(ssa->others, vars + ssa->locals->count + ssa->stack->count);
 
-               for (itinout = bb->outvars; itinout != bb->outvars + bb->outdepth; ++itinout) {
-                       *itinout += off;
-               }
+       jd->var = vars;
+       jd->vartop = jd->varcount = vartop;
 
-               FOR_EACH_INSTRUCTION(bb, iptr) {
-                       if (instruction_has_dst(iptr)) {
-                               if (iptr->dst.varindex >= 0xFFFF) {
-                                       iptr->dst.varindex += off;
-                                       iptr->dst.varindex -= 0xFFFF;
-                               }
+       /* Grow local map to accomodate all new locals and iovars.
+          But keep the local map for version 1 of locals, that contains the holes. */
+       
+       jd->local_map = DMREALLOC(
+               jd->local_map, 
+               s4, 
+               5 * jd->maxlocals, 
+               5 * (jd->maxlocals + ssa->locals->count + ssa->stack->count - jd->localcount)
+       );
+
+       it = jd->local_map + (jd->maxlocals * 5); /* start adding entries here */
+
+       /* Add version > 1 of all locals */
+
+       for (i = jd->localcount; i < ssa->locals->count; ++i) {
+               for (j = 0; j < 5; ++j) {
+                       if (jd->var[i].type != j) {
+                               *it = UNUSED;
+                       } else {
+                               *it = i;
                        }
-                       get_uses(ssa, iptr, &uses, &uses_count);
-                       for (ituse = uses; ituse != uses + uses_count; ++ituse) {
-                               if (*ituse >= 0xFFFF) {
-                                       *ituse += off;
-                                       *ituse -= 0xFFFF;
-                               }
+                       it += 1;
+               }
+       }
+       
+       /* Add all io vars. */
+
+       for (i = ssa->locals->count; i < ssa->locals->count + ssa->stack->count; ++i) {
+               for (j = 0; j < 5; ++j) {
+                       if (jd->var[i].type != j) {
+                               *it = UNUSED;
+                       } else {
+                               *it = i;
                        }
-                       set_uses(ssa, iptr, uses, uses_count);
+                       it += 1;
                }
        }
+
+       /* Add locals. */
+
+       jd->maxlocals += (ssa->locals->count + ssa->stack->count - jd->localcount);
+       jd->localcount = ssa->locals->count + ssa->stack->count;
+
+       /* Eliminate interfaces. */
+
+       jd->maxinterfaces = 0;
+
+}
+
+/* TODO rename */
+static inline void ssa_enter_eliminate_category(ssa_info_t *ssa, s4 *pvar) {
+       switch (vars_get_category(*pvar)) {
+               case VARS_CATEGORY_LOCAL:
+                       *pvar = vars_get_index(vars_resolve_subst(ssa->locals, *pvar));
+                       break;
+               case VARS_CATEGORY_STACK:
+                       *pvar = vars_get_index(vars_resolve_subst(ssa->stack, *pvar)) + ssa->locals->count;
+                       break;
+               case VARS_CATEGORY_OTHERS:
+                       *pvar = vars_get_index(*pvar) + ssa->locals->count + ssa->stack->count;
+                       break;
+       }
 }
 
-static void fill_in_phi_args(ssa_info *ssa) {
+/* TODO rename */
+void ssa_enter_eliminate_categories(ssa_info_t *ssa) {
        basicblock *bb;
-       basicblock_info *bbi;
-       phi_function *itphi;
-       unsigned j;
-       basicblock **itpred;
-       basicblock_info *predi;
+       instruction *iptr;
+       s4 *ituse, *uses;
+       unsigned uses_count;
+       basicblock_info_t *bbi;
+       instruction *itph;
 
        FOR_EACH_BASICBLOCK(ssa->jd, bb) {
-               if (!(bb->flags >= BBREACHED)) continue;
+
                bbi = bb_info(bb);
-               j = 0;
-               FOR_EACH_PREDECESSOR(bb, itpred) {
-                       predi = bb_info(*itpred);
-                       for (itphi = bbi->phi_functions; itphi != bbi->phi_functions + bbi->phi_count; ++itphi) {
-                               if (predi->state_array[itphi->local]) {
-                                       itphi->args[j] = predi->state_array[itphi->local]->dst.varindex;
-                               } else {
-                                       itphi->args[j] = itphi->local;
-                               }
+
+               bb->indepth = 0;
+               bb->outdepth = 0;
+
+               if (bbi != NULL) {
+                       FOR_EACH_PHI_FUNCTION(bbi->locals->phis, itph) {
+                               ssa_enter_eliminate_category(ssa, &(itph->dst.varindex));
+                       }
+
+                       FOR_EACH_PHI_FUNCTION(bbi->stack->phis, itph) {
+                               ssa_enter_eliminate_category(ssa, &(itph->dst.varindex));
+                       }
+               }
+
+               FOR_EACH_INSTRUCTION(bb, iptr) {
+                       if (instruction_has_dst(iptr)) {
+                               ssa_enter_eliminate_category(ssa, &(iptr->dst.varindex));
+                       }
+                       instruction_get_uses(iptr, ssa->s_buf, &uses, &uses_count);
+                       for (ituse = uses; ituse != uses + uses_count; ++ituse) {
+                               ssa_enter_eliminate_category(ssa, ituse);
                        }
-                       ++j;
+                       instruction_set_uses(iptr, ssa->s_buf, uses, uses_count);
                }
        }
 }
 
-static void ssa_export(ssa_info *ssa) {
-       unsigned i, j;
-       jitdata *jd = ssa->jd;
-       varinfo *vars, *it;
-       s4 vartop, varindex;
+static void ssa_enter_create_phi_graph(ssa_info *ssa) {
+       basicblock *bptr;
+       basicblock_info_t *bbi;
+       instruction *itph;
+       instruction **ituse;
+       unsigned i;
+       char path[PATH_MAX], *ppath;
+       FILE *f;
 
-       vartop = ssa->locals_count + jd->vartop - jd->localcount;
-       vars = DMNEW(varinfo, vartop);
+       snprintf(path, PATH_MAX, "|tmp|graphs|%s.%s.dot", ssa->jd->m->clazz->name->text, ssa->jd->m->name->text);
+       for (ppath = path; *ppath; ++ppath) {
+               if (*ppath == '|') *ppath = '/';
+               else if (*ppath == '/') *ppath = '.';
+       }
 
-       MCOPY(vars, ssa->locals, varinfo, ssa->locals_count);
-       MCOPY(vars + ssa->locals_count, jd->var + jd->localcount, varinfo, jd->vartop - jd->localcount);
+       f = fopen(path, "w");
 
-       jd->var = vars;
-       jd->vartop = jd->varcount = vartop;
+       if (f == NULL) return;
 
-       jd->local_map = DMREALLOC(jd->local_map, s4, 5 * jd->maxlocals, 5 * (jd->maxlocals + ssa->locals_count - jd->localcount));
+       fprintf(f, "digraph G {\n");
 
-       for (i = 0; i < ssa->locals_count - jd->localcount; ++i) {
-               for (j = 0; j < 5; ++j) {
-                       varindex = jd->localcount + i;
-                       if (jd->var[varindex].type != j) {
-                               varindex = UNUSED;
+       FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
+               bbi = bb_info(bptr);
+               if (bbi != NULL) {
+                       FOR_EACH_PHI_FUNCTION(bbi->locals->phis, itph) {
+                               i = 0;
+                               FOR_EACH_PHI_USE(itph, ituse) {
+                                       if ((*ituse)->opc == ICMD_PHI) {
+                                               fprintf(f, "%d -> %d;\n", (*ituse)->dst.varindex, itph->dst.varindex);
+                                       }
+                                       i += 1;
+                               }
                        }
-                       jd->local_map[((jd->maxlocals + i) * 5) + j] = varindex;
                }
        }
 
-       jd->maxlocals += (ssa->locals_count - jd->localcount);
-       jd->localcount = ssa->locals_count;
+       fprintf(f, "};\n");
+
+       fclose(f);
 }
 
-static basicblock *create_block_intern(ssa_info *ssa, basicblock *from, basicblock *to, unsigned j) {
-       basicblock *mid;
-       basicblock_info *toi;
+static basicblock *ssa_leave_create_transition_block_intern(
+       ssa_info *ssa,
+       basicblock *from,
+       basicblock *to,
+       unsigned predecessor_index,
+       unsigned reserved_insns
+) {
+       basicblock *bb;
        instruction *iptr;
-       phi_function *itph;
-       
-       mid = DNEW(basicblock);
-       MZERO(mid, basicblock, 1);
+       instruction *itph;
+       basicblock_info_t *toi;
 
        toi = bb_info(to);
-       assert(toi);
 
-       mid->nr = ssa->jd->basicblockcount;
+       /* Create basicblock and instruction array. */
+
+       bb = DNEW(basicblock);
+       MZERO(bb, basicblock, 1);
+
+       bb->nr = ssa->jd->basicblockcount;
        ssa->jd->basicblockcount += 1;
-       mid->mpc = -1;
-       mid->type = 666;
-       mid->icount = toi->phi_count + 1;
-       iptr = mid->iinstr = DMNEW(instruction, mid->icount);
-       MZERO(mid->iinstr, instruction, mid->icount);
-
-       for (itph = toi->phi_functions; itph != toi->phi_functions + toi->phi_count; ++itph) {
-               iptr->opc = ICMD_COPY;
-               iptr->dst.varindex = itph->dst;
-               iptr->s1.varindex =  itph->args[j];
-               assert(j < itph->instr.s1.argcount);
-               assert(itph->dst < ssa->locals_count);
-               assert(itph->args[j] < ssa->locals_count);
-               iptr++;
+       bb->mpc = -1;
+       bb->type = BBTYPE_STD;
+       bb->icount = 
+               reserved_insns + 
+               toi->locals->phis->count + 
+               toi->stack->phis->count + 
+               1;
+       bb->iinstr = DMNEW(instruction, bb->icount);
+       MZERO(bb->iinstr, instruction, bb->icount);
+
+       /* Populate instruction array. */
+
+       iptr = bb->iinstr + reserved_insns;
+       
+       /* Add phi moves. */
+
+       FOR_EACH_PHI_FUNCTION(toi->locals->phis, itph) {
+               phi_create_copy(itph, predecessor_index, iptr++);
        }
 
-       iptr->opc = ICMD_GOTO;
-       iptr->dst.block = to;
+       FOR_EACH_PHI_FUNCTION(toi->stack->phis, itph) {
+               phi_create_copy(itph, predecessor_index, iptr++);
+       }
 
-       return mid;
-}
+       /* Add goto to real block. */
 
-static basicblock *create_block(ssa_info *ssa, basicblock *from, basicblock *to) {
-       basicblock *ret;
-       ret = create_block_intern(ssa, from, to, get_predecessor_index(from, to));
+       goto_init(iptr, to);
 
-       while (from->next) {
-               from = from->next;
-       }
+       /* Add basicblock to chain of newly created basicblocks. */
 
-       from->next = ret;
+       basicblock_chain_add(ssa->new_blocks, bb);
 
-       return ret;
+       return bb;
 }
 
-static void crate_fallthrough(ssa_info *ssa, basicblock *bptr) {
-       unsigned j;
-       basicblock_info *toi;
-       instruction *iptr;
-       phi_function *itph;
+static inline basicblock *ssa_leave_create_transition_block(
+       ssa_info *ssa,
+       basicblock *from,
+       basicblock *to
+) {
+       return ssa_leave_create_transition_block_intern(
+               ssa, 
+               from, 
+               to,
+               basicblock_get_predecessor_index(from, to),
+               0
+       );
+}
 
-       if (bptr->next == NULL) return;
+static void ssa_leave_create_fallthrough(ssa_info *ssa, basicblock *bptr) {
+       unsigned predecessor_index;
+       basicblock_info_t *toi;
+       instruction *iptr;
+       instruction *itph;
+       unsigned icount;
 
-       j = get_predecessor_index(bptr, bptr->next);
+       if (bptr->next == NULL) {
+               /* No fallthrough. */
+               return;
+       }
 
+       predecessor_index = basicblock_get_predecessor_index(bptr, bptr->next);
        toi = bb_info(bptr->next);
+
        assert(toi);
 
-       bptr->iinstr = DMREALLOC(bptr->iinstr, instruction, bptr->icount, bptr->icount + toi->phi_count);
+       /* Resize instruction array to accomodate all phi moves. */
+
+       icount = bptr->icount + toi->locals->phis->count + toi->stack->phis->count;
+
+       bptr->iinstr = DMREALLOC(
+               bptr->iinstr, 
+               instruction, 
+               bptr->icount, 
+               icount
+       );
+
        iptr = bptr->iinstr + bptr->icount;
-       bptr->icount += toi->phi_count;
+       bptr->icount = icount;
+
+       /* Create phi moves. */
 
-       for (itph = toi->phi_functions; itph != toi->phi_functions + toi->phi_count; ++itph) {
-               iptr->opc = ICMD_COPY;
-               iptr->dst.varindex = itph->dst;
-               iptr->s1.varindex =  itph->args[j];
-               assert(itph->dst < ssa->locals_count);
-               assert(itph->args[j] < ssa->locals_count);
-               iptr++;
+       FOR_EACH_PHI_FUNCTION(toi->locals->phis, itph) {
+               phi_create_copy(itph, predecessor_index, iptr++);
        }
 
+       FOR_EACH_PHI_FUNCTION(toi->stack->phis, itph) {
+               phi_create_copy(itph, predecessor_index, iptr++);
+       }
 }
 
-static void ssa_create_phi_moves(ssa_info *ssa) {
+static void ssa_leave_create_phi_moves(ssa_info *ssa) {
        basicblock *bptr;
        instruction *iptr;
+       basicblock *last = NULL;
 
        s4 i, l;
        branch_target_t *table;
        lookup_target_t *lookup;
-       bool gt;
+       bool has_fallthrough;
 
-       for (bptr = ssa->jd->basicblocks; bptr; bptr = bptr->next) {
-               if (bptr->type == 666) {
-                       bptr->type = BBTYPE_STD;
+       FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
+
+               if (bptr->next == NULL) {
+                       last = bptr;
+               }
+
+               if (bptr->vp == NULL) {
+                       continue;
+               }
+
+               if (! basicblock_reached(bptr)) {
                        continue;
                }
-               if (! bptr->vp) continue;
-               if (! (bptr->flags >= BBREACHED)) continue;
-               gt = false;
+
+               has_fallthrough = true;
+
                for (iptr = bptr->iinstr; iptr != bptr->iinstr + bptr->icount; ++iptr) {
                        switch (icmd_table[iptr->opc].controlflow) {
                                case CF_IF:
                                case CF_RET:
                                case CF_GOTO:
-                                       iptr->dst.block = create_block(ssa, bptr, iptr->dst.block);     
+                                       iptr->dst.block = 
+                                               ssa_leave_create_transition_block(ssa, bptr, iptr->dst.block);  
                                        break;
                                case CF_TABLE:
                                        table = iptr->dst.table;
@@ -762,7 +1753,8 @@ static void ssa_create_phi_moves(ssa_info *ssa) {
                                        i = i - l + 1;
                                        i += 1; /* default */
                                        while (--i >= 0) {
-                                               table->block = create_block(ssa, bptr, table->block);
+                                               table->block = 
+                                                       ssa_leave_create_transition_block(ssa, bptr, table->block);
                                                ++table;
                                        }
                                        break;
@@ -770,53 +1762,85 @@ static void ssa_create_phi_moves(ssa_info *ssa) {
                                        lookup = iptr->dst.lookup;
                                        i = iptr->sx.s23.s2.lookupcount;
                                        while (--i >= 0) {
-                                               lookup->target.block = create_block(ssa, bptr, lookup->target.block);
+                                               lookup->target.block = 
+                                                       ssa_leave_create_transition_block(ssa, bptr, lookup->target.block);
                                                lookup++;
                                        }
-                                       iptr->sx.s23.s3.lookupdefault.block = create_block(ssa, bptr, iptr->sx.s23.s3.lookupdefault.block);
+                                       iptr->sx.s23.s3.lookupdefault.block = 
+                                               ssa_leave_create_transition_block(ssa, bptr, iptr->sx.s23.s3.lookupdefault.block);
                                        break;
                                case CF_JSR:
-                                       iptr->sx.s23.s3.jsrtarget.block = create_block(ssa, bptr, iptr->sx.s23.s3.jsrtarget.block);
+                                       iptr->sx.s23.s3.jsrtarget.block = 
+                                               ssa_leave_create_transition_block(ssa, bptr, iptr->sx.s23.s3.jsrtarget.block);
                                        break;
                        }
-                       if ((iptr->opc == ICMD_GOTO) || (iptr->opc == ICMD_JSR) || (iptr->opc == ICMD_RET) || icmd_table[iptr->opc].controlflow == CF_END || (iptr->opc == ICMD_TABLESWITCH) || (iptr->opc == ICMD_LOOKUPSWITCH))
-                               gt = true;
-                       else if (iptr->opc != ICMD_NOP)
-                               gt = false;
+
+                       if (
+                               (iptr->opc == ICMD_GOTO) || 
+                               (iptr->opc == ICMD_JSR) || 
+                               (iptr->opc == ICMD_RET) || 
+                               icmd_table[iptr->opc].controlflow == CF_END || 
+                               (iptr->opc == ICMD_TABLESWITCH) || 
+                               (iptr->opc == ICMD_LOOKUPSWITCH)
+                       ) {
+                               has_fallthrough = false;
+                       } else if (iptr->opc != ICMD_NOP) {
+                               has_fallthrough = true;
+                       }
+
+               }
+
+               if (bptr->next == NULL) {
+                       continue;
+               }
+
+               if (! basicblock_reached(bptr->next)) {
+                       continue;
                }
-               if (! bptr->next) continue;
-               if (! (bptr->next->flags >= BBREACHED)) continue;
-               if (bptr->next->type == 666) continue;
-               if (!gt) crate_fallthrough(ssa, bptr);
+
+               if (has_fallthrough) {
+                       ssa_leave_create_fallthrough(ssa, bptr);
+               }
+       }
+
+       /* Add chain of new basic blocks */
+
+       if (last != NULL && ! basicblock_chain_empty(ssa->new_blocks)) {
+               last->next = basicblock_chain_front(ssa->new_blocks);
        }
+
 }
 
-static basicblock *split_basicblock_at(ssa_info *ssa, basicblock *bptr, instruction *iptr) {
+static basicblock *ssa_leave_split_basicblock_at(ssa_info *ssa, basicblock *bptr, instruction *iptr) {
 
+       basicblock_info_t *bbi = bb_info(bptr);
+       unsigned iidx = iptr - bptr->iinstr;
        basicblock *newblock;
        basicblock *tosplit;
-       basicblock **pnext;
-       unsigned icount;
-       basicblock *it;
+       unsigned ileft;
        unsigned pos;
 
-       unsigned origidx = iptr - bptr->iinstr;
+       assert(iidx < bptr->icount);
+       assert(bbi);
 
-       printf(" *** split basicblock bb%d at %s/%d/%d\n", bptr->nr, instruction_name(iptr), instruction_line(iptr), origidx);
-       assert(origidx < bptr->icount);
+       /* If there are no subbasicblocks yet, we initialize the first one to be a 
+          copy of the original basicblock. */
 
-
-       if (! bptr->subbasicblocks) {
-               bptr->subbasicblocks = DNEW(basicblock);
-               ass(bptr->subbasicblocks, bptr);
-               bptr->subbasicblocks->subbasicblocks = NULL;
-               bptr->subbasicblocks->next = NULL;
+       if (basicblock_chain_empty(bbi->subbasicblocks)) {
+               newblock = DNEW(basicblock);
+               *newblock = *bptr;
+               newblock->next = NULL;
+               newblock->vp = NULL;
+               basicblock_chain_add(bbi->subbasicblocks, newblock);
        }
 
-       tosplit = bptr->subbasicblocks;
+       /* Find the subbasicblock that will be split: 
+          the one that cointains iptr. */
+
+       tosplit = basicblock_chain_front(bbi->subbasicblocks);
        pos = 0;
 
-       while (tosplit->next && (origidx >= (pos + tosplit->icount))) {
+       while (tosplit->next && (iidx >= (pos + tosplit->icount))) {
                assert(bptr->nr == tosplit->nr);
                pos += tosplit->icount;
                tosplit = tosplit->next;
@@ -824,211 +1848,247 @@ static basicblock *split_basicblock_at(ssa_info *ssa, basicblock *bptr, instruct
 
        assert(bptr->nr == tosplit->nr);
        
-       icount = iptr - tosplit->iinstr + 1;
-       assert(icount <= tosplit->icount);
+       /* Calculate number of instructions left in block to split. */
 
-       if (icount < tosplit->icount) {
+       ileft = iptr - tosplit->iinstr + 1;
+       assert(ileft <= tosplit->icount);
+
+       /* If there are any instructions left in the block to split, split */
+
+       if (ileft < tosplit->icount) {
                newblock = DNEW(basicblock);
-               ass(newblock, tosplit);
+               *newblock = *tosplit;
        
                tosplit->next = newblock;
-               tosplit->icount = icount;
+               tosplit->icount = ileft;
 
-               newblock->icount -= icount;
-               newblock->iinstr += icount;
-               newblock->next = NULL;
+               newblock->icount -= ileft;
+               newblock->iinstr += ileft;
 
                assert(tosplit->nr == bptr->nr);
                assert(newblock->nr == bptr->nr);
                assert(newblock->next == NULL);
-       } else {
-               printf("xx split\n");
+
+               if (newblock->next == NULL) {
+                       bbi->subbasicblocks->last = newblock;
+               }
        }
 
-       /* To not break references to block bptr, we will replace 
-          the block by the first fragment later. */
+       /* We won't break pointers/references to bptr.
+          So return bptr instread of the first fragment.
+          Later, we will put the first fragment into the memory used by bptr.
+       */
 
-       if (tosplit == bptr->subbasicblocks) tosplit = bptr;
+       if (tosplit == basicblock_chain_front(bbi->subbasicblocks)) {
+               tosplit = bptr;
+       }
 
        return tosplit;
 }
 
-static exception_entry *create_exception_handler(ssa_info *ssa, basicblock *from, unsigned pei, basicblock *to, classref_or_classinfo catchtype) {
-       basicblock *it;
-       exception_entry *ee = DNEW(exception_entry);
-       basicblock *exh = create_block_intern(ssa, from, to, get_ex_predecessor_index(from, pei, to));
+static basicblock *ssa_leave_create_transition_exception_handler(
+       ssa_info *ssa,
+       basicblock *from,
+       unsigned pei,
+       basicblock *to
+) {
+       basicblock *exh;
+
+       /* From is a try block, to is an exception handler prologue. */
+
+       /* Remove old prologue. */
+
+       to->flags = BBDELETED;
+
+       /* Create new exception handler. */
+
+       exh = ssa_leave_create_transition_block_intern(
+               ssa,
+               from,
+               to,
+               basicblock_get_ex_predecessor_index(from, pei, to),
+               1
+       );
        exh->type = BBTYPE_EXH;
-       to->type = BBTYPE_STD;
 
-       exh->indepth = exh->outdepth = 1;
-       exh->invars = exh->outvars = DNEW(s4);
-       /* assigned in caller */
+       /* Copy goto to real exception handler at the end of the exception handler 
+          prologue. */
+
+       assert(to->iinstr[to->icount - 1].opc == ICMD_GOTO);
+       assert(exh->iinstr[exh->icount - 1].opc == ICMD_GOTO);
+       exh->iinstr[exh->icount - 1] = to->iinstr[to->icount - 1];
+
+       /* Copy getexception from the old prologue. */
+
+       assert(to->iinstr[0].opc == ICMD_GETEXCEPTION);
+       exh->iinstr[0] = to->iinstr[0];
+
+       return exh;
+}
+
+static exception_entry *ssa_leave_create_transition_exception_entry(
+       ssa_info_t *ssa,
+       basicblock *from,
+       basicblock *handler,
+       classref_or_classinfo catchtype
+) {
+
+       exception_entry *ee = DNEW(exception_entry);
+       basicblock_info_t *fromi = bb_info(from);
 
        ee->start = from;
-       /* XXX evil hack: if from is first fragment of BB, then from->next is not the next fragment */
-       ee->end = from->subbasicblocks ? from->subbasicblocks->next : from->next;
-       ee->handler = exh;
+
+       /* If the try block has subbasicblocks, the next block is the next fragment,
+          not the successor block. */
+
+       if (fromi != NULL) {
+               ee->end = basicblock_chain_front(fromi->subbasicblocks)->next;
+       } else {
+               ee->end = from->next;
+       }
+       ee->handler = handler;
        ee->catchtype = catchtype;
        ee->next = NULL;
        ee->down = NULL;
 
-       for (it = ssa->jd->basicblocks; it->next; it = it->next);
-
-       it->next = exh;
-
        return ee;
 }
 
-static void ssa_create_ex_phi_moves(ssa_info *ssa) {
+static void ssa_leave_create_exceptional_phi_moves(ssa_info *ssa) {
        basicblock *bptr;
        instruction *iptr;
-       basicblock_info *bbi;
        exception_entry *ite;
-       exception_entry *firstee, *lastee, *ee;
-       basicblock *ittry, *try;
+       exception_entry_chain_t chain;
        classref_or_classinfo catchtype;
+       basicblock *ittry;
        unsigned pei;
-       unsigned exhandler_count = 0;
-       varinfo *v;
+       basicblock *try;
+       basicblock *exh;
+       exception_entry *ee;
+       basicblock *last = NULL;
 
-       FOR_EACH_BASICBLOCK(ssa->jd, bptr) {
-               if (! bptr->vp) continue;
-               if (! (bptr->flags >= BBREACHED)) continue;
-               if (bptr->expredecessorcount == 0) continue;
-               bbi = bb_info(bptr);
-               if (bbi->phi_count == 0) continue;
-
-               for (ite = ssa->jd->exceptiontable; ite; ite = ite->down) {
-                       /* Traverse all exhandlers */
-                       if (bptr == ite->handler) {
-                               printf(" *** mess with handler bb%d\n", bptr->nr);
-                               catchtype = ite->catchtype;
-                               firstee = lastee = NULL;
-                               /* If bptr is handler, remove exhandler */
-                               /* Traverse all guarded blocks */
-                               for (ittry = ite->start; ittry != ite->end; ittry = ittry->next) {
-                                       pei = 0;
-                                       FOR_EACH_INSTRUCTION(ittry, iptr) {
-                                               if (icmd_table[iptr->opc].flags & ICMDTABLE_PEI) {
-                                                       /* try is basicblock fragment till (including) the pei */
-                                                       try = split_basicblock_at(ssa, ittry, iptr);
-                                                       /* ee is handler for try */
-                                                       ee = create_exception_handler(ssa, try, pei, bptr, catchtype);
-                                                       ee->handler->invars[0] = ssa->jd->vartop + exhandler_count;
-                                                       exhandler_count += 1;
-                                                       ssa->jd->exceptiontablelength += 1;
-                                                       if (firstee == NULL) {
-                                                               firstee = lastee = ee;
-                                                       } else {
-                                                               lastee->next = ee;
-                                                               lastee->down = ee;
-                                                               lastee = ee;
-                                                       }
-                                                       pei += 1;
-                                               }
+       if (! basicblock_chain_empty(ssa->new_blocks)) {
+               last = basicblock_chain_back(ssa->new_blocks);
+       }
+
+       basicblock_chain_clear(ssa->new_blocks);
+
+       for (ite = ssa->jd->exceptiontable; ite; ite = ite->down) {
+               bptr = ite->handler;
+               catchtype = ite->catchtype;
+               exception_entry_chain_init(&chain);
+               for (ittry = ite->start; ittry != ite->end; ittry = ittry->next) {
+                       if (basicblock_reached(ittry)) {
+                               /* Dead code does not have a basicblock_info_t associated. */
+                               pei = 0;
+                               FOR_EACH_INSTRUCTION(ittry, iptr) {
+                                       if (icmd_table[iptr->opc].flags & ICMDTABLE_PEI) {
+                                               /* try is basicblock fragment till (including) the pei */
+                                               try = ssa_leave_split_basicblock_at(ssa, ittry, iptr);
+                                               /* ee is handler for try */
+                                               exh = ssa_leave_create_transition_exception_handler(
+                                                       ssa, try, pei, bptr
+                                               );
+                                               ee = ssa_leave_create_transition_exception_entry(
+                                                       ssa, try, exh, catchtype
+                                               );
+                                               exception_entry_chain_add(&chain, ee);
+                                               pei += 1;
+                                               ssa->jd->exceptiontablelength += 1;
                                        }
                                }
-                               /* XXX 
-                                  <------------------->
-                                  <---><--><--->missing */
-                               if (firstee) {
-                                       lastee->next = ite->next;
-                                       lastee->down = ite->down;
-                                       *ite = *firstee;
-                                       ite = lastee;
-                               }
                        }
                }
+               if (! exception_entry_chain_empty(&chain)) {
+                       exception_entry_chain_back(&chain)->down = ite->down;
+                       exception_entry_chain_back(&chain)->next = ite->next;
+                       /* Replace original exception entry by first new one. */
+                       *ite = *exception_entry_chain_front(&chain);
+                       /* Set current iteration position to last newly created one. */
+                       ite = exception_entry_chain_back(&chain);
+               }
+       }
+
+       if (last == NULL) {
+               for (last = ssa->jd->basicblocks; last->next != NULL; last = last->next);
        }
-       
-       /* Allocate interface vars */
 
-       ssa->jd->var = DMREALLOC(ssa->jd->var, varinfo, ssa->jd->vartop, ssa->jd->vartop + exhandler_count);
-       for (v = ssa->jd->var + ssa->jd->vartop; v != ssa->jd->var + ssa->jd->vartop + exhandler_count; ++v) {
-               v->type = TYPE_ADR;
-               v->flags = INOUT;
+       if (last != NULL && ! basicblock_chain_empty(ssa->new_blocks)) {
+               last->next = basicblock_chain_front(ssa->new_blocks);
        }
-       ssa->jd->vartop += exhandler_count;
-       ssa->jd->varcount += exhandler_count;
 }
 
 void yssa(jitdata *jd) {
        basicblock *it;
-       basicblock_info *iti;
+       basicblock_info_t *iti;
        ssa_info *ssa;
 
-       if (jd->localcount == 0) return;
-
-       if (test_do_verbose(jd)) do_verbose = 1;
-
+#ifdef SSA_VERBOSE
        printf("=============== [ before %s ] =========================\n", jd->m->name->text);
        show_method(jd, 3);
        printf("=============== [ /before ] =========================\n");
+#endif
 
        ssa = DNEW(ssa_info);
-       ssa->jd = jd;
-       ssa->max_locals = sizeof(ssa->locals) / sizeof(ssa->locals[0]);
-       MCOPY(ssa->locals, jd->var, varinfo, jd->localcount);
-       ssa->locals_count = jd->localcount;
+
+       ssa_info_init(ssa, jd);
 
        FOR_EACH_BASICBLOCK(jd, it) {
                if (basicblock_reached(it)) {
-                       iti = DNEW(basicblock_info);
-                       MZERO(iti, basicblock_info, 1);
-                       if (jd->localcount > 0) {
-                               iti->phi_functions = DMNEW(phi_function, jd->localcount);
-                               iti->phi_max = jd->localcount;
-                       }
+                       iti = DNEW(basicblock_info_t);
+                       basicblock_info_init(iti, it, jd);
                        it->vp = iti;
                } else {
                        it->vp = NULL;
                }
        }
 
-       mark_loops(jd->basicblocks);
+       ssa_enter_mark_loops(jd->basicblocks);
+
+       ssa_enter_traverse(ssa, jd->basicblocks);
 
-       traverse(ssa, jd->basicblocks, traverse_fun_impl);
+       ssa_enter_eliminate_categories(ssa);
 
-       ssa_rename_others(ssa);
+       ssa_enter_export_variables(ssa);
 
-       /*fill_in_phi_args(ssa);*/
+       ssa_enter_verify_no_redundant_phis(ssa);
 
-       ssa_export(ssa);
+       /*ssa_enter_create_phi_graph(ssa);*/
 
-       ssa_create_phi_moves(ssa);
-       ssa_create_ex_phi_moves(ssa);
+       ssa_leave_create_phi_moves(ssa);
 
+       ssa_leave_create_exceptional_phi_moves(ssa);
+
+#ifdef SSA_VERBOSE
        printf("=============== [ after ] =========================\n");
        show_method(jd, 3);
        printf("=============== [ /after ] =========================\n");
+#endif
 
-       do_verbose = 0;
 }
 
 void eliminate_subbasicblocks(jitdata *jd) {
        basicblock *bptr, *next;
+       basicblock_info_t *bbi;
 
        FOR_EACH_BASICBLOCK(jd, bptr) {
-               if (bptr->subbasicblocks) {
-                       next = bptr->next;
-                       *bptr = *(bptr->subbasicblocks);
-                       bptr->subbasicblocks = NULL;
-
-                       /* *prev = bptr->subbasicblocks;
-                       bptr = bptr->subbasicblocks; */
-
-                       while (bptr->next) {
-                               bptr = bptr->next;
+               bbi = bb_info(bptr);
+               if (bbi != NULL) {
+                       if (! basicblock_chain_empty(bbi->subbasicblocks)) {
+                               next = bptr->next;
+                               /* Copy first subblock, to keep pointers intact. */
+                               *bptr = *basicblock_chain_front(bbi->subbasicblocks);
+                               bptr = basicblock_chain_back(bbi->subbasicblocks);
+                               bptr->next = next;
                        }
-                       bptr->next = next;
                }
        }
 
-       if (test_do_verbose(jd)) do_verbose = 1;
+#ifdef SSA_VERBOSE
        printf("=============== [ elim ] =========================\n");
        show_method(jd, 3);
        printf("=============== [ /elim ] =========================\n");
-       do_verbose = 0;
+#endif
 }
 
 /*
index ccfa92cf86713a170a05b0159de8b0a4b56d385b..37de069008202e107531539eb15bcc3f068cf0a7 100644 (file)
@@ -1796,13 +1796,13 @@ bool codegen_emit(jitdata *jd)
 
                        N_L(
                                GET_LOW_REG(d) /* maybe itmp3 */, 
-                               OFFSET(java_intarray_t, data[0]) + 4, 
+                               OFFSET(java_longarray_t, data[0]) + 4, 
                                REG_ITMP2, s1 /* maybe itmp1 */
                        );
 
                        N_L(
                                GET_HIGH_REG(d) /* maybe itmp1 */, 
-                               OFFSET(java_intarray_t, data[0]), 
+                               OFFSET(java_longarray_t, data[0]), 
                                REG_ITMP2, s1 /* maybe itmp1 */
                        );
 
@@ -1838,7 +1838,7 @@ bool codegen_emit(jitdata *jd)
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(3, REG_ITMP2); /* scale index by 8 */
        
-                       N_LD(d, OFFSET(java_floatarray_t, data[0]), REG_ITMP2, s1);
+                       N_LD(d, OFFSET(java_doublearray_t, data[0]), REG_ITMP2, s1);
 
                        emit_store_dst(jd, iptr, d);
                        break;
@@ -1921,9 +1921,9 @@ bool codegen_emit(jitdata *jd)
                        M_SLL_IMM(3, REG_ITMP2);
 
                        s3 = emit_load_s3_high(jd, iptr, REG_ITMP3);
-                       N_ST(s3, OFFSET(java_intarray_t, data[0]), REG_ITMP2, s1);
+                       N_ST(s3, OFFSET(java_longarray_t, data[0]), REG_ITMP2, s1);
                        s3 = emit_load_s3_low(jd, iptr, REG_ITMP3);
-                       N_ST(s3, OFFSET(java_intarray_t, data[0]) + 4, REG_ITMP2, s1);
+                       N_ST(s3, OFFSET(java_longarray_t, data[0]) + 4, REG_ITMP2, s1);
                        break;
 
                case ICMD_FASTORE:    /* ..., arrayref, index, value  ==> ...         */
index 61f92565134ad65629e3c8a3e3ad239763a36d33..0b429ccadba6ef1cc03c43d1298c5e5c24aedfc8 100644 (file)
@@ -1422,6 +1422,9 @@ void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
                SHOW_S1(iptr);
                SHOW_DST(iptr);
                break;
+       case ICMD_GETEXCEPTION:
+               SHOW_DST(iptr);
+               break;
        }
        fflush(stdout);
 }
index 461c09d18f68d38ff92196ac1ad0f2daf64febab..4f4765acacddc48767da0446ff49d747be82dd73 100644 (file)
@@ -46,7 +46,7 @@
 #include "native/include/java_lang_Object.h"
 #include "native/include/java_lang_Throwable.h"
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 # include "native/include/gnu_classpath_Pointer.h"
 # include "native/include/java_lang_VMThrowable.h"
 #endif
@@ -593,7 +593,7 @@ java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi)
                        /* Check "fillInStackTrace" only once, so we negate the
                           flag after the first time check. */
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
                        /* For GNU Classpath we also need to skip
                           VMThrowable.fillInStackTrace(). */
 
@@ -728,7 +728,7 @@ classinfo *stacktrace_get_caller_class(int depth)
                if (m->flags & ACC_METHOD_BUILTIN)
                        continue;
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
                /* NOTE: See hotspot/src/share/vm/runtime/vframe.cpp
                   (vframeStreamCommon::security_get_caller_frame). */
 
@@ -972,7 +972,7 @@ classinfo *stacktrace_get_current_class(void)
 
 *******************************************************************************/
 
-#if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
+#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 java_handle_objectarray_t *stacktrace_get_stack(void)
 {
        stackframeinfo_t          *sfi;
@@ -1254,7 +1254,7 @@ void stacktrace_print_exception(java_handle_t *h)
 {
        java_lang_Throwable     *o;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        java_lang_VMThrowable   *vmt;
 #endif
 
@@ -1269,12 +1269,12 @@ void stacktrace_print_exception(java_handle_t *h)
 
        /* now print the stacktrace */
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        LLNI_field_get_ref(o,   vmState, vmt);
        LLNI_field_get_ref(vmt, vmdata,  backtrace);
 
-#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
        LLNI_field_get_ref(o, backtrace, backtrace);
 
index 8e5429847a68e936f9029e53c07d3c543bafce65..4f7a69f9fa074b5c22ccfaed0c05c59ea077b545 100644 (file)
@@ -61,6 +61,8 @@
        .globl asm_compare_and_swap
        .globl asm_memory_barrier
 
+       .globl asm_get_cycle_count
+
 
 /********************* function asm_calljavafunction ***************************
 *                                                                              *
@@ -416,6 +418,20 @@ asm_memory_barrier:
        ret
 
 
+/* asm_get_cycle_count *********************************************************
+
+   Get the current time-stamp counter from the CPU.
+
+*******************************************************************************/
+
+asm_get_cycle_count:
+       rdtsc
+       shl $0x20, %rdx
+       mov %eax, %eax
+       or %rdx, %rax
+       ret
+
+
 /* disable exec-stacks ********************************************************/
 
 #if defined(__linux__) && defined(__ELF__)
index 9f763f6f3ef5a6a3ca2863c915af768a3a7dc16d..ea986654db988da4b61ee195ea0006ee7c15ac4b 100644 (file)
@@ -108,7 +108,7 @@ void properties_set(void)
        char           *extdirs;
        char           *endorseddirs;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        char           *cwd;
        char           *env_user;
        char           *env_home;
@@ -142,7 +142,7 @@ void properties_set(void)
        p = system_dirname(p);
        p = system_dirname(p);
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Set java.home. */
 
@@ -157,7 +157,7 @@ void properties_set(void)
        strcpy(boot_library_path, java_home);
        strcat(boot_library_path, "/lib/classpath");
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        /* Find correct java.home.  We check if there is a JRE
           co-located. */
@@ -209,15 +209,15 @@ void properties_set(void)
 #else
        java_home         = CACAO_PREFIX;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
-       boot_library_path = CLASSPATH_LIBDIR"/classpath";
+       boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR"/classpath";
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
-       boot_library_path = CLASSPATH_LIBDIR;
+       boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR;
 
-# elif defined(WITH_CLASSPATH_CLDC1_1)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
        /* No boot_library_path required. */
 
@@ -238,7 +238,7 @@ void properties_set(void)
        }
        else {
 #if defined(ENABLE_JRE_LAYOUT)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
                len =
                        strlen(java_home) + strlen("/share/cacao/vm.zip:") +
@@ -253,7 +253,7 @@ void properties_set(void)
                strcat(boot_class_path, java_home);
                strcat(boot_class_path, "/share/classpath/glibj.zip");
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
                /* This is the bootclasspath taken from HotSpot (see
                   hotspot/src/share/vm/runtime/os.cpp
@@ -290,55 +290,55 @@ void properties_set(void)
 #  error unknown classpath configuration
 # endif
 #else
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
                len =
                        strlen(CACAO_VM_ZIP) +
                        strlen(":") +
-                       strlen(CLASSPATH_CLASSES) +
+                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
                        strlen("0");
 
                boot_class_path = MNEW(char, len);
 
                strcpy(boot_class_path, CACAO_VM_ZIP);
                strcat(boot_class_path, ":");
-               strcat(boot_class_path, CLASSPATH_CLASSES);
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES);
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
                /* This is the bootclasspath taken from HotSpot (see
                   hotspot/src/share/vm/runtime/os.cpp
                   (os::set_boot_path)). */
 
                len =
-                       strlen(CLASSPATH_PREFIX"/lib/resources.jar:") +
-                       strlen(CLASSPATH_PREFIX"/lib/rt.jar:") +
-                       strlen(CLASSPATH_PREFIX"/lib/sunrsasign.jar:") +
-                       strlen(CLASSPATH_PREFIX"/lib/jsse.jar:") +
-                       strlen(CLASSPATH_PREFIX"/lib/jce.jar:") +
-                       strlen(CLASSPATH_PREFIX"/lib/charsets.jar:") +
-                       strlen(CLASSPATH_PREFIX"/classes") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:") +
+                       strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/classes") +
                        strlen("0");
 
                boot_class_path = MNEW(char, len);
 
-               strcpy(boot_class_path, CLASSPATH_PREFIX"/lib/resources.jar:");
-               strcat(boot_class_path, CLASSPATH_PREFIX"/lib/rt.jar:");
-               strcat(boot_class_path, CLASSPATH_PREFIX"/lib/sunrsasign.jar:");
-               strcat(boot_class_path, CLASSPATH_PREFIX"/lib/jsse.jar:");
-               strcat(boot_class_path, CLASSPATH_PREFIX"/lib/jce.jar:");
-               strcat(boot_class_path, CLASSPATH_PREFIX"/lib/charsets.jar:");
-               strcat(boot_class_path, CLASSPATH_PREFIX"/classes");
+               strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:");
+               strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/classes");
 
-# elif defined(WITH_CLASSPATH_CLDC1_1)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
                len =
-                       strlen(CLASSPATH_CLASSES) +
+                       strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
                        strlen("0");
 
                boot_class_path = MNEW(char, len);
 
-               strcpy(boot_class_path, CLASSPATH_CLASSES);
+               strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES);
 
 # else
 #  error unknown classpath configuration
@@ -389,7 +389,7 @@ void properties_set(void)
                properties_add("java.vm.info", "JIT mode");
        }
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
        /* Get properties from system. */
 
@@ -519,7 +519,7 @@ void properties_set(void)
                properties_add("user.country", "US");
        }
 
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
        /* Actually this property is set by OpenJDK, but we need it in
           nativevm_preinit(). */
index 39e1c6b22455211b34828b3d7cf93159b7736b32..f11a67bc6dabfeea24f6fa7d76deb7bbc753b53c 100644 (file)
@@ -82,7 +82,7 @@ bool signal_init(void)
        if (sigemptyset(&mask) != 0)
                vm_abort_errno("signal_init: sigemptyset failed");
 
-#if !defined(WITH_CLASSPATH_SUN)
+#if !defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        /* Let OpenJDK handle SIGINT itself. */
 
        if (sigaddset(&mask, SIGINT) != 0)
@@ -252,7 +252,7 @@ static void signal_thread(void)
        if (sigemptyset(&mask) != 0)
                vm_abort_errno("signal_thread: sigemptyset failed");
 
-#if !defined(WITH_CLASSPATH_SUN)
+#if !defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        /* Let OpenJDK handle SIGINT itself. */
 
        if (sigaddset(&mask, SIGINT) != 0)
index ea79bcc71946caef7fadd6fa1f59dd49e9eb0432..0a6536aa96fb9ea7d097edc6618e7782c5c589eb 100644 (file)
@@ -49,7 +49,7 @@
 #include "native/include/java_lang_Object.h"             /* required by j.l.C */
 #include "native/include/java_lang_String.h"             /* required by j.l.C */
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 # include "native/include/java_nio_ByteBuffer.h"        /* required by j.l.CL */
 # include "native/include/java_lang_ClassLoader.h"       /* required by j.l.C */
 #endif
@@ -135,8 +135,7 @@ bool vm_initializing = false;
 bool vm_created      = false;
 bool vm_exiting      = false;
 
-char      *mainstring = NULL;
-classinfo *mainclass = NULL;
+static classinfo *mainclass = NULL;
 
 #if defined(ENABLE_INTRP)
 u1 *intrp_main_stack = NULL;
@@ -639,12 +638,12 @@ static void vm_printconfig(void)
        /* When we're building with JRE-layout, the default paths are the
           same as the runtime paths. */
 #else
-# if defined(WITH_CLASSPATH_GNU)
-       puts("  gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR);
-       puts("  java.boot.class.path           : "CACAO_VM_ZIP":"CLASSPATH_CLASSES"");
-# elif defined(WITH_CLASSPATH_SUN)
-       puts("  sun.boot.library.path          : "CLASSPATH_LIBDIR);
-       puts("  java.boot.class.path           : "CLASSPATH_CLASSES);
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+       puts("  gnu.classpath.boot.library.path: "JAVA_RUNTIME_LIBRARY_LIBDIR);
+       puts("  java.boot.class.path           : "CACAO_VM_ZIP":"JAVA_RUNTIME_LIBRARY_CLASSES"");
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       puts("  sun.boot.library.path          : "JAVA_RUNTIME_LIBRARY_LIBDIR);
+       puts("  java.boot.class.path           : "JAVA_RUNTIME_LIBRARY_CLASSES);
 # endif
 #endif
 
@@ -655,9 +654,9 @@ static void vm_printconfig(void)
        printf("  initial heap size              : %d\n", opt_heapstartsize);
        printf("  stack size                     : %d\n", opt_stacksize);
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        printf("  gnu.classpath.boot.library.path: %s\n", properties_get("gnu.classpath.boot.library.path"));
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        printf("  sun.boot.library.path          : %s\n", properties_get("sun.boot.library.path"));
 #endif
 
@@ -671,7 +670,7 @@ static void vm_printconfig(void)
 static char *vm_get_mainclass_from_jar(char *mainstring);
 #if !defined(NDEBUG)
 static void  vm_compile_all(void);
-static void  vm_compile_method(void);
+static void  vm_compile_method(char* mainname);
 #endif
 
 
@@ -1363,37 +1362,6 @@ bool vm_create(JavaVMInitArgs *vm_args)
                }
        }
 
-       /* get the main class *****************************************************/
-
-       if (opt_index < vm_args->nOptions) {
-               mainstring = vm_args->options[opt_index++].optionString;
-
-               /* Put the jar file into the classpath (if any). */
-
-               if (opt_jar == true) {
-                       /* free old classpath */
-
-/*                     MFREE(_Jv_classpath, char, strlen(_Jv_classpath)); */
-
-                       /* put jarfile into classpath */
-
-                       p = MNEW(char, strlen(mainstring) + strlen("0"));
-
-                       strcpy(p, mainstring);
-
-#if defined(ENABLE_JAVASE)
-                       properties_add("java.class.path", p);
-#endif
-               }
-               else {
-                       /* replace .'s with /'s in classname */
-
-                       for (i = strlen(mainstring) - 1; i >= 0; i--)
-                               if (mainstring[i] == '.')
-                                       mainstring[i] = '/';
-               }
-       }
-
 #if defined(ENABLE_JVMTI)
        if (jvmti) {
                jvmti_set_phase(JVMTI_PHASE_ONLOAD);
@@ -1657,6 +1625,9 @@ bool vm_create(JavaVMInitArgs *vm_args)
 
 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
 {
+       char*                      option;
+       char*                      mainname;
+       char*                      p;
        utf                       *mainutf;
        classinfo                 *mainclass;
        java_handle_t             *e;
@@ -1677,18 +1648,67 @@ void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
                vm_compile_all();
                return;
        }
+#endif
 
-       if (opt_method != NULL) {
-               vm_compile_method();
-               return;
+       /* Get the main class plus it's arguments. */
+
+       mainname = NULL;
+
+       if (opt_index < vm_args->nOptions) {
+               /* Get main-class argument. */
+
+               mainname = vm_args->options[opt_index].optionString;
+
+               /* If the main class argument is a jar file, put it into the
+                  classpath. */
+
+               if (opt_jar == true) {
+                       p = MNEW(char, strlen(mainname) + strlen("0"));
+
+                       strcpy(p, mainname);
+
+#if defined(ENABLE_JAVASE)
+                       properties_add("java.class.path", p);
+#endif
+               }
+               else {
+                       /* Replace dots with slashes in the class name. */
+
+                       for (i = 0; i < strlen(mainname); i++)
+                               if (mainname[i] == '.')
+                                       mainname[i] = '/';
+               }
+
+               /* Build argument array.  Move index to first argument. */
+
+               opt_index++;
+
+               oalength = vm_args->nOptions - opt_index;
+
+               oa = builtin_anewarray(oalength, class_java_lang_String);
+
+               for (i = 0; i < oalength; i++) {
+                       option = vm_args->options[opt_index + i].optionString;
+
+                       u = utf_new_char(option);
+                       s = javastring_new(u);
+
+                       array_objectarray_element_set(oa, i, s);
+               }
        }
-#endif /* !defined(NDEBUG) */
 
-       /* should we run the main-method? */
+       /* Do we have a main-class argument? */
 
-       if (mainstring == NULL)
+       if (mainname == NULL)
                usage();
 
+#if !defined(NDEBUG)
+       if (opt_method != NULL) {
+               vm_compile_method(mainname);
+               return;
+       }
+#endif
+
        /* set return value to OK */
 
        status = 0;
@@ -1696,15 +1716,15 @@ void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
        if (opt_jar == true) {
                /* open jar file with java.util.jar.JarFile */
 
-               mainstring = vm_get_mainclass_from_jar(mainstring);
+               mainname = vm_get_mainclass_from_jar(mainname);
 
-               if (mainstring == NULL)
+               if (mainname == NULL)
                        vm_exit(1);
        }
 
        /* load the main class */
 
-       mainutf = utf_new_char(mainstring);
+       mainutf = utf_new_char(mainname);
 
 #if defined(ENABLE_JAVAME_CLDC1_1)
        mainclass = load_class_bootstrap(mainutf);
@@ -1752,24 +1772,10 @@ void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
                vm_exit(1);
        }
 
-       /* build argument array */
-
-       oalength = vm_args->nOptions - opt_index;
-
-       oa = builtin_anewarray(oalength, class_java_lang_String);
-
-       for (i = 0; i < oalength; i++) {
-               u = utf_new_char(vm_args->options[opt_index + i].optionString);
-               s = javastring_new(u);
-
-               array_objectarray_element_set(oa, i, s);
-       }
-
 #ifdef TYPEINFO_DEBUG_TEST
        /* test the typeinfo system */
        typeinfo_test();
 #endif
-       /*class_showmethods(currentThread->group->header.vftbl->class); */
 
 #if defined(ENABLE_JVMTI)
        jvmti_set_phase(JVMTI_PHASE_LIVE);
@@ -2137,7 +2143,7 @@ void vm_abort_disassemble(void *pc, int count, const char *text, ...)
 
 *******************************************************************************/
 
-static char *vm_get_mainclass_from_jar(char *mainstring)
+static char *vm_get_mainclass_from_jar(char *mainname)
 {
        classinfo     *c;
        java_handle_t *o;
@@ -2171,7 +2177,7 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
                return NULL;
        }
 
-       s = javastring_new_from_ascii(mainstring);
+       s = javastring_new_from_ascii(mainname);
 
        (void) vm_call_method(m, o, s);
 
@@ -2196,7 +2202,7 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
        o = vm_call_method(m, o);
 
        if (o == NULL) {
-               fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
+               fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainname);
                return NULL;
        }
 
@@ -2219,7 +2225,7 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
        o = vm_call_method(m, o);
 
        if (o == NULL) {
-               fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
+               fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainname);
                return NULL;
        }
 
@@ -2245,7 +2251,7 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
 
        if (o == NULL) {
                fprintf(stderr, "Failed to load Main-Class manifest attribute from\n");
-               fprintf(stderr, "%s\n", mainstring);
+               fprintf(stderr, "%s\n", mainname);
                return NULL;
        }
 
@@ -2338,13 +2344,13 @@ static void vm_compile_all(void)
 *******************************************************************************/
 
 #if !defined(NDEBUG)
-static void vm_compile_method(void)
+static void vm_compile_method(char* mainname)
 {
        methodinfo *m;
 
        /* create, load and link the main class */
 
-       mainclass = load_class_bootstrap(utf_new_char(mainstring));
+       mainclass = load_class_bootstrap(utf_new_char(mainname));
 
        if (mainclass == NULL)
                exceptions_print_stacktrace();
index 8a786cd835ba5ad054abf98ece0263c066ead71b..6c5fe4e1836e683eafef89b2bd7191291bd0998c 100644 (file)
@@ -50,9 +50,6 @@ extern bool vm_initializing;
 extern bool vm_created;
 extern bool vm_exiting;
 
-extern char      *mainstring;
-extern classinfo *mainclass;
-
 #if defined(ENABLE_INTRP)
 extern u1 *intrp_main_stack;
 #endif
index bccb4d5d12909cad41ffe18b5dd241c31f75ddb5..ec8432278550d6e33f5e891ddb9c62c6088d9716 100644 (file)
@@ -93,7 +93,7 @@ classinfo *class_java_lang_ThreadGroup;
 classinfo *class_java_lang_Throwable;
 classinfo *class_java_io_Serializable;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 classinfo *class_java_lang_VMSystem;
 classinfo *class_java_lang_VMThread;
 classinfo *class_java_lang_VMThrowable;
@@ -105,7 +105,7 @@ classinfo *class_java_lang_Exception;
 classinfo *class_java_lang_ClassNotFoundException;
 classinfo *class_java_lang_RuntimeException;
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 classinfo *class_sun_reflect_MagicAccessorImpl;
 #endif
 
@@ -132,7 +132,7 @@ classinfo *class_java_security_PrivilegedAction;
 classinfo *class_java_util_Vector;
 classinfo *class_java_util_HashMap;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 classinfo *class_java_lang_reflect_VMConstructor;
 classinfo *class_java_lang_reflect_VMField;
 classinfo *class_java_lang_reflect_VMMethod;
@@ -142,7 +142,7 @@ classinfo *arrayclass_java_lang_Object;
 
 # if defined(ENABLE_ANNOTATIONS)
 classinfo *class_sun_reflect_ConstantPool;
-#  if defined(WITH_CLASSPATH_GNU)
+#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 classinfo *class_sun_reflect_annotation_AnnotationParser;
 #  endif
 # endif
@@ -380,7 +380,7 @@ classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *d
        }
 
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_SUN)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        /* Store the protection domain. */
 
        c->protectiondomain = pd;
index 2bd79593c9cd54f28e7f8f78a43b671fedbf45d2..13c85d8171852dd2919317ec89f6d5fe3d82affe 100644 (file)
@@ -83,11 +83,11 @@ typedef struct castinfo       castinfo;
 
 typedef struct {
        java_object_t      header;
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        intptr_t           padding[4];
-#elif defined(WITH_CLASSPATH_SUN)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        intptr_t           padding[19];
-#elif defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
        intptr_t           padding[3];
 #else
 # error unknown classpath configuration
@@ -161,7 +161,7 @@ struct classinfo {                /* class structure                          */
        classloader_t *classloader;       /* NULL for bootstrap classloader         */
 
 #if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_SUN)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        java_object_t      *protectiondomain;
        java_objectarray_t *signers;
 # endif
@@ -224,13 +224,13 @@ extern classinfo *class_java_lang_Exception;
 extern classinfo *class_java_lang_ClassNotFoundException;
 extern classinfo *class_java_lang_RuntimeException;
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 extern classinfo *class_java_lang_VMSystem;
 extern classinfo *class_java_lang_VMThread;
 extern classinfo *class_java_lang_VMThrowable;
 #endif
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 extern classinfo *class_sun_reflect_MagicAccessorImpl;
 #endif
 
@@ -258,7 +258,7 @@ extern classinfo *class_java_security_PrivilegedAction;
 extern classinfo *class_java_util_Vector;
 extern classinfo *class_java_util_HashMap;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 extern classinfo *class_java_lang_reflect_VMConstructor;
 extern classinfo *class_java_lang_reflect_VMField;
 extern classinfo *class_java_lang_reflect_VMMethod;
@@ -268,7 +268,7 @@ extern classinfo *arrayclass_java_lang_Object;
 
 # if defined(ENABLE_ANNOTATIONS)
 extern classinfo *class_sun_reflect_ConstantPool;
-#  if defined(WITH_CLASSPATH_GNU)
+#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 extern classinfo *class_sun_reflect_annotation_AnnotationParser;
 #  endif
 # endif
index e8b985aad4891065d335bea85195f6081964781d..cee3866ee312c30c30532673bb8c05ce7f379e57 100644 (file)
@@ -268,7 +268,7 @@ void linker_init(void)
        if (!link_class(class_java_lang_Throwable))
                vm_abort("linker_init: linking failed");
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        if (!link_class(class_java_lang_VMSystem))
                vm_abort("linker_init: linking failed");
 
@@ -305,7 +305,7 @@ void linker_init(void)
        if (!link_class(class_java_lang_reflect_Method))
                vm_abort("linker_init: linking failed");
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        if (!link_class(class_java_lang_reflect_VMConstructor))
                vm_abort("linker_init: linking failed");
 
@@ -325,7 +325,7 @@ void linker_init(void)
        if (!link_class(class_java_util_HashMap))
                vm_abort("linker_init: linking failed");
 
-# if defined(WITH_CLASSPATH_SUN)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        if (!link_class(class_sun_reflect_MagicAccessorImpl))
                vm_abort("linker_init: linking failed");
 # endif
index c664b12eaf7f5c9e96ce1c8a13c0090540114763..a1d730ccc39f29d7978405fd7c3436cfa10cddd2 100644 (file)
@@ -186,7 +186,7 @@ void loader_init(void)
 
        class_java_lang_Throwable  = load_class_bootstrap(utf_java_lang_Throwable);
 
-#if defined(WITH_CLASSPATH_GNU)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        class_java_lang_VMSystem   =
                load_class_bootstrap(utf_new_char("java/lang/VMSystem"));
 
@@ -216,7 +216,7 @@ void loader_init(void)
        class_java_lang_reflect_Field          = load_class_bootstrap(utf_java_lang_reflect_Field);
        class_java_lang_reflect_Method         = load_class_bootstrap(utf_java_lang_reflect_Method);
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        class_java_lang_reflect_VMConstructor  = load_class_bootstrap(utf_java_lang_reflect_VMConstructor);
        class_java_lang_reflect_VMField        = load_class_bootstrap(utf_java_lang_reflect_VMField);
        class_java_lang_reflect_VMMethod       = load_class_bootstrap(utf_java_lang_reflect_VMMethod);
@@ -227,7 +227,7 @@ void loader_init(void)
        class_java_util_HashMap                = load_class_bootstrap(utf_new_char("java/util/HashMap"));
        class_java_util_Vector                 = load_class_bootstrap(utf_java_util_Vector);
 
-# if defined(WITH_CLASSPATH_SUN)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
        class_sun_reflect_MagicAccessorImpl =
                load_class_bootstrap(utf_new_char("sun/reflect/MagicAccessorImpl"));
 # endif
@@ -240,7 +240,7 @@ void loader_init(void)
        class_sun_reflect_ConstantPool =
                load_class_bootstrap(utf_new_char("sun/reflect/ConstantPool"));
 
-#  if defined(WITH_CLASSPATH_GNU)
+#  if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        /* needed by GNU Classpaths annotation support */
        class_sun_reflect_annotation_AnnotationParser =
                load_class_bootstrap(utf_new_char("sun/reflect/annotation/AnnotationParser"));
@@ -1130,7 +1130,7 @@ classinfo *load_class_from_classloader(utf *name, classloader_t *cl)
 
                LLNI_class_get(cl, c);
 
-#if defined(WITH_CLASSPATH_SUN)
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
                /* OpenJDK uses this internal function because it's
                   synchronized. */
 
index 9cb1f1109dbb7d292c32b3f63efb6d1cdf7e2abd..b292d95b046ed062bdb8ef067b2f11cd71082143 100644 (file)
@@ -132,7 +132,7 @@ utf *utf_java_lang_reflect_Constructor;
 utf *utf_java_lang_reflect_Field;
 utf *utf_java_lang_reflect_Method;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 utf *utf_java_lang_reflect_VMConstructor;
 utf *utf_java_lang_reflect_VMField;
 utf *utf_java_lang_reflect_VMMethod;
@@ -393,7 +393,7 @@ void utf8_init(void)
        utf_java_lang_reflect_Field    = utf_new_char("java/lang/reflect/Field");
        utf_java_lang_reflect_Method   = utf_new_char("java/lang/reflect/Method");
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        utf_java_lang_reflect_VMConstructor = utf_new_char("java/lang/reflect/VMConstructor");
        utf_java_lang_reflect_VMField       = utf_new_char("java/lang/reflect/VMField");
        utf_java_lang_reflect_VMMethod      = utf_new_char("java/lang/reflect/VMMethod");
index c2fd69bee10495c123bd6d484fc6c43ee43835f4..6f766106288705ae4aa91d2feeee4e0e08389429 100644 (file)
@@ -128,7 +128,7 @@ extern utf *utf_java_lang_reflect_Constructor;
 extern utf *utf_java_lang_reflect_Field;
 extern utf *utf_java_lang_reflect_Method;
 
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 extern utf *utf_java_lang_reflect_VMConstructor;
 extern utf *utf_java_lang_reflect_VMField;
 extern utf *utf_java_lang_reflect_VMMethod;