jdk1.2 and loader optimisation
authorroman <none@none>
Mon, 4 Oct 1999 10:35:09 +0000 (10:35 +0000)
committerroman <none@none>
Mon, 4 Oct 1999 10:35:09 +0000 (10:35 +0000)
149 files changed:
Makefile.am
Makefile.in
alpha/asmpart.c
alpha/ngen.c
asmpart.h
builtin.c
builtin.h
comp/block.c
comp/parse.c
comp/tools.c
compiler.c
global.h
headers.c
jit.c
jit/parse.c
jit/stack.c
jni.c [new file with mode: 0644]
jni.h [new file with mode: 0644]
loader.c
loader.h
main.c
nat/AccessController.c [new file with mode: 0644]
nat/AccessController.h [new file with mode: 0644]
nat/Adler32.c [new file with mode: 0644]
nat/Adler32.h [new file with mode: 0644]
nat/Array.c [new file with mode: 0644]
nat/Array.h [new file with mode: 0644]
nat/BigInteger.c [new file with mode: 0644]
nat/BigInteger.h [new file with mode: 0644]
nat/CRC32.c [new file with mode: 0644]
nat/CRC32.h [new file with mode: 0644]
nat/Class.c [new file with mode: 0644]
nat/Class.h [new file with mode: 0644]
nat/ClassLoader.c [new file with mode: 0644]
nat/ClassLoader.h [new file with mode: 0644]
nat/ClassLoader_NativeLibrary.c [new file with mode: 0644]
nat/ClassLoader_NativeLibrary.h [new file with mode: 0644]
nat/Compiler.c [new file with mode: 0644]
nat/Compiler.h [new file with mode: 0644]
nat/Constructor.c [new file with mode: 0644]
nat/Constructor.h [new file with mode: 0644]
nat/Date.h [new file with mode: 0644]
nat/Deflater.c [new file with mode: 0644]
nat/Deflater.h [new file with mode: 0644]
nat/Double.c [new file with mode: 0644]
nat/Double.h [new file with mode: 0644]
nat/Exception.h [new file with mode: 0644]
nat/Field.c [new file with mode: 0644]
nat/Field.h [new file with mode: 0644]
nat/File.h [new file with mode: 0644]
nat/FileDescriptor.c [new file with mode: 0644]
nat/FileDescriptor.h [new file with mode: 0644]
nat/FileInputStream.c [new file with mode: 0644]
nat/FileInputStream.h [new file with mode: 0644]
nat/FileOutputStream.c [new file with mode: 0644]
nat/FileOutputStream.h [new file with mode: 0644]
nat/FileSystem.c [new file with mode: 0644]
nat/FileSystem.h [new file with mode: 0644]
nat/Finalizer.c [new file with mode: 0644]
nat/Finalizer.h [new file with mode: 0644]
nat/Float.c [new file with mode: 0644]
nat/Float.h [new file with mode: 0644]
nat/InetAddress.c [new file with mode: 0644]
nat/InetAddress.h [new file with mode: 0644]
nat/InetAddressImpl.c [new file with mode: 0644]
nat/InetAddressImpl.h [new file with mode: 0644]
nat/Inflater.c [new file with mode: 0644]
nat/Inflater.h [new file with mode: 0644]
nat/InputStream.h [new file with mode: 0644]
nat/JarFile.c [new file with mode: 0644]
nat/JarFile.h [new file with mode: 0644]
nat/Makefile.am
nat/Makefile.in
nat/Math.c [new file with mode: 0644]
nat/Math.h [new file with mode: 0644]
nat/Method.c [new file with mode: 0644]
nat/Method.h [new file with mode: 0644]
nat/Modifier.h [new file with mode: 0644]
nat/Object.c [new file with mode: 0644]
nat/Object.h [new file with mode: 0644]
nat/ObjectInputStream.c [new file with mode: 0644]
nat/ObjectInputStream.h [new file with mode: 0644]
nat/ObjectStreamClass.c [new file with mode: 0644]
nat/ObjectStreamClass.h [new file with mode: 0644]
nat/Package.c [new file with mode: 0644]
nat/Package.h [new file with mode: 0644]
nat/PrintStream.h [new file with mode: 0644]
nat/PrivilegedAction.h [new file with mode: 0644]
nat/PrivilegedActionException.h [new file with mode: 0644]
nat/PrivilegedExceptionAction.h [new file with mode: 0644]
nat/Properties.h [new file with mode: 0644]
nat/RandomAccessFile.c [new file with mode: 0644]
nat/RandomAccessFile.h [new file with mode: 0644]
nat/ResourceBundle.c [new file with mode: 0644]
nat/ResourceBundle.h [new file with mode: 0644]
nat/Runtime.c [new file with mode: 0644]
nat/Runtime.h [new file with mode: 0644]
nat/SecurityManager.c [new file with mode: 0644]
nat/SecurityManager.h [new file with mode: 0644]
nat/String.c [new file with mode: 0644]
nat/String.h [new file with mode: 0644]
nat/System.c [new file with mode: 0644]
nat/System.h [new file with mode: 0644]
nat/Thread.c [new file with mode: 0644]
nat/Thread.h [new file with mode: 0644]
nat/ThreadGroup.h [new file with mode: 0644]
nat/Throwable.c [new file with mode: 0644]
nat/Throwable.h [new file with mode: 0644]
nat/UnixFileSystem.c [new file with mode: 0644]
nat/UnixFileSystem.h [new file with mode: 0644]
nat/ZipEntry.c [new file with mode: 0644]
nat/ZipEntry.h [new file with mode: 0644]
nat/ZipFile.c [new file with mode: 0644]
nat/ZipFile.h [new file with mode: 0644]
nat/io.c [deleted file]
nat/lang.c [deleted file]
nat/util.c [deleted file]
native.c
native.h
src/cacao/cacao.c
src/cacaoh/headers.c
src/native/jni.c [new file with mode: 0644]
src/native/jni.h [new file with mode: 0644]
src/native/native.c
src/native/native.h
src/native/vm/Constructor.c [new file with mode: 0644]
src/native/vm/Field.c [new file with mode: 0644]
src/native/vm/Makefile.am
src/native/vm/Method.c [new file with mode: 0644]
src/native/vm/VMRuntime.c [new file with mode: 0644]
src/native/vm/VMThread.c [new file with mode: 0644]
src/threads/green/locks.c
src/threads/green/threadio.c
src/threads/green/threads.c
src/vm/builtin.c
src/vm/builtin.h
src/vm/global.h
src/vm/jit/asmpart.h
src/vm/jit/parse.c
src/vm/jit/stack.c
src/vm/loader.c
src/vm/loader.h
src/vm/tables.c
src/vm/tables.h
tables.c
tables.h
threads/locks.c
threads/thread.c
threads/threadio.c

index 31126a85023f0044c37f9d0afb5e97fb6bc273eb..26c443eae0aa5de137c5c30bba6dd3f7f5183d17 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-# $Id: Makefile.am 131 1999-09-27 15:33:16Z chris $
+# $Id: Makefile.am 135 1999-10-04 10:35:09Z roman $
 
 MAINTAINERCLEANFILES = Makefile.in configure
 SUBDIRS = toolbox mm alpha jit comp nat threads mips tst doc narray
@@ -63,26 +63,54 @@ nativetypes.hh @SYSDEP_DIR@/offsets.h nativetable.hh: cacaoh
        ./cacaoh \
                java.lang.Object \
                java.lang.String \
-               java.lang.Class \
                java.lang.ClassLoader \
+               java.lang.Class \
                java.lang.Compiler \
                java.lang.Double \
                java.lang.Float \
                java.lang.Math \
+               java.lang.Package \
                java.lang.Runtime \
                java.lang.SecurityManager \
+               java.lang.Exception \
+               java.io.PrintStream \
+               java.io.InputStream \
                java.lang.System \
                java.lang.Thread \
                java.lang.ThreadGroup \
                java.lang.Throwable \
-               java.io.File \
+               java.lang.reflect.Array \
+               java.lang.reflect.Constructor \
+               java.lang.reflect.Field \
+               java.lang.reflect.Method \
+               java.lang.reflect.Modifier \
                java.io.FileDescriptor \
                java.io.FileInputStream \
                java.io.FileOutputStream \
-               java.io.PrintStream \
+               java.io.FileSystem \
+               java.io.ObjectInputStream \
+               java.io.ObjectStreamClass \
                java.io.RandomAccessFile \
+               java.util.ResourceBundle \
+               java.util.jar.JarFile \
+               java.util.zip.Adler32 \
+               java.util.zip.CRC32 \
+               java.util.zip.Deflater \
+               java.util.zip.Inflater \
+               java.util.zip.ZipEntry \
+               java.util.zip.ZipFile \
                java.util.Properties \
-               java.util.Date
+               java.util.Date \
+               java.math.BigInteger \
+               java.net.InetAddress \
+               java.net.InetAddressImpl \
+               java.security.PrivilegedActionException \
+               java.security.PrivilegedAction \
+               java.security.PrivilegedExceptionAction \
+               java.security.AccessController \
+               java.io.File \
+               java.io.UnixFileSystem \
+               java.lang.ClassLoader_NativeLibrary
 
 @SYSDEP_DIR@/asmpart.o: $(top_srcdir)/@SYSDEP_DIR@/asmpart.c @SYSDEP_DIR@/offsets.h
        rm -f @SYSDEP_DIR@/asmpart.s
index 38aaff47abb58d5f8220188f379ca1dde9027052..4f142f20c5c046b1d2a5c6e52c650a5a41df6f05 100644 (file)
@@ -10,7 +10,7 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-# $Id: Makefile.in 132 1999-09-27 15:54:42Z chris $
+# $Id: Makefile.in 135 1999-10-04 10:35:09Z roman $
 
 
 SHELL = /bin/sh
@@ -86,21 +86,8 @@ CLEANFILES = @SYSDEP_DIR@/asmpart.o \
 
 bin_PROGRAMS = cacao
 noinst_PROGRAMS = cacaoh
-<<<<<<< Makefile.in
 
 INCLUDES=-I/usr/include -I$(top_srcdir)/@SYSDEP_DIR@ -I$(top_srcdir)/jit -I@SYSDEP_DIR@ -I$(top_srcdir)
-=======
-
-INCLUDES = -I/usr/include -I$(top_srcdir)/@SYSDEP_DIR@ -I$(top_srcdir)/jit -I@SYSDEP_DIR@ -I$(top_srcdir)
-
-cacao_SOURCES =        asmpart.h       builtin.c       builtin.h       callargs.h      @COMPILER_SOURCES@      global.h        jit.c   jit.h   loader.c        loader.h        main.c  native.c        native.h        tables.c        tables.h
-
-
-EXTRA_cacao_SOURCES =          compiler.c      compiler.h 
-
-
-cacao_LDADD =          @SYSDEP_DIR@/asmpart.o  @COMPILER_OBJECTS@      toolbox/libtoolbox.a    @GC_OBJ@     @THREAD_OBJ@
->>>>>>> 3.10
 
 cacao_SOURCES = \
        asmpart.h \
@@ -519,26 +506,54 @@ nativetypes.hh @SYSDEP_DIR@/offsets.h nativetable.hh: cacaoh
        ./cacaoh \
                java.lang.Object \
                java.lang.String \
-               java.lang.Class \
                java.lang.ClassLoader \
+               java.lang.Class \
                java.lang.Compiler \
                java.lang.Double \
                java.lang.Float \
                java.lang.Math \
+               java.lang.Package \
                java.lang.Runtime \
                java.lang.SecurityManager \
+               java.lang.Exception \
+               java.io.PrintStream \
+               java.io.InputStream \
                java.lang.System \
                java.lang.Thread \
                java.lang.ThreadGroup \
                java.lang.Throwable \
-               java.io.File \
+               java.lang.reflect.Array \
+               java.lang.reflect.Constructor \
+               java.lang.reflect.Field \
+               java.lang.reflect.Method \
+               java.lang.reflect.Modifier \
                java.io.FileDescriptor \
                java.io.FileInputStream \
                java.io.FileOutputStream \
-               java.io.PrintStream \
+               java.io.FileSystem \
+               java.io.ObjectInputStream \
+               java.io.ObjectStreamClass \
                java.io.RandomAccessFile \
+               java.util.ResourceBundle \
+               java.util.jar.JarFile \
+               java.util.zip.Adler32 \
+               java.util.zip.CRC32 \
+               java.util.zip.Deflater \
+               java.util.zip.Inflater \
+               java.util.zip.ZipEntry \
+               java.util.zip.ZipFile \
                java.util.Properties \
-               java.util.Date
+               java.util.Date \
+               java.math.BigInteger \
+               java.net.InetAddress \
+               java.net.InetAddressImpl \
+               java.security.PrivilegedActionException \
+               java.security.PrivilegedAction \
+               java.security.PrivilegedExceptionAction \
+               java.security.AccessController \
+               java.io.File \
+               java.io.UnixFileSystem \
+               java.lang.ClassLoader_NativeLibrary
 
 @SYSDEP_DIR@/asmpart.o: $(top_srcdir)/@SYSDEP_DIR@/asmpart.c @SYSDEP_DIR@/offsets.h
        rm -f @SYSDEP_DIR@/asmpart.s
@@ -555,7 +570,6 @@ compiler.o: $(top_srcdir)/builtin.h $(top_srcdir)/compiler.h \
             $(top_srcdir)/@SYSDEP_DIR@/gen.c $(top_srcdir)/@SYSDEP_DIR@/disass.c
        @CC@ $(CFLAGS) -I. $(INCLUDES) -c $(top_srcdir)/compiler.c
 
-<<<<<<< Makefile.in
 jit.o: jit.c \
        jit/mcode.c \
        jit/parse.c \
@@ -568,15 +582,6 @@ jit.o: jit.c \
        narray/tracing.c \
        narray/loop.h
 
-=======
-jit.o: jit.c \
-       jit/mcode.c \
-       jit/parse.c \
-       jit/reg.c \
-       jit/stack.c \
-       jit/jitdef.h
-
->>>>>>> 3.10
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
index a6ce31b909b81159865fd011d9bc0d8fe392a0ec..b08c022bdd23f474afc541884d1f646cbe70c2d1 100644 (file)
        .globl has_no_x_instr_set
        .globl synchronize_caches
        .globl asm_calljavamethod
+       .globl asm_calljavafunction
        .globl asm_call_jit_compiler
        .globl asm_dumpregistersandcall
        .globl asm_handle_exception
        .globl asm_handle_nat_exception
+       .globl asm_builtin_checkcast    
        .globl asm_builtin_checkarraycast
        .globl asm_builtin_aastore
        .globl asm_builtin_monitorenter
        .globl asm_perform_threadswitch
        .globl asm_initialize_thread_stack
        .globl asm_switchstackandcall
-
+       .globl asm_getcallingmethod
 
 /*************************** imported variables *******************************/
 
@@ -244,6 +246,86 @@ calljava_xhandler:
        .end    asm_calljavamethod
 
 
+/********************* function asm_calljavafunction ***************************
+*                                                                              *
+*   This function calls a Java-method (which possibly needs compilation)       *
+*   with up to 4 address parameters.                                           *
+*                                                                              *
+*   This functions calls the JIT-compiler which eventually translates the      *
+*   method into machine code.                                                  *
+*                                                                              *
+*   C-prototype:                                                               *
+*    javaobject_header *asm_calljavamethod (methodinfo *m,                     *
+*         void *arg1, void *arg2, void *arg3, void *arg4);                     *
+*                                                                              *
+*******************************************************************************/
+
+       .ent    asm_calljavafunction
+
+call_name2:
+       .ascii  "calljavafunction\0\0"
+
+       .align  3
+       .quad   0                         /* catch type all                       */
+       .quad   calljava_xhandler2        /* handler pc                           */
+       .quad   calljava_xhandler2        /* end pc                               */
+       .quad   asm_calljavafunction      /* start pc                             */
+       .long   1                         /* extable size                         */
+       .long   0                         /* fltsave                              */
+       .long   0                         /* intsave                              */
+       .long   0                         /* isleaf                               */
+       .long   0                         /* IsSync                               */
+       .long   32                        /* frame size                           */
+       .quad   0                         /* method pointer (pointer to name)     */
+
+asm_calljavafunction:
+
+       ldgp    gp,0(pv)
+       lda     sp,-32(sp)                /* allocate stack space                 */
+       stq     gp,24(sp)                 /* save global pointer                  */
+       stq     ra,0(sp)                  /* save return address                  */
+
+       stq     a0,16(sp)                 /* save method pointer for compiler     */
+       lda     v0,16(sp)                 /* pass pointer to method pointer via v0*/
+
+       mov     a1,a0                     /* pass the remaining parameters        */
+       mov     a2,a1
+       mov     a3,a2
+       mov     a4,a3
+
+       lda     $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
+       stq     $28,8(sp)                 /* store function address               */
+       mov     sp,$28                    /* set method pointer                   */
+
+       ldq     pv,8($28)                 /* method call as in Java               */
+       jmp     ra,(pv)                   /* call JIT compiler                    */
+calljava_jit2:
+       lda     pv,-64(ra)                /* asm_calljavafunction-calljava_jit !!!!!*/
+
+calljava_return2:
+
+       ldq     ra,0(sp)                  /* restore return address               */
+       ldq     gp,24(sp)                 /* restore global pointer               */
+       lda     sp,32(sp)                 /* free stack space                     */
+
+/*     ldl     v0,newcompiler */         /* load newcompiler flag                */
+/*     subq    v0,1,v0        */         /* negate for clearing v0               */
+/*     beq     v0,calljava_ret*/         /* if newcompiler skip ex copying       */
+/*     mov     $1,v0 */                  /* pass exception to caller (C)         */
+calljava_ret2:
+       jmp     zero,(ra)
+
+calljava_xhandler2:
+
+       ldq     gp,24(sp)                 /* restore global pointer               */
+       mov     itmp1,a0
+       jsr     ra,builtin_throw_exception
+       ldq     ra,0(sp)                  /* restore return address               */
+       lda     sp,32(sp)                 /* free stack space                     */
+       jmp     zero,(ra)
+       .end    asm_calljavafunction
+                                               
+
 /****************** function asm_call_jit_compiler *****************************
 *                                                                              *
 *   invokes the compiler for untranslated JavaVM methods.                      *
@@ -781,6 +863,36 @@ nb_lrem:
        .end    asm_builtin_lrem
 
 
+ /*********************** function new_builtin_checkcast ************************
+ *                                                                              *
+ *   Does the cast check and eventually throws an exception                     *
+ *                                                                              *
+ *******************************************************************************/
+
+    .ent    asm_builtin_checkcast
+asm_builtin_checkcast:
+
+    ldgp    gp,0(pv)
+    lda     sp,-16(sp)                  # allocate stack space
+    stq     ra,0(sp)                    # save return address
+    stq     a0,8(sp)                    # save object pointer
+    jsr     ra,builtin_checkcast        # builtin_checkcast
+    ldgp    gp,0(ra)
+    beq     v0,nb_ccast_throw           # if (false) throw exception
+    ldq     ra,0(sp)                    # restore return address
+    ldq     v0,8(sp)                    # return object pointer
+    lda     sp,16(sp)                   # free stack space
+    jmp     zero,(ra)
+
+nb_ccast_throw:
+    ldq     xptr,proto_java_lang_ClassCastException
+    ldq     ra,0(sp)                    # restore return address
+    lda     sp,16(sp)                   # free stack space
+    lda     xpc,-4(ra)                  # faulting address is return adress - 4
+    br      asm_handle_nat_exception
+    .end    asm_builtin_checkcast
+
+               
 /******************* function asm_builtin_checkarraycast ***********************
 *                                                                              *
 *   Does the cast check and eventually throws an exception                     *
@@ -973,3 +1085,80 @@ asm_switchstackandcall:
        jmp     zero,(ra)       /* return                                             */
 
        .end    asm_switchstackandcall
+
+               
+/********************* function asm_getcallingmethod ***************************
+*                                                                              *
+*   classinfo *asm_getcallingmethodclass ();                                                              *
+*                                                                                                                                                         *    
+*   goes back stack frames to get the calling method                                              *       
+*                                                                                                                                                         *    
+*                              t2 .. sp                                                                                                       *
+*                              t3 .. ra                                                                                                       *
+*                              t4 .. pv                                                                                                       *
+*                                                                              *
+*******************************************************************************/
+
+
+       .ent    asm_getcallingmethod
+asm_getcallingmethod:
+
+       ldq             t3,16(sp)             /* load return address of native function   */                            
+       addq    sp,24,t2                          /* skip frames of C-Function and nativestub */        
+               
+    /* determine pv (t3) of java-function from ra */
+
+       ldl     t0,0(t3)              /* load instruction LDA PV,xxx(RA)          */
+       sll     t0,48,t0
+       sra     t0,48,t0              /* isolate offset                           */
+       addq    t0,t3,t4              /* compute update address                   */
+       ldl     t0,4(t3)              /* load instruction LDAH PV,xxx(PV)         */
+       srl     t0,16,t0              /* isolate instruction code                 */
+       lda     t0,-0x177b(t0)        /* test for LDAH                            */
+       bne     t0,pv_ok1       
+       ldl     t0,0(t3)              /* load instruction LDA PV,xxx(RA)          */
+       sll     t0,16,t0              /* compute high offset                      */
+       addl    t0,0,t0               /* sign extend high offset                  */
+       addq    t0,t4,t4              /* compute update address                   */
+
+pv_ok1:                        
+       ldl     t0,FrameSize(t4)      /* t0 = frame size                          */            
+       addq    t2,t0,t2                          /* skip frame of java function                          */
+       ldq             t3,-8(t2)                         /* load new ra                              */                                                                
+
+    /* determine pv (t3) of java-function from ra */
+
+       ldl     t0,0(t3)              /* load instruction LDA PV,xxx(RA)          */
+       sll     t0,48,t0
+       sra     t0,48,t0              /* isolate offset                           */
+       addq    t0,t3,t4              /* compute update address                   */
+       ldl     t0,4(t3)              /* load instruction LDAH PV,xxx(PV)         */
+       srl     t0,16,t0              /* isolate instruction code                 */
+       lda     t0,-0x177b(t0)        /* test for LDAH                            */
+       bne     t0,pv_ok2
+       ldl     t0,0(t3)              /* load instruction LDA PV,xxx(RA)          */
+       sll     t0,16,t0              /* compute high offset                      */
+       addl    t0,0,t0               /* sign extend high offset                  */
+       addq    t0,t4,t4              /* compute update address                   */
+
+pv_ok2:                
+       ldq     v0,MethodPointer(t4)  /*                                                                                  */
+
+                                                                               
+       jmp     zero,(ra)                                 /* return                                   */
+
+       .end    asm_getcallingmethod
+
+
+
+
+
+
+
+
+
+
+
+
+
+
index 69771a08159665e56a6f9889cef324d7965b679d..9fe14cea00ddcd1941b1251c37b81346335b0ddf 100644 (file)
@@ -11,7 +11,7 @@
        Authors: Andreas  Krall      EMAIL: cacao@complang.tuwien.ac.at
                 Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: ngen.c 132 1999-09-27 15:54:42Z chris $
+       Last Change: $Id: ngen.c 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
@@ -3709,28 +3709,46 @@ void removecompilerstub (u1 *stub)
        CFREE (stub, COMPSTUBSIZE * 8);
 }
 
-
 /* function: createnativestub **************************************************
 
        creates a stub routine which calls a native method
-       
+
 *******************************************************************************/
 
-#define NATIVESTUBSIZE 11
+#define NATIVESTUBSIZE 18
 
 u1 *createnativestub (functionptr f, methodinfo *m)
 {
        u8 *s = CNEW (u8, NATIVESTUBSIZE);  /* memory to hold the stub            */
        s4 *p = (s4*) s;                    /* code generation pointer            */
 
+       reg_init();
+
+       M_MOV  (argintregs[4],argintregs[5]); 
+       M_FMOV (argfltregs[4],argfltregs[5]);
+
+       M_MOV  (argintregs[3],argintregs[4]);
+       M_FMOV (argfltregs[3],argfltregs[4]);
+
+       M_MOV  (argintregs[2],argintregs[3]);
+       M_FMOV (argfltregs[2],argfltregs[3]);
+
+       M_MOV  (argintregs[1],argintregs[2]);
+       M_FMOV (argfltregs[1],argfltregs[2]);
+
+       M_MOV  (argintregs[0],argintregs[1]);
+       M_FMOV (argfltregs[0],argfltregs[1]);
+       
+       M_ALD  (argintregs[0], REG_PV, 17*8); /* load adress of jni_environement  */
+
        M_LDA  (REG_SP, REG_SP, -8);        /* build up stackframe                */
        M_AST  (REG_RA, REG_SP, 0);         /* store return address               */
 
-       M_ALD  (REG_PV, REG_PV, 8*8);       /* load adress of native method       */
+       M_ALD  (REG_PV, REG_PV, 14*8);      /* load adress of native method       */
        M_JSR  (REG_RA, REG_PV);            /* call native method                 */
 
-       M_LDA  (REG_PV, REG_RA, -4*4);      /* recompute pv from ra               */
-       M_ALD  (REG_ITMP3, REG_PV, 9*8);    /* get address of exceptionptr        */
+       M_LDA  (REG_PV, REG_RA, -15*4);      /* recompute pv from ra               */
+       M_ALD  (REG_ITMP3, REG_PV, 15*8);    /* get address of exceptionptr        */
 
        M_ALD  (REG_RA, REG_SP, 0);         /* load return address                */
        M_ALD  (REG_ITMP1, REG_ITMP3, 0);   /* load exception into reg. itmp1     */
@@ -3743,13 +3761,13 @@ u1 *createnativestub (functionptr f, methodinfo *m)
        M_AST  (REG_ZERO, REG_ITMP3, 0);    /* store NULL into exceptionptr       */
        M_LDA  (REG_ITMP2, REG_RA, -4);     /* move fault address into reg. itmp2 */
 
-       M_ALD  (REG_ITMP3, REG_PV,10*8);    /* load asm exception handler address */
+       M_ALD  (REG_ITMP3, REG_PV,16*8);    /* load asm exception handler address */
        M_JMP  (REG_ZERO, REG_ITMP3);       /* jump to asm exception handler      */
 
-
-       s[8] = (u8) f;                      /* address of native method           */
-       s[9] = (u8) (&exceptionptr);        /* address of exceptionptr            */
-       s[10]= (u8) (asm_handle_nat_exception); /* addr of asm exception handler  */
+       s[14] = (u8) f;                      /* address of native method          */
+       s[15] = (u8) (&exceptionptr);        /* address of exceptionptr           */
+       s[16] = (u8) (asm_handle_nat_exception); /* addr of asm exception handler */
+       s[17] = (u8) (&env);                  /* addr of jni_environement         */
 
 #ifdef STATISTICS
        count_nstub_len += NATIVESTUBSIZE * 8;
@@ -3758,7 +3776,6 @@ u1 *createnativestub (functionptr f, methodinfo *m)
        return (u1*) s;
 }
 
-
 /* function: removenativestub **************************************************
 
     removes a previously created native-stub from memory
index a9d2136250be9a0ed75c5560c3dcc28c5a1bf294..66a7e9b13ccb81cf3f407dd6a0d2962c7139d8ac 100644 (file)
--- a/asmpart.h
+++ b/asmpart.h
@@ -34,6 +34,15 @@ java_objectheader *asm_calljavamethod (methodinfo *m, void *arg1, void*arg2,
           with up to 4 parameters. This function calls a Java-method (which
           possibly needs compilation) with up to 4 parameters. */
 
+java_objectheader *asm_calljavafunction (methodinfo *m, void *arg1, void*arg2,
+                                         void*arg3, void*arg4);
+       /* This function calls a Java-method (which possibly needs compilation)
+          with up to 4 parameters. This function calls a Java-method (which
+          possibly needs compilation) with up to 4 parameters. 
+          also supports a return value */
+
+methodinfo *asm_getcallingmethod ();
+        /* gets the class of the caller from the stack frame */
 
 void asm_dumpregistersandcall ( functionptr f);
        /* This funtion saves all callee saved registers and calls the function
@@ -41,3 +50,7 @@ void asm_dumpregistersandcall ( functionptr f);
           This function is needed by the garbage collector, which needs to access
           all registers which are stored on the stack. Unused registers are
           cleared to avoid interferances with the GC. */
+
+
+
+
index dd1fa71d6946a918bd58f2bb676a46c8aacc22da..ab89cc25eb7344df25b6d24a22bd487a634ffeb8 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -33,6 +33,7 @@
 builtin_descriptor builtin_desc[] = {
        {(functionptr) builtin_instanceof,         "instanceof"},
        {(functionptr) builtin_checkcast,          "checkcast"},
+    {(functionptr) asm_builtin_checkcast,      "checkcast"},
        {(functionptr) builtin_arrayinstanceof,    "arrayinstanceof"},
        {(functionptr) builtin_checkarraycast,     "checkarraycast"},
        {(functionptr) asm_builtin_checkarraycast, "checkarraycast"},
@@ -121,14 +122,24 @@ builtin_descriptor builtin_desc[] = {
                        
 *****************************************************************************/                 
 
-static s4 builtin_isanysubclass (classinfo *sub, classinfo *super)
-{
+s4 builtin_isanysubclass (classinfo *sub, classinfo *super)
+{ 
        if (super->flags & ACC_INTERFACE)
                return (sub->vftbl->interfacetablelength > super->index) &&
                       (sub->vftbl->interfacetable[-super->index] != NULL);
 
+    while (sub != 0)
+               if (sub == super)
+                       return 1;
+               else
+                       sub = sub->super;
+       
+       return 0;
+
+       /*
        return (unsigned) (sub->vftbl->baseval - super->vftbl->baseval) <=
               (unsigned) (super->vftbl->diffval);
+       */
 }
 
 
@@ -144,9 +155,9 @@ static s4 builtin_isanysubclass (classinfo *sub, classinfo *super)
 
 s4 builtin_instanceof(java_objectheader *obj, classinfo *class)
 {
-#ifdef DEBUG
+       #ifdef DEBUG
        log_text ("builtin_instanceof called");
-#endif
+       #endif
        
        if (!obj) return 0;
        return builtin_isanysubclass (obj->vftbl->class, class);
@@ -166,22 +177,22 @@ s4 builtin_instanceof(java_objectheader *obj, classinfo *class)
 
 s4 builtin_checkcast(java_objectheader *obj, classinfo *class)
 {
-#ifdef DEBUG
+       #ifdef DEBUG
        log_text ("builtin_checkcast called");
-#endif
+       #endif
 
        if (obj == NULL)
                return 1;
        if (builtin_isanysubclass (obj->vftbl->class, class))
                return 1;
 
-#if DEBUG
+       #if DEBUG
        printf ("#### checkcast failed ");
-       unicode_display (obj->vftbl->class->name);
+       utf_display (obj->vftbl->class->name);
        printf (" -> ");
-       unicode_display (class->name);
+       utf_display (class->name);
        printf ("\n");
-#endif
+       #endif
 
        return 0;
 }
@@ -275,11 +286,12 @@ s4 builtin_arrayinstanceof
 
 ******************************************************************************/
 
-java_objectheader *builtin_throw_exception (java_objectheader *exceptionptr) {
-       unicode_display (exceptionptr->vftbl->class->name);
+java_objectheader *builtin_throw_exception (java_objectheader *local_exceptionptr) {
+       exceptionptr = local_exceptionptr;
+       utf_display (local_exceptionptr->vftbl->class->name);
        printf ("\n");
        fflush (stdout);
-       return exceptionptr;
+       return local_exceptionptr;
 }
 
 
@@ -798,12 +810,12 @@ java_objectheader *builtin_trace_exception (java_objectheader *exceptionptr,
                methodindent--;
        if (verbose || runverbose) {
                printf("Exception ");
-               unicode_display (exceptionptr->vftbl->class->name);
+               utf_display (exceptionptr->vftbl->class->name);
                printf(" thrown in ");
                if (method) {
-                       unicode_display (method->class->name);
+                       utf_display (method->class->name);
                        printf(".");
-                       unicode_display (method->name);
+                       utf_display (method->name);
                        if (method->flags & ACC_SYNCHRONIZED)
                                printf("(SYNC)");
                        else
@@ -823,10 +835,10 @@ void builtin_trace_args(long a0, long a1, long a2, long a3, long a4, long a5,
 {
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "called: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        sprintf (logtext+strlen(logtext), "(");
        switch (method->paramcount) {
                case 6:
@@ -861,10 +873,10 @@ void builtin_displaymethodstart(methodinfo *method)
 {
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "called: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        dolog ();
        methodindent++;
 }
@@ -874,10 +886,10 @@ void builtin_displaymethodstop(methodinfo *method, long l, double d)
        methodindent--;
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "finished: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        switch (method->returntype) {
                case TYPE_INT:
                case TYPE_LONG:
@@ -898,10 +910,10 @@ void builtin_displaymethodexception(methodinfo *method)
 {
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "exception abort: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        dolog ();
 }
 
index 9fcae7dddc0d6a4de1fd64dcc5c4cd54f4f2c3d6..e760e21c772aca42089a8d0a1e640bb8a0617229 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -22,9 +22,12 @@ typedef struct builtin_descriptor {
        } builtin_descriptor;
 
 extern builtin_descriptor builtin_desc[];
+extern java_objectheader* exceptionptr;
 
 s4 builtin_instanceof(java_objectheader *obj, classinfo *class);
+s4 builtin_isanysubclass (classinfo *sub, classinfo *super);
 s4 builtin_checkcast(java_objectheader *obj, classinfo *class);
+s4 asm_builtin_checkcast(java_objectheader *obj, classinfo *class);
 s4 builtin_arrayinstanceof
        (java_objectheader *obj, constant_arraydescriptor *desc);
 s4 builtin_checkarraycast
index 813c88cdb53d27c6dc99f2d429826ba5873cd19f..85fddbb2d1e5e832d10a0fb7f4d47c50e6290771 100644 (file)
@@ -356,7 +356,7 @@ static void block_firstscann ()
                                i = code_get_u2(p + 1);
                        pushconstantitem:
                                if (class_constanttype(class, i) == CONSTANT_String) {
-                                       unicode *s;
+                                       utf *s;
                                        s = class_getconstant(class, i, CONSTANT_String);
                                        (void) literalstring_new(s);
                                        }
index 9abb4e0187072583dbfdcb1cd11bd4fa96e87b8b..b97c2f9f994237e3b70639c0501be11c813c3284 100644 (file)
@@ -337,7 +337,7 @@ static void parse (basicblock *b)
                                                break;
 
                                        case CONSTANT_String:
-                                               { unicode *s;
+                                               { utf *s;
 
                                                s = class_getconstant (class, poolindex, CONSTANT_String);
 
index 6a9216a79196ce8fb1240dd7f965238db097ed28..4a22b99cdba22a21652a7700a22548b908aff011 100644 (file)
@@ -39,7 +39,7 @@ void compiler_addinitclass (classinfo *c)
                if (cl == NULL) {
                        if (runverbose) {
                                sprintf(logtext, "compiler_addinitclass: ");
-                               unicode_sprint(logtext+strlen(logtext), c->name);
+                               utf_sprint(logtext+strlen(logtext), c->name);
                                dolog();
                                }
                        chain_addlast(uninitializedclasses, c);
@@ -48,7 +48,7 @@ void compiler_addinitclass (classinfo *c)
                if (c < cl) {
                        if (runverbose) {
                                sprintf(logtext, "compiler_addinitclass: ");
-                               unicode_sprint(logtext+strlen(logtext), c->name);
+                               utf_sprint(logtext+strlen(logtext), c->name);
                                dolog();
                                }
                        chain_addbefore(uninitializedclasses, c);
@@ -121,10 +121,10 @@ static s4 code_get_s4 (u4 pos)
        
 ******************************************************************************/                
 
-static void descriptor2types (unicode *desc, bool isstatic,
+static void descriptor2types (utf *desc, bool isstatic,
                  s4 *paramnum, u1 **paramtypes, s4 *returntype)
 {
-       u2 *text = desc->text;
+       u1 *text = desc->text;
        s4 pos;
        u1 *types;
        s4 tnum;
index b1d55bb507781e747ff08d584fb642b1a52b97f8..3d3f872b6069696f9d7f5cd2270fdd4acfdef91e 100644 (file)
@@ -94,7 +94,7 @@ int count_nstub_len = 0;
 /******************* globale Variablen fuer den Compiler *********************/
 
 static methodinfo *method;      /* Zeiger auf die Methodenstruktur */
-static unicode   *descriptor;   /* Typbeschreibung der Methode */
+static utf       *descriptor;   /* Typbeschreibung der Methode */
 static classinfo *class;        /* Klasse, in der die Methode steht */
        
 static s4 maxstack;             /* maximale Gr"osse des JavaVM-Stacks */
@@ -202,19 +202,19 @@ methodptr compiler_compile (methodinfo *m)
        if (m->jcode) {
                if (compileverbose) {
                        sprintf (logtext, "Compiling: ");
-                       unicode_sprint (logtext+strlen(logtext), m->class->name);
+                       utf_sprint (logtext+strlen(logtext), m->class->name);
                        strcpy (logtext+strlen(logtext), ".");
-                       unicode_sprint (logtext+strlen(logtext), m->name);
-                       unicode_sprint (logtext+strlen(logtext), m->descriptor);
+                       utf_sprint (logtext+strlen(logtext), m->name);
+                       utf_sprint (logtext+strlen(logtext), m->descriptor);
                        dolog ();
                        }
                }
        else {
                sprintf (logtext, "No code given for: ");
-               unicode_sprint (logtext+strlen(logtext), m->class->name);
+               utf_sprint (logtext+strlen(logtext), m->class->name);
                strcpy (logtext+strlen(logtext), ".");
-               unicode_sprint (logtext+strlen(logtext), m->name);
-               unicode_sprint (logtext+strlen(logtext), m->descriptor);
+               utf_sprint (logtext+strlen(logtext), m->name);
+               utf_sprint (logtext+strlen(logtext), m->descriptor);
                dolog ();
                intsRestore();           /* schani */
                return (methodptr) do_nothing_function;
@@ -374,7 +374,7 @@ methodptr compiler_compile (methodinfo *m)
                                                    /* globalen Variablen verwendet */
                while ( (c = chain_first(u)) ) {    /* werden */
                        chain_remove (u);
-                       
+
                        class_init (c);                         /* ruft unter Umst"anden wieder */
                                                        /* den Compiler auf */
                        }
index a5e7c0db879d7fcae87584ac23648ccb3b2a7956..c4497031a0383d257752e38c34c98adf308e00c6 100644 (file)
--- a/global.h
+++ b/global.h
@@ -12,7 +12,7 @@
        Changes: Mark     Probst  (schani)   EMAIL: cacao@complang.tuwien.ac.at
                         Philipp  Tomsich (phil)     EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: global.h 132 1999-09-27 15:54:42Z chris $
+       Last Change: $Id: global.h 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
@@ -61,6 +61,8 @@ typedef int   bool;             /* boolean data type */
 #define true  1
 #define false 0
 
+#define PRIMITIVETYPE_COUNT  9  /* number of primitive types */
+
 typedef void (*functionptr) (); /* generic function pointer */
 
 
@@ -119,7 +121,8 @@ void cacao_shutdown(s4 status);
 
 /* resolve typedef cycles *****************************************************/
 
-typedef struct unicode unicode;
+typedef struct utf utf;
+typedef struct literalstring literalstring;
 typedef struct java_objectheader java_objectheader; 
 typedef struct classinfo classinfo; 
 typedef struct vftbl vftbl;
@@ -150,28 +153,86 @@ typedef u1* methodptr;
 
 *******************************************************************************/
 
-/* data structures of Unicode symbol *******************************************
+/* data structures for hashtables ********************************************
+
+
+       All utf-symbols, javastrings and classes are stored in global hashtables,
+       so every symbol exists only once. Equal symbols have identical pointers.
+       The functions for adding hashtable elements search the table for the 
+       element with the specified name/text and return it on success. Otherwise a 
+       new hashtable element is created.
+
+    The hashtables use external linking for handling collisions. The hashtable 
+       structure contains a pointer <ptr> to the array of hashtable slots. The 
+       number of hashtable slots and therefore the size of this array is specified 
+       by the element <size> of hashtable structure. <entries> contains the number
+       of all hashtable elements stored in the table, including those in the 
+       external chains.
+       The hashtable element structures (utf, literalstring, classinfo) contain
+       both a pointer to the next hashtable element as a link for the external hash 
+       chain and the key of the element. The key is computed from the text of
+       the string or the classname by using up to 8 characters.
+       
+       If the number of entries in the hashtable exceeds twice the size of the 
+       hashtableslot-array it is supposed that the average length of the 
+       external chains has reached a value beyond 2. Therefore the functions for
+       adding hashtable elements (utf_new, class_new, literalstring_new) double
+       the hashtableslot-array. In this restructuring process all elements have
+       to be inserted into the new hashtable and new external chains must be built.
+
+
+example for the layout of a hashtable:
+
+hashtable.ptr-->  +-------------------+
+                  |                   |
+                           ...
+                  |                   |
+                  +-------------------+   +-------------------+   +-------------------+
+                  | hashtable element |-->| hashtable element |-->| hashtable element |-->NULL
+                  +-------------------+   +-------------------+   +-------------------+
+                  | hashtable element |
+                  +-------------------+   +-------------------+   
+                  | hashtable element |-->| hashtable element |-->NULL
+                  +-------------------+   +-------------------+   
+                  | hashtable element |-->NULL
+                  +-------------------+
+                  |                   |
+                           ...
+                  |                   |
+                  +-------------------+
 
-       All Unicode symbols are stored in one global (hash) table, every symbol
-       exists only once. Equal symbols have identical pointers.
 */
 
-struct unicode {
-       unicode   *hashlink;        /* link for external hash chain               */
-       u4         key;             /* hash key (computed from text)              */
-       int        length;          /* text length                                */           
-       u2        *text;            /* pointer to text (each character is 16 Bit) */
-       classinfo *class;           /* class pointer if it exists, otherwise NULL */
-       java_objectheader *string;  /* string pointer if it exists, otherwise NULL*/ 
+
+/* data structure for utf8 symbols ********************************************/
+
+struct utf {
+       utf        *hashlink;       /* link for external hash chain               */
+       int         blength;        /* text length in bytes                       */           
+       char       *text;           /* pointer to text                            */
 };
 
+/* data structure of internal javastrings stored in global hashtable **********/
+
+struct literalstring {
+       literalstring     *hashlink;     /* link for external hash chain          */
+       java_objectheader *string;  
+};
+
+/* data structure for accessing hashtables ************************************/
+
+typedef struct {            
+  u4 size;
+  u4 entries;        /* number of entries in the table */
+  void **ptr;        /* pointer to hashtable */
+} hashtable;
 
 /* data structures of remaining constant pool entries *************************/
 
-typedef struct {            /* Fieldref, Methodref and InterfaceMethodref     */
+typedef struct {                /* Fieldref, Methodref and InterfaceMethodref     */
        classinfo *class;       /* class containing this field/method/interface   */
-       unicode   *name;        /* field/method/interface name                    */
-       unicode   *descriptor;  /* field/method/interface type descriptor string  */
+       utf       *name;        /* field/method/interface name                    */
+       utf       *descriptor;  /* field/method/interface type descriptor string  */
 } constant_FMIref;
 
 typedef struct {            /* Integer                                        */
@@ -191,8 +252,8 @@ typedef struct {            /* Double                                         */
 } constant_double;
 
 typedef struct {            /* NameAndType (Field or Method)                  */
-       unicode *name;          /* field/method name                              */
-       unicode *descriptor;    /* field/method type descriptor string            */
+       utf *name;              /* field/method name                              */
+       utf *descriptor;        /* field/method type descriptor string            */
 } constant_nameandtype;
 
 /*  arraydescriptor describes array types. Basic array types contain their
@@ -314,6 +375,16 @@ typedef struct java_arrayarray {
 } java_arrayarray;
 
 
+/* structure for primitive classes ********************************************/
+
+typedef struct primitivetypeinfo {
+       classinfo *class_wrap;               /* class for wrapping primitive type */
+       classinfo *class_primitive;          /* primitive class                   */
+       char *wrapname;                      /* name of class for wrapping        */
+       char typesig;                        /* one character type signature      */
+       char *name;                          /* name of primitive class           */
+} primitivetypeinfo;
+
 /* field, method and class structures *****************************************/
 
 /* fieldinfo ******************************************************************/
@@ -321,8 +392,8 @@ typedef struct java_arrayarray {
 typedef struct fieldinfo {/* field of a class                                 */
        s4       flags;       /* ACC flags                                        */
        s4       type;        /* basic data type                                  */
-       unicode *name;        /* name of field                                    */
-       unicode *descriptor;  /* JavaVM descriptor string of field                */
+       utf *name;            /* name of field                                    */
+       utf *descriptor;      /* JavaVM descriptor string of field                */
        
        s4       offset;      /* offset from start of object (instance variables) */
 
@@ -369,8 +440,8 @@ typedef struct exceptiontable { /* exceptiontable entry in a method           */
 
 typedef struct methodinfo {         /* method structure                       */
        s4             flags;               /* ACC flags                              */
-       unicode   *name;                /* name of method                         */
-       unicode   *descriptor;          /* JavaVM descriptor string of method     */
+       utf       *name;                /* name of method                         */
+       utf       *descriptor;          /* JavaVM descriptor string of method     */
        s4         returntype;          /* only temporary valid, return type      */
        s4         paramcount;          /* only temporary valid, parameter count  */
        u1        *paramtypes;          /* only temporary valid, parameter types  */
@@ -394,13 +465,22 @@ typedef struct methodinfo {         /* method structure                       */
 } methodinfo;
 
 
+/* innerclassinfo *************************************************************/
+
+typedef struct innerclassinfo {
+       classinfo *inner_class;       /* inner class pointer                      */
+       classinfo *outer_class;       /* outer class pointer                      */
+       utf *name;                    /* innerclass name                          */ 
+       s4 flags;                     /* ACC flags                                */
+} innerclassinfo;
+
 /* classinfo ******************************************************************/
 
 struct classinfo {                /* class structure                          */
        java_objectheader header;     /* classes are also objects                 */
 
        s4          flags;            /* ACC flags                                */
-       unicode    *name;             /* class name                               */ 
+       utf        *name;             /* class name                               */ 
 
        s4          cpcount;          /* number of entries in constant pool       */
        u1         *cptags;           /* constant pool tags                       */
@@ -437,6 +517,11 @@ struct classinfo {                /* class structure                          */
 #ifdef JIT_MARKER_SUPPORT
        methodinfo *marker; 
 #endif
+
+    u2             innerclasscount;   /* number of inner classes              */
+    innerclassinfo *innerclass;
+
+    classinfo      *hashlink;         /* link for external hash chain         */
 };
 
 
@@ -527,10 +612,8 @@ extern classinfo *class_java_lang_OutOfMemoryError;
 extern classinfo *class_java_lang_ArithmeticException;
 extern classinfo *class_java_lang_ArrayStoreException;
 extern classinfo *class_java_lang_ThreadDeath;
 extern classinfo *class_array;
 
-
 /* instances of some system classes *******************************************/
 
 extern java_objectheader *proto_java_lang_ClassCastException;
@@ -555,10 +638,16 @@ extern bool verbose;
 extern int count_class_infos;
 extern int count_const_pool_len;
 extern int count_vftbl_len;
-extern int count_unicode_len;
+extern int count_utf_len;
 extern int count_all_methods;
 extern int count_vmcode_len;
 extern int count_extable_len;
+extern int count_utf_new;
+extern int count_utf_new_found;
+
+/* table of primitive types ***************************************************/
+
+extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
 
 #endif
 
index 76f6d510c7b178c0869b8b379c57057232f3007c..134276556ab9f90eb2b9725a1210d3b443b0af32 100644 (file)
--- a/headers.c
+++ b/headers.c
        Changes: Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
                 Philipp Tomsich     EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: headers.c 115 1999-01-20 01:52:45Z phil $
+       Last Change: $Id: headers.c 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
 #include "config.h" /* phil */
-
 #include "global.h"
-
 #include "tables.h"
 #include "loader.h"
 
 
-/******* verschiedene externe Funktionen "faelschen" (=durch Dummys ersetzen), 
-  damit der Linker zufrieden ist *********/
+/******* replace some external functions  *********/
  
-functionptr native_findfunction 
-  (unicode *cname, unicode *mname, unicode *desc, bool isstatic)
+functionptr native_findfunction (utf *cname, utf *mname, utf *desc, bool isstatic)
 { return NULL; }
 
-java_objectheader *literalstring_new (unicode *text)
+java_objectheader *javastring_new (utf *text)         /* schani */
 { return NULL; }
 
-java_objectheader *javastring_new (unicode *text)         /* schani */
-{ return NULL; }
+void throw_classnotfoundexception() 
+{ 
+       panic("class not found"); 
+}
 
+java_objectheader *literalstring_new (utf *u)
+{ return NULL; }  
+
+void literalstring_free (java_objectheader *o) { }
+void stringtable_update () { }
 void synchronize_caches() { }
 void asm_call_jit_compiler () { }
 void asm_calljavamethod () { }
 void asm_dumpregistersandcall () { }
+s4 asm_builtin_checkcast(java_objectheader *obj, classinfo *class) { return 0; }
 
 s4 asm_builtin_idiv (s4 a, s4 b) {return 0;}
 s4 asm_builtin_irem (s4 a, s4 b) {return 0;}
@@ -75,14 +79,18 @@ void asm_switchstackandcall () { }
 
 java_objectheader *native_new_and_init (void *p) { return NULL; }
 
-/************************ globale Variablen **********************/
+/************************ global variables **********************/
 
 java_objectheader *exceptionptr;                       /* schani */
 int  newcompiler = true;
 bool verbose =  false;
 
-static chain *nativechain;
+static chain *nativemethod_chain;                             /* chain with native methods     */
+static chain *nativeclass_chain;                              /* chain with processed classes  */      
+static chain *ident_chain;        /* chain with method and field names in current class */
 static FILE *file = NULL;
+static u4 outputsize;
+static bool dopadding;
 
 static void printIDpart (int c) 
 {
@@ -95,17 +103,14 @@ static void printIDpart (int c)
 
 }
 
-static void printID (unicode *name)
+static void printID (utf *u)
 {
+       char *utf_ptr = u->text;
        int i;
-       for (i=0; i<name->length; i++) {
-               printIDpart (name->text[i]);
-       }
-}
 
-
-u4 outputsize;
-bool dopadding;
+       for (i=0; i<utf_strlen(u); i++) 
+               printIDpart (utf_nextu2(&utf_ptr));
+}
 
 static void addoutputsize (int len)
 {
@@ -119,11 +124,11 @@ static void addoutputsize (int len)
 }
 
 
-static u2 *printtype (u2 *desc)
+static char *printtype (char *utf_ptr)
 {
        u2 c;
 
-       switch (*(desc++)) {
+       switch (utf_nextu2(&utf_ptr)) {
                case 'V': fprintf (file, "void");
                          break;
                case 'I':
@@ -144,7 +149,7 @@ static u2 *printtype (u2 *desc)
                   break;
                case '[':
                        addoutputsize ( sizeof(java_arrayheader*) ); 
-                       switch (*(desc++)) {
+                       switch (utf_nextu2(&utf_ptr)) {
                                case 'I':  fprintf (file, "java_intarray*"); break;
                                case 'J':  fprintf (file, "java_longarray*"); break;
                                case 'Z':  fprintf (file, "java_booleanarray*"); break;
@@ -154,14 +159,14 @@ static u2 *printtype (u2 *desc)
                                case 'F':  fprintf (file, "java_floatarray*"); break;
                                case 'D':  fprintf (file, "java_doublearray*"); break;
                                
-                               case '[':  fprintf (file, "java_arrayarray*");
-                                          while ((*desc) == '[') desc++;
-                                          if ((*desc)!='L') desc++;
-                                          else while (*(desc++) != ';');
+                               case '[':  fprintf (file, "java_arrayarray*");                                         
+                                          while ((c = utf_nextu2(&utf_ptr)) == '[') ;
+                                          if (c=='L') 
+                                                          while (utf_nextu2(&utf_ptr) != ';');
                            break;
                            
                                case 'L':  fprintf (file, "java_objectarray*");
-                                          while ( *(desc++) != ';');
+                                          while ( utf_nextu2(&utf_ptr) != ';');
                                           break;
                                default: panic ("invalid type descriptor");
                                }
@@ -170,22 +175,38 @@ static u2 *printtype (u2 *desc)
                case 'L': 
                        addoutputsize ( sizeof(java_objectheader*));
             fprintf (file, "struct ");
-            while ( (c = *(desc++)) != ';' ) printIDpart (c);           
+            while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c);        
             fprintf (file, "*");
                        break;
                                        
                default:  panic ("Unknown type in field descriptor");
        }
        
-       return (desc);
+       return utf_ptr;
 }
 
+/******* determine the number of entries of a utf string in the ident chain *****/
 
+static int searchidentchain_utf(utf *ident) 
+{
+       utf *u = chain_first(ident_chain);     /* first element of list */
+       int count = 0;
+
+       while (u) {
+               if (u==ident) count++;         /* string found */
+               u = chain_next(ident_chain);   /* next element in list */ 
+       }
+
+       return count;
+}
+
+/**************** print structure for direct access to objects ******************/     
 
 static void printfields (classinfo *c)
 {
        u4 i;
        fieldinfo *f;
+       int ident_count;
        
        if (!c) {
                addoutputsize ( sizeof(java_objectheader) );
@@ -202,106 +223,189 @@ static void printfields (classinfo *c)
                        fprintf (file,"   ");
                        printtype (f->descriptor->text);
                        fprintf (file, " ");
-                       unicode_fprint (file, f->name);
-                       fprintf (file, ";\n");
-                       }
-               }
-}
-
-
-
-
-static void remembermethods (classinfo *c)
-{
-       u2 i;
-       methodinfo *m;
+                       utf_fprint (file, f->name);
 
-       for (i=0; i<c->methodscount; i++) {
-               m = &(c->methods[i]);
+                       /* rename multiple fieldnames */
+                       if (ident_count = searchidentchain_utf(f->name))
+                               fprintf(file,"%d",ident_count - 1);             
+                       chain_addlast(ident_chain,f->name);     
 
-               if (m->flags & ACC_NATIVE) {
-                       chain_addlast (nativechain, m);
+                       fprintf (file, ";\n");
                        }
-                                       
                }
 }
 
-
-
+/***************** store prototype for native method in file ******************/
 
 static void printmethod (methodinfo *m)
 {
-       u2 *d;
+       char *utf_ptr;
        u2 paramnum=1;
-       
-       d = m->descriptor->text;
-       while (*(d++) != ')');
-                               
-       printtype (d);
-       fprintf (file," ");
-       printID (m->class->name);
+       u2 ident_count;
+
+       /* search for return-type in descriptor */      
+       utf_ptr = m->descriptor->text;
+       while (utf_nextu2(&utf_ptr) != ')');
+
+       /* create remarks */
+       fprintf (file,"/*\n * Class:     ");
+       utf_fprint (file, m->class->name);
+       fprintf (file,"\n * Method:    ");
+       utf_fprint (file, m->name);
+       fprintf (file,"\n * Signature: ");
+       utf_fprint (file, m->descriptor);
+       fprintf (file,"\n */\n");       
+
+       /* create prototype */                  
+       fprintf (file,"JNIEXPORT ");                            
+       printtype (utf_ptr);
+       fprintf (file," JNICALL Java_");
+       printID (m->class->name);           
+
+       /* rename overloaded method */
+       if (ident_count = searchidentchain_utf(m->name))
+               fprintf(file,"%d",ident_count - 1);             
+       chain_addlast(ident_chain,m->name);     
+
        fprintf (file,"_");
        printID (m->name);
-       fprintf (file," (");
-                                       
-       d = m->descriptor->text+1;
+       fprintf (file," (JNIEnv *env ");
+       
+       utf_ptr = m->descriptor->text+1;
                        
        if (! (m->flags & ACC_STATIC) ) {
-               fprintf (file, "struct ");
+       
+               fprintf (file, ",  struct ");
                printID (m->class->name);
-               fprintf (file, "* this");
-               if ((*d)!=')') fprintf (file, ", ");
-               }
+               fprintf (file, "* this ");
+
+           };
+
+       if ((*utf_ptr)!=')') fprintf (file, ", "); 
                        
-       while ((*d)!=')') {
-               d = printtype (d);
+       while ((*utf_ptr)!=')') {
+               utf_ptr = printtype (utf_ptr);
                fprintf (file, " par%d", paramnum++);
-               if ((*d)!=')') fprintf (file, ", ");
+               if ((*utf_ptr)!=')') fprintf (file, ", ");
                }
                        
        fprintf (file, ");\n");
 }
 
 
-static void headers_generate (classinfo *c)
+/****************** remove package-name in fully-qualified classname *********************/
+
+static void simple_classname(char *buffer, utf *u)
+{
+  u2 i, simplename_start;
+
+  for (i=utf_strlen(u); i>0; i--) { 
+
+       if (u->text[i] == '$') u->text[i] = '_'; else /* convert '$' to '_' */
+    if (u->text[i] == '/') {
+       /* beginning of simple name */
+        simplename_start = i+1;
+               break;
+       }
+  }
+
+  for (i=simplename_start; i < utf_strlen(u); i++) 
+                 buffer[i-simplename_start] = u->text[i];
+
+  buffer[i-simplename_start] = '\0';                
+}
+
+/*********** create headerfile for classes and store native methods in chain ************/
+
+static void headerfile_generate (classinfo *c)
 {
+       char header_filename[1024] = "";
+       char classname[1024]; 
+       u2 i;
+       methodinfo *m;                  
+                     
+       /* store class in chain */                    
+       chain_addlast (nativeclass_chain, c);                                                           
+                               
+       /* open headerfile for class */
+       simple_classname(classname,c->name);                                                                                                                                            
+
+       /* create chain for renaming fields */
+       ident_chain = chain_new ();
+       
+       sprintf(header_filename, "nat/%s.h", classname);
+       file = fopen (header_filename, "w");
+       if (!file) panic ("Can not open file to store header information");                                                                                     
+       fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n"); 
+
+       /* create structure for direct access to objects */     
        fprintf (file, "/* Structure information for class: ");
-       unicode_fprint (file, c->name);
+       utf_fprint (file, c->name);
        fprintf (file, " */\n\n");
-
        fprintf (file, "typedef struct ");
-       printID (c->name);
+       printID (c->name);                                                      
        fprintf (file, " {\n");
-       
        outputsize=0;
        dopadding=true;
-       printfields (c);
-
+       printfields (c);                                                        
        fprintf (file, "} ");
        printID (c->name);
-       fprintf (file, ";\n\n");
+       fprintf (file, ";\n\n");                            
 
-       remembermethods (c);
-       
+       /* create chain for renaming overloaded methods */
+       chain_free(ident_chain);                                        
+       ident_chain = chain_new ();
+
+       /* create method-prototypes */
+                               
+       for (i=0; i<c->methodscount; i++) {
+
+               m = &(c->methods[i]);
 
-       fprintf (file, "\n\n");
+               if (m->flags & ACC_NATIVE) {
+                       chain_addlast (nativemethod_chain, m);     
+                       printmethod(m);                                             
+                       }                                                       
+               }
+                               
+
+       chain_free(ident_chain);                                 
+       fclose(file);
 }
 
+/******** print classname, '$' used to seperate inner-class name ***********/
+
+void print_classname (classinfo *clazz)
+{
+       utf *u = clazz->name;
+    char *endpos  = u->text + u->blength;
+    char *utf_ptr = u->text; 
+       u2 c;
+
+    while (utf_ptr<endpos) {
+               if ((c=utf_nextu2(&utf_ptr)) == '_')
+                       putc ('$',file);
+               else
+                       putc (c,file);
+       }
+} 
+
 
+/*************** create table for locating native functions ****************/
 
 static void printnativetableentry (methodinfo *m)
 {
        fprintf (file, "   { \"");
-       unicode_fprint (file, m->class->name);
+       print_classname(m->class);
        fprintf (file, "\",\n     \"");
-       unicode_fprint (file, m->name);
+       utf_fprint (file, m->name);
        fprintf (file, "\",\n     \"");
-       unicode_fprint (file, m->descriptor);
+       utf_fprint (file, m->descriptor);
        fprintf (file, "\",\n     ");
        if ( (m->flags & ACC_STATIC) !=0)  fprintf (file, "true");
                                      else fprintf (file, "false");
        fprintf (file, ",\n     ");
-       fprintf (file, "(functionptr) ");
+       fprintf (file, "(functionptr) Java_");
        printID (m->class->name);
        fprintf (file,"_");
        printID (m->name);
@@ -309,35 +413,39 @@ static void printnativetableentry (methodinfo *m)
 }
 
 
+/***************************************************************************
 
+       create the nativetypes-headerfile which includes 
+       the headerfiles of the classes stored in the classes-chain 
 
+****************************************************************************/
 
-static void headers_start ()
+static void headers_finish ()
 {
+       methodinfo *m;
+       classinfo *c;
+       char classname[1024];
+       
        file = fopen ("nativetypes.hh", "w");
        if (!file) panic ("Can not open file 'native.h' to store header information");
        
        fprintf (file, "/* Headerfile for native methods: nativetypes.hh */\n");
-       fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n"); 
-
-       nativechain = chain_new ();
-}
-
-
-static void headers_finish ()
-{
-       methodinfo *m;
-       
-       fprintf (file, "\n/* Prototypes for native methods */\n\n");
+       fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n");     
+       fprintf (file, "\n/* include native-Headerfiles */\n\n");
+                       
+       c = chain_first (nativeclass_chain);
+       while (c) {
        
-       m = chain_first (nativechain);
-       while (m) {
-               dopadding=false;                
-               printmethod (m);
-               
-               m = chain_next (nativechain);
-               }
+               dopadding=false;
+               simple_classname(classname,c->name);                                                                                                                                                                                    
+               fprintf(file,"#include \"nat/%s.h\"\n",classname);              
+               c = chain_next (nativeclass_chain);             
+       }
 
+    fclose(file);
+       chain_free (nativeclass_chain);
+       
+       /* create table of native-methods */
 
        file = fopen ("nativetable.hh", "w");
        if (!file) panic ("Can not open file 'nativetable' to store native-link-table");
@@ -345,19 +453,15 @@ static void headers_finish ()
        fprintf (file, "/* Table of native methods: nativetables.hh */\n");
        fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n"); 
 
-       while ( (m = chain_first (nativechain)) != NULL) {
-               chain_remove (nativechain);
-               
+       while ( (m = chain_first (nativemethod_chain)) != NULL) {
+               chain_remove (nativemethod_chain);              
                printnativetableentry (m);
+       }
                
-               }
-               
-       chain_free (nativechain);
+       chain_free (nativemethod_chain);
        fclose (file);
-}
-
-
 
+}
 
 
 /******************** interne Funktion: print_usage ************************
@@ -373,7 +477,6 @@ static void print_usage()
 
 
 
-
 /************************** Funktion: main *******************************
 
    Das Hauptprogramm.
@@ -417,7 +520,7 @@ int main(int argc, char **argv)
    /**************************** Programmstart *****************************/
 
        log_init (NULL);
-       log_text ("Java - header-generator started");
+       log_text ("Java - header-generator started"); 
        
        sprintf(offsets_filename, "%s/offsets.h", SYSDEP_DIR); /* phil */
        file = fopen(offsets_filename, "w");
@@ -435,39 +538,43 @@ int main(int argc, char **argv)
        fprintf (file, "#define offdiffval     %3d\n", (int) OFFSET(vftbl, diffval));
 
        fclose (file);
-       
+
        suck_init (classpath);
-       
-       unicode_init ();
+   
+       tables_init ();
        heap_init (heapsize, heapsize, &dummy);
        loader_init ();
 
 
    /*********************** JAVA-Klassen laden  ***************************/
-   
-       headers_start ();
-
+       
+       nativemethod_chain = chain_new ();
+       nativeclass_chain = chain_new ();
        
        for (a=1; a<argc; a++) {   
-               cp = argv[a];
-               for (i=strlen(cp)-1; i>=0; i--) {     /* Punkte im Klassennamen */
-                       if (cp[i]=='.') cp[i]='/';        /* auf slashes umbauen */
+               cp = argv[a];
+
+               /* convert classname */
+               for (i=strlen(cp)-1; i>=0; i--)    
+                       switch (cp[i]) {
+                         case '.': cp[i]='/';
+                                       break;
+                         case '_': cp[i]='$';    
                        }
-
-               topclass = loader_load ( unicode_new_char (cp) );
-               
-               headers_generate (topclass);
-               }
        
+               topclass = loader_load ( utf_new_char (cp) );
+               
+        headerfile_generate (topclass);
+       }
 
        headers_finish ();
 
-
    /************************ Freigeben aller Resourcen *******************/
 
        loader_close ();
        heap_close ();
-       unicode_close (NULL);
+       tables_close ( literalstring_free );
        
 
    /* Endemeldung ausgeben und mit entsprechendem exit-Status terminieren */
diff --git a/jit.c b/jit.c
index 7a69432a214c45a4b7699f93a1945d1913859714..0264bc93c296fa1291ad3dbec640433cf4bb0d14 100644 (file)
--- a/jit.c
+++ b/jit.c
@@ -118,7 +118,7 @@ int *count_store_depth = count_store_depth_init;
 
 static classinfo  *class;       /* class the compiled method belongs to       */
 static methodinfo *method;      /* pointer to method info of compiled method  */
-static unicode    *descriptor;  /* type descriptor of compiled method         */
+static utf        *descriptor;  /* type descriptor of compiled method         */
 static int         mparamcount; /* number of parameters (incl. this)          */
 static u1         *mparamtypes; /* types of all parameters (TYPE_INT, ...)    */
 static int         mreturntype; /* return type of method                      */
@@ -161,7 +161,7 @@ static chain *uninitializedclasses;
 #include "jit/parse.c"          /* parsing of JavaVM code                     */ 
 #include "jit/reg.c"            /* register allocation and support routines   */ 
 #include "jit/stack.c"          /* analysing the stack operations             */ 
-#include "sysdep/ngen.c"        /* code generator                             */ 
+#include "ngen.c"        /* code generator                             */ 
 #include "narray/graph.c"      /* array bound removal                        */
 #include "narray/loop.c"       /* array bound removal                        */
 #include "narray/tracing.c"    /* array bound removal                        */
@@ -234,10 +234,10 @@ methodptr jit_compile(methodinfo *m)
 
        if (! m->jcode) {
                sprintf(logtext, "No code given for: ");
-               unicode_sprint(logtext+strlen(logtext), m->class->name);
+               utf_sprint(logtext+strlen(logtext), m->class->name);
                strcpy(logtext+strlen(logtext), ".");
-               unicode_sprint(logtext+strlen(logtext), m->name);
-               unicode_sprint(logtext+strlen(logtext), m->descriptor);
+               utf_sprint(logtext+strlen(logtext), m->name);
+               utf_sprint(logtext+strlen(logtext), m->descriptor);
                dolog();
                intsRestore();                             /* enable interrupts again */
                return (methodptr) do_nothing_function;    /* return empty method     */
@@ -247,10 +247,10 @@ methodptr jit_compile(methodinfo *m)
 
        if (compileverbose) {
                sprintf(logtext, "Compiling: ");
-               unicode_sprint(logtext+strlen(logtext), m->class->name);
+               utf_sprint(logtext+strlen(logtext), m->class->name);
                strcpy(logtext+strlen(logtext), ".");
-               unicode_sprint(logtext+strlen(logtext), m->name);
-               unicode_sprint(logtext+strlen(logtext), m->descriptor);
+               utf_sprint(logtext+strlen(logtext), m->name);
+               utf_sprint(logtext+strlen(logtext), m->descriptor);
                dolog ();
                }
 
index 958068eb3b8b424da749681b4ce8741b08fec16a..eb7a9f31d7692d7e53af4e2806c1a4e80959815b 100644 (file)
@@ -8,7 +8,7 @@
        
        Author: Andreas  Krall      EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: parse.c 132 1999-09-27 15:54:42Z chris $
+       Last Change: $Id: parse.c 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
@@ -54,7 +54,7 @@ static void compiler_addinitclass (classinfo *c)
                if (cl == NULL) {
                        if (runverbose) {
                                sprintf(logtext, "compiler_addinitclass: ");
-                               unicode_sprint(logtext+strlen(logtext), c->name);
+                               utf_sprint(logtext+strlen(logtext), c->name);
                                dolog();
                                }
                        chain_addlast(uninitializedclasses, c);
@@ -63,7 +63,7 @@ static void compiler_addinitclass (classinfo *c)
                if (c < cl) {
                        if (runverbose) {
                                sprintf(logtext, "compiler_addinitclass: ");
-                               unicode_sprint(logtext+strlen(logtext), c->name);
+                               utf_sprint(logtext+strlen(logtext), c->name);
                                dolog();
                                }
                        chain_addbefore(uninitializedclasses, c);
@@ -85,20 +85,19 @@ static void descriptor2types (methodinfo *m)
 {
        u1 *types, *tptr;
        int pcount, c;
-       u2 *cptr;
-
+       char *utf_ptr;
        pcount = 0;
-       types = DMNEW (u1, m->descriptor->length);
-       
+       types = DMNEW (u1, m->descriptor->blength); 
+       
        tptr = types;
        if (!(m->flags & ACC_STATIC)) {
                *tptr++ = TYPE_ADR;
                pcount++;
                }
 
-       cptr = m->descriptor->text;
-       cptr++;
-       while ((c = *cptr++) != ')') {
+       utf_ptr = m->descriptor->text + 1;
+   
+       while ((c = *utf_ptr++) != ')') {
                pcount++;
                switch (c) {
                        case 'B':
@@ -114,13 +113,13 @@ static void descriptor2types (methodinfo *m)
                        case 'D':  *tptr++ = TYPE_DBL;
                                   break;
                        case 'L':  *tptr++ = TYPE_ADR;
-                                  while (*cptr++ != ';');
+                                  while (*utf_ptr++ != ';');
                                   break;
                        case '[':  *tptr++ = TYPE_ADR;
                                   while (c == '[')
-                                      c = *cptr++;
+                                      c = *utf_ptr++;
                                   if (c == 'L')
-                                      while (*cptr++ != ';') /* skip */;
+                                      while (*utf_ptr++ != ';') /* skip */;
                                   break;
                        default:   panic ("Ill formed methodtype-descriptor");
                        }
@@ -128,7 +127,7 @@ static void descriptor2types (methodinfo *m)
 
        /* compute return type */
 
-       switch (*cptr) {
+       switch (*utf_ptr++) {
                case 'B':
                case 'C':
                case 'I':
@@ -170,7 +169,7 @@ static void allocate_literals()
        int     p, nextp;
        int     opcode, i;
        s4      num;
-       unicode *s;
+       utf     *s;
 
        for (p = 0; p < jcodelength; p = nextp) {
 
@@ -402,7 +401,7 @@ static void parse()
                                                             (class->cpinfos[i]))->value);
                                                break;
                                        case CONSTANT_String:
-                                               LOADCONST_A(literalstring_new((unicode*)
+                                               LOADCONST_A(literalstring_new((utf*)
                                                                              (class->cpinfos[i])));
                                                break;
                                        default: panic("Invalid constant type to push");
index dd9fc35dd1a73d2ffc16bd7d1cda4a2a6a34001f..5af4e7e8ae491813c4d4f860f2ad55804989fe45 100644 (file)
@@ -1110,7 +1110,7 @@ icmd_lconst_lcmp_tail:
                                                /* pop 3 push 4 dup */
                                                
                                                case ICMD_DUP_X2:
-                                                       if (IS_2_WORD_TYPE(curstack[-1].type)) {
+                                                       if (IS_2_WORD_TYPE(curstack->prev->type)) {
                                                                iptr->opc = ICMD_DUP_X1;
                                                                DUP_X1;
                                                                }
@@ -1121,7 +1121,7 @@ icmd_lconst_lcmp_tail:
 
                                                case ICMD_DUP2_X2:
                                                        if (IS_2_WORD_TYPE(curstack->type)) {
-                                                               if (IS_2_WORD_TYPE(curstack[-1].type)) {
+                                                               if (IS_2_WORD_TYPE(curstack->prev->type)) {
                                                                        iptr->opc = ICMD_DUP_X1;
                                                                        DUP_X1;
                                                                        }
@@ -1131,7 +1131,7 @@ icmd_lconst_lcmp_tail:
                                                                        }
                                                                }
                                                        else
-                                                               if (IS_2_WORD_TYPE(curstack[-2].type)) {
+                                                               if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
                                                                        iptr->opc = ICMD_DUP2_X1;
                                                                        DUP2_X1;
                                                                        }
@@ -1719,11 +1719,11 @@ static void show_icmd_method()
        xtable *ex;
 
        printf("\n");
-       unicode_fprint(stdout, class->name);
+       utf_fprint(stdout, class->name);
        printf(".");
-       unicode_fprint(stdout, method->name);
+       utf_fprint(stdout, method->name);
        printf(" ");
-       unicode_fprint(stdout, method->descriptor);
+       utf_fprint(stdout, method->descriptor);
        printf ("\n\nMax locals: %d\n", (int) maxlocals);
        printf ("Max stack:  %d\n", (int) maxstack);
 
@@ -1864,7 +1864,7 @@ static void show_icmd_method()
                                case ICMD_PUTSTATIC:
                                case ICMD_GETSTATIC:
                                        printf(" ");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                        ((fieldinfo *) iptr->val.a)->name);
                                        break;
                                case ICMD_IINC:
@@ -1907,7 +1907,7 @@ static void show_icmd_method()
                                        break;
                                case ICMD_NEW:
                                        printf(" ");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                       ((classinfo *) iptr->val.a)->name);
                                        break;
                                case ICMD_NEWARRAY:
@@ -1941,7 +1941,7 @@ static void show_icmd_method()
                                case ICMD_ANEWARRAY:
                                        if (iptr->op1) {
                                                printf(" ");
-                                               unicode_fprint(stdout,
+                                               utf_fprint(stdout,
                                                               ((classinfo *) iptr->val.a)->name);
                                                }
                                        break;
@@ -1953,7 +1953,7 @@ static void show_icmd_method()
                                                        printf(" (INTERFACE) ");
                                                else
                                                        printf(" (CLASS,%3d) ", c->vftbl->diffval);
-                                               unicode_fprint(stdout, c->name);
+                                               utf_fprint(stdout, c->name);
                                                }
                                        break;
                                case ICMD_BUILTIN3:
@@ -1966,10 +1966,10 @@ static void show_icmd_method()
                                case ICMD_INVOKESTATIC:
                                case ICMD_INVOKEINTERFACE:
                                        printf(" ");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                       ((methodinfo *) iptr->val.a)->class->name);
                                        printf(".");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                       ((methodinfo *) iptr->val.a)->name);
                                        break;
                                case ICMD_IFEQ:
diff --git a/jni.c b/jni.c
new file mode 100644 (file)
index 0000000..d743272
--- /dev/null
+++ b/jni.c
@@ -0,0 +1,2156 @@
+/********************************** jni.c *****************************************
+
+       implementation of the Java Native Interface functions                             
+       which are used in the JNI function table                                         
+
+***********************************************************************************/
+
+
+#define JNI_VERSION       0x00010002
+
+
+/********************* accessing instance-fields **********************************/
+
+#define setField(obj,typ,var,val) *((typ*) ((long int) obj + (long int) var->offset))=val;  
+#define getField(obj,typ,var)     *((typ*) ((long int) obj + (long int) var->offset))
+#define setfield_critical(clazz,obj,name,sig,jdatatype,val) setField(obj,jdatatype,getFieldID_critical(env,clazz,name,sig),val); 
+
+/*************************** function: jclass_findfield ****************************
+       
+       searches for field with specified name and type in a 'classinfo'-structur
+       if no such field is found NULL is returned 
+
+************************************************************************************/
+
+fieldinfo *jclass_findfield (classinfo *c, utf *name, utf *desc)
+{
+       s4 i;
+       for (i = 0; i < c->fieldscount; i++) {
+               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc))
+                       return &(c->fields[i]);
+               }
+
+       return NULL;
+}
+
+/********************* returns version of native method interface *****************/
+
+jint GetVersion (JNIEnv* env)
+{
+       return JNI_VERSION;
+}
+
+/****************** loads a class from a buffer of raw class data *****************/
+
+jclass DefineClass(JNIEnv* env, const char *name, jobject loader, const jbyte *buf, jsize len) 
+{
+        jclass clazz; 
+
+       /* change suck-mode, so subsequent class_load will read from memory-buffer */
+       classload_buffer( (u1*) buf,len);
+
+        clazz = loader_load(utf_new_char ((char *) name));
+
+       /* restore old suck-mode */
+       classload_buffer(NULL,0);
+
+       return clazz;
+}
+
+
+/*************** loads locally defined class with the specified name **************/
+
+jclass FindClass (JNIEnv* env, const char *name) 
+{
+       classinfo *c;  
+  
+       c = loader_load(utf_new_char ((char *) name));
+
+       if (!c) exceptionptr = native_new_and_init(class_java_lang_ClassFormatError);
+
+       return c;
+}
+  
+
+/*********************************************************************************** 
+
+       converts java.lang.reflect.Method or 
+       java.lang.reflect.Constructor object to a method ID  
+  
+ **********************************************************************************/   
+  
+jmethodID FromReflectedMethod (JNIEnv* env, jobject method)
+{
+       log_text("JNI-Call: FromReflectedMethod");
+}
+
+
+/*************** return superclass of the class represented by sub ****************/
+jclass GetSuperclass (JNIEnv* env, jclass sub) 
+{
+       classinfo *c;
+
+       c = ((classinfo*) sub) -> super;
+
+       if (!c) return NULL; 
+       use_class_as_object (c);
+       return c;               
+}
+  
+/*********************** check whether sub can be cast to sup  ********************/
+  
+jboolean IsAssignableForm (JNIEnv* env, jclass sub, jclass sup)
+{
+        return builtin_isanysubclass(sub,sup);
+}
+
+
+/***** converts a field ID derived from cls to a java.lang.reflect.Field object ***/
+
+jobject ToReflectedField (JNIEnv* env, jclass cls, jfieldID fieldID, jboolean isStatic)
+{
+       log_text("JNI-Call: ToReflectedField");
+}
+
+
+/***************** throw java.lang.Throwable object  ******************************/
+
+jint Throw (JNIEnv* env, jthrowable obj)
+{
+       exceptionptr = (java_objectheader*) obj;
+       return 0;
+}
+
+
+/*********************************************************************************** 
+
+       create exception object from the class clazz with the 
+       specified message and cause it to be thrown
+
+ **********************************************************************************/   
+
+
+jint ThrowNew (JNIEnv* env, jclass clazz, const char *msg) 
+{
+       java_lang_Throwable *o;
+
+       /* instantiate exception object */
+       o = (java_lang_Throwable *) native_new_and_init ((classinfo*) clazz);
+
+       if (!o) return (-1);
+
+       o->detailMessage = (java_lang_String*) javastring_new_char((char *) msg);
+
+       exceptionptr = (java_objectheader*) o;  
+       return 0;
+}
+
+/************************* check if exception occured *****************************/
+
+jthrowable ExceptionOccurred (JNIEnv* env) 
+{
+       return (jthrowable) exceptionptr;
+}
+
+/********** print exception and a backtrace of the stack (for debugging) **********/
+
+void ExceptionDescribe (JNIEnv* env) 
+{
+       utf_display(exceptionptr->vftbl->class->name);
+       printf ("\n");
+       fflush (stdout);        
+}
+
+
+/******************* clear any exception currently being thrown *******************/
+
+void ExceptionClear (JNIEnv* env) 
+{
+       exceptionptr = NULL;    
+}
+
+
+/********** raises a fatal error and does not expect the VM to recover ************/
+
+void FatalError (JNIEnv* env, const char *msg)
+{
+       panic((char *) msg);    
+}
+
+/******************* creates a new local reference frame **************************/ 
+
+jint PushLocalFrame (JNIEnv* env, jint capacity)
+{
+       /* empty */
+}
+
+/**************** Pops off the current local reference frame **********************/
+
+jobject PopLocalFrame (JNIEnv* env, jobject result)
+{
+       /* empty */
+}
+    
+
+/** Creates a new global reference to the object referred to by the obj argument **/
+    
+jobject NewGlobalRef (JNIEnv* env, jobject lobj)
+{
+       heap_addreference ( (void**) &lobj);
+       return lobj;
+}
+
+/*************  Deletes the global reference pointed to by globalRef **************/
+
+void DeleteGlobalRef (JNIEnv* env, jobject gref)
+{
+       /* empty */
+}
+
+
+/*************** Deletes the local reference pointed to by localRef ***************/
+
+void DeleteLocalRef (JNIEnv* env, jobject localRef)
+{
+       /* empty */
+}
+
+/********** Tests whether two references refer to the same Java object ************/
+
+jboolean IsSameObject (JNIEnv* env, jobject obj1, jobject obj2)
+{
+       return (obj1==obj2);
+}
+
+/***** Creates a new local reference that refers to the same object as ref  *******/
+
+jobject NewLocalRef (JNIEnv* env, jobject ref)
+{
+       return ref;
+}
+
+/*********************************************************************************** 
+
+       Ensures that at least a given number of local references can 
+       be created in the current thread
+
+ **********************************************************************************/   
+
+jint EnsureLocalCapacity (JNIEnv* env, jint capacity)
+{
+       return 0; /* return 0 on success */
+}
+
+
+/********* Allocates a new Java object without invoking a constructor *************/
+
+jobject AllocObject (JNIEnv* env, jclass clazz)
+{
+        java_objectheader *o = builtin_new(clazz);     
+       return o;
+}
+
+
+/*********************************************************************************** 
+
+       Constructs a new Java object
+       arguments that are to be passed to the constructor are placed after methodID
+
+***********************************************************************************/
+
+jobject NewObject (JNIEnv* env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: NewObject");
+}
+
+/*********************************************************************************** 
+
+       Constructs a new Java object
+       arguments that are to be passed to the constructor are placed in va_list args 
+
+***********************************************************************************/
+
+jobject NewObjectV (JNIEnv* env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: NewObjectV");
+}
+
+/*********************************************************************************** 
+
+       Constructs a new Java object
+       arguments that are to be passed to the constructor are placed in 
+       args array of jvalues 
+
+***********************************************************************************/
+
+jobject NewObjectA (JNIEnv* env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: NewObjectA");
+}
+
+
+/************************ returns the class of an object **************************/ 
+
+jclass GetObjectClass (JNIEnv* env, jobject obj)
+{
+       classinfo *c = obj->vftbl -> class;
+       use_class_as_object (c);
+       return c;
+}
+
+/************* tests whether an object is an instance of a class ******************/
+
+jboolean IsInstanceOf (JNIEnv* env, jobject obj, jclass clazz)
+{
+        return builtin_instanceof(obj,clazz);
+}
+
+
+/***************** converts a java.lang.reflect.Field to a field ID ***************/
+jfieldID FromReflectedField (JNIEnv* env, jobject field)
+{
+       log_text("JNI-Call: FromReflectedField");
+}
+
+/**********************************************************************************
+
+       converts a method ID to a java.lang.reflect.Method or 
+       java.lang.reflect.Constructor object
+
+**********************************************************************************/
+
+jobject ToReflectedMethod (JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic)
+{
+       log_text("JNI-Call: ToReflectedMethod");
+}
+
+/**************** returns the method ID for an instance method ********************/
+
+jmethodID GetMethodID (JNIEnv* env, jclass clazz, const char *name, const char *sig)
+{
+       jmethodID m;
+
+       m = class_resolvemethod (
+               clazz, 
+               utf_new_char ((char*) name), 
+               utf_new_char ((char*) sig)
+       );
+
+       if (!m) exceptionptr = native_new_and_init(class_java_lang_NoSuchMethodError);          
+
+       return m;
+}
+
+/******************** JNI-functions for calling instance methods ******************/
+
+jobject CallObjectMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallObjectMethod");
+
+       return NULL;
+}
+
+
+jobject CallObjectMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallObjectMethodV");
+
+       return NULL;
+}
+
+
+jobject CallObjectMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallObjectMethodA");
+
+       return NULL;
+}
+
+
+jboolean CallBooleanMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallBooleanMethod");
+
+       return 0;
+}
+
+jboolean CallBooleanMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallBooleanMethodV");
+
+       return 0;
+}
+
+jboolean CallBooleanMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallBooleanMethodA");
+
+       return 0;
+}
+
+jbyte CallByteMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallByteMethod");
+
+       return 0;
+}
+
+jbyte CallByteMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallByteMethodV");
+
+       return 0;
+}
+
+
+jbyte CallByteMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallByteMethodA");
+
+       return 0;
+}
+
+
+jchar CallCharMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallCharMethod");
+
+       return 0;
+}
+
+jchar CallCharMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallCharMethodV");
+
+       return 0;
+}
+
+
+jchar CallCharMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallCharMethodA");
+
+       return 0;
+}
+
+
+jshort CallShortMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallShortMethod");
+
+       return 0;
+}
+
+
+jshort CallShortMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallShortMethodV");
+
+       return 0;
+}
+
+
+jshort CallShortMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallShortMethodA");
+
+       return 0;
+}
+
+
+
+jint CallIntMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallIntMethod");
+
+       return 0;
+}
+
+
+jint CallIntMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallIntMethodV");
+
+       return 0;
+}
+
+
+jint CallIntMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallIntMethodA");
+
+       return 0;
+}
+
+
+
+jlong CallLongMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallLongMethod");
+
+       return 0;
+}
+
+
+jlong CallLongMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallLongMethodV");
+
+       return 0;
+}
+
+
+jlong CallLongMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallLongMethodA");
+
+       return 0;
+}
+
+
+
+jfloat CallFloatMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallFloatMethod");
+
+       return 0;
+}
+
+
+jfloat CallFloatMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallFloatMethodV");
+
+       return 0;
+}
+
+
+jfloat CallFloatMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallFloatMethodA");
+
+       return 0;
+}
+
+
+
+jdouble CallDoubleMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallDoubleMethod");
+
+       return 0;
+}
+
+
+jdouble CallDoubleMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallDoubleMethodV");
+
+       return 0;
+}
+
+
+jdouble CallDoubleMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallDoubleMethodA");
+
+       return 0;
+}
+
+
+
+void CallVoidMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallVoidMethod");
+
+}
+
+
+void CallVoidMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallVoidMethodV");
+
+}
+
+
+void CallVoidMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallVoidMethodA");
+
+}
+
+
+
+jobject CallNonvirtualObjectMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualObjectMethod");
+
+       return NULL;
+}
+
+
+jobject CallNonvirtualObjectMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualObjectMethodV");
+
+       return NULL;
+}
+
+
+jobject CallNonvirtualObjectMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallNonvirtualObjectMethodA");
+
+       return NULL;
+}
+
+
+
+jboolean CallNonvirtualBooleanMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualBooleanMethod");
+
+       return 0;
+}
+
+
+jboolean CallNonvirtualBooleanMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualBooleanMethodV");
+
+       return 0;
+}
+
+
+jboolean CallNonvirtualBooleanMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallNonvirtualBooleanMethodA");
+
+       return 0;
+}
+
+
+
+jbyte CallNonvirtualByteMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualByteMethod");
+
+       return 0;
+}
+
+
+jbyte CallNonvirtualByteMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualByteMethodV");
+
+       return 0;
+}
+
+
+jbyte CallNonvirtualByteMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualByteMethodA");
+
+       return 0;
+}
+
+
+
+jchar CallNonvirtualCharMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualCharMethod");
+
+       return 0;
+}
+
+
+jchar CallNonvirtualCharMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualCharMethodV");
+
+       return 0;
+}
+
+
+jchar CallNonvirtualCharMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualCharMethodA");
+
+       return 0;
+}
+
+
+
+jshort CallNonvirtualShortMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualShortMethod");
+
+       return 0;
+}
+
+
+jshort CallNonvirtualShortMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualShortMethodV");
+
+       return 0;
+}
+
+
+jshort CallNonvirtualShortMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualShortMethodA");
+
+       return 0;
+}
+
+
+
+jint CallNonvirtualIntMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualIntMethod");
+
+       return 0;
+}
+
+
+jint CallNonvirtualIntMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualIntMethodV");
+
+       return 0;
+}
+
+
+jint CallNonvirtualIntMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualIntMethodA");
+
+       return 0;
+}
+
+
+
+jlong CallNonvirtualLongMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualLongMethod");
+
+       return 0;
+}
+
+
+jlong CallNonvirtualLongMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualLongMethodV");
+
+       return 0;
+}
+
+
+jlong CallNonvirtualLongMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualLongMethodA");
+
+       return 0;
+}
+
+
+
+jfloat CallNonvirtualFloatMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualFloatMethod");
+
+       return 0;
+}
+
+
+jfloat CallNonvirtualFloatMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualFloatMethodV");
+
+       return 0;
+}
+
+
+jfloat CallNonvirtualFloatMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualFloatMethodA");
+
+       return 0;
+}
+
+
+
+jdouble CallNonvirtualDoubleMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualDoubleMethod");
+
+       return 0;
+}
+
+
+jdouble CallNonvirtualDoubleMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualDoubleMethodV");
+
+       return 0;
+}
+
+
+jdouble CallNonvirtualDoubleMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualDoubleMethodA");
+
+       return 0;
+}
+
+
+
+void CallNonvirtualVoidMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualVoidMethod");
+}
+
+
+void CallNonvirtualVoidMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualVoidMethodV");
+}
+
+
+void CallNonvirtualVoidMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallNonvirtualVoidMethodA");
+}
+
+/************************* JNI-functions for accessing fields ************************/
+
+jfieldID GetFieldID (JNIEnv *env, jclass clazz, const char *name, const char *sig) 
+{
+       jfieldID f;
+
+       f = jclass_findfield(clazz,
+                           utf_new_char ((char*) name), 
+                           utf_new_char ((char*) sig)
+                           ); 
+       
+       if (!f) exceptionptr =  native_new_and_init(class_java_lang_NoSuchFieldError);  
+
+       return f;
+}
+
+/*************************** retrieve fieldid, abort on error ************************/
+
+jfieldID getFieldID_critical(JNIEnv *env,jclass clazz,const char *name,const char *sig)
+{
+    jfieldID id = env->GetFieldID(env,clazz,name,sig);     
+    if (!id) panic("setfield_critical failed"); 
+    return id;
+}
+
+jobject GetObjectField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jobject,fieldID);
+}
+
+jboolean GetBooleanField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jboolean,fieldID);
+}
+
+
+jbyte GetByteField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+               return getField(obj,jbyte,fieldID);
+}
+
+
+jchar GetCharField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jchar,fieldID);
+}
+
+
+jshort GetShortField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jshort,fieldID);
+}
+
+
+jint GetIntField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jint,fieldID);
+}
+
+
+jlong GetLongField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jlong,fieldID);
+}
+
+
+jfloat GetFloatField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jfloat,fieldID);
+}
+
+
+jdouble GetDoubleField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jdouble,fieldID);
+}
+
+void SetObjectField (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val)
+{
+        setField(obj,jobject,fieldID,val);
+}
+
+
+void SetBooleanField (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val)
+{
+        setField(obj,jboolean,fieldID,val);
+}
+
+
+void SetByteField (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val)
+{
+        setField(obj,jbyte,fieldID,val);
+}
+
+
+void SetCharField (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val)
+{
+        setField(obj,jchar,fieldID,val);
+}
+
+
+void SetShortField (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val)
+{
+        setField(obj,jshort,fieldID,val);
+}
+
+
+void SetIntField (JNIEnv *env, jobject obj, jfieldID fieldID, jint val)
+{
+        setField(obj,jint,fieldID,val);
+}
+
+
+void SetLongField (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val)
+{
+        setField(obj,jlong,fieldID,val);
+}
+
+
+void SetFloatField (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val)
+{
+        setField(obj,jfloat,fieldID,val);
+}
+
+
+void SetDoubleField (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val)
+{
+        setField(obj,jdouble,fieldID,val);
+}
+
+/**************** JNI-functions for calling static methods **********************/ 
+
+jmethodID GetStaticMethodID (JNIEnv *env, jclass clazz, const char *name, const char *sig)
+{
+       jmethodID m;
+
+       m = class_resolvemethod (
+               clazz, 
+               utf_new_char ((char*) name), 
+               utf_new_char ((char*) sig)
+       );
+
+       if (!m) exceptionptr =  native_new_and_init(class_java_lang_NoSuchMethodError);  
+
+       return m;
+}
+
+jobject CallStaticObjectMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticObjectMethod");
+
+       return NULL;
+}
+
+
+jobject CallStaticObjectMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticObjectMethodV");
+
+       return NULL;
+}
+
+
+jobject CallStaticObjectMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticObjectMethodA");
+
+       return NULL;
+}
+
+
+jboolean CallStaticBooleanMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticBooleanMethod");
+
+       return 0;
+}
+
+
+jboolean CallStaticBooleanMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticBooleanMethodV");
+
+       return 0;
+}
+
+
+jboolean CallStaticBooleanMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticBooleanMethodA");
+
+       return 0;
+}
+
+
+jbyte CallStaticByteMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticByteMethod");
+
+       return 0;
+}
+
+
+jbyte CallStaticByteMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticByteMethodV");
+
+       return 0;
+}
+
+
+jbyte CallStaticByteMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticByteMethodA");
+
+       return 0;
+}
+
+jchar CallStaticCharMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticCharMethod");
+
+       return 0;
+}
+
+
+jchar CallStaticCharMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticCharMethodV");
+
+       return 0;
+}
+
+
+jchar CallStaticCharMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticCharMethodA");
+
+       return 0;
+}
+
+
+
+jshort CallStaticShortMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticShortMethod");
+
+       return 0;
+}
+
+
+jshort CallStaticShortMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticShortMethodV");
+
+       return 0;
+}
+
+
+jshort CallStaticShortMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticShortMethodA");
+
+       return 0;
+}
+
+
+
+jint CallStaticIntMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticIntMethod");
+
+       return 0;
+}
+
+
+jint CallStaticIntMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticIntMethodV");
+
+       return 0;
+}
+
+
+jint CallStaticIntMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticIntMethodA");
+
+       return 0;
+}
+
+
+
+jlong CallStaticLongMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticLongMethod");
+
+       return 0;
+}
+
+
+jlong CallStaticLongMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticLongMethodV");
+
+       return 0;
+}
+
+
+jlong CallStaticLongMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticLongMethodA");
+
+       return 0;
+}
+
+
+
+jfloat CallStaticFloatMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticFloatMethod");
+
+       return 0;
+}
+
+
+jfloat CallStaticFloatMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticFloatMethodV");
+
+       return 0;
+}
+
+
+jfloat CallStaticFloatMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticFloatMethodA");
+
+       return 0;
+}
+
+
+
+jdouble CallStaticDoubleMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticDoubleMethod");
+
+       return 0;
+}
+
+
+jdouble CallStaticDoubleMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticDoubleMethodV");
+
+       return 0;
+}
+
+
+jdouble CallStaticDoubleMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticDoubleMethodA");
+
+       return 0;
+}
+
+
+
+void CallStaticVoidMethod (JNIEnv *env, jclass cls, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticVoidMethod");
+
+}
+
+
+void CallStaticVoidMethodV (JNIEnv *env, jclass cls, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticVoidMethodV");
+
+}
+
+
+void CallStaticVoidMethodA (JNIEnv *env, jclass cls, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallStaticVoidMethodA");
+
+}
+
+/****************** JNI-functions for accessing static fields ********************/
+
+jfieldID GetStaticFieldID (JNIEnv *env, jclass clazz, const char *name, const char *sig) 
+{
+       jfieldID f;
+
+       f = jclass_findfield(clazz,
+                           utf_new_char ((char*) name), 
+                           utf_new_char ((char*) sig)
+                           ); 
+       
+       if (!f) exceptionptr =  native_new_and_init(class_java_lang_NoSuchFieldError);  
+
+       return f;
+}
+
+
+jobject GetStaticObjectField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.a;       
+}
+
+
+jboolean GetStaticBooleanField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jbyte GetStaticByteField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jchar GetStaticCharField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jshort GetStaticShortField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jint GetStaticIntField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jlong GetStaticLongField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.l;
+}
+
+
+jfloat GetStaticFloatField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.f;
+}
+
+
+jdouble GetStaticDoubleField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.d;
+}
+
+
+
+void SetStaticObjectField (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)
+{
+       fieldID->value.a = value;
+}
+
+
+void SetStaticBooleanField (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticByteField (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticCharField (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticShortField (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticIntField (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticLongField (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value)
+{
+       fieldID->value.l = value;
+}
+
+
+void SetStaticFloatField (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value)
+{
+       fieldID->value.f = value;
+}
+
+
+void SetStaticDoubleField (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value)
+{
+       fieldID->value.d = value;
+}
+
+
+/*****  create new java.lang.String object from an array of Unicode characters ****/ 
+
+jstring NewString (JNIEnv *env, const jchar *buf, jsize len)
+{
+       u4 i;
+       java_lang_String *s;
+       java_chararray *a;
+       
+       s = (java_lang_String*) builtin_new (class_java_lang_String);
+       a = builtin_newarray_char (len);
+
+       /* javastring or characterarray could not be created */
+       if ( (!a) || (!s) ) return NULL;
+
+       /* copy text */
+       for (i=0; i<len; i++) a->data[i] = buf[i];
+       s -> value = a;
+       s -> offset = 0;
+       s -> count = len;
+
+       return (jstring) s;
+}
+
+/******************* returns the length of a Java string ***************************/
+
+jsize GetStringLength (JNIEnv *env, jstring str)
+{
+       return ((java_lang_String*) str)->count;
+}
+
+
+/********************  convertes javastring to u2-array ****************************/
+       
+u2 *javastring_tou2 (jstring so) 
+{
+       java_lang_String *s = (java_lang_String*) so;
+       java_chararray *a;
+       u4 i;
+       u2 *stringbuffer;
+       
+       if (!s) return NULL;
+
+       a = s->value;
+       if (!a) return NULL;
+
+       /* allocate memory */
+       stringbuffer = MNEW( u2 , s->count + 1 );
+
+       /* copy text */
+       for (i=0; i<s->count; i++) stringbuffer[i] = a->data[s->offset+i];
+       
+       /* terminate string */
+       stringbuffer[i] = '\0';
+
+       return stringbuffer;
+}
+
+/********* returns a pointer to an array of Unicode characters of the string *******/
+
+const jchar *GetStringChars (JNIEnv *env, jstring str, jboolean *isCopy)
+{      
+       return javastring_tou2(str);
+}
+
+/**************** native code no longer needs access to chars **********************/
+
+void ReleaseStringChars (JNIEnv *env, jstring str, const jchar *chars)
+{
+       MFREE(((jchar*) chars),jchar,((java_lang_String*) str)->count);
+}
+
+/************ create new java.lang.String object from utf8-characterarray **********/
+
+jstring NewStringUTF (JNIEnv *env, const char *utf)
+{
+    log_text("NewStringUTF called");
+}
+
+/****************** returns the utf8 length in bytes of a string *******************/
+
+jsize GetStringUTFLength (JNIEnv *env, jstring string)
+{   
+    java_lang_String *s = (java_lang_String*) string;
+
+    return (jsize) u2_utflength(s->value->data, s->count); 
+}
+
+/************ converts a Javastring to an array of UTF-8 characters ****************/
+
+const char* GetStringUTFChars (JNIEnv *env, jstring string, jboolean *isCopy)
+{
+    return javastring_toutf((java_lang_String*) string,false)->text;
+}
+
+/***************** native code no longer needs access to utf ***********************/
+
+void ReleaseStringUTFChars (JNIEnv *env, jstring str, const char* chars)
+{
+    log_text("JNI-Call: ReleaseStringUTFChars");
+}
+
+/************************** array operations ***************************************/
+
+jsize GetArrayLength (JNIEnv *env, jarray array)
+{
+    return array->size;
+}
+
+jobjectArray NewObjectArray (JNIEnv *env, jsize len, jclass clazz, jobject init)
+{
+    java_objectarray *j = builtin_anewarray (len, clazz);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+jobject GetObjectArrayElement (JNIEnv *env, jobjectArray array, jsize index)
+{
+    jobject j = NULL;
+
+    if (index<array->header.size)      
+       j = array->data[index];
+    else
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    
+    return j;
+}
+
+void SetObjectArrayElement (JNIEnv *env, jobjectArray array, jsize index, jobject val)
+{
+    if (index>=array->header.size)     
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else {
+
+       /* check if the class of value is a subclass of the element class of the array */
+
+       if (!builtin_instanceof(val, array->elementtype))
+           exceptionptr = proto_java_lang_ArrayStoreException;
+       else
+           array->data[index] = val;
+    }
+}
+
+
+
+jbooleanArray NewBooleanArray (JNIEnv *env, jsize len)
+{
+    java_booleanarray *j = builtin_newarray_boolean(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jbyteArray NewByteArray (JNIEnv *env, jsize len)
+{
+    java_bytearray *j = builtin_newarray_byte(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jcharArray NewCharArray (JNIEnv *env, jsize len)
+{
+    java_chararray *j = builtin_newarray_char(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jshortArray NewShortArray (JNIEnv *env, jsize len)
+{
+    java_shortarray *j = builtin_newarray_short(len);   
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jintArray NewIntArray (JNIEnv *env, jsize len)
+{
+    java_intarray *j = builtin_newarray_int(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jlongArray NewLongArray (JNIEnv *env, jsize len)
+{
+    java_longarray *j = builtin_newarray_long(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jfloatArray NewFloatArray (JNIEnv *env, jsize len)
+{
+    java_floatarray *j = builtin_newarray_float(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jdoubleArray NewDoubleArray (JNIEnv *env, jsize len)
+{
+    java_doublearray *j = builtin_newarray_double(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jboolean * GetBooleanArrayElements (JNIEnv *env, jbooleanArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jbyte * GetByteArrayElements (JNIEnv *env, jbyteArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jchar * GetCharArrayElements (JNIEnv *env, jcharArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jshort * GetShortArrayElements (JNIEnv *env, jshortArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jint * GetIntArrayElements (JNIEnv *env, jintArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jlong * GetLongArrayElements (JNIEnv *env, jlongArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jfloat * GetFloatArrayElements (JNIEnv *env, jfloatArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jdouble * GetDoubleArrayElements (JNIEnv *env, jdoubleArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+
+void ReleaseBooleanArrayElements (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseByteArrayElements (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseCharArrayElements (JNIEnv *env, jcharArray array, jchar *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseShortArrayElements (JNIEnv *env, jshortArray array, jshort *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseIntArrayElements (JNIEnv *env, jintArray array, jint *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseLongArrayElements (JNIEnv *env, jlongArray array, jlong *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseFloatArrayElements (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseDoubleArrayElements (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode)
+{
+    /* empty */
+}
+
+void GetBooleanArrayRegion (JNIEnv* env, jbooleanArray array, jsize start, jsize len, jboolean *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetByteArrayRegion (JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size) 
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));
+}
+
+
+void GetCharArrayRegion (JNIEnv* env, jcharArray array, jsize start, jsize len, jchar *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetShortArrayRegion (JNIEnv* env, jshortArray array, jsize start, jsize len, jshort *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else       
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetIntArrayRegion (JNIEnv* env, jintArray array, jsize start, jsize len, jint *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)      
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetLongArrayRegion (JNIEnv* env, jlongArray array, jsize start, jsize len, jlong *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)      
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetFloatArrayRegion (JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)      
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetDoubleArrayRegion (JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size) 
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void SetBooleanArrayRegion (JNIEnv* env, jbooleanArray array, jsize start, jsize len, jboolean *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+
+void SetByteArrayRegion (JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+
+void SetCharArrayRegion (JNIEnv* env, jcharArray array, jsize start, jsize len, jchar *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+
+void SetShortArrayRegion (JNIEnv* env, jshortArray array, jsize start, jsize len, jshort *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+
+void SetIntArrayRegion (JNIEnv* env, jintArray array, jsize start, jsize len, jint *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+void SetLongArrayRegion (JNIEnv* env, jlongArray array, jsize start, jsize len, jlong *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+void SetFloatArrayRegion (JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+void SetDoubleArrayRegion (JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+jint RegisterNatives (JNIEnv* env, jclass clazz, const JNINativeMethod *methods, jint nMethods)
+{
+    log_text("JNI-Call: RegisterNatives");
+    return 0;
+}
+
+
+jint UnregisterNatives (JNIEnv* env, jclass clazz)
+{
+    log_text("JNI-Call: UnregisterNatives");
+    return 0;
+}
+
+/******************************* monitor operations ********************************/
+
+jint MonitorEnter (JNIEnv* env, jobject obj)
+{
+    builtin_monitorenter(obj);
+    return 0;
+}
+
+
+jint MonitorExit (JNIEnv* env, jobject obj)
+{
+    builtin_monitorexit(obj);
+    return 0;
+}
+
+
+/************************************* JavaVM interface ****************************/
+
+jint GetJavaVM (JNIEnv* env, JavaVM **vm)
+{
+    log_text("JNI-Call: GetJavaVM");
+    return 0;
+}
+
+void GetStringRegion (JNIEnv* env, jstring str, jsize start, jsize len, jchar *buf)
+{
+    log_text("JNI-Call: GetStringRegion");
+
+}
+
+void GetStringUTFRegion (JNIEnv* env, jstring str, jsize start, jsize len, char *buf)
+{
+    log_text("JNI-Call: GetStringUTFRegion");
+
+}
+
+/****************** obtain direct pointer to array elements ***********************/
+
+void * GetPrimitiveArrayCritical (JNIEnv* env, jarray array, jboolean *isCopy)
+{
+       java_arrayheader *s = (java_arrayheader*) array;
+
+       switch (s->arraytype) {
+               case ARRAYTYPE_BYTE:    return (((java_bytearray*)    array)->data);
+               case ARRAYTYPE_BOOLEAN: return (((java_booleanarray*) array)->data);
+               case ARRAYTYPE_CHAR:    return (((java_chararray*)    array)->data);
+               case ARRAYTYPE_SHORT:   return (((java_shortarray*)   array)->data);
+               case ARRAYTYPE_INT:     return (((java_intarray*)     array)->data);
+               case ARRAYTYPE_LONG:    return (((java_longarray*)    array)->data);
+               case ARRAYTYPE_FLOAT:   return (((java_floatarray*)   array)->data);
+               case ARRAYTYPE_DOUBLE:  return (((java_doublearray*)  array)->data);
+               case ARRAYTYPE_OBJECT:  return (((java_objectarray*)  array)->data); 
+               case ARRAYTYPE_ARRAY:   return (((java_arrayarray*)   array)->data);
+       }
+
+       return NULL;
+}
+
+
+void ReleasePrimitiveArrayCritical (JNIEnv* env, jarray array, void *carray, jint mode)
+{
+       log_text("JNI-Call: ReleasePrimitiveArrayCritical");
+
+       /* empty */
+}
+
+/********* returns a pointer to an array of Unicode characters of the string *******/
+
+const jchar * GetStringCritical (JNIEnv* env, jstring string, jboolean *isCopy)
+{
+       log_text("JNI-Call: GetStringCritical");
+
+       return GetStringChars(env,string,isCopy);
+}
+
+/**************** native code no longer needs access to chars **********************/
+
+void ReleaseStringCritical (JNIEnv* env, jstring string, const jchar *cstring)
+{
+       log_text("JNI-Call: ReleaseStringCritical");
+
+       ReleaseStringChars(env,string,cstring);
+}
+
+
+jweak NewWeakGlobalRef (JNIEnv* env, jobject obj)
+{
+       log_text("JNI-Call: NewWeakGlobalRef");
+
+       return obj;
+}
+
+
+void DeleteWeakGlobalRef (JNIEnv* env, jweak ref)
+{
+       log_text("JNI-Call: DeleteWeakGlobalRef");
+
+       /* empty */
+}
+
+
+/******************************* check for pending exception ***********************/
+
+
+jboolean ExceptionCheck (JNIEnv* env)
+{
+       log_text("JNI-Call: ExceptionCheck");
+
+       return exceptionptr ? JNI_TRUE : JNI_FALSE;
+}
+       
+/********************************* JNI function table ******************************/
+
+JNIEnv env =     
+   {   
+    NULL,
+    NULL,
+    NULL,
+    NULL,    
+    &GetVersion,
+    &DefineClass,
+    &FindClass,
+    &FromReflectedMethod,
+    &FromReflectedField,
+    &ToReflectedMethod,
+    &GetSuperclass,
+    &IsAssignableForm,
+    &ToReflectedField,
+    &Throw,
+    &ThrowNew,
+    &ExceptionOccurred,
+    &ExceptionDescribe,
+    &ExceptionClear,
+    &FatalError,
+    &PushLocalFrame,
+    &PopLocalFrame,
+    &NewGlobalRef,
+    &DeleteGlobalRef,
+    &DeleteLocalRef,
+    &IsSameObject,
+    &NewLocalRef,
+    &EnsureLocalCapacity,
+    &AllocObject,
+    &NewObject,
+    &NewObjectV,
+    &NewObjectA,
+    &GetObjectClass,
+    &IsInstanceOf,
+    &GetMethodID,
+    &CallObjectMethod,
+    &CallObjectMethodV,
+    &CallObjectMethodA,
+    &CallBooleanMethod,
+    &CallBooleanMethodV,
+    &CallBooleanMethodA,
+    &CallByteMethod,
+    &CallByteMethodV,
+    &CallByteMethodA,
+    &CallCharMethod,
+    &CallCharMethodV,
+    &CallCharMethodA,
+    &CallShortMethod,
+    &CallShortMethodV,
+    &CallShortMethodA,
+    &CallIntMethod,
+    &CallIntMethodV,
+    &CallIntMethodA,
+    &CallLongMethod,
+    &CallLongMethodV,
+    &CallLongMethodA,
+    &CallFloatMethod,
+    &CallFloatMethodV,
+    &CallFloatMethodA,
+    &CallDoubleMethod,
+    &CallDoubleMethodV,
+    &CallDoubleMethodA,
+    &CallVoidMethod,
+    &CallVoidMethodV,
+    &CallVoidMethodA,
+    &CallNonvirtualObjectMethod,
+    &CallNonvirtualObjectMethodV,
+    &CallNonvirtualObjectMethodA,
+    &CallNonvirtualBooleanMethod,
+    &CallNonvirtualBooleanMethodV,
+    &CallNonvirtualBooleanMethodA,
+    &CallNonvirtualByteMethod,
+    &CallNonvirtualByteMethodV,
+    &CallNonvirtualByteMethodA,
+    &CallNonvirtualCharMethod,
+    &CallNonvirtualCharMethodV,
+    &CallNonvirtualCharMethodA,
+    &CallNonvirtualShortMethod,
+    &CallNonvirtualShortMethodV,
+    &CallNonvirtualShortMethodA,
+    &CallNonvirtualIntMethod,
+    &CallNonvirtualIntMethodV,
+    &CallNonvirtualIntMethodA,
+    &CallNonvirtualLongMethod,
+    &CallNonvirtualLongMethodV,
+    &CallNonvirtualLongMethodA,
+    &CallNonvirtualFloatMethod,
+    &CallNonvirtualFloatMethodV,
+    &CallNonvirtualFloatMethodA,
+    &CallNonvirtualDoubleMethod,
+    &CallNonvirtualDoubleMethodV,
+    &CallNonvirtualDoubleMethodA,
+    &CallNonvirtualVoidMethod,
+    &CallNonvirtualVoidMethodV,
+    &CallNonvirtualVoidMethodA,
+    &GetFieldID,
+    &GetObjectField,
+    &GetBooleanField,
+    &GetByteField,
+    &GetCharField,
+    &GetShortField,
+    &GetIntField,
+    &GetLongField,
+    &GetFloatField,
+    &GetDoubleField,
+    &SetObjectField,
+    &SetBooleanField,
+    &SetByteField,
+    &SetCharField,
+    &SetShortField,
+    &SetIntField,
+    &SetLongField,
+    &SetFloatField,
+    &SetDoubleField,
+    &GetStaticMethodID,
+    &CallStaticObjectMethod,
+    &CallStaticObjectMethodV,
+    &CallStaticObjectMethodA,
+    &CallStaticBooleanMethod,
+    &CallStaticBooleanMethodV,
+    &CallStaticBooleanMethodA,
+    &CallStaticByteMethod,
+    &CallStaticByteMethodV,
+    &CallStaticByteMethodA,
+    &CallStaticCharMethod,
+    &CallStaticCharMethodV,
+    &CallStaticCharMethodA,
+    &CallStaticShortMethod,
+    &CallStaticShortMethodV,
+    &CallStaticShortMethodA,
+    &CallStaticIntMethod,
+    &CallStaticIntMethodV,
+    &CallStaticIntMethodA,
+    &CallStaticLongMethod,
+    &CallStaticLongMethodV,
+    &CallStaticLongMethodA,
+    &CallStaticFloatMethod,
+    &CallStaticFloatMethodV,
+    &CallStaticFloatMethodA,
+    &CallStaticDoubleMethod,
+    &CallStaticDoubleMethodV,
+    &CallStaticDoubleMethodA,
+    &CallStaticVoidMethod,
+    &CallStaticVoidMethodV,
+    &CallStaticVoidMethodA,
+    &GetStaticFieldID,
+    &GetStaticObjectField,
+    &GetStaticBooleanField,
+    &GetStaticByteField,
+    &GetStaticCharField,
+    &GetStaticShortField,
+    &GetStaticIntField,
+    &GetStaticLongField,
+    &GetStaticFloatField,
+    &GetStaticDoubleField,
+    &SetStaticObjectField,
+    &SetStaticBooleanField,
+    &SetStaticByteField,
+    &SetStaticCharField,
+    &SetStaticShortField,
+    &SetStaticIntField,
+    &SetStaticLongField,
+    &SetStaticFloatField,
+    &SetStaticDoubleField,
+    &NewString,
+    &GetStringLength,
+    &GetStringChars,
+    &ReleaseStringChars,
+    &NewStringUTF,
+    &GetStringUTFLength,
+    &GetStringUTFChars,
+    &ReleaseStringUTFChars,
+    &GetArrayLength,
+    &NewObjectArray,
+    &GetObjectArrayElement,
+    &SetObjectArrayElement,
+    &NewBooleanArray,
+    &NewByteArray,
+    &NewCharArray,
+    &NewShortArray,
+    &NewIntArray,
+    &NewLongArray,
+    &NewFloatArray,
+    &NewDoubleArray,
+    &GetBooleanArrayElements,
+    &GetByteArrayElements,
+    &GetCharArrayElements,
+    &GetShortArrayElements,
+    &GetIntArrayElements,
+    &GetLongArrayElements,
+    &GetFloatArrayElements,
+    &GetDoubleArrayElements,
+    &ReleaseBooleanArrayElements,
+    &ReleaseByteArrayElements,
+    &ReleaseCharArrayElements,
+    &ReleaseShortArrayElements,
+    &ReleaseIntArrayElements,
+    &ReleaseLongArrayElements,
+    &ReleaseFloatArrayElements,
+    &ReleaseDoubleArrayElements,
+    &GetBooleanArrayRegion,
+    &GetByteArrayRegion,
+    &GetCharArrayRegion,
+    &GetShortArrayRegion,
+    &GetIntArrayRegion,
+    &GetLongArrayRegion,
+    &GetFloatArrayRegion,
+    &GetDoubleArrayRegion,
+    &SetBooleanArrayRegion,
+    &SetByteArrayRegion,
+    &SetCharArrayRegion,
+    &SetShortArrayRegion,
+    &SetIntArrayRegion,
+    &SetLongArrayRegion,
+    &SetFloatArrayRegion,
+    &SetDoubleArrayRegion,
+    &RegisterNatives,
+    &UnregisterNatives,
+    &MonitorEnter,
+    &MonitorExit,
+    &GetJavaVM,
+    &GetStringRegion,
+    &GetStringUTFRegion,
+    &GetPrimitiveArrayCritical,
+    &ReleasePrimitiveArrayCritical,
+    &GetStringCritical,
+    &ReleaseStringCritical,
+    &NewWeakGlobalRef,
+    &DeleteWeakGlobalRef,
+    &ExceptionCheck
+    };
diff --git a/jni.h b/jni.h
new file mode 100644 (file)
index 0000000..183fcda
--- /dev/null
+++ b/jni.h
@@ -0,0 +1,425 @@
+/******************************** jni.h ***************************************
+
+       contains Java Native Interface types and data structures 
+       includes layout of the JNI function table
+       
+*******************************************************************************/
+
+#include <stdarg.h>
+
+#define JNIEXPORT
+#define JNICALL
+
+/* JNI datatypes */
+
+#define jobject         java_objectheader*
+#define jclass          struct classinfo*
+#define jthrowable                        jobject
+#define jweak                     jobject
+#define jarray          java_arrayheader*
+#define jlongArray        java_longarray*
+#define jbooleanArray  java_booleanarray*
+#define jintArray           java_intarray*
+#define jcharArray        java_chararray*
+#define jbyteArray        java_bytearray*
+#define jshortArray      java_shortarray*
+#define jdoubleArray    java_doublearray*
+#define jfloatArray      java_floatarray*
+#define jobjectArray    java_objectarray*
+#define jstring                           jobject
+#define jint                           s4
+#define jchar                          s2
+#define jboolean                       u1
+#define jbyte                          s1
+#define jshort                         s2
+#define jlong                          s8
+#define jfloat                      float
+#define jdouble                    double
+#define jsize                        jint
+#define jfieldID               fieldinfo*
+#define jmethodID             methodinfo*      
+
+struct _JavaVM;                                     /* opaque structure */
+typedef struct _JavaVM* JavaVM;
+
+typedef union jvalue {
+    jboolean z;
+    jbyte    b;
+    jchar    c;
+    jshort   s;
+    jint     i;
+    jlong    j;
+    jfloat   f;
+    jdouble  d;
+    jobject  l;
+} jvalue;
+
+/* JNI-Boolean */
+
+#define JNI_FALSE 0
+#define JNI_TRUE  1
+
+/* native method name, signature and function pointer for use in RegisterNatives */
+
+typedef struct {
+    char *name;
+    char *signature;
+    void *fnPtr;
+} JNINativeMethod;
+
+
+/* 
+       JNI function table, contains functions for the following usages:        
+       
+       Version Information 
+       Class Operations 
+       Exceptions 
+       Global and Local References 
+       Object Operations 
+       Accessing Fields of Objects 
+       Calling Instance Methods 
+       Accessing Static Fields 
+       Calling Static Methods 
+       String Operations 
+       Array Operations 
+       Registering Native Methods 
+       Monitor Operations 
+       Java VM Interface 
+*/
+
+typedef struct JNI_Table JNIEnv;
+
+struct JNI_Table {
+    
+    /* reserverd for future JNI-functions */
+    void *unused0;
+    void *unused1;
+    void *unused2;
+    void *unused3;
+    
+    /* version information */
+    
+    jint (*GetVersion) (JNIEnv*);
+
+    /* class operations */
+
+    jclass (*DefineClass) (JNIEnv*, const char *name, jobject loader, const jbyte *buf, jsize len);
+    jclass (*FindClass) (JNIEnv*, const char *name);
+
+    jmethodID (*FromReflectedMethod) (JNIEnv*, jobject method);
+    jfieldID (*FromReflectedField) (JNIEnv*, jobject field);
+
+    jobject (*ToReflectedMethod) (JNIEnv*, jclass cls, jmethodID methodID, jboolean isStatic);
+
+    jclass (*GetSuperclass) (JNIEnv*, jclass sub);
+    jboolean (*IsAssignableForm) (JNIEnv*, jclass sub, jclass sup);
+
+    jobject (*ToReflectedField) (JNIEnv*, jclass cls, jfieldID fieldID, jboolean isStatic);
+
+    /* exceptions */ 
+
+    jint (*Throw) (JNIEnv*, jthrowable obj);
+    jint (*ThrowNew) (JNIEnv*, jclass clazz, const char *msg);
+    jthrowable (*ExceptionOccurred) (JNIEnv*);
+    void (*ExceptionDescribe) (JNIEnv*);
+    void (*ExceptionClear) (JNIEnv*);
+    void (*FatalError) (JNIEnv*, const char *msg);
+
+    /* global and local references */
+
+    jint (*PushLocalFrame) (JNIEnv*, jint capacity);
+    jobject (*PopLocalFrame) (JNIEnv*, jobject result);
+    
+    jobject (*NewGlobalRef) (JNIEnv*, jobject lobj);
+    void (*DeleteGlobalRef) (JNIEnv*, jobject gref);
+    void (*DeleteLocalRef) (JNIEnv*, jobject obj);
+    jboolean (*IsSameObject) (JNIEnv*, jobject obj1, jobject obj2);
+    jobject (*NewLocalRef) (JNIEnv*, jobject ref);
+    jint (*EnsureLocalCapacity) (JNIEnv*, jint capacity);
+
+    /* object operations */ 
+
+    jobject (*AllocObject) (JNIEnv*, jclass clazz);
+    jobject (*NewObject) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jobject (*NewObjectV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jobject (*NewObjectA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jclass (*GetObjectClass) (JNIEnv*, jobject obj);
+    jboolean (*IsInstanceOf) (JNIEnv*, jobject obj, jclass clazz);
+
+    jmethodID (*GetMethodID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+
+    /* calling instance methods */ 
+
+    jobject (*CallObjectMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jobject (*CallObjectMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jobject (*CallObjectMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
+
+    jboolean (*CallBooleanMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jboolean (*CallBooleanMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jboolean (*CallBooleanMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
+
+    jbyte (*CallByteMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jbyte (*CallByteMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jbyte (*CallByteMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jchar (*CallCharMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jchar (*CallCharMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jchar (*CallCharMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jshort (*CallShortMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jshort (*CallShortMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jshort (*CallShortMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jint (*CallIntMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jint (*CallIntMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jint (*CallIntMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jlong (*CallLongMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jlong (*CallLongMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jlong (*CallLongMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jfloat (*CallFloatMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jfloat (*CallFloatMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jfloat (*CallFloatMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jdouble (*CallDoubleMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jdouble (*CallDoubleMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jdouble (*CallDoubleMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    void (*CallVoidMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    void (*CallVoidMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    void (*CallVoidMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
+
+    jobject (*CallNonvirtualObjectMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jobject (*CallNonvirtualObjectMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jobject (*CallNonvirtualObjectMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
+
+    jboolean (*CallNonvirtualBooleanMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jboolean (*CallNonvirtualBooleanMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jboolean (*CallNonvirtualBooleanMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
+
+    jbyte (*CallNonvirtualByteMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jbyte (*CallNonvirtualByteMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jbyte (*CallNonvirtualByteMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jchar (*CallNonvirtualCharMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jchar (*CallNonvirtualCharMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jchar (*CallNonvirtualCharMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jshort (*CallNonvirtualShortMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jshort (*CallNonvirtualShortMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jshort (*CallNonvirtualShortMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jint (*CallNonvirtualIntMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jint (*CallNonvirtualIntMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jint (*CallNonvirtualIntMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jlong (*CallNonvirtualLongMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jlong (*CallNonvirtualLongMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jlong (*CallNonvirtualLongMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jfloat (*CallNonvirtualFloatMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jfloat (*CallNonvirtualFloatMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jfloat (*CallNonvirtualFloatMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jdouble (*CallNonvirtualDoubleMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jdouble (*CallNonvirtualDoubleMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jdouble (*CallNonvirtualDoubleMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    void (*CallNonvirtualVoidMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    void (*CallNonvirtualVoidMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    void (*CallNonvirtualVoidMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
+
+    /* accessing fields */
+
+    jfieldID (*GetFieldID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+
+    jobject (*GetObjectField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jboolean (*GetBooleanField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jbyte (*GetByteField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jchar (*GetCharField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jshort (*GetShortField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jint (*GetIntField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jlong (*GetLongField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jfloat (*GetFloatField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jdouble (*GetDoubleField) (JNIEnv*, jobject obj, jfieldID fieldID);
+
+    void (*SetObjectField) (JNIEnv*, jobject obj, jfieldID fieldID, jobject val);
+    void (*SetBooleanField) (JNIEnv*, jobject obj, jfieldID fieldID, jboolean val);
+    void (*SetByteField) (JNIEnv*, jobject obj, jfieldID fieldID, jbyte val);
+    void (*SetCharField) (JNIEnv*, jobject obj, jfieldID fieldID, jchar val);
+    void (*SetShortField) (JNIEnv*, jobject obj, jfieldID fieldID, jshort val);
+    void (*SetIntField) (JNIEnv*, jobject obj, jfieldID fieldID, jint val);
+    void (*SetLongField) (JNIEnv*, jobject obj, jfieldID fieldID, jlong val);
+    void (*SetFloatField) (JNIEnv*, jobject obj, jfieldID fieldID, jfloat val);
+    void (*SetDoubleField) (JNIEnv*, jobject obj, jfieldID fieldID, jdouble val);
+
+    /* calling static methods */ 
+    
+    jmethodID (*GetStaticMethodID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+
+    jobject (*CallStaticObjectMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jobject (*CallStaticObjectMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jobject (*CallStaticObjectMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jboolean (*CallStaticBooleanMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jboolean (*CallStaticBooleanMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jboolean (*CallStaticBooleanMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jbyte (*CallStaticByteMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jbyte (*CallStaticByteMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jbyte (*CallStaticByteMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jchar (*CallStaticCharMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jchar (*CallStaticCharMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jchar (*CallStaticCharMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jshort (*CallStaticShortMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jshort (*CallStaticShortMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jshort (*CallStaticShortMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jint (*CallStaticIntMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jint (*CallStaticIntMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jint (*CallStaticIntMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jlong (*CallStaticLongMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jlong (*CallStaticLongMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jlong (*CallStaticLongMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jfloat (*CallStaticFloatMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jfloat (*CallStaticFloatMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jfloat (*CallStaticFloatMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jdouble (*CallStaticDoubleMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jdouble (*CallStaticDoubleMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jdouble (*CallStaticDoubleMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    void (*CallStaticVoidMethod) (JNIEnv*, jclass cls, jmethodID methodID, ...);
+    void (*CallStaticVoidMethodV) (JNIEnv*, jclass cls, jmethodID methodID, va_list args);
+    void (*CallStaticVoidMethodA) (JNIEnv*, jclass cls, jmethodID methodID, jvalue * args);
+
+    /* accessing static fields */
+
+    jfieldID (*GetStaticFieldID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+    jobject (*GetStaticObjectField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jboolean (*GetStaticBooleanField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jbyte (*GetStaticByteField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jchar (*GetStaticCharField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jshort (*GetStaticShortField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jint (*GetStaticIntField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jlong (*GetStaticLongField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jfloat (*GetStaticFloatField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jdouble (*GetStaticDoubleField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+
+    void (*SetStaticObjectField) (JNIEnv*, jclass clazz, jfieldID fieldID, jobject value);
+    void (*SetStaticBooleanField) (JNIEnv*, jclass clazz, jfieldID fieldID, jboolean value);
+    void (*SetStaticByteField) (JNIEnv*, jclass clazz, jfieldID fieldID, jbyte value);
+    void (*SetStaticCharField) (JNIEnv*, jclass clazz, jfieldID fieldID, jchar value);
+    void (*SetStaticShortField) (JNIEnv*, jclass clazz, jfieldID fieldID, jshort value);
+    void (*SetStaticIntField) (JNIEnv*, jclass clazz, jfieldID fieldID, jint value);
+    void (*SetStaticLongField) (JNIEnv*, jclass clazz, jfieldID fieldID, jlong value);
+    void (*SetStaticFloatField) (JNIEnv*, jclass clazz, jfieldID fieldID, jfloat value);
+    void (*SetStaticDoubleField) (JNIEnv*, jclass clazz, jfieldID fieldID, jdouble value);
+
+    /* string operations */ 
+
+    jstring (*NewString) (JNIEnv*, const jchar *unicode, jsize len);
+    jsize (*GetStringLength) (JNIEnv*, jstring str);
+    const jchar *(*GetStringChars) (JNIEnv*, jstring str, jboolean *isCopy);
+    void (*ReleaseStringChars) (JNIEnv*, jstring str, const jchar *chars);
+
+    jstring (*NewStringUTF) (JNIEnv*, const char *utf);
+    jsize (*GetStringUTFLength) (JNIEnv*, jstring str);
+    const char* (*GetStringUTFChars) (JNIEnv*, jstring str, jboolean *isCopy);
+    void (*ReleaseStringUTFChars) (JNIEnv*, jstring str, const char* chars);
+
+    /* array operations */
+
+    jsize (*GetArrayLength) (JNIEnv*, jarray array);
+
+    jobjectArray (*NewObjectArray) (JNIEnv*, jsize len, jclass clazz, jobject init);
+    jobject (*GetObjectArrayElement) (JNIEnv*, jobjectArray array, jsize index);
+    void (*SetObjectArrayElement) (JNIEnv*, jobjectArray array, jsize index, jobject val);
+
+    jbooleanArray (*NewBooleanArray) (JNIEnv*, jsize len);
+    jbyteArray (*NewByteArray) (JNIEnv*, jsize len);
+    jcharArray (*NewCharArray) (JNIEnv*, jsize len);
+    jshortArray (*NewShortArray) (JNIEnv*, jsize len);
+    jintArray (*NewIntArray) (JNIEnv*, jsize len);
+    jlongArray (*NewLongArray) (JNIEnv*, jsize len);
+    jfloatArray (*NewFloatArray) (JNIEnv*, jsize len);
+    jdoubleArray (*NewDoubleArray) (JNIEnv*, jsize len);
+
+    jboolean * (*GetBooleanArrayElements) (JNIEnv*, jbooleanArray array, jboolean *isCopy);
+    jbyte * (*GetByteArrayElements) (JNIEnv*, jbyteArray array, jboolean *isCopy);
+    jchar * (*GetCharArrayElements) (JNIEnv*, jcharArray array, jboolean *isCopy);
+    jshort * (*GetShortArrayElements) (JNIEnv*, jshortArray array, jboolean *isCopy);
+    jint * (*GetIntArrayElements) (JNIEnv*, jintArray array, jboolean *isCopy);
+    jlong * (*GetLongArrayElements) (JNIEnv*, jlongArray array, jboolean *isCopy);
+    jfloat * (*GetFloatArrayElements) (JNIEnv*, jfloatArray array, jboolean *isCopy);
+    jdouble * (*GetDoubleArrayElements) (JNIEnv*, jdoubleArray array, jboolean *isCopy);
+
+    void (*ReleaseBooleanArrayElements) (JNIEnv*, jbooleanArray array, jboolean *elems, jint mode);
+    void (*ReleaseByteArrayElements) (JNIEnv*, jbyteArray array, jbyte *elems, jint mode);
+    void (*ReleaseCharArrayElements) (JNIEnv*, jcharArray array, jchar *elems, jint mode);
+    void (*ReleaseShortArrayElements) (JNIEnv*, jshortArray array, jshort *elems, jint mode);
+    void (*ReleaseIntArrayElements) (JNIEnv*, jintArray array, jint *elems, jint mode);
+    void (*ReleaseLongArrayElements) (JNIEnv*, jlongArray array, jlong *elems, jint mode);
+    void (*ReleaseFloatArrayElements) (JNIEnv*, jfloatArray array, jfloat *elems, jint mode);
+    void (*ReleaseDoubleArrayElements) (JNIEnv*, jdoubleArray array, jdouble *elems, jint mode);
+
+    void (*GetBooleanArrayRegion) (JNIEnv*, jbooleanArray array, jsize start, jsize l, jboolean *buf);
+    void (*GetByteArrayRegion) (JNIEnv*, jbyteArray array, jsize start, jsize len, jbyte *buf);
+    void (*GetCharArrayRegion) (JNIEnv*, jcharArray array, jsize start, jsize len, jchar *buf);
+    void (*GetShortArrayRegion) (JNIEnv*, jshortArray array, jsize start, jsize len, jshort *buf);
+    void (*GetIntArrayRegion) (JNIEnv*, jintArray array, jsize start, jsize len, jint *buf);
+    void (*GetLongArrayRegion) (JNIEnv*, jlongArray array, jsize start, jsize len, jlong *buf);
+    void (*GetFloatArrayRegion) (JNIEnv*, jfloatArray array, jsize start, jsize len, jfloat *buf);
+    void (*GetDoubleArrayRegion) (JNIEnv*, jdoubleArray array, jsize start, jsize len, jdouble *buf);
+
+    void (*SetBooleanArrayRegion) (JNIEnv*, jbooleanArray array, jsize start, jsize l, jboolean *buf);
+    void (*SetByteArrayRegion) (JNIEnv*, jbyteArray array, jsize start, jsize len, jbyte *buf);
+    void (*SetCharArrayRegion) (JNIEnv*, jcharArray array, jsize start, jsize len, jchar *buf);
+    void (*SetShortArrayRegion) (JNIEnv*, jshortArray array, jsize start, jsize len, jshort *buf);
+    void (*SetIntArrayRegion) (JNIEnv*, jintArray array, jsize start, jsize len, jint *buf);
+    void (*SetLongArrayRegion) (JNIEnv*, jlongArray array, jsize start, jsize len, jlong *buf);
+    void (*SetFloatArrayRegion) (JNIEnv*, jfloatArray array, jsize start, jsize len, jfloat *buf);
+    void (*SetDoubleArrayRegion) (JNIEnv*, jdoubleArray array, jsize start, jsize len, jdouble *buf);
+
+    /* registering native methods */
+
+    jint (*RegisterNatives) (JNIEnv*, jclass clazz, const JNINativeMethod *methods, jint nMethods);
+    jint (*UnregisterNatives) (JNIEnv*, jclass clazz);
+
+    /* monitor operations */
+
+    jint (*MonitorEnter) (JNIEnv*, jobject obj);
+    jint (*MonitorExit) (JNIEnv*, jobject obj);
+
+    /* JavaVM interface */
+
+    jint (*GetJavaVM) (JNIEnv*, JavaVM **vm);
+
+    void (*GetStringRegion) (JNIEnv*, jstring str, jsize start, jsize len, jchar *buf);
+    void (*GetStringUTFRegion) (JNIEnv*, jstring str, jsize start, jsize len, char *buf);
+
+    void * (*GetPrimitiveArrayCritical) (JNIEnv*, jarray array, jboolean *isCopy);
+    void (*ReleasePrimitiveArrayCritical) (JNIEnv*, jarray array, void *carray, jint mode);
+
+    const jchar * (*GetStringCritical) (JNIEnv*, jstring string, jboolean *isCopy);
+    void (*ReleaseStringCritical) (JNIEnv*, jstring string, const jchar *cstring);
+
+    jweak (*NewWeakGlobalRef) (JNIEnv*, jobject obj);
+    void (*DeleteWeakGlobalRef) (JNIEnv*, jweak ref);
+
+    jboolean (*ExceptionCheck) (JNIEnv*);
+};
+
+
+/* the active JNI function table */
+
+extern JNIEnv env;
+
+
+
index 9b58781060b1e91090a6343d6c6b9dceef55c842..d40b095cd0e197322426dc892b83c69904a5293f 100644 (file)
--- a/loader.c
+++ b/loader.c
@@ -1,3 +1,4 @@
+
 /* loader.c ********************************************************************
 
        Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
@@ -18,9 +19,8 @@
 
 #include "global.h"
 #include "loader.h"
-
-#include "tables.h"
 #include "native.h"
+#include "tables.h"
 #include "builtin.h"
 #include "jit.h"
 #ifdef OLD_COMPILER
@@ -29,7 +29,7 @@
 #include "asmpart.h"
 
 #include "threads/thread.h"                        /* schani */
-
+#include <sys/stat.h>
 
 /* global variables ***********************************************************/
 
@@ -48,17 +48,26 @@ bool initverbose = false;
 
 bool makeinitializations = true;
 
-bool getloadingtime = false;
+bool getloadingtime  = false;   /* to measure the runtime                     */
 long int loadingtime = 0;
 
-
 static s4 interfaceindex;    /* sequential numbering of interfaces            */ 
 
-static list unloadedclasses; /* list of all referenced but not loaded classes */
-static list unlinkedclasses; /* list of all loaded but not linked classes     */
-       list linkedclasses;   /* list of all completely linked classes         */
+list unloadedclasses; /* list of all referenced but not loaded classes */
+list unlinkedclasses; /* list of all loaded but not linked classes     */
+list linkedclasses;   /* list of all completely linked classes         */
+
 
+/* utf-symbols for pointer comparison of frequently used strings */
 
+static utf *utf_innerclasses;          /* InnerClasses                    */
+static utf *utf_constantvalue;                 /* ConstantValue                   */
+static utf *utf_code;                      /* Code                            */
+static utf *utf_finalize;                  /* finalize                            */
+static utf *utf_fidesc;                    /* ()V                                     */
+static utf *utf_clinit;                    /* <clinit>                            */
+static utf *utf_initsystemclass;       /* initializeSystemClass   */
+static utf *utf_systemclass;           /* java/lang/System        */
 
 /* important system classes ***************************************************/
 
@@ -72,9 +81,26 @@ classinfo *class_java_lang_OutOfMemoryError;
 classinfo *class_java_lang_ArithmeticException;
 classinfo *class_java_lang_ArrayStoreException;
 classinfo *class_java_lang_ThreadDeath;                 /* schani */
+classinfo *class_array = NULL;
 
-classinfo *class_array;
+/******************************************************************************
 
+   structure for primitive classes: contains the class for wrapping the 
+   primitive type, the primitive class, the name of the class for wrapping, 
+   the one character type signature and the name of the primitive class
+ ******************************************************************************/
+primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT] = { 
+               { NULL, NULL, "java/lang/Double",    'D', "double"  },
+               { NULL, NULL, "java/lang/Float",     'F', "float"   },
+               { NULL, NULL, "java/lang/Character", 'C', "char"    },
+               { NULL, NULL, "java/lang/Integer",   'I', "int"     },
+               { NULL, NULL, "java/lang/Long",      'J', "long"    },
+               { NULL, NULL, "java/lang/Byte",      'B', "byte"    },
+               { NULL, NULL, "java/lang/Short",     'S', "short"   },
+               { NULL, NULL, "java/lang/Boolean",   'Z', "boolean" },
+               { NULL, NULL, "java/lang/Void",      'V', "void"    }};
 
 /* instances of important system classes **************************************/
 
@@ -88,7 +114,209 @@ java_objectheader *proto_java_lang_ArrayStoreException;
 java_objectheader *proto_java_lang_ThreadDeath;         /* schani */
 
 
+/************* functions for reading classdata ********************************
+
+    getting classdata in blocks of variable size
+    (8,16,32,64-bit integer or float)
+
+*******************************************************************************/
+
+static char *classpath    = "";     /* searchpath for classfiles              */
+static u1 *classbuffer    = NULL;   /* pointer to buffer with classfile-data  */
+static u1 *classbuf_pos;            /* current position in classfile buffer   */
+static int classbuffer_size;        /* size of classfile-data                 */
+
+/* transfer block of classfile data into a buffer */
+#define suck_nbytes(buffer,len) memcpy(buffer,classbuf_pos+1,len);classbuf_pos+=len;
+
+/* skip block of classfile data */
+#define skip_nbytes(len) classbuf_pos += len;
+
+#define suck_u1() (*++classbuf_pos)
+#define suck_s8() (s8) suck_u8()
+#define suck_s2() (s2) suck_u2()
+#define suck_s4() (s4) suck_u4()
+#define suck_s1() (s1) suck_u1()
+#define suck_u2() (u2) ((suck_u1()<<8)+suck_u1())
+#define suck_u4() (u4) ((((u4)suck_u1())<<24)+(((u4)suck_u1())<<16)+(((u4)suck_u1())<<8)+((u4)suck_u1()))
+
+/* get u8 from classfile data */
+static u8 suck_u8 ()
+{
+#if U8_AVAILABLE
+       u8 lo,hi;
+       hi = suck_u4();
+       lo = suck_u4();
+       return (hi<<32) + lo;
+#else
+       u8 v;
+       v.high = suck_u4();
+       v.low = suck_u4();
+       return v;
+#endif
+}
+
+/* get float from classfile data */
+static float suck_float ()
+{
+       float f;
+
+#if !WORDS_BIGENDIAN 
+               u1 buffer[4];
+               u2 i;
+               for (i=0; i<4; i++) buffer[3-i] = suck_u1 ();
+               memcpy ( (u1*) (&f), buffer, 4);
+#else 
+               suck_nbytes ( (u1*) (&f), 4 );
+#endif
+
+       PANICIF (sizeof(float) != 4, "Incompatible float-format");
+       
+       return f;
+}
+
+/* get double from classfile data */
+static double suck_double ()
+{
+       double d;
+
+#if !WORDS_BIGENDIAN 
+               u1 buffer[8];
+               u2 i;   
+               for (i=0; i<8; i++) buffer[7-i] = suck_u1 ();
+               memcpy ( (u1*) (&d), buffer, 8);
+#else 
+               suck_nbytes ( (u1*) (&d), 8 );
+#endif
+
+       PANICIF (sizeof(double) != 8, "Incompatible double-format" );
+       
+       return d;
+}
+
+/************************** function: suck_init ******************************
+
+       called once at startup, sets the searchpath for the classfiles
+
+******************************************************************************/
+
+void suck_init (char *cpath)
+{
+       classpath   = cpath;
+       classbuffer = NULL;
+}
+
+
+/************************** function: suck_start ******************************
+
+       open file for the specified class and the read classfile data,
+       all directory of the searchpath are used to find the classfile
+       ( <classname>.class)
+       
+******************************************************************************/
+
+
+bool suck_start (utf *classname)
+{
+#define MAXFILENAME 1000              /* maximum length of a filename */
+       
+       char filename[MAXFILENAME+10]; /* room for '.class' */  
+       char *pathpos;                 /* position in searchpath */
+       FILE *classfile;
+       u2 filenamelen;
+       u2 c;
+
+       if (classbuffer)               /* classbuffer already valid */
+               return true;
+
+       pathpos = classpath;
+       
+       while (*pathpos) {
+               /* pointer to the next utf8-character */
+               char *utf_ptr = classname->text; 
+
+               /* skip path separator */
+               while ( *pathpos == ':' ) pathpos++;
+               /* extract directory from searchpath */
+               filenamelen=0;
+               while ( (*pathpos) && (*pathpos!=':') ) {
+                   PANICIF (filenamelen >= MAXFILENAME, "Filename too long") ;
+                       
+                       filename[filenamelen++] = *(pathpos++);
+                       }
+
+               filename[filenamelen++] = '/';  
+   
+               /* add classname to filename */
+               while (utf_ptr<utf_end(classname)) {
+                       PANICIF (filenamelen >= MAXFILENAME, "Filename too long");
+                       
+                       c = *utf_ptr++;
+                       if (c=='/') c = '/';     
+                       else {
+                               if ( c<=' ' || c>'z') { 
+                                       /* invalid character */
+                                       c = '?'; 
+                                       }
+                               }
+                       
+                       filename[filenamelen++] = c;    
+                       }
+      
+               /* add suffix */
+               strcpy (filename+filenamelen, ".class");
+
+               classfile = fopen(filename, "r");
+               if (classfile) {
+                       /* file exists */
+                       struct stat buffer;
+                       int err;
+       
+                       /* determine size of classfile */
+                       err = stat (filename, &buffer);
+
+                       if (!err) {
+                               /* read classfile data */                               
+                               classbuffer_size = buffer.st_size;                              
+                               classbuffer      = MNEW(u1,classbuffer_size);
+                               classbuf_pos     = classbuffer-1;
+                               fread(classbuffer, 1, classbuffer_size, classfile);
+                               fclose(classfile);
+                               return true;
+                       }
+               }
+       }
+
+       sprintf (logtext,"Can not open class file '%s'", filename);
+       error();
+
+       return false;
+}
+
+
+/************************** function: suck_stop *******************************
+
+       free memory for buffer with classfile data
+       
+******************************************************************************/
+
+void suck_stop ()
+{
+       /* determine number of bytes of classdata not retrieved by suck-operations */
+       int classdata_left = (classbuffer+classbuffer_size)-classbuf_pos-1;
+
+        if (classdata_left>0) {                
+                       /* surplus */           
+                       sprintf (logtext,"There are %d access bytes at end of classfile",
+                                classdata_left);
+                       dolog();
+       }
 
+       /* free memory */
+       MFREE(classbuffer,u1,classbuffer_size);
+       classbuffer = NULL;
+}
 
 /******************************************************************************/
 /******************* Einige Support-Funkionen *********************************/
@@ -137,7 +365,6 @@ static void skipattributebody ()
        skip_nbytes(suck_u4());
 }
 
-
 /************************* Funktion: skipattributes ****************************
 
        "uberliest im ClassFile eine gew"unschte Anzahl von attribute-Strukturen
@@ -151,169 +378,268 @@ static void skipattributes (u4 num)
                skipattribute();
 }
 
+/******************** function: innerclass_getconstant ************************
 
-
-/************************** Funktion: loadUtf8 *********************************
-
-       liest aus dem ClassFile einen Utf8-String (=komprimierter unicode-text) 
-       und legt daf"ur ein unicode-Symbol an. 
-       Return: Zeiger auf das Symbol 
-
+    like class_getconstant, but if cptags is ZERO null is returned                                      
+       
 *******************************************************************************/
 
-#define MAXUNICODELEN 5000
-static u2 unicodebuffer[MAXUNICODELEN];
-
-static unicode *loadUtf8 ()
+voidptr innerclass_getconstant (classinfo *c, u4 pos, u4 ctype) 
 {
-       u4 unicodelen;
-       u4 letter;
+       /* invalid position in constantpool */
+       if (pos >= c->cpcount) 
+               panic ("Attempt to access constant outside range");
 
-       u4 utflen;
-       u4 b1,b2,b3;
+       /* constantpool entry of type 0 */      
+       if (!c->cptags[pos])
+               return NULL;
 
-       unicodelen = 0;
+       /* check type of constantpool entry */
+       if (c->cptags[pos] != ctype) {
+               sprintf (logtext, "Type mismatch on constant: %d requested, %d here",
+                (int) ctype, (int) c->cptags[pos] );
+               error();
+               }
+               
+       return c->cpinfos[pos];
+}
 
-       utflen = suck_u2 ();
-       while (utflen > 0) {
-               b1 = suck_u1 ();
-               utflen --;
-               if (b1<0x80) letter = b1;
-               else {
-                       b2 = suck_u1 ();
-                       utflen --;
-                       if (b1<0xe0) letter = ((b1 & 0x1f) << 6) | (b2 & 0x3f);
-                       else {
-                               b3 = suck_u1 ();
-                               utflen --;
-                               letter = ((b1 & 0x0f) << 12) | ((b2 & 0x3f) << 6) | (b3 & 0x3f);
-                               }
-                       }       
+/************************ function: attribute_load ****************************
+
+    read attributes from classfile
        
+*******************************************************************************/
+
+static void attribute_load (u4 num, classinfo *c)
+{
+       u4 i,j;
+
+       for (i = 0; i < num; i++) {
+               /* retrieve attribute name */   
+               utf *aname = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
 
-               if (unicodelen >= MAXUNICODELEN) {
-                       panic ("String constant too long");
+               if ( aname == utf_innerclasses)  {                      
+                       /* innerclasses attribute */
+                               
+                       /* skip attribute length */                                             
+                       suck_u4(); 
+                       /* number of records */
+                       c->innerclasscount = suck_u2();
+                       /* allocate memory for innerclass structure */
+                       c->innerclass = MNEW (innerclassinfo, c->innerclasscount);
+
+                       for (j=0;j<c->innerclasscount;j++) {
+                               
+                               /*  The innerclass structure contains a class with an encoded name, 
+                                   its defining scope, its simple name  and a bitmask of the access flags. 
+                                   If an inner class is not a member, its outer_class is NULL, 
+                                   if a class is anonymous, its name is NULL.                              */
+                                                               
+                               innerclassinfo *info = c->innerclass + j;
+
+                               info->inner_class = innerclass_getconstant(c, suck_u2(), CONSTANT_Class); /* CONSTANT_Class_info index */
+                               info->outer_class = innerclass_getconstant(c, suck_u2(), CONSTANT_Class); /* CONSTANT_Class_info index */
+                               info->name  = innerclass_getconstant(c, suck_u2(), CONSTANT_Utf8);        /* CONSTANT_Utf8_info index  */
+                               info->flags = suck_u2 ();                                                 /* access_flags bitmask      */
                        }
-               
-               unicodebuffer[unicodelen++] = letter;                   
+               } else {
+                       /* unknown attribute */
+                       skipattributebody ();
                }
+       }
+}
+
+/******************* function: checkfielddescriptor ****************************
 
+       checks whether a field-descriptor is valid and aborts otherwise
+       all referenced classes are inserted into the list of unloaded classes
        
-       return unicode_new_u2 (unicodebuffer, unicodelen);
-}
+*******************************************************************************/
 
+static void checkfielddescriptor (char *utf_ptr, char *end_pos)
+{
+       char *tstart;  /* pointer to start of classname */
+       char ch;
+       
+       switch (*utf_ptr++) {
+       case 'B':
+       case 'C':
+       case 'I':
+       case 'S':
+       case 'Z':  
+       case 'J':  
+       case 'F':  
+       case 'D':
+               /* primitive type */  
+               break;
 
+       case 'L':
+               /* save start of classname */
+               tstart = utf_ptr;  
+               
+               /* determine length of classname */
+               while ( *utf_ptr++ != ';' )
+                       if (utf_ptr>=end_pos) 
+                               panic ("Missing ';' in objecttype-descriptor");
 
-/******************** interne Funktion: checkfieldtype ************************/
+               /* cause loading of referenced class */                 
+               class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+               break;
 
-static void checkfieldtype (u2 *text, u4 *count, u4 length)
-{
-       u4 l;
+       case '[' : 
+               /* array type */
+               while ((ch = *utf_ptr++)=='[') 
+                       /* skip */ ;
 
-       if (*count >= length) panic ("Type-descriptor exceeds unicode length");
-       
-       l = text[(*count)++];
-       
-       switch (l) {
-               default: panic ("Invalid symbol in type descriptor");
-                        return;
+               /* component type of array */
+               switch (ch) {
                case 'B':
                case 'C':
-               case 'D':
-               case 'F':
                case 'I':
-               case 'J':
                case 'S':
-               case 'Z': return;
-               
-               case '[': checkfieldtype (text, count, length);
-                         return;
-                         
-               case 'L': 
-                       {
-                       u4 tlen,tstart = *count;
+               case 'Z':  
+               case 'J':  
+               case 'F':  
+               case 'D':
+                       /* primitive type */  
+                       break;
                        
-                       if (*count >= length) 
-                          panic ("Objecttype descriptor of length zero");
+               case 'L':
+                       /* save start of classname */
+                       tstart = utf_ptr;
                        
-                       while ( text[*count] != ';' ) {
-                               (*count)++;
-                               if (*count >= length) 
-                                  panic ("Missing ';' in objecttype-descriptor");
-                               }
+                       /* determine length of classname */
+                       while ( *utf_ptr++ != ';' )
+                               if (utf_ptr>=end_pos) 
+                                       panic ("Missing ';' in objecttype-descriptor");
+
+                       /* cause loading of referenced class */                 
+                       class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+                       break;
+
+               default:   
+                       panic ("Ill formed methodtype-descriptor");
+               }
+               break;
                        
-                       tlen = (*count) - tstart;
-                       (*count)++;
+       default:   
+               panic ("Ill formed methodtype-descriptor");
+       }                       
 
-                       if (tlen == 0) panic ("Objecttype descriptor with empty name");
-                                       
-                       class_get ( unicode_new_u2 (text+tstart, tlen) );
-                       }
-               }       
+        /* exceeding characters */             
+       if (utf_ptr!=end_pos) panic ("descriptor has exceeding chars");
 }
 
 
-/******************* Funktion: checkfielddescriptor ****************************
+/******************* function: checkmethoddescriptor ***************************
 
-       "uberpr"uft, ob ein Field-Descriptor ein g"ultiges Format hat.
-       Wenn nicht, dann wird das System angehalten.
-       Au"serdem werden alle Klassen, die hier referenziert werden, 
-       in die Liste zu ladender Klassen eingetragen.
+    checks whether a method-descriptor is valid and aborts otherwise
+    all referenced classes are inserted into the list of unloaded classes      
        
 *******************************************************************************/
 
-void checkfielddescriptor (unicode *d)
+static void checkmethoddescriptor (utf *d)
 {
-       u4 count=0;
-       checkfieldtype (d->text, &count, d->length);
-       if (count != d->length) panic ("Invalid type-descritor encountered");
-}
+       char *utf_ptr = d->text;     /* current position in utf text   */
+       char *end_pos = utf_end(d);  /* points behind utf string       */
+       char *tstart;                /* pointer to start of classname  */
+       char c,ch;
 
+       /* method descriptor must start with parenthesis */
+       if (*utf_ptr++ != '(') panic ("Missing '(' in method descriptor");
 
-/******************* Funktion: checkmethoddescriptor ***************************
+       /* check arguments */
+       while ((c = *utf_ptr++) != ')') {
+               switch (c) {
+               case 'B':
+               case 'C':
+               case 'I':
+               case 'S':
+               case 'Z':  
+               case 'J':  
+               case 'F':  
+               case 'D':
+                       /* primitive type */  
+                       break;
 
-       "uberpr"uft, ob ein Method-Descriptor ein g"ultiges Format hat.
-       Wenn nicht, dann wird das System angehalten.
-       Au"serdem werden alle Klassen, die hier referenziert werden, 
-       in die Liste zu ladender Klassen eingetragen.
-       
-*******************************************************************************/
+               case 'L':
+                       /* save start of classname */ 
+                       tstart = utf_ptr;
+                       
+                       /* determine length of classname */
+                       while ( *utf_ptr++ != ';' )
+                               if (utf_ptr>=end_pos) 
+                                       panic ("Missing ';' in objecttype-descriptor");
+                       
+                       /* cause loading of referenced class */
+                       class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+                       break;
+          
+               case '[' :
+                       /* array type */ 
+                       while ((ch = *utf_ptr++)=='[') 
+                               /* skip */ ;
+
+                       /* component type of array */
+                       switch (ch) {
+                       case 'B':
+                       case 'C':
+                       case 'I':
+                       case 'S':
+                       case 'Z':  
+                       case 'J':  
+                       case 'F':  
+                       case 'D':
+                               /* primitive type */  
+                               break;
 
-void checkmethoddescriptor (unicode *d)
-{
-       u2 *text=d->text;
-       u4 length=d->length;
-       u4 count=0;
-       
-       if (length<2) panic ("Method descriptor too short");
-       if (text[0] != '(') panic ("Missing '(' in method descriptor");
-       count=1;
-       
-       while (text[count] != ')') {
-               checkfieldtype (text,&count,length);
-               if ( count > length-2 ) panic ("Unexpected end of descriptor");
-               }
-               
-       count++;
-       if (text[count] == 'V') count++;
-       else                    checkfieldtype (text, &count,length);
-               
-       if (count != length) panic ("Method-descriptor has exceeding chars");
+                       case 'L':
+                               /* save start of classname */
+                               tstart = utf_ptr;
+                       
+                               /* determine length of classname */     
+                               while ( *utf_ptr++ != ';' )
+                                       if (utf_ptr>=end_pos) 
+                                               panic ("Missing ';' in objecttype-descriptor");
+
+                               /* cause loading of referenced class */
+                               class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+                               break;
+
+                       default:   
+                               panic ("Ill formed methodtype-descriptor");
+                       } 
+                       break;
+                       
+               default:   
+                       panic ("Ill formed methodtype-descriptor");
+               }                       
+       }
+
+       /* check returntype */
+       if (*utf_ptr=='V') {
+               /* returntype void */
+               if ((utf_ptr+1) != end_pos) panic ("Method-descriptor has exceeding chars");
+       }
+       else
+               /* treat as field-descriptor */
+               checkfielddescriptor (utf_ptr,end_pos);
 }
 
 
 /******************** Funktion: buildarraydescriptor ***************************
 
-       erzeugt zu einem namentlich als u2-String vorliegenden Arraytyp eine
+       erzeugt zu einem namentlich als utf-String vorliegenden Arraytyp eine
        entsprechende constant_arraydescriptor - Struktur 
        
 *******************************************************************************/
 
-static constant_arraydescriptor * buildarraydescriptor(u2 *name, u4 namelen)
+constant_arraydescriptor * buildarraydescriptor(char *utf_ptr, u4 namelen)
 {
        constant_arraydescriptor *d;
        
-       if (name[0]!='[') panic ("Attempt to build arraydescriptor for non-array");
+       if (*utf_ptr++ != '[') panic ("Attempt to build arraydescriptor for non-array");
+
        d = NEW (constant_arraydescriptor);
        d -> objectclass = NULL;
        d -> elementdescriptor = NULL;
@@ -322,7 +648,7 @@ static constant_arraydescriptor * buildarraydescriptor(u2 *name, u4 namelen)
        count_const_pool_len += sizeof(constant_arraydescriptor);
 #endif
 
-       switch (name[1]) {
+       switch (*utf_ptr) {
        case 'Z': d -> arraytype = ARRAYTYPE_BOOLEAN; break;
        case 'B': d -> arraytype = ARRAYTYPE_BYTE; break;
        case 'C': d -> arraytype = ARRAYTYPE_CHAR; break;
@@ -334,12 +660,12 @@ static constant_arraydescriptor * buildarraydescriptor(u2 *name, u4 namelen)
 
        case '[':
                d -> arraytype = ARRAYTYPE_ARRAY; 
-               d -> elementdescriptor = buildarraydescriptor (name+1, namelen-1);
+               d -> elementdescriptor = buildarraydescriptor (utf_ptr, namelen-1);
                break;
                
        case 'L':
                d -> arraytype = ARRAYTYPE_OBJECT;
-               d -> objectclass = class_get ( unicode_new_u2 (name+2, namelen-3) );
+               d -> objectclass = class_new ( utf_new(utf_ptr+1, namelen-3) );
                break;
        }
        return d;
@@ -376,7 +702,7 @@ static void displayarraydescriptor (constant_arraydescriptor *d)
        case ARRAYTYPE_LONG: printf ("long[]"); break;
        case ARRAYTYPE_SHORT: printf ("short[]"); break;
        case ARRAYTYPE_ARRAY: displayarraydescriptor(d->elementdescriptor); printf("[]"); break;
-       case ARRAYTYPE_OBJECT: unicode_display(d->objectclass->name); printf("[]"); break;
+       case ARRAYTYPE_OBJECT: utf_display(d->objectclass->name); printf("[]"); break;
        }
 }
 
@@ -401,18 +727,18 @@ static void field_load (fieldinfo *f, classinfo *c)
        u4 attrnum,i;
        u4 jtype;
 
-       f -> flags = suck_u2 ();
-       f -> name = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
-       f -> descriptor = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
-       f -> type = jtype = desc_to_type (f->descriptor);
-       f -> offset = 0;
-
+       f -> flags = suck_u2 ();                                           /* ACC flags                   */
+       f -> name = class_getconstant (c, suck_u2(), CONSTANT_Utf8);       /* name of field               */
+       f -> descriptor = class_getconstant (c, suck_u2(), CONSTANT_Utf8); /* JavaVM descriptor           */
+       f -> type = jtype = desc_to_type (f->descriptor);                  /* data type                   */
+       f -> offset = 0;                                                   /* offset from start of object */
+       
        switch (f->type) {
        case TYPE_INT:        f->value.i = 0; break;
        case TYPE_FLOAT:      f->value.f = 0.0; break;
        case TYPE_DOUBLE:     f->value.d = 0.0; break;
-       case TYPE_ADDRESS:    f->value.a = NULL; 
-                             heap_addreference (&(f->value.a));
+       case TYPE_ADDRESS:    f->value.a = NULL;                              
+                             heap_addreference (&(f->value.a));           /* make global reference (GC)  */    
                              break;
        case TYPE_LONG:
 #if U8_AVAILABLE
@@ -421,21 +747,28 @@ static void field_load (fieldinfo *f, classinfo *c)
                f->value.l.low = 0; f->value.l.high = 0; break;
 #endif 
        }
-       
+
+       /* read attributes */
        attrnum = suck_u2();
        for (i=0; i<attrnum; i++) {
                u4 pindex;
-               unicode *aname;
+               utf *aname;
 
                aname = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
-
-               if ( aname != unicode_new_char ("ConstantValue") ) {
+               
+               if ( aname != utf_constantvalue ) {
+                       /* unknown attribute */
                        skipattributebody ();
                        }
                else {
+                       /* constant value attribute */
+                       
+                       /* skip attribute length */
                        suck_u4();
+                       /* index of value in constantpool */            
                        pindex = suck_u2();
-                               
+               
+                       /* initialize field with value from constantpool */             
                        switch (jtype) {
                                case TYPE_INT: {
                                        constant_integer *ci = 
@@ -468,9 +801,9 @@ static void field_load (fieldinfo *f, classinfo *c)
                                        }
                                        break;
                                                
-                               case TYPE_ADDRESS: {
-                                       unicode *u = 
-                                               class_getconstant(c, pindex, CONSTANT_String);
+                               case TYPE_ADDRESS: { 
+                                       utf *u = class_getconstant(c, pindex, CONSTANT_String);
+                                       /* create javastring from compressed utf8-string */                                     
                                        f->value.a = literalstring_new(u);
                                        }
                                        break;
@@ -482,14 +815,14 @@ static void field_load (fieldinfo *f, classinfo *c)
 
                        }
                }
-               
 }
 
 
-/********************** Funktion: field_free **********************************/
+/********************** function: field_free **********************************/
 
 static void field_free (fieldinfo *f)
 {
+       /* empty */
 }
 
 
@@ -500,15 +833,13 @@ static void field_display (fieldinfo *f)
        printf ("   ");
        printflags (f -> flags);
        printf (" ");
-       unicode_display (f -> name);
+       utf_display (f -> name);
        printf (" ");
-       unicode_display (f -> descriptor);      
+       utf_display (f -> descriptor);  
        printf (" offset: %ld\n", (long int) (f -> offset) );
 }
 
 
-
-
 /******************************************************************************/
 /************************* Funktionen f"ur Methods ****************************/ 
 /******************************************************************************/
@@ -548,6 +879,7 @@ static void method_load (methodinfo *m, classinfo *c)
                m -> stubroutine = createcompilerstub (m);
                }
        else {
+
                functionptr f = native_findfunction 
                       (c->name, m->name, m->descriptor, (m->flags & ACC_STATIC) != 0);
                if (f) {
@@ -565,11 +897,11 @@ static void method_load (methodinfo *m, classinfo *c)
        
        attrnum = suck_u2();
        for (i=0; i<attrnum; i++) {
-               unicode *aname;
+               utf *aname;
 
                aname = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
 
-               if ( aname != unicode_new_char("Code"))  {
+               if ( aname != utf_code)  {
                        skipattributebody ();
                        }
                else {
@@ -609,10 +941,8 @@ static void method_load (methodinfo *m, classinfo *c)
                        
                }
 
-
 }
 
-
 /********************* Funktion: method_free ***********************************
 
        gibt allen Speicher, der extra f"ur eine Methode angefordert wurde,
@@ -640,9 +970,9 @@ void method_display (methodinfo *m)
        printf ("   ");
        printflags (m -> flags);
        printf (" ");
-       unicode_display (m -> name);
+       utf_display (m -> name);
        printf (" "); 
-       unicode_display (m -> descriptor);
+       utf_display (m -> descriptor);
        printf ("\n");
 }
 
@@ -671,65 +1001,20 @@ static bool method_canoverwrite (methodinfo *m, methodinfo *old)
 /******************************************************************************/
 
 
-/******************** Funktion: class_get **************************************
+/******************** function: class_getconstant ******************************
 
-       Sucht im System die Klasse mit dem gew"unschten Namen, oder erzeugt
-       eine neue 'classinfo'-Struktur (und h"angt sie in die Liste der zu
-       ladenen Klassen ein).
-
-*******************************************************************************/
-
-classinfo *class_get (unicode *u)
-{
-       classinfo *c;
-       
-       if (u->class) return u->class;
-       
-#ifdef STATISTICS
-       count_class_infos += sizeof(classinfo);
-#endif
-
-       c = NEW (classinfo);
-       c -> flags = 0;
-       c -> name = u;
-       c -> cpcount = 0;
-       c -> cptags = NULL;
-       c -> cpinfos = NULL;
-       c -> super = NULL;
-       c -> sub = NULL;
-       c -> nextsub = NULL;
-       c -> interfacescount = 0;
-       c -> interfaces = NULL;
-       c -> fieldscount = 0;
-       c -> fields = NULL;
-       c -> methodscount = 0;
-       c -> methods = NULL;
-       c -> linked = false;
-       c -> index = 0;
-       c -> instancesize = 0;
-       c -> header.vftbl = NULL;
-       c -> vftbl = NULL;
-       c -> initialized = false;
-       
-       unicode_setclasslink (u,c);
-       list_addlast (&unloadedclasses, c);
-               
-       return c;
-}
-
-
-
-/******************** Funktion: class_getconstant ******************************
-
-       holt aus dem ConstantPool einer Klasse den Wert an der Stelle 'pos'.
-       Der Wert mu"s vom Typ 'ctype' sein, sonst wird das System angehalten.
+       retrieves the value at position 'pos' of the constantpool of a class
+       if the type of the value is other than 'ctype' the system is stopped
 
 *******************************************************************************/
 
 voidptr class_getconstant (classinfo *c, u4 pos, u4 ctype) 
 {
+       /* invalid position in constantpool */  
        if (pos >= c->cpcount) 
                panic ("Attempt to access constant outside range");
+
+       /* check type of constantpool entry */
        if (c->cptags[pos] != ctype) {
                sprintf (logtext, "Type mismatch on constant: %d requested, %d here",
                 (int) ctype, (int) c->cptags[pos] );
@@ -755,31 +1040,38 @@ u4 class_constanttype (classinfo *c, u4 pos)
 }
 
 
-/******************** Funktion: class_loadcpool ********************************
+/******************** function: class_loadcpool ********************************
 
-       l"adt den gesammten ConstantPool einer Klasse.
-       
-       Dabei werden die einzelnen Eintr"age in ein wesentlich einfachers 
-       Format gebracht (Klassenreferenzen werden aufgel"ost, ...)
-       F"ur eine genaue "Ubersicht "uber das kompakte Format siehe: 'global.h' 
+       loads the constantpool of a class, 
+       the entries are transformed into a simpler format 
+       by resolving references
+       (a detailed overview of the compact structures can be found in global.h)        
 
 *******************************************************************************/
 
 static void class_loadcpool (classinfo *c)
 {
 
-       typedef struct forward_class {      /* Diese Strukturen dienen dazu, */
-               struct forward_class *next;     /* die Infos, die beim ersten */
-               u2 thisindex;                   /* Durchgang durch den ConstantPool */
-               u2 name_index;                  /* gelesen werden, aufzunehmen. */
-       } forward_class;                    /* Erst nachdem der ganze Pool */ 
-                                        /* gelesen wurde, k"onnen alle */
-       typedef struct forward_string {     /* Felder kompletiert werden */
-               struct forward_string *next;    /* (und das auch nur in der richtigen */
-               u2 thisindex;                   /* Reihenfolge) */
+       /* The following structures are used to save information which cannot be 
+          processed during the first pass. After the complete constantpool has 
+          been traversed the references can be resolved. 
+          (only in specific order)                                                */
+       
+       /* CONSTANT_Class_info entries */
+       typedef struct forward_class {      
+               struct forward_class *next; 
+               u2 thisindex;               
+               u2 name_index;              
+       } forward_class;                    
+                                        
+       /* CONSTANT_String */                                      
+       typedef struct forward_string { 
+               struct forward_string *next; 
+               u2 thisindex;                
                u2 string_index;
        } forward_string;
 
+       /* CONSTANT_NameAndType */
        typedef struct forward_nameandtype {
                struct forward_nameandtype *next;
                u2 thisindex;
@@ -787,6 +1079,7 @@ static void class_loadcpool (classinfo *c)
                u2 sig_index;
        } forward_nameandtype;
 
+       /* CONSTANT_Fieldref, CONSTANT_Methodref or CONSTANT_InterfaceMethodref */
        typedef struct forward_fieldmethint {   
                struct forward_fieldmethint *next;
                u2 thisindex;
@@ -796,7 +1089,6 @@ static void class_loadcpool (classinfo *c)
        } forward_fieldmethint;
 
 
-
        u4 idx;
        long int dumpsize = dump_size ();
 
@@ -805,29 +1097,31 @@ static void class_loadcpool (classinfo *c)
        forward_nameandtype *forward_nameandtypes = NULL;
        forward_fieldmethint *forward_fieldmethints = NULL;
 
+       /* number of entries in the constant_pool table  */
        u4 cpcount       = c -> cpcount = suck_u2();
+       /* allocate memory */
        u1 *cptags       = c -> cptags  = MNEW (u1, cpcount);
-       voidptr *cpinfos = c -> cpinfos =  MNEW (voidptr, cpcount);
+       voidptr *cpinfos = c -> cpinfos = MNEW (voidptr, cpcount);
 
 #ifdef STATISTICS
        count_const_pool_len += (sizeof(voidptr) + 1) * cpcount;
 #endif
-
        
+       /* initialize constantpool */
        for (idx=0; idx<cpcount; idx++) {
                cptags[idx] = CONSTANT_UNUSED;
                cpinfos[idx] = NULL;
                }
 
                        
-               /******* Erster Durchgang *******/
-               /* Alle Eintr"age, die nicht unmittelbar aufgel"ost werden k"onnen, 
-                  werden einmal `auf Vorrat' in tempor"are Strukturen eingelesen,
-                  und dann am Ende nocheinmal durchgegangen */
-
+               /******* first pass *******/
+               /* entries which cannot be resolved now are written into 
+                  temporary structures and traversed again later        */
+                  
        idx = 1;
        while (idx < cpcount) {
-               u4 t = suck_u1 ();
+               /* get constant type */
+               u4 t = suck_u1 (); 
                switch ( t ) {
 
                        case CONSTANT_Class: { 
@@ -837,7 +1131,8 @@ static void class_loadcpool (classinfo *c)
                                forward_classes = nfc;
 
                                nfc -> thisindex = idx;
-                               nfc -> name_index = suck_u2 ();
+                               /* reference to CONSTANT_NameAndType */
+                               nfc -> name_index = suck_u2 (); 
 
                                idx++;
                                break;
@@ -845,18 +1140,21 @@ static void class_loadcpool (classinfo *c)
                        
                        case CONSTANT_Fieldref:
                        case CONSTANT_Methodref:
-                       case CONSTANT_InterfaceMethodref: {
+                       case CONSTANT_InterfaceMethodref: { 
                                forward_fieldmethint *nff = DNEW (forward_fieldmethint);
                                
                                nff -> next = forward_fieldmethints;
                                forward_fieldmethints = nff;
 
                                nff -> thisindex = idx;
+                               /* constant type */
                                nff -> tag = t;
-                               nff -> class_index = suck_u2 ();
+                               /* class or interface type that contains the declaration of the field or method */
+                               nff -> class_index = suck_u2 (); 
+                               /* name and descriptor of the field or method */
                                nff -> nameandtype_index = suck_u2 ();
 
-                               idx ++;                                         
+                               idx ++;
                                break;
                                }
                                
@@ -867,6 +1165,7 @@ static void class_loadcpool (classinfo *c)
                                forward_strings = nfs;
                                
                                nfs -> thisindex = idx;
+                               /* reference to CONSTANT_Utf8_info with string characters */
                                nfs -> string_index = suck_u2 ();
                                
                                idx ++;
@@ -880,7 +1179,9 @@ static void class_loadcpool (classinfo *c)
                                forward_nameandtypes = nfn;
                                
                                nfn -> thisindex = idx;
+                               /* reference to CONSTANT_Utf8_info containing simple name */
                                nfn -> name_index = suck_u2 ();
+                               /* reference to CONSTANT_Utf8_info containing field or method descriptor */
                                nfn -> sig_index = suck_u2 ();
                                
                                idx ++;
@@ -944,13 +1245,15 @@ static void class_loadcpool (classinfo *c)
                                break;
                                }
                                
-                       case CONSTANT_Utf8: {
-                               unicode *u;
-
-                               u = loadUtf8 ();
-
-                               cptags [idx] = CONSTANT_Utf8;
-                               cpinfos [idx] = u;
+                       case CONSTANT_Utf8: { 
+
+                               /* number of bytes in the bytes array (not string-length) */
+                               u4 length = suck_u2();
+                               cptags [idx]  = CONSTANT_Utf8;
+                               /* insert utf-string into the utf-symboltable */
+                               cpinfos [idx] = utf_new(classbuf_pos+1, length);
+                               /* skip bytes of the string */
+                               skip_nbytes(length);
                                idx++;
                                break;
                                }
@@ -965,32 +1268,35 @@ static void class_loadcpool (classinfo *c)
                
 
 
-          /* Aufl"osen der noch unfertigen Eintr"age */
+          /* resolve entries in temporary structures */
 
        while (forward_classes) {
-               unicode *name =
+               utf *name =
                  class_getconstant (c, forward_classes -> name_index, CONSTANT_Utf8);
                
-               if ( (name->length>0) && (name->text[0]=='[') ) {
-                       checkfielddescriptor (name); 
+               if ( (name->blength>0) && (name->text[0]=='[') ) {
+                       /* check validity of descriptor */
+                       checkfielddescriptor (name->text, utf_end(name)); 
 
                        cptags  [forward_classes -> thisindex] = CONSTANT_Arraydescriptor;
                        cpinfos [forward_classes -> thisindex] = 
-                          buildarraydescriptor(name->text, name->length);
+                          buildarraydescriptor(name->text, name->blength);
 
                        }
-               else {          
+               else {                                  
                        cptags  [forward_classes -> thisindex] = CONSTANT_Class;
-                       cpinfos [forward_classes -> thisindex] = class_get (name);
+                       /* retrieve class from class-table */
+                       cpinfos [forward_classes -> thisindex] = class_new (name);
                        }
                forward_classes = forward_classes -> next;
                
                }
 
        while (forward_strings) {
-               unicode *text = 
+               utf *text = 
                  class_getconstant (c, forward_strings -> string_index, CONSTANT_Utf8);
-                       
+       
+               /* resolve utf-string */                
                cptags   [forward_strings -> thisindex] = CONSTANT_String;
                cpinfos  [forward_strings -> thisindex] = text;
                
@@ -1004,6 +1310,7 @@ static void class_loadcpool (classinfo *c)
                count_const_pool_len += sizeof(constant_nameandtype);
 #endif
 
+               /* resolve simple name and descriptor */
                cn -> name = class_getconstant 
                   (c, forward_nameandtypes -> name_index, CONSTANT_Utf8);
                cn -> descriptor = class_getconstant
@@ -1023,7 +1330,7 @@ static void class_loadcpool (classinfo *c)
 #ifdef STATISTICS
                count_const_pool_len += sizeof(constant_FMIref);
 #endif
-
+               /* resolve simple name and descriptor */
                nat = class_getconstant
                        (c, forward_fieldmethints -> nameandtype_index, CONSTANT_NameAndType);
 
@@ -1036,10 +1343,12 @@ static void class_loadcpool (classinfo *c)
                cpinfos [forward_fieldmethints -> thisindex] = fmi;
        
                switch (forward_fieldmethints -> tag) {
-               case CONSTANT_Fieldref:  checkfielddescriptor (fmi->descriptor);
+               case CONSTANT_Fieldref:  /* check validity of descriptor */
+                                        checkfielddescriptor (fmi->descriptor->text,utf_end(fmi->descriptor));
                                         break;
                case CONSTANT_InterfaceMethodref: 
-               case CONSTANT_Methodref: checkmethoddescriptor (fmi->descriptor);
+               case CONSTANT_Methodref: /* check validity of descriptor */
+                                        checkmethoddescriptor (fmi->descriptor);
                                         break;
                }               
        
@@ -1066,22 +1375,27 @@ static void class_loadcpool (classinfo *c)
        
 *******************************************************************************/
 
-static void class_load (classinfo *c)
+static int class_load (classinfo *c)
 {
        u4 i;
        u4 mi,ma;
 
-
-       if (loadverbose) {
+       /* output for debugging purposes */
+       if (loadverbose) {              
                sprintf (logtext, "Loading class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name );
+               utf_sprint (logtext+strlen(logtext), c->name );
                dolog();
                }
-
-
-       suck_start (c->name);
-
-       if (suck_u4() != MAGIC) panic("Can not find class-file signature");   
+       
+       /* load classdata, throw exception on error */
+       if (!suck_start (c->name)) {
+               throw_classnotfoundexception();            
+               return false;
+       }
+       
+       /* check signature */           
+       if (suck_u4() != MAGIC) panic("Can not find class-file signature");     
+       /* check version */
        mi = suck_u2(); 
        ma = suck_u2();
        if (ma != MAJOR_VERSION) {
@@ -1097,9 +1411,12 @@ static void class_load (classinfo *c)
 
        class_loadcpool (c);
        
-       c -> flags = suck_u2 ();
-       suck_u2 ();       /* this */
+       /* ACC flags */
+       c -> flags = suck_u2 (); 
+       /* this class */
+       suck_u2 ();       
        
+       /* retrieve superclass */
        if ( (i = suck_u2 () ) ) {
                c -> super = class_getconstant (c, i, CONSTANT_Class);
                }
@@ -1107,6 +1424,7 @@ static void class_load (classinfo *c)
                c -> super = NULL;
                }
                         
+       /* retrieve interfaces */
        c -> interfacescount = suck_u2 ();
        c -> interfaces = MNEW (classinfo*, c -> interfacescount);
        for (i=0; i < c -> interfacescount; i++) {
@@ -1114,12 +1432,14 @@ static void class_load (classinfo *c)
                      class_getconstant (c, suck_u2(), CONSTANT_Class);
                }
 
+       /* load fields */
        c -> fieldscount = suck_u2 ();
        c -> fields = MNEW (fieldinfo, c -> fieldscount);
        for (i=0; i < c -> fieldscount; i++) {
                field_load (&(c->fields[i]), c);
                }
 
+       /* load methods */
        c -> methodscount = suck_u2 ();
        c -> methods = MNEW (methodinfo, c -> methodscount);
        for (i=0; i < c -> methodscount; i++) {
@@ -1132,14 +1452,18 @@ static void class_load (classinfo *c)
        count_class_infos += sizeof(methodinfo) * c -> methodscount;
 #endif
 
+       /* load variable-length attribute structures */ 
+       attribute_load (suck_u2(), c);
 
-       skipattributes ( suck_u2() );
-
-
+       /* free memory */
        suck_stop ();
 
+       /* remove class from list of unloaded classes and 
+          add to list of unlinked classes                */
        list_remove (&unloadedclasses, c);
        list_addlast (&unlinkedclasses, c);
+
+       return true;
 }
 
 
@@ -1158,7 +1482,7 @@ static s4 class_highestinterface (classinfo *c)
        
        if ( ! (c->flags & ACC_INTERFACE) ) {
                sprintf (logtext, "Interface-methods count requested for non-interface:  ");
-       unicode_sprint (logtext+strlen(logtext), c->name);
+       utf_sprint (logtext+strlen(logtext), c->name);
        error();
        }
     
@@ -1302,7 +1626,7 @@ static void class_link (classinfo *c)
 
        if (linkverbose) {
                sprintf (logtext, "Linking Class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name );
+               utf_sprint (logtext+strlen(logtext), c->name );
                dolog ();
                }
 
@@ -1409,13 +1733,13 @@ foundvftblindex: ;
 
        if (super != NULL) {
                methodinfo *fi;
-               static unicode *finame = NULL;
-               static unicode *fidesc = NULL;
+               static utf *finame = NULL;
+               static utf *fidesc = NULL;
 
                if (finame == NULL)
-                       finame = unicode_new_char("finalize");
+                       finame = utf_finalize;
                if (fidesc == NULL)
-                       fidesc = unicode_new_char("()V");
+                       fidesc = utf_fidesc;
 
                fi = class_findmethod (c, finame, fidesc);
                if (fi != NULL) {
@@ -1496,8 +1820,6 @@ static void class_free (classinfo *c)
        s4 i;
        vftbl *v;
                
-       unicode_unlinkclass (c->name);
-       
        class_freecpool (c);
 
        MFREE (c->interfaces, classinfo*, c->interfacescount);
@@ -1523,11 +1845,13 @@ static void class_free (classinfo *c)
                                             (v->interfacetablelength > 1));
                mem_free (v, i);
                }
-               
+
+       if (c->innerclasscount)
+               MFREE (c->innerclass, innerclassinfo, c->innerclasscount);
+
        FREE (c, classinfo);
 }
 
-
 /************************* Funktion: class_findfield ***************************
        
        sucht in einer 'classinfo'-Struktur nach einem Feld mit gew"unschtem
@@ -1535,13 +1859,16 @@ static void class_free (classinfo *c)
 
 *******************************************************************************/
 
-fieldinfo *class_findfield (classinfo *c, unicode *name, unicode *desc)
+
+fieldinfo *class_findfield (classinfo *c, utf *name, utf *desc)
 {
        s4 i;
-       for (i = 0; i < c->fieldscount; i++) {
-               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc))
-                       return &(c->fields[i]);
-               }
+
+       for (i = 0; i < c->fieldscount; i++) { 
+               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) 
+                       return &(c->fields[i]);                                                         
+    }
+
        panic ("Can not find field given in CONSTANT_Fieldref");
        return NULL;
 }
@@ -1555,7 +1882,7 @@ fieldinfo *class_findfield (classinfo *c, unicode *name, unicode *desc)
 
 *******************************************************************************/
 
-methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc)
+methodinfo *class_findmethod (classinfo *c, utf *name, utf *desc)
 {
        s4 i;
        for (i = 0; i < c->methodscount; i++) {
@@ -1566,6 +1893,71 @@ methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc)
        return NULL;
 }
 
+/************************* Funktion: class_findmethod_approx ******************
+       
+       sucht in einer 'classinfo'-Struktur nach einer Methode mit gew"unschtem
+       Namen und Typ.
+       Wenn als Typ NULL angegeben wird, dann ist der Typ egal.
+       beim Vergleichen des Descriptors wird der R"uckgabewert nicht betrachtet
+
+*******************************************************************************/
+
+methodinfo *class_findmethod_approx (classinfo *c, utf *name, utf *desc)
+{
+       s4 i;
+
+       for (i = 0; i < c->methodscount; i++) 
+               if (c->methods[i].name == name) {
+                       utf *meth_descr = c->methods[i].descriptor;
+                       
+                       if (desc == NULL) 
+                               /* ignore type */
+                               return &(c->methods[i]);
+
+                       if (desc->blength <= meth_descr->blength) {
+                                          /* current position in utf text   */
+                                          char *desc_utf_ptr = desc->text;      
+                                          char *meth_utf_ptr = meth_descr->text;                                         
+                                          /* points behind utf strings */
+                                          char *desc_end = utf_end(desc);         
+                                          char *meth_end = utf_end(meth_descr);   
+                                          char ch;
+
+                                          /* compare argument types */
+                                          while (desc_utf_ptr<desc_end && meth_utf_ptr<meth_end) {
+
+                                                  if ((ch=*desc_utf_ptr++) != (*meth_utf_ptr++))
+                                                          break; /* no match */
+
+                                                  if (ch==')')
+                                                          return &(c->methods[i]);   /* all parameter types equal */
+                                          }
+                       }
+               }
+
+       return NULL;
+}
+
+/***************** Funktion: class_resolvemethod_approx ***********************
+       
+       sucht eine Klasse und alle Superklassen ab, um eine Methode zu finden.
+       (ohne Beachtung des R"uckgabewertes)
+
+*******************************************************************************/
+
+methodinfo *class_resolvemethod_approx (classinfo *c, utf *name, utf *desc)
+{
+       while (c) {
+               /* search for method (ignore returntype) */
+               methodinfo *m = class_findmethod_approx (c, name, desc);
+               /* method found */
+               if (m) return m;
+               /* search superclass */
+               c = c->super;
+               }
+       return NULL;
+}
+
 
 /************************* Funktion: class_resolvemethod ***********************
        
@@ -1574,11 +1966,12 @@ methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc)
 *******************************************************************************/
 
 
-methodinfo *class_resolvemethod (classinfo *c, unicode *name, unicode *desc)
+methodinfo *class_resolvemethod (classinfo *c, utf *name, utf *desc)
 {
        while (c) {
                methodinfo *m = class_findmethod (c, name, desc);
                if (m) return m;
+               /* search superclass */
                c = c->super;
                }
        return NULL;
@@ -1631,13 +2024,13 @@ void class_init (classinfo *c)
        for (i=0; i < c->interfacescount; i++) class_init(c->interfaces[i]);
 
        m = class_findmethod (c, 
-                             unicode_new_char ("<clinit>")
-                             unicode_new_char ("()V"));
+                             utf_clinit
+                             utf_fidesc);
        if (!m) {
                if (initverbose) {
                        sprintf (logtext, "Class ");
-                       unicode_sprint (logtext+strlen(logtext), c->name);
-                       sprintf (logtext+strlen(logtext), " has no initializer");       
+                       utf_sprint (logtext+strlen(logtext), c->name);
+                       sprintf (logtext+strlen(logtext), " has no initializer");       
                        dolog ();
                        }
                return;
@@ -1647,7 +2040,7 @@ void class_init (classinfo *c)
        
        if (initverbose) {
                sprintf (logtext, "Starting initializer for class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name);
+               utf_sprint (logtext+strlen(logtext), c->name);
                dolog ();
        }
 
@@ -1663,19 +2056,57 @@ void class_init (classinfo *c)
        blockInts = b;
 #endif
 
-       if (exceptionptr) {     
-               printf ("#### Initializer has thrown: ");
-               unicode_display (exceptionptr->vftbl->class->name);
+       if (exceptionptr) {     
+               printf ("#### Initializer of ");
+               utf_display (c->name);
+               printf (" has thrown: ");
+               utf_display (exceptionptr->vftbl->class->name);
                printf ("\n");
                fflush (stdout);
                }
 
        if (initverbose) {
                sprintf (logtext, "Finished initializer for class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name);
+               utf_sprint (logtext+strlen(logtext), c->name);
                dolog ();
        }
 
+       if (c->name == utf_systemclass) {
+               /* class java.lang.System requires explicit initialization */
+               
+               if (initverbose)
+                       printf ("#### Initializing class System");
+
+               /* find initializing method */     
+               m = class_findmethod (c, 
+                                       utf_initsystemclass,
+                                       utf_fidesc);
+
+               if (!m) {
+                       /* no method found */
+                       log("initializeSystemClass failed");
+                       return;
+               }
+
+               #ifdef USE_THREADS
+                       b = blockInts;
+                       blockInts = 0;
+               #endif
+
+               exceptionptr = asm_calljavamethod (m, NULL,NULL,NULL,NULL);
+
+               #ifdef USE_THREADS
+                       assert(blockInts == 0);
+                       blockInts = b;
+               #endif
+
+               if (exceptionptr) {                     
+                       printf ("#### initializeSystemClass has thrown: ");
+                       utf_display (exceptionptr->vftbl->class->name);
+                       printf ("\n");
+                       fflush (stdout);                  
+               }
+       }
 }
 
 
@@ -1699,7 +2130,7 @@ void class_showconstantpool (classinfo *c)
                        switch (c -> cptags [i]) {
                                case CONSTANT_Class:
                                        printf ("Classreference -> ");
-                                       unicode_display ( ((classinfo*)e) -> name );
+                                       utf_display ( ((classinfo*)e) -> name );
                                        break;
                                
                                case CONSTANT_Fieldref:
@@ -1711,17 +2142,17 @@ void class_showconstantpool (classinfo *c)
                                  displayFMI:
                                        {
                                        constant_FMIref *fmi = e;
-                                       unicode_display ( fmi->class->name );
+                                       utf_display ( fmi->class->name );
                                        printf (".");
-                                       unicode_display ( fmi->name);
+                                       utf_display ( fmi->name);
                                        printf (" ");
-                                       unicode_display ( fmi->descriptor );
+                                       utf_display ( fmi->descriptor );
                                    }
                                        break;
 
                                case CONSTANT_String:
                                        printf ("String -> ");
-                                       unicode_display (e);
+                                       utf_display (e);
                                        break;
                                case CONSTANT_Integer:
                                        printf ("Integer -> %d", (int) ( ((constant_integer*)e) -> value) );
@@ -1746,14 +2177,14 @@ void class_showconstantpool (classinfo *c)
                                case CONSTANT_NameAndType:
                                        { constant_nameandtype *cnt = e;
                                          printf ("NameAndType: ");
-                                         unicode_display (cnt->name);
+                                         utf_display (cnt->name);
                                          printf (" ");
-                                         unicode_display (cnt->descriptor);
+                                         utf_display (cnt->descriptor);
                                        }
                                        break;
                                case CONSTANT_Utf8:
                                        printf ("Utf8 -> ");
-                                       unicode_display (e);
+                                       utf_display (e);
                                        break;
                                case CONSTANT_Arraydescriptor:  {
                                        printf ("Arraydescriptor: ");
@@ -1782,16 +2213,16 @@ void class_showmethods (classinfo *c)
        printf ("--------- Fields and Methods ----------------\n");
        printf ("Flags: ");     printflags (c->flags);  printf ("\n");
 
-       printf ("This: "); unicode_display (c->name); printf ("\n");
+       printf ("This: "); utf_display (c->name); printf ("\n");
        if (c->super) {
-               printf ("Super: "); unicode_display (c->super->name); printf ("\n");
+               printf ("Super: "); utf_display (c->super->name); printf ("\n");
                }
        printf ("Index: %d\n", c->index);
        
        printf ("interfaces:\n");       
        for (i=0; i < c-> interfacescount; i++) {
                printf ("   ");
-               unicode_display (c -> interfaces[i] -> name);
+               utf_display (c -> interfaces[i] -> name);
                printf (" (%d)\n", c->interfaces[i] -> index);
                }
 
@@ -1832,7 +2263,7 @@ void class_showmethods (classinfo *c)
 
 *******************************************************************************/
 
-classinfo *loader_load (unicode *topname)
+classinfo *loader_load (utf *topname)
 {
        classinfo *top;
        classinfo *c;
@@ -1842,16 +2273,22 @@ classinfo *loader_load (unicode *topname)
 
        if (getloadingtime) starttime = getcputime();
 
-       top = class_get (topname);
+       top = class_new (topname);
 
+       /* load classes */
        while ( (c = list_first(&unloadedclasses)) ) {
-               class_load (c);
-               }
+               if (!class_load (c)) {
+                       list_remove (&unloadedclasses, c);
+                       top=NULL;
+                   }
+        }
 
+       /* link classes */
        while ( (c = list_first(&unlinkedclasses)) ) {
                class_link (c);
                }
 
+       /* measure time */
        if (getloadingtime) {
                stoptime = getcputime();
                loadingtime += (stoptime-starttime);
@@ -1859,31 +2296,60 @@ classinfo *loader_load (unicode *topname)
 
        intsRestore();                          /* schani */
 
-       return top;
+       return top; 
 }
 
 
-/******************* interne Funktion: loader_createarrayclass *****************
+/**************** function: create_primitive_classes ***************************
 
-       Erzeugt (und linkt) eine Klasse f"ur die Arrays.
-       
-*******************************************************************************/
+       create classes representing primitive types 
 
-static classinfo *loader_createarrayclass ()
-{
-       classinfo *c;
-       c = class_get ( unicode_new_char ("The_Array_Class") );
-       
+********************************************************************************/
+
+
+void create_primitive_classes()
+{  
+       int i;
+
+       for (i=0;i<PRIMITIVETYPE_COUNT;i++) {
+               /* create primitive class */
+               classinfo *c = class_new ( utf_new_char(primitivetype_table[i].name) );
+               
+               /* prevent loader from loading primitive class */
+               list_remove (&unloadedclasses, c);
+               /* add to unlinked classes */
+               list_addlast (&unlinkedclasses, c);             
+               c -> super = class_java_lang_Object;
+               class_link (c);
+
+               primitivetype_table[i].class_primitive = c;
+
+               /* create class for wrapping the primitive type */
+               primitivetype_table[i].class_wrap =
+                       class_new( utf_new_char(primitivetype_table[i].wrapname) );
+       }
+}
+
+/***************** function: create_array_class ********************************
+
+       create class representing an array
+
+********************************************************************************/
+
+
+classinfo *create_array_class(utf *u)
+{  
+       classinfo *c = class_new (u);
+       /* prevent loader from loading the array class */
        list_remove (&unloadedclasses, c);
+       /* add to unlinked classes */
        list_addlast (&unlinkedclasses, c);
        c -> super = class_java_lang_Object;
-       
-       class_link (c);
+       class_link(c);
+
        return c;
 }
 
-
-
 /********************** Funktion: loader_init **********************************
 
        Initialisiert alle Listen und l"adt alle Klassen, die vom System
@@ -1893,37 +2359,67 @@ static classinfo *loader_createarrayclass ()
  
 void loader_init ()
 {
+       utf *string_class;
        interfaceindex = 0;
        
        list_init (&unloadedclasses, OFFSET(classinfo, listnode) );
        list_init (&unlinkedclasses, OFFSET(classinfo, listnode) );
        list_init (&linkedclasses, OFFSET(classinfo, listnode) );
 
+       /* create utf-symbols for pointer comparison of frequently used strings */
+       utf_innerclasses    = utf_new_char("InnerClasses");
+       utf_constantvalue   = utf_new_char("ConstantValue");
+       utf_code                = utf_new_char("Code");
+       utf_finalize        = utf_new_char("finalize");
+       utf_fidesc              = utf_new_char("()V");
+       utf_clinit              = utf_new_char("<clinit>");
+       utf_initsystemclass = utf_new_char("initializeSystemClass");
+       utf_systemclass     = utf_new_char("java/lang/System");
+
+       /* create class for arrays */
+       class_array = class_new ( utf_new_char ("The_Array_Class") );
+       list_remove (&unloadedclasses, class_array);
+
+       /* create class for strings, load it after class Object was loaded */
+       string_class = utf_new_char ("java/lang/String");
+       class_java_lang_String = class_new(string_class);
+       list_remove (&unloadedclasses, class_java_lang_String);
 
        class_java_lang_Object = 
-               loader_load ( unicode_new_char ("java/lang/Object") );
+               loader_load ( utf_new_char ("java/lang/Object") );
+
+       list_addlast(&unloadedclasses, class_java_lang_String);
+
        class_java_lang_String = 
-               loader_load ( unicode_new_char ("java/lang/String") );
+               loader_load ( string_class );
        class_java_lang_ClassCastException = 
-               loader_load ( unicode_new_char ("java/lang/ClassCastException") );
+               loader_load ( utf_new_char ("java/lang/ClassCastException") );
        class_java_lang_NullPointerException = 
-               loader_load ( unicode_new_char ("java/lang/NullPointerException") );
+               loader_load ( utf_new_char ("java/lang/NullPointerException") );
        class_java_lang_ArrayIndexOutOfBoundsException = loader_load ( 
-            unicode_new_char ("java/lang/ArrayIndexOutOfBoundsException") );
+            utf_new_char ("java/lang/ArrayIndexOutOfBoundsException") );
        class_java_lang_NegativeArraySizeException = loader_load ( 
-            unicode_new_char ("java/lang/NegativeArraySizeException") );
+            utf_new_char ("java/lang/NegativeArraySizeException") );
        class_java_lang_OutOfMemoryError = loader_load ( 
-            unicode_new_char ("java/lang/OutOfMemoryError") );
+            utf_new_char ("java/lang/OutOfMemoryError") );
        class_java_lang_ArrayStoreException =
-               loader_load ( unicode_new_char ("java/lang/ArrayStoreException") );
+               loader_load ( utf_new_char ("java/lang/ArrayStoreException") );
        class_java_lang_ArithmeticException = 
-               loader_load ( unicode_new_char ("java/lang/ArithmeticException") );
+               loader_load ( utf_new_char ("java/lang/ArithmeticException") );
        class_java_lang_ThreadDeath =                             /* schani */
-               loader_load ( unicode_new_char ("java/lang/ThreadDeath") );
+               loader_load ( utf_new_char ("java/lang/ThreadDeath") );
 
-       class_array = loader_createarrayclass ();
+       /* link class for arrays */
+       list_addlast (&unlinkedclasses, class_array);
+       class_array -> super = class_java_lang_Object;
+       class_link (class_array);
 
+       /* correct vftbl-entries (retarded loading of class java/lang/String) */
+       stringtable_update(); 
 
+       /* create classes representing primitive types */
+       create_primitive_classes();
+               
        proto_java_lang_ClassCastException = 
                builtin_new(class_java_lang_ClassCastException);
        heap_addreference ( (void**) &proto_java_lang_ClassCastException);
@@ -2002,7 +2498,7 @@ static void loader_compute_class_values (classinfo *c)
        for (i = 0; i < c->index; i++)
                printf(" ");
        printf("%3d  %3d  ", (int) c->vftbl->baseval, c->vftbl->diffval);
-       unicode_display(c->name);
+       utf_display(c->name);
        printf("\n");
        }
 */
@@ -2031,6 +2527,19 @@ void loader_compute_subclasses ()
 
 
 
+/******************** function: classloader_buffer ***************************
+    set buffer for reading classdata
+
+******************************************************************************/
+
+void classload_buffer(u1 *buf,int len)
+{
+       classbuffer        =  buf;
+       classbuffer_size   =  len;
+       classbuf_pos       =  buf-1;
+}
+
 /******************** Funktion: loader_close ***********************************
 
        gibt alle Resourcen wieder frei
@@ -2068,3 +2577,4 @@ void loader_close ()
  * tab-width: 4
  * End:
  */
+
index 57686b0845b3cdcfea460c2d755836bdc48c2eae..41bdbcf2daa17f0d1f93e2e7158be31ffa0f5d15 100644 (file)
--- a/loader.h
+++ b/loader.h
@@ -13,6 +13,7 @@
 *******************************************************************************/
 
 
+
 /************************* program switches ***********************************/
 
 extern bool loadverbose;         /* Debug-Meldungen beim Laden ausgeben */
@@ -29,26 +30,54 @@ extern list linkedclasses;       /* Liste aller fertig gelinkten Klassen */
 
 /************************ prototypes ******************************************/
 
+/* initialize laoder, load important systemclasses */
 void loader_init ();
+
+/* free resources */
 void loader_close ();
 
-classinfo *loader_load (unicode *topname);
+/* load a class and all referenced classes */
+classinfo *loader_load (utf *topname);
+
+/* initializes all loaded classes */
 void loader_initclasses ();
+
 void loader_compute_subclasses ();
 
-classinfo *class_get (unicode *name);
+/* retrieve constantpool element */
 voidptr class_getconstant (classinfo *class, u4 pos, u4 ctype);
+
+/* determine type of a constantpool element */
 u4 class_constanttype (classinfo *class, u4 pos);
 
-fieldinfo *class_findfield (classinfo *c, unicode *name, unicode *desc);
-methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc);
+/* search class for a field */
+fieldinfo *class_findfield (classinfo *c, utf *name, utf *desc);
+
+/* search for a method with a specified name and descriptor */
+methodinfo *class_findmethod (classinfo *c, utf *name, utf *desc);
+methodinfo *class_resolvemethod (classinfo *c, utf *name, utf *dest);
 
-methodinfo *class_resolvemethod (classinfo *c, unicode *name, unicode *dest);
+/* search for a method with specified name and arguments (returntype ignored) */
+methodinfo *class_findmethod_approx (classinfo *c, utf *name, utf *desc);
+methodinfo *class_resolvemethod_approx (classinfo *c, utf *name, utf *dest);
 
 bool class_issubclass (classinfo *sub, classinfo *super);
 
+/* call initializer of class */
 void class_init (classinfo *c);
 
+/* debug purposes */
 void class_showmethods (classinfo *c);
 void class_showconstantpool (classinfo *c);
 
+/* set buffer for reading classdata */
+void classload_buffer(u1 *buf,int len);
+
+/* create class representing specific arraytype */
+classinfo *create_array_class(utf *u);
+
+/* create the arraydescriptor for the arraytype specified by the utf-string */
+constant_arraydescriptor * buildarraydescriptor(char *utf, u4 namelen);
+
+
+
diff --git a/main.c b/main.c
index e47a1098c3e67cfb5c6701dcb0bd3ea3e26d3f17..b1b3bad7f502ab0d1592e5a527ce9cbeb8929bae 100644 (file)
--- a/main.c
+++ b/main.c
@@ -17,7 +17,7 @@
                 Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
                         Philipp Tomsich     EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: main.c 132 1999-09-27 15:54:42Z chris $
+       Last Change: $Id: main.c 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
@@ -45,7 +45,7 @@ bool new_gc = false;
 
 static bool showmethods = false;
 static bool showconstantpool = false;
-static bool showunicode = false;
+static bool showutf = false;
 static classinfo *topclass;
 
 #ifndef USE_THREADS
@@ -220,7 +220,7 @@ static void print_usage()
 #ifdef OLD_COMPILER
        printf ("                 s(tack) ....... show stack for every javaVM-command\n");
 #endif
-       printf ("                 u(nicode) ..... show the unicode - hash\n");
+       printf ("                 u(tf) ......... show the utf - hash\n");
 }   
 
 
@@ -381,7 +381,7 @@ static void print_stats()
        sprintf (logtext, "Distribution of basic block sizes");
        dolog();
        sprintf (logtext,
-       "  1    2    3    4   5   6   7   8   9  10 <13 <15 <17 <19 <21 <26 <31 >30");
+       "  0    1    2    3    4   5   6   7   8   9 <13 <15 <17 <19 <21 <26 <31 >30");
        dolog();
        sprintf (logtext, "%3d%5d%5d%5d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d",
                count_block_size_distribution[0], count_block_size_distribution[1], count_block_size_distribution[2],
@@ -397,7 +397,7 @@ static void print_stats()
        dolog();
        sprintf (logtext, "Size of Class Infos (Kb):%10.3f", (float) (count_class_infos) / 1024);
        dolog();
-       sprintf (logtext, "Size of Const Pool (Kb): %10.3f", (float) (count_const_pool_len + count_unicode_len) / 1024);
+       sprintf (logtext, "Size of Const Pool (Kb): %10.3f", (float) (count_const_pool_len + count_utf_len) / 1024);
        dolog();
        sprintf (logtext, "Size of Vftbl (Kb):      %10.3f", (float) count_vftbl_len / 1024);
        dolog();
@@ -405,7 +405,7 @@ static void print_stats()
        dolog();
        sprintf (logtext, "Size of native stub (Kb):%10.3f", (float) count_nstub_len / 1024);
        dolog();
-       sprintf (logtext, "Size of Unicode (Kb):    %10.3f", (float) count_unicode_len / 1024);
+       sprintf (logtext, "Size of Utf (Kb):        %10.3f", (float) count_utf_len / 1024);
        dolog();
        sprintf (logtext, "Size of VMCode (Kb):     %10.3f(%d)", (float) count_vmcode_len / 1024,
                                                      count_vmcode_len - 18 * count_all_methods);
@@ -414,6 +414,11 @@ static void print_stats()
        dolog();
        sprintf (logtext, "Number of loaded Methods: %d\n\n", count_all_methods);
        dolog();
+
+       sprintf (logtext, "Calls of utf_new: %22d", count_utf_new);
+       dolog();
+       sprintf (logtext, "Calls of utf_new (element found): %6d\n\n", count_utf_new_found);
+       dolog();
 }
 
 
@@ -457,7 +462,7 @@ void exit_handler(void)
                                
        if (showmethods) class_showmethods (topclass);
        if (showconstantpool)  class_showconstantpool (topclass);
-       if (showunicode)       unicode_show ();
+       if (showutf)           utf_show ();
 
 #ifdef USE_THREADS
        clear_thread_flags();           /* restores standard file descriptor
@@ -474,7 +479,7 @@ void exit_handler(void)
        compiler_close ();
 #endif
        loader_close ();
-       unicode_close ( literalstring_free );
+       tables_close ( literalstring_free );
 
        if (verbose || getcompilingtime || statistics) {
                log_text ("CACAO terminated");
@@ -671,7 +676,7 @@ int main(int argc, char **argv)
 #ifdef OLD_COMPILER
                                case 's':  showstack=true; compileverbose=true; break;
 #endif
-                               case 'u':  showunicode=true; break;
+                               case 'u':  showutf=true; break;
                                default:   print_usage();
                                        exit(10);
                                }
@@ -708,7 +713,7 @@ int main(int argc, char **argv)
        suck_init (classpath);
        native_setclasspath (classpath);
                
-       unicode_init();
+       tables_init();
        heap_init(heapsize, heapstartsize, &dummy);
        loader_init();
 #ifdef OLD_COMPILER
@@ -726,7 +731,7 @@ int main(int argc, char **argv)
                if (cp[i]=='.') cp[i]='/';        /* auf slashes umbauen */
        }
 
-       topclass = loader_load ( unicode_new_char (cp) );
+       topclass = loader_load ( utf_new_char (cp) );
 
        loader_compute_subclasses();
 
@@ -746,21 +751,21 @@ int main(int argc, char **argv)
 
                mainmethod = class_findmethod (
                                                                           topclass,
-                                                                          unicode_new_char ("main"), 
-                                                                          unicode_new_char ("([Ljava/lang/String;)V")
+                                                                          utf_new_char ("main"), 
+                                                                          utf_new_char ("([Ljava/lang/String;)V")
                                                                           );
                if (!mainmethod) panic ("Can not find method 'void main(String[])'");
                if ((mainmethod->flags & ACC_STATIC) != ACC_STATIC) panic ("main is not static!");
                        
                a = builtin_anewarray (argc - opt_ind, class_java_lang_String);
                for (i=opt_ind; i<argc; i++) {
-                       a->data[i-opt_ind] = javastring_new (unicode_new_char (argv[i]) );
+                       a->data[i-opt_ind] = javastring_new (utf_new_char (argv[i]) );
                }
                exceptionptr = asm_calljavamethod (mainmethod, a, NULL,NULL,NULL );
        
                if (exceptionptr) {
                        printf ("#### Program has thrown: ");
-                       unicode_display (exceptionptr->vftbl->class->name);
+                       utf_display (exceptionptr->vftbl->class->name);
                        printf ("\n");
                }
 
@@ -783,11 +788,11 @@ int main(int argc, char **argv)
                methodinfo *m;
                if (specificsignature)
                        m = class_findmethod(topclass, 
-                                                                unicode_new_char(specificmethodname),
-                                                                unicode_new_char(specificsignature));
+                                                                utf_new_char(specificmethodname),
+                                                                utf_new_char(specificsignature));
                else
                        m = class_findmethod(topclass, 
-                                                                unicode_new_char(specificmethodname), NULL);
+                                                                utf_new_char(specificmethodname), NULL);
                if (!m) panic ("Specific method not found");
 #ifdef OLD_COMPILER
                if (newcompiler)
diff --git a/nat/AccessController.c b/nat/AccessController.c
new file mode 100644 (file)
index 0000000..f8c6422
--- /dev/null
@@ -0,0 +1,131 @@
+/* class: java/security/AccessController */
+
+
+/* wrap exception in PrivilegedActionException */
+
+void check_for_exception(JNIEnv *env)
+{
+       if (exceptionptr) {
+
+         java_security_PrivilegedActionException *wrapped_exception; 
+
+         /* create exception object */   
+         wrapped_exception = (java_security_PrivilegedActionException *) 
+                             native_new_and_init(class_java_security_PrivilegedActionException);
+         
+         /* set field */
+         wrapped_exception->exception = (java_lang_Exception*) exceptionptr;
+
+         /* replace exception by wrapped one */
+         exceptionptr = (java_objectheader*) wrapped_exception;
+       }
+}
+
+
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedAction;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController_doPrivileged (JNIEnv *env , struct java_security_PrivilegedAction* action)
+{
+       methodinfo *m;    
+       java_lang_Object* o;
+
+       /* find run-Method */
+       m = class_resolvemethod (
+               action->header.vftbl->class, 
+               utf_new_char ("run"), 
+               utf_new_char ("()Ljava/lang/Object;")
+       );
+
+       /* illegal PrivilegedAction specified */
+       if (!m) panic ("Can not find method 'run' of PrivliegedAction for doPrivileged");
+
+       /* call run-Method */
+       o = (java_lang_Object*) asm_calljavafunction (m, action , NULL,NULL,NULL);
+       
+       /* wrap exception */
+       check_for_exception(env);
+       return o;
+}
+
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController_doPrivileged0 (JNIEnv *env , struct java_security_PrivilegedAction* action, struct java_security_AccessControlContext* par2)
+{
+    return Java_java_security_AccessController_doPrivileged(env, action);
+}
+
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController_doPrivileged1 (JNIEnv *env , struct java_security_PrivilegedExceptionAction* action)
+{
+       methodinfo *m;    
+       java_lang_Object* o;
+
+       /* find run-Method */
+       m = class_resolvemethod (
+               action->header.vftbl->class, 
+               utf_new_char ("run"), 
+               utf_new_char ("()Ljava/lang/Object;")
+       );
+
+       /* illegal PrivilegedAction specified */
+       if (!m) panic ("Can not find method 'run' of PrivliegedAction for doPrivileged");
+
+       /* call run-Method */
+       o = (java_lang_Object*) asm_calljavafunction (m, action ,NULL,NULL,NULL);
+       
+       /* wrap exception */
+       check_for_exception(env);
+       return o;
+}
+
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController_doPrivileged2 (JNIEnv *env , struct java_security_PrivilegedExceptionAction* action, struct java_security_AccessControlContext* par2)
+{
+    Java_java_security_AccessController_doPrivileged1(env,action);
+}
+
+/*
+ * Class:     java/security/AccessController
+ * Method:    getInheritedAccessControlContext
+ * Signature: ()Ljava/security/AccessControlContext;
+ */
+JNIEXPORT struct java_security_AccessControlContext* JNICALL Java_java_security_AccessController_getInheritedAccessControlContext (JNIEnv *env )
+{
+  /* null if there was only privileged system code */
+  return NULL;
+}
+
+/*
+ * Class:     java/security/AccessController
+ * Method:    getStackAccessControlContext
+ * Signature: ()Ljava/security/AccessControlContext;
+ */
+JNIEXPORT struct java_security_AccessControlContext* JNICALL Java_java_security_AccessController_getStackAccessControlContext (JNIEnv *env )
+{
+  /* null if there was only privileged system code */
+  return NULL;
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/nat/AccessController.h b/nat/AccessController.h
new file mode 100644 (file)
index 0000000..bb51ac4
--- /dev/null
@@ -0,0 +1,44 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/security/AccessController */
+
+typedef struct java_security_AccessController {
+   java_objectheader header;
+} java_security_AccessController;
+
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedAction;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController_doPrivileged (JNIEnv *env , struct java_security_PrivilegedAction* par1);
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController0_doPrivileged (JNIEnv *env , struct java_security_PrivilegedAction* par1, struct java_security_AccessControlContext* par2);
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController1_doPrivileged (JNIEnv *env , struct java_security_PrivilegedExceptionAction* par1);
+/*
+ * Class:     java/security/AccessController
+ * Method:    doPrivileged
+ * Signature: (Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_security_AccessController2_doPrivileged (JNIEnv *env , struct java_security_PrivilegedExceptionAction* par1, struct java_security_AccessControlContext* par2);
+/*
+ * Class:     java/security/AccessController
+ * Method:    getInheritedAccessControlContext
+ * Signature: ()Ljava/security/AccessControlContext;
+ */
+JNIEXPORT struct java_security_AccessControlContext* JNICALL Java_java_security_AccessController_getInheritedAccessControlContext (JNIEnv *env );
+/*
+ * Class:     java/security/AccessController
+ * Method:    getStackAccessControlContext
+ * Signature: ()Ljava/security/AccessControlContext;
+ */
+JNIEXPORT struct java_security_AccessControlContext* JNICALL Java_java_security_AccessController_getStackAccessControlContext (JNIEnv *env );
diff --git a/nat/Adler32.c b/nat/Adler32.c
new file mode 100644 (file)
index 0000000..fb04065
--- /dev/null
@@ -0,0 +1,25 @@
+/* class: java/util/zip/Adler32 */
+
+/*
+ * Class:     java/util/zip/Adler32
+ * Method:    update
+ * Signature: (II)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Adler32_update ( JNIEnv *env ,  s4 par1, s4 par2)
+{
+  /* Adler-32 checksum not implemented */
+  log_text("Java_java_util_zip_Adler32_update called");
+  return 0;
+}
+
+/*
+ * Class:     java/util/zip/Adler32
+ * Method:    updateBytes
+ * Signature: (I[BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Adler32_updateBytes ( JNIEnv *env ,  s4 par1, java_bytearray* par2, s4 par3, s4 par4)
+{
+  /* Adler-32 checksum not implemented */
+  log_text("Java_java_util_zip_Adler32_updateBytes  called");
+  return 0;
+}
diff --git a/nat/Adler32.h b/nat/Adler32.h
new file mode 100644 (file)
index 0000000..b17a125
--- /dev/null
@@ -0,0 +1,21 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/zip/Adler32 */
+
+typedef struct java_util_zip_Adler32 {
+   java_objectheader header;
+   s4 adler;
+} java_util_zip_Adler32;
+
+/*
+ * Class:     java/util/zip/Adler32
+ * Method:    update
+ * Signature: (II)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Adler32_update (JNIEnv *env , s4 par1, s4 par2);
+/*
+ * Class:     java/util/zip/Adler32
+ * Method:    updateBytes
+ * Signature: (I[BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Adler32_updateBytes (JNIEnv *env , s4 par1, java_bytearray* par2, s4 par3, s4 par4);
diff --git a/nat/Array.c b/nat/Array.c
new file mode 100644 (file)
index 0000000..f24c0d7
--- /dev/null
@@ -0,0 +1,547 @@
+/* class: java/lang/reflect/Array */
+
+
+
+/* creates a new object for wrapping a primitive type and calls its constructor */
+
+java_lang_Object *create_primitive_object (classinfo *c,void *value,char *sig)
+{
+       methodinfo *m;
+       java_objectheader *o = builtin_new (c);
+       
+       if (!o) return NULL;
+       
+       /* find constructor */
+       m = class_findmethod (c,                                  
+                             utf_new_char ("<init>"),        /*  method name  */
+                             utf_new_char (sig));            /*  descriptor   */
+
+       /* constructor not found */
+       if (!m) panic("invalid object for wrapping primitive type");
+
+       /* call constructor and pass the value of the primitive type */
+       exceptionptr = asm_calljavamethod (m, o, value,NULL,NULL);
+
+       if (exceptionptr) return NULL;
+
+       return (java_lang_Object*) o;
+}
+
+
+/* checks whether an array index is valid and throws an exception otherwise */
+
+int arrayindex_valid(java_arrayheader * array, s4 index)
+{
+  if (!array) {        
+       /* NULL passed as argument */
+       exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+       return 0;
+  }
+
+  if (index >= array->size || index<0) {
+       /* out of bounds */
+       exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+       return 0;
+  }
+
+  return 1;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    get
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Array_get ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_arrayheader *a = (java_arrayheader *) array;
+
+  /* verify validity of the arrayindex */ 
+  if (!arrayindex_valid(a,index))
+       return NULL;
+  
+  switch (a->arraytype) {
+      /* for primitive types an object for wrapping the primitive type is created */
+      case ARRAYTYPE_INT      : {
+                                  java_intarray *b = (java_intarray *) array;
+                                  return create_primitive_object(class_java_lang_Integer, (void*) (long) b->data[index],"(I)V");
+                               }
+      case ARRAYTYPE_LONG     : {
+                                  java_longarray *b = (java_longarray *) array;
+                                  return create_primitive_object(class_java_lang_Long, (void*) b->data[index],"(J)V");
+                               }
+      case ARRAYTYPE_FLOAT    : {
+                                  java_floatarray *b = (java_floatarray *) array;
+                                  return create_primitive_object(class_java_lang_Float, (void*) (long) b->data[index],"(F)V");
+                               }
+      case ARRAYTYPE_DOUBLE   : {
+                                  java_doublearray *b = (java_doublearray *) array;
+                                  return create_primitive_object(class_java_lang_Double, (void*) (long) b->data[index],"(D)V");
+                               }
+      case ARRAYTYPE_BYTE     : {
+                                  java_bytearray *b = (java_bytearray *) array;
+                                  return create_primitive_object(class_java_lang_Byte, (void*) (long) b->data[index],"(B)V");
+                               }
+      case ARRAYTYPE_CHAR     : {
+                                  java_chararray *b = (java_chararray *) array;
+                                  return create_primitive_object(class_java_lang_Character, (void*) (long) b->data[index],"(C)V");
+                               }
+      case ARRAYTYPE_SHORT    : {
+                                  java_shortarray *b = (java_shortarray *) array;
+                                  return create_primitive_object(class_java_lang_Short, (void*) (long) b->data[index],"(S)V");
+                               }
+      case ARRAYTYPE_BOOLEAN  : {
+                                  java_booleanarray *b = (java_booleanarray *) array;
+                                  return create_primitive_object(class_java_lang_Boolean, (void*) (long) b->data[index],"(Z)V");
+                               }
+      case ARRAYTYPE_ARRAY    : {
+                                  java_arrayarray *b = (java_arrayarray *) array;
+                                  return (java_lang_Object*) b->data[index];
+                               }
+      case ARRAYTYPE_OBJECT   : /* use JNI-function to get the object */
+                               return (java_lang_Object*) GetObjectArrayElement (env, (jobjectArray) array, index);
+  }
+
+  /* unknown arraytype */
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+  return NULL;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;I)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getBoolean ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_booleanarray *a = (java_booleanarray *) array;
+
+  /* verify validity of the arrayindex */ 
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;I)B
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getByte ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_bytearray *a = (java_bytearray *) array;
+
+  /* verify validity of the arrayindex */ 
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;I)C
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getChar ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_chararray *a = (java_chararray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;I)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_reflect_Array_getDouble ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_doublearray *a = (java_doublearray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;I)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_reflect_Array_getFloat ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_floatarray *a = (java_floatarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;I)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getInt ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_intarray *a = (java_intarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getLength
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getLength ( JNIEnv *env ,  struct java_lang_Object* array)
+{
+  java_arrayheader *a = (java_arrayheader *) array;  
+
+  if (!a)
+       exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+  else
+       return a->size;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;I)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_reflect_Array_getLong ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_longarray *a = (java_longarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;I)S
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getShort ( JNIEnv *env ,  struct java_lang_Object* array, s4 index)
+{
+  java_shortarray *a = (java_shortarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+         return a->data[index];
+}
+
+
+/* get one character representation of componenttype class */
+
+char identify_componenttype(classinfo *c)
+{
+  int i;
+
+  if (c->name->text[0] == '[')
+       /* array */
+       return '[';
+
+  /* check whether primitive type */ 
+  for (i=0;i<PRIMITIVETYPE_COUNT;i++)
+    if (primitivetype_table[i].class_primitive == c) 
+       return primitivetype_table[i].typesig;
+
+
+  /* no array and no primitive type, must be object */
+  return 'L';
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    multiNewArray
+ * Signature: (Ljava/lang/Class;[I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Array_multiNewArray ( JNIEnv *env ,  struct java_lang_Class* componenttype, java_intarray* dimensions)
+{
+  classinfo *c = (classinfo*) componenttype;
+  constant_arraydescriptor *desc;
+  utf *classname;
+  u4 buf_len,i,dims;
+  char *buffer,*pos;
+  char ch;
+
+  /* check arguments */
+  if (!dimensions || !componenttype) {
+       exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+       return 0; 
+  }
+
+  /* build constant_arraydescriptor, so builtin_multianewarray can be called */
+  dims = dimensions->header.size;
+  classname = c->name;
+
+  /* allocate buffer for desciptor */
+  buf_len = classname->blength + dims + 2;
+  buffer = MNEW(u1, buf_len);
+  pos = buffer;
+
+  for (i=0;i<dims;i++) *pos++ = '[';
+
+  switch (ch = identify_componenttype(c)) {
+       case ']':
+               /* component is array */
+               memcpy(pos,classname->text,classname->blength);
+               pos+=classname->blength;
+               desc = buildarraydescriptor(buffer,pos-buffer);
+               break;
+       case 'L':
+               /* component is object */
+               *pos++ = 'L';
+               memcpy(pos,classname->text,classname->blength);
+               pos+=classname->blength;
+               *pos++ = ';';
+               desc = buildarraydescriptor(buffer,pos-buffer);
+               break;  
+        default:
+               /* primitive type */
+               *pos++ = ch;
+               desc = buildarraydescriptor(buffer,pos-buffer);
+  }
+       
+  /* dispose buffer */
+  MFREE(buffer, u1, buf_len);
+  return (java_lang_Object*) builtin_multianewarray(dimensions,desc);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    newArray
+ * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Array_newArray ( JNIEnv *env ,  struct java_lang_Class* componenttype, s4 size)
+{
+  classinfo *c = (classinfo *) componenttype;
+
+  if (componenttype) {
+      switch (identify_componenttype(c)) {
+       case 'Z':return (java_lang_Object*) builtin_newarray_boolean (size); 
+       case 'C':return (java_lang_Object*) builtin_newarray_char (size); 
+       case 'F':return (java_lang_Object*) builtin_newarray_float (size); 
+       case 'D':return (java_lang_Object*) builtin_newarray_double (size); 
+       case 'B':return (java_lang_Object*) builtin_newarray_byte (size); 
+       case 'S':return (java_lang_Object*) builtin_newarray_short (size); 
+       case 'I':return (java_lang_Object*) builtin_newarray_int (size); 
+       case 'J':return (java_lang_Object*) builtin_newarray_long (size); 
+       case 'L':return (java_lang_Object*) builtin_anewarray (size, c);                
+       case '[':{
+                  /* arrayarray */
+                  constant_arraydescriptor *desc;
+                  desc = buildarraydescriptor(c->name->text,c->name->blength);
+                  return (java_lang_Object*) builtin_newarray_array (size, desc);
+                }
+       }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+  return NULL; 
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    set
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_set ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, struct java_lang_Object* val)
+{
+  java_arrayheader *a = (java_arrayheader *) array;
+  classinfo *c;
+  jfieldID fid;
+
+  /* check arguments */
+  if (!arrayindex_valid(a,index) || !val)
+       return;
+
+  /* determine class of the object containing the value */
+  c = val->header.vftbl -> class;  
+
+  /* The new value of the arrayelement is retrieved from the argument 'val' using a JNI-function 'GetxxxField'.
+     For primitive types the argument-object is first unwrapped to retrieve this value. */
+
+  switch (a->arraytype) {
+      case ARRAYTYPE_INT      : {
+                                  /* unwrap */
+                                  java_intarray *b = (java_intarray *) array;
+                                  if (c!=class_java_lang_Integer) break;
+                                  fid = env->GetFieldID(env,c,"value","I");
+                                  if (!fid) break;
+                                  b->data[index] = GetIntField(env,(jobject) val,fid);
+                                  return;                                                      
+                               }
+      case ARRAYTYPE_LONG     : {
+                                  java_longarray *b = (java_longarray *) array;
+                                  if (c!=class_java_lang_Long) break;
+                                  fid = env->GetFieldID(env,c,"value","J");
+                                  if (!fid) break;
+                                  b->data[index] = GetLongField(env,(jobject) val,fid);
+                                  return;                      
+                               }
+      case ARRAYTYPE_FLOAT    : {
+                                  java_floatarray *b = (java_floatarray *) array;
+                                  if (c!=class_java_lang_Float) break;
+                                  fid = env->GetFieldID(env,c,"value","F");
+                                  if (!fid) break;
+                                  b->data[index] = GetFloatField(env,(jobject) val,fid);
+                                  return;                      
+                               }
+      case ARRAYTYPE_DOUBLE   : {
+                                  java_doublearray *b = (java_doublearray *) array;
+                                  if (c!=class_java_lang_Double) break;
+                                  fid = env->GetFieldID(env,c,"value","D");
+                                  if (!fid) break;
+                                  b->data[index] = GetDoubleField(env,(jobject) val,fid);
+                                  return;                      
+                               }
+      case ARRAYTYPE_BYTE     : {
+                                  java_bytearray *b = (java_bytearray *) array;
+                                  if (c!=class_java_lang_Byte) break;
+                                  fid = env->GetFieldID(env,c,"value","B");
+                                  if (!fid) break;
+                                  b->data[index] = GetIntField(env,(jobject) val,fid);
+                                  return;                      
+                               }
+      case ARRAYTYPE_CHAR     : {
+                                  java_chararray *b = (java_chararray *) array;
+                                  if (c!=class_java_lang_Character) break;
+                                  fid = env->GetFieldID(env,c,"value","C");
+                                  if (!fid) break;
+                                  b->data[index] = GetByteField(env,(jobject) val,fid);
+                                  return;                      
+                               }
+      case ARRAYTYPE_SHORT    : {
+                                  java_shortarray *b = (java_shortarray *) array;
+                                  if (c!=class_java_lang_Short) break;
+                                  fid = env->GetFieldID(env,c,"value","S");
+                                  if (!fid) break;
+                                  b->data[index] = GetShortField(env,(jobject) val,fid);
+                                  return;                      
+                               }
+      case ARRAYTYPE_BOOLEAN  : {
+                                  java_booleanarray *b = (java_booleanarray *) array;
+                                  if (c!=class_java_lang_Boolean) break;
+                                  fid = env->GetFieldID(env,c,"value","Z");
+                                  if (!fid) break;
+                                  b->data[index] = GetBooleanField(env,(jobject) val,fid);
+                                  return;                      
+                               }
+      case ARRAYTYPE_ARRAY    : {
+                                  java_arrayarray *b = (java_arrayarray *) array;
+                                  b->data[index] = (java_arrayheader*) val;
+                               }
+      case ARRAYTYPE_OBJECT   : {
+                                  java_objectarray *b = (java_objectarray *) array;
+                                  b->data[index] = (java_objectheader*) val;
+                               }
+  }
+
+  /* unknown arraytype */
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;IZ)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setBoolean ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, s4 val)
+{
+  java_booleanarray *a = (java_booleanarray *) array;
+
+  if (arrayindex_valid(&a->header,index)) 
+       a->data[index]=val;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;IB)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setByte ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, s4 val)
+{
+  java_bytearray *a = (java_bytearray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+       a->data[index]=val;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;IC)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setChar ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, s4 val)
+{
+  java_chararray *a = (java_chararray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+       a->data[index]=val;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;ID)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setDouble ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, double val)
+{
+  java_doublearray *a = (java_doublearray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+       a->data[index]=val;
+
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;IF)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setFloat ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, float val)
+{
+  java_floatarray *a = (java_floatarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+       a->data[index]=val;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setInt ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, s4 val)
+{
+  java_intarray *a = (java_intarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+       a->data[index]=val;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;IJ)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setLong ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, s8 val)
+{
+  java_longarray *a = (java_longarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+       a->data[index]=val;
+}
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;IS)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setShort ( JNIEnv *env ,  struct java_lang_Object* array, s4 index, s4 val)
+{
+  java_shortarray *a = (java_shortarray *) array;
+
+  if (arrayindex_valid(&a->header,index))
+       a->data[index]=val;
+}
diff --git a/nat/Array.h b/nat/Array.h
new file mode 100644 (file)
index 0000000..a32826d
--- /dev/null
@@ -0,0 +1,134 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/reflect/Array */
+
+typedef struct java_lang_reflect_Array {
+   java_objectheader header;
+} java_lang_reflect_Array;
+
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    get
+ * Signature: (Ljava/lang/Object;I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Array_get (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;I)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getBoolean (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;I)B
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getByte (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;I)C
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getChar (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;I)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_reflect_Array_getDouble (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;I)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_reflect_Array_getFloat (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;I)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getInt (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getLength
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getLength (JNIEnv *env , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;I)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_reflect_Array_getLong (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;I)S
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Array_getShort (JNIEnv *env , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    multiNewArray
+ * Signature: (Ljava/lang/Class;[I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Array_multiNewArray (JNIEnv *env , struct java_lang_Class* par1, java_intarray* par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    newArray
+ * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Array_newArray (JNIEnv *env , struct java_lang_Class* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    set
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_set (JNIEnv *env , struct java_lang_Object* par1, s4 par2, struct java_lang_Object* par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;IZ)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setBoolean (JNIEnv *env , struct java_lang_Object* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;IB)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setByte (JNIEnv *env , struct java_lang_Object* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;IC)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setChar (JNIEnv *env , struct java_lang_Object* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;ID)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setDouble (JNIEnv *env , struct java_lang_Object* par1, s4 par2, double par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;IF)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setFloat (JNIEnv *env , struct java_lang_Object* par1, s4 par2, float par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setInt (JNIEnv *env , struct java_lang_Object* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;IJ)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setLong (JNIEnv *env , struct java_lang_Object* par1, s4 par2, s8 par3);
+/*
+ * Class:     java/lang/reflect/Array
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;IS)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Array_setShort (JNIEnv *env , struct java_lang_Object* par1, s4 par2, s4 par3);
diff --git a/nat/BigInteger.c b/nat/BigInteger.c
new file mode 100644 (file)
index 0000000..fa92c5a
--- /dev/null
@@ -0,0 +1,121 @@
+/* class: java/math/BigInteger */
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbAdd
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbAdd ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+{      
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbDivide
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbDivide ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbDivideAndRemainder
+ * Signature: ([B[B)[[B
+ */
+JNIEXPORT java_arrayarray* JNICALL Java_java_math_BigInteger_plumbDivideAndRemainder ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+
+
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbGcd
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbGcd ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbGeneratePrime
+ * Signature: ([B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbGeneratePrime ( JNIEnv *env , java_bytearray* par1)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbInit
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_math_BigInteger_plumbInit ( JNIEnv *env   )
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbModInverse
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbModInverse ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbModPow
+ * Signature: ([B[B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbModPow ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2, java_bytearray* mant)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbMultiply
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbMultiply ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbRemainder
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbRemainder ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbSquare
+ * Signature: ([B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbSquare ( JNIEnv *env , java_bytearray* par1)
+{
+}
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbSubtract
+ * Signature: ([B[B)Ljava/math/BigInteger;
+ */
+JNIEXPORT struct java_math_BigInteger* JNICALL Java_java_math_BigInteger_plumbSubtract ( JNIEnv *env , java_bytearray* par1, java_bytearray* par2)
+{
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/nat/BigInteger.h b/nat/BigInteger.h
new file mode 100644 (file)
index 0000000..677b5ec
--- /dev/null
@@ -0,0 +1,86 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/math/BigInteger */
+
+typedef struct java_math_BigInteger {
+   java_objectheader header;
+   s4 signum;
+   java_bytearray* magnitude;
+   s4 bitCount;
+   s4 bitLength;
+   s4 lowestSetBit;
+   s4 firstNonzeroByteNum;
+} java_math_BigInteger;
+
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbAdd
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbAdd (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbDivide
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbDivide (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbDivideAndRemainder
+ * Signature: ([B[B)[[B
+ */
+JNIEXPORT java_arrayarray* JNICALL Java_java_math_BigInteger_plumbDivideAndRemainder (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbGcd
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbGcd (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbGeneratePrime
+ * Signature: ([B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbGeneratePrime (JNIEnv *env , java_bytearray* par1);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbInit
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_math_BigInteger_plumbInit (JNIEnv *env );
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbModInverse
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbModInverse (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbModPow
+ * Signature: ([B[B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbModPow (JNIEnv *env , java_bytearray* par1, java_bytearray* par2, java_bytearray* par3);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbMultiply
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbMultiply (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbRemainder
+ * Signature: ([B[B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbRemainder (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbSquare
+ * Signature: ([B)[B
+ */
+JNIEXPORT java_bytearray* JNICALL Java_java_math_BigInteger_plumbSquare (JNIEnv *env , java_bytearray* par1);
+/*
+ * Class:     java/math/BigInteger
+ * Method:    plumbSubtract
+ * Signature: ([B[B)Ljava/math/BigInteger;
+ */
+JNIEXPORT struct java_math_BigInteger* JNICALL Java_java_math_BigInteger_plumbSubtract (JNIEnv *env , java_bytearray* par1, java_bytearray* par2);
diff --git a/nat/CRC32.c b/nat/CRC32.c
new file mode 100644 (file)
index 0000000..935e098
--- /dev/null
@@ -0,0 +1,21 @@
+/* class: java/util/zip/CRC32 */
+
+/*
+ * Class:     java/util/zip/CRC32
+ * Method:    update
+ * Signature: (II)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_CRC32_update ( JNIEnv *env ,  s4 par1, s4 par2)
+{
+  log_text("Java_java_util_zip_CRC32_update called");
+}
+
+/*
+ * Class:     java/util/zip/CRC32
+ * Method:    updateBytes
+ * Signature: (I[BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_CRC32_updateBytes ( JNIEnv *env ,  s4 par1, java_bytearray* par2, s4 par3, s4 par4)
+{
+  log_text("Java_java_util_zip_CRC32_updateBytes called");
+}
diff --git a/nat/CRC32.h b/nat/CRC32.h
new file mode 100644 (file)
index 0000000..aab2113
--- /dev/null
@@ -0,0 +1,21 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/zip/CRC32 */
+
+typedef struct java_util_zip_CRC32 {
+   java_objectheader header;
+   s4 crc;
+} java_util_zip_CRC32;
+
+/*
+ * Class:     java/util/zip/CRC32
+ * Method:    update
+ * Signature: (II)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_CRC32_update (JNIEnv *env , s4 par1, s4 par2);
+/*
+ * Class:     java/util/zip/CRC32
+ * Method:    updateBytes
+ * Signature: (I[BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_CRC32_updateBytes (JNIEnv *env , s4 par1, java_bytearray* par2, s4 par3, s4 par4);
diff --git a/nat/Class.c b/nat/Class.c
new file mode 100644 (file)
index 0000000..3640598
--- /dev/null
@@ -0,0 +1,885 @@
+/* class: java/lang/Class */
+
+
+/* for selecting public members */
+#define MEMBER_PUBLIC  0
+
+
+/******************************************************************************************                                                                                                            
+
+       creates method signature (excluding return type) from array of 
+       class-objects representing the parameters of the method 
+
+*******************************************************************************************/
+
+
+utf *create_methodsig(java_objectarray* types)
+{
+    char *buffer;       /* buffer for building the desciptor */
+    char *pos;          /* current position in buffer */
+    utf *result;        /* the method signature */
+    u4 buffer_size = 3; /* minimal size=3: room for parenthesis and returntype */
+    u4 len = 0;                /* current length of the descriptor */
+    u4 i,j,n;
+
+    if (!types) return NULL;
+
+    /* determine required buffer-size */    
+    for (i=0;i<types->header.size;i++) {
+      classinfo *c = (classinfo *) types->data[i];
+      buffer_size  = buffer_size + c->name->blength+2;
+    }
+
+    /* allocate buffer */
+    buffer = MNEW(u1, buffer_size);
+    pos    = buffer;
+    
+    /* method-desciptor starts with parenthesis */
+    *pos++ = '(';
+
+    for (i=0;i<types->header.size;i++) {
+
+            char ch;      
+            /* current argument */
+           classinfo *c = (classinfo *) types->data[i];
+           /* current position in utf-text */
+           char *utf_ptr = c->name->text; 
+           
+           /* determine type of argument */
+           if ( (ch = utf_nextu2(&utf_ptr)) == '[' ) {
+       
+               /* arrayclass */
+               for ( utf_ptr--; utf_ptr<utf_end(c->name); utf_ptr++)
+                  *pos++ = *utf_ptr; /* copy text */
+
+           } else
+           {           
+               /* check for primitive types */
+               for (j=0; j<PRIMITIVETYPE_COUNT; j++) {
+
+                       char *utf_pos   = utf_ptr-1;
+                       char *primitive = primitivetype_table[j].wrapname;
+
+                       /* compare text */
+                       while (utf_pos<utf_end(c->name))
+                               if (*utf_pos++ != *primitive++) goto nomatch;
+
+                       /* primitive type found */
+                       *pos++ = primitivetype_table[j].typesig;
+                       goto next_type;
+
+               nomatch:
+               }
+
+               /* no primitive type and no arrayclass, so must be object */
+               *pos++ = 'L';
+               /* copy text */
+               for ( utf_ptr--; utf_ptr<utf_end(c->name); utf_ptr++)
+                       *pos++ = *utf_ptr;
+               *pos++ = ';';
+
+               next_type:
+           }  
+    }      
+
+    *pos++ = ')';
+
+    /* create utf-string */
+    result = utf_new(buffer,(pos-buffer));
+    MFREE(buffer, u1, buffer_size);
+
+    return result;
+}
+
+/******************************************************************************************
+
+       retrieve the next argument or returntype from a descriptor
+       and return the corresponding class 
+
+*******************************************************************************************/
+
+
+classinfo *get_type(char **utf_ptr,char *desc_end, bool skip)
+{
+    classinfo *c = NULL;
+
+    if (*utf_ptr>=desc_end)
+       panic("illegal methoddescriptor");
+
+    switch (utf_nextu2(utf_ptr)) {
+      /* primitive types */
+      case 'I' : c = class_java_lang_Integer;
+                break;
+      case 'J' : c = class_java_lang_Long;
+                break;
+      case 'F' : c = class_java_lang_Float;
+                break;
+      case 'D' : c = class_java_lang_Double;
+                break;
+      case 'B' : c = class_java_lang_Byte;
+                break;
+      case 'C' : c = class_java_lang_Character;
+                break;
+      case 'S' : c = class_java_lang_Short;
+                break;
+      case 'Z' : c = class_java_lang_Boolean;
+                break;
+      case 'V' : c = class_java_lang_Void;
+                break;
+
+      case 'L' : {
+                   char *start = *utf_ptr;
+                   
+                   while (utf_nextu2(utf_ptr)!=';') 
+                       /* skip */ ;
+
+                   if (skip) return NULL; /* just analyze */
+
+                   /* load the class */        
+                   c = loader_load(utf_new(start,*utf_ptr-start-1));
+                   break;
+                 }
+
+      case '[' : {
+                   /* arrayclass */
+                   char *start = *utf_ptr;
+                   char ch;
+
+                   while ((ch = utf_nextu2(utf_ptr))=='[') 
+                       /* skip */ ;
+
+                   if (ch == 'L') {
+                       while (utf_nextu2(utf_ptr)!=';') 
+                           /* skip */ ;
+                   }
+
+                   if (skip) return NULL; /* just analyze */
+
+                   /* create the specific arrayclass */
+                   c = create_array_class(utf_new(start-1,*utf_ptr-start+1));
+                   break;
+                 }
+    }
+
+    if (!c)
+       /* unknown type */
+       panic("illegal methoddescriptor");
+
+    if (skip) return NULL;
+
+    use_class_as_object(c);
+    return c;
+}
+
+/******************************************************************************************
+
+       use the descriptor of a method to generate a java/lang/Class array
+       which contains the classes of the parametertypes of the method
+
+*******************************************************************************************/
+
+java_objectarray* get_parametertypes(methodinfo *m) 
+{
+    utf  *descr    =  m->descriptor;    /* method-descriptor */ 
+    char *utf_ptr  =  descr->text;      /* current position in utf-text */
+    char *desc_end =  utf_end(descr);   /* points behind utf string     */
+    java_objectarray* result;
+    int parametercount = 0;
+    int i;
+
+    /* skip '(' */
+    utf_nextu2(&utf_ptr);
+  
+    /* determine number of parameters */
+    while ( *utf_ptr != ')' ) {
+       get_type(&utf_ptr,desc_end,true);
+       parametercount++;
+    }
+
+    /* create class-array */
+    result = builtin_anewarray(parametercount, class_java_lang_Class);
+
+    utf_ptr  =  descr->text;
+    utf_nextu2(&utf_ptr);
+
+    /* get returntype classes */
+    for (i = 0; i < parametercount; i++)
+           result->data[i] = (java_objectheader *) get_type(&utf_ptr,desc_end, false);
+
+    return result;
+}
+
+
+/******************************************************************************************
+
+       get the returntype class of a method
+
+*******************************************************************************************/
+
+classinfo *get_returntype(methodinfo *m) 
+{
+       char *utf_ptr;   /* current position in utf-text */
+       char *desc_end;  /* points behind utf string     */
+        utf *desc = m->descriptor; /* method-descriptor  */
+
+       utf_ptr  = desc->text;
+       desc_end = utf_end(desc);
+
+       /* ignore parametertypes */
+        while ((utf_ptr<desc_end) && utf_nextu2(&utf_ptr)!=')')
+               /* skip */ ;
+
+       return get_type(&utf_ptr,desc_end, false);
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    forName0
+ * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_forName0 ( JNIEnv *env ,  struct java_lang_String* s, s4 initialize, struct java_lang_ClassLoader* par3)
+{
+       classinfo *c;
+       utf *u;
+       u4 i;
+
+       /* illegal argument */
+       if (!s) return NULL;
+       
+       if (s->value->data[s->offset]=='[') {
+
+         /*  arrayclasses, e.g. [Ljava.lang.String; */   
+         c = create_array_class(javastring_toutf(s, true));
+
+       } else
+       {
+
+         /* create utf string in which '.' is replaced by '/' */
+         u = javastring_toutf(s, true);
+
+         if ( !(c = class_get(u)) ) {
+
+           /* class was not found, raise exception */
+           exceptionptr = 
+             native_new_and_init (class_java_lang_ClassNotFoundException);
+
+           return NULL;
+         }
+        }
+
+       use_class_as_object (c);
+       return (java_lang_Class*) c;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getClassLoader0
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT struct java_lang_ClassLoader* JNICALL Java_java_lang_Class_getClassLoader0 ( JNIEnv *env ,  struct java_lang_Class* this)
+{  
+  init_systemclassloader();
+  return SystemClassLoader;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getComponentType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getComponentType ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+  classinfo *c = NULL; 
+
+  if ((classinfo*) this == class_array) {
+       java_arrayheader *a = (java_arrayheader*) this;
+
+       /* determine componenttype */
+       switch (a->arraytype) {
+          case ARRAYTYPE_BYTE:    c = class_java_lang_Byte; break;  
+           case ARRAYTYPE_BOOLEAN: c = class_java_lang_Boolean; break;   
+          case ARRAYTYPE_CHAR:    c = class_java_lang_Character; break;   
+          case ARRAYTYPE_SHORT:   c = class_java_lang_Short; break;    
+          case ARRAYTYPE_INT:     c = class_java_lang_Integer; break;   
+          case ARRAYTYPE_LONG:    c = class_java_lang_Long; break;   
+          case ARRAYTYPE_FLOAT:   c = class_java_lang_Float; break;   
+          case ARRAYTYPE_DOUBLE:  c = class_java_lang_Double; break;   
+          case ARRAYTYPE_OBJECT:  c = ((java_objectarray*) a) -> elementtype; break;
+          case ARRAYTYPE_ARRAY:   c = (classinfo *) ((java_arrayarray*) a) -> data[0]; break;
+          default: panic("illegal arraytype");
+       }               
+
+       /* set vftbl */
+       use_class_as_object (c);
+  }
+  
+  return (java_lang_Class*) c;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getConstructor0
+ * Signature: ([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT struct java_lang_reflect_Constructor* JNICALL Java_java_lang_Class_getConstructor0 ( JNIEnv *env ,  struct java_lang_Class* this, java_objectarray* par1, s4 par2)
+{
+  panic("Java_java_lang_Class_getConstructor0 called");
+  return NULL;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getConstructors0
+ * Signature: (I)[Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getConstructors0 ( JNIEnv *env ,  struct java_lang_Class* this, s4 par1)
+{
+  panic("Java_java_lang_Class_getConstructors0 called");
+  return NULL;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaredClasses0
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getDeclaredClasses0 ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+  classinfo *c = (classinfo *) this;
+  int pos = 0;                /* current declared class */
+  int declaredclasscount = 0; /* number of declared classes */
+  java_objectarray *result;   /* array of declared classes */
+  int i;
+
+  if (!this)
+    return NULL;
+
+  if (!Java_java_lang_Class_isPrimitive(env, this) && (c->name->text[0]!='[')) {
+    /* determine number of declared classes */
+    for (i = 0; i < c->innerclasscount; i++) {
+      if (c->innerclass[i].outer_class == c) 
+        /* outer class is this class */
+       declaredclasscount++;
+    }
+  }
+     
+  result = builtin_anewarray(declaredclasscount, class_java_lang_Class);       
+
+  for (i = 0; i < c->innerclasscount; i++) {
+    
+    classinfo *inner =  c->innerclass[i].inner_class;
+    classinfo *outer =  c->innerclass[i].outer_class;
+      
+    if (outer == c) {
+      /* outer class is this class, store innerclass in array */
+      use_class_as_object (inner);
+      result->data[pos++] = (java_objectheader *) inner;
+    }
+  }
+
+  return result;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaringClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getDeclaringClass ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+  classinfo *c = (classinfo *) this;
+
+  if (this && !Java_java_lang_Class_isPrimitive(env, this) && (c->name->text[0]!='[')) {    
+    int i, j;
+
+    if (c->innerclasscount == 0)  /* no innerclasses exist */
+       return NULL;
+    
+    for (i = 0; i < c->innerclasscount; i++) {
+
+      classinfo *inner =  c->innerclass[i].inner_class;
+      classinfo *outer =  c->innerclass[i].outer_class;
+      
+      if (inner == c) {
+       /* innerclass is this class */
+       use_class_as_object (outer);
+       return (java_lang_Class*) outer;
+      }
+    }
+  }
+
+  /* return NULL for arrayclasses and primitive classes */
+  return NULL;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getField0
+ * Signature: (Ljava/lang/String;I)Ljava/lang/reflect/Field;
+ */
+JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_java_lang_Class_getField0 ( JNIEnv *env ,  struct java_lang_Class* this, struct java_lang_String* name, s4 which)
+{
+    classinfo *c, *fieldtype;   
+    fieldinfo *f;               /* the field to be represented */
+    java_lang_reflect_Field *o; /* result: field-object */
+    utf *desc;                 /* the fielddescriptor */
+    char buffer[MAXSTRINGSIZE];
+    
+    /* create Field object */
+    c = (classinfo*) loader_load(utf_new_char ("java/lang/reflect/Field"));
+    o = (java_lang_reflect_Field*) native_new_and_init(c);
+
+    /* get fieldinfo entry */
+    f = class_findfield_approx((classinfo*) this, javastring_toutf(name, false));
+
+    if (f) {
+
+       if (which==MEMBER_PUBLIC && !(f->flags & ACC_PUBLIC))
+       {
+           /* field is not public */
+           exceptionptr = native_new_and_init(class_java_lang_NoSuchFieldException);
+           return NULL;
+       }
+
+      desc = f->descriptor;
+
+      /* use the the field-descriptor to determine the class of the field */
+      if (desc->text[0]=='[')
+          /* arrayclass */
+         fieldtype = create_array_class(f->descriptor);
+      else
+      if (desc->text[0]=='L') {
+         
+         if (desc->blength<2)
+             return NULL;
+         
+         fieldtype = loader_load(utf_new(desc->text+1,desc->blength-2));
+
+      } else
+      switch (desc->text[0]) {
+         /* primitive type */
+         case 'C': fieldtype = class_java_lang_Character;
+                   break;
+         case 'I': fieldtype = class_java_lang_Integer;
+                   break;
+         case 'F': fieldtype = class_java_lang_Float;
+                   break;
+         case 'D': fieldtype = class_java_lang_Double;
+                   break;
+         case 'J': fieldtype = class_java_lang_Long;
+                   break;
+         case 'B': fieldtype = class_java_lang_Byte;
+                   break;
+         case 'S': fieldtype = class_java_lang_Short;
+                   break;
+         case 'Z': fieldtype = class_java_lang_Boolean;
+                   break;
+           default: /* unknown type */
+                   return NULL;
+         }
+        
+      /* initialize instance fields */
+      setfield_critical(c,o,"clazz",          "Ljava/lang/Class;",  jobject, (jobject) this);
+      setfield_critical(c,o,"modifiers",      "I",                 jint,    f->flags);
+      /* save type in slot-field for faster processing */
+      setfield_critical(c,o,"slot",           "I",                 jint,    (jint) f->descriptor->text[0]);  
+      setfield_critical(c,o,"name",           "Ljava/lang/String;", jstring, (jstring) name);
+      setfield_critical(c,o,"type",           "Ljava/lang/Class;",  jclass,  c);
+
+      return o;
+    }
+
+    return NULL;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getFields0
+ * Signature: (I)[Ljava/lang/reflect/Field;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getFields0 ( JNIEnv *env ,  struct java_lang_Class* this, s4 which)
+{
+    classinfo *c = (classinfo *) this;
+    classinfo *class_field;
+    java_objectarray *array_field; /* result: array of field-objects */
+    int public_fields = 0;         /* number of elements in field-array */
+    int pos = 0;
+    int i;
+
+    /* determine number of fields */
+    for (i = 0; i < c->fieldscount; i++) 
+       if ((c->fields[i].flags & ACC_PUBLIC) || which!=MEMBER_PUBLIC) public_fields++;
+
+    class_field = loader_load(utf_new_char("java/lang/reflect/Field"));
+
+    if (!class_field) 
+       return NULL;
+
+    /* create array of fields */
+    array_field = builtin_anewarray(public_fields, class_field);
+
+    /* creation of array failed */
+    if (!array_field) 
+       return NULL;
+
+    /* get the fields and store in the array */    
+    for (i = 0; i < c->fieldscount; i++) 
+       if (c->fields[i].flags & ACC_PUBLIC)
+           array_field->data[pos++] = (java_objectheader*) Java_java_lang_Class_getField0
+                                                            (env,
+                                                             this,
+                                                             (java_lang_String*) javastring_new(c->fields[i].name), 
+                                                             which);
+    return array_field;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getInterfaces
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getInterfaces ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+       classinfo *c = (classinfo*) this;
+       u4 i;
+       java_objectarray *a = builtin_anewarray (c->interfacescount, class_java_lang_Class);
+       if (!a) return NULL;
+       for (i=0; i<c->interfacescount; i++) {
+               use_class_as_object (c->interfaces[i]);
+
+               a->data[i] = (java_objectheader*) c->interfaces[i];
+               }
+       return a;
+}
+
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getMethod0
+ * Signature: (Ljava/lang/String;[Ljava/lang/Class;I)Ljava/lang/reflect/Method;
+ */
+JNIEXPORT struct java_lang_reflect_Method* JNICALL Java_java_lang_Class_getMethod0 ( JNIEnv *env ,  struct java_lang_Class* this, struct java_lang_String* name, java_objectarray* types, s4 which)
+{
+    classinfo *c; 
+    classinfo *clazz = (classinfo *) this;
+    java_lang_reflect_Method* o;         /* result: Method-object */ 
+    java_objectarray *exceptiontypes;    /* the exceptions thrown by the method */
+    methodinfo *m;                      /* the method to be represented */
+
+    c = (classinfo*) loader_load(utf_new_char ("java/lang/reflect/Method"));
+    o = (java_lang_reflect_Method*) native_new_and_init(c);
+
+    /* find the method */
+    m = class_resolvemethod_approx (
+               clazz, 
+               javastring_toutf(name, false),
+               create_methodsig(types)
+       );
+
+    if (!m || (which==MEMBER_PUBLIC && !(m->flags & ACC_PUBLIC)))
+    {
+       /* no apropriate method was found */
+       exceptionptr = native_new_and_init (class_java_lang_NoSuchMethodException);
+       return NULL;
+    }
+   
+    /* array of exceptions declared to be thrown, information not available !! */
+    exceptiontypes = builtin_anewarray (0, class_java_lang_Class);
+
+    /* initialize instance fields */
+    setfield_critical(c,o,"clazz",          "Ljava/lang/Class;",  jobject, (jobject) this);
+    setfield_critical(c,o,"parameterTypes", "[Ljava/lang/Class;", jobject, (jobject) types);
+    setfield_critical(c,o,"exceptionTypes", "[Ljava/lang/Class;", jobject, (jobject) exceptiontypes);
+    setfield_critical(c,o,"name",           "Ljava/lang/String;", jstring, javastring_new(m->name));
+    setfield_critical(c,o,"modifiers",      "I",                 jint,    m->flags);
+    setfield_critical(c,o,"slot",           "I",                 jint,    0); 
+    setfield_critical(c,o,"returnType",     "Ljava/lang/Class;",  jclass,  get_returntype(m));
+
+    return o;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getMethods0
+ * Signature: (I)[Ljava/lang/reflect/Method;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getMethods0 ( JNIEnv *env ,  struct java_lang_Class* this, s4 which)
+{
+    classinfo *c = (classinfo *) this;    
+    java_objectheader *o;
+    classinfo *class_method;
+    java_objectarray *array_method;     /* result: array of Method-objects */
+    java_objectarray *exceptiontypes;   /* the exceptions thrown by the method */
+    methodinfo *m;                     /* the current method to be represented */    
+    int public_methods = 0;            /* number of public methods of the class */
+    int pos = 0;
+    int i;
+
+    /* determine number of methods */
+    for (i = 0; i < c->methodscount; i++) 
+       if (((c->methods[i].flags & ACC_PUBLIC)) || which!=MEMBER_PUBLIC) public_methods++;
+
+    class_method = (classinfo*) loader_load(utf_new_char ("java/lang/reflect/Method"));
+
+    if (!class_method) 
+       return NULL;
+    
+    array_method = builtin_anewarray(public_methods, class_method);
+
+    if (!array_method) 
+       return NULL;
+
+    for (i = 0; i < c->methodscount; i++) 
+       if (c->methods[i].flags & ACC_PUBLIC) {
+
+           m = &c->methods[i];     
+           o = native_new_and_init(class_method);     
+           array_method->data[pos++] = o;
+
+           /* array of exceptions declared to be thrown, information not available !! */
+           exceptiontypes = builtin_anewarray (0, class_java_lang_Class);
+
+           /* initialize instance fields */
+           setfield_critical(class_method,o,"clazz",          "Ljava/lang/Class;",  jobject, (jobject) this);
+           setfield_critical(class_method,o,"name",           "Ljava/lang/String;", jstring, javastring_new(m->name));
+           setfield_critical(class_method,o,"modifiers",      "I",                  jint,    m->flags);
+           setfield_critical(class_method,o,"slot",           "I",                  jint,    0); 
+           setfield_critical(class_method,o,"returnType",     "Ljava/lang/Class;",  jclass,  get_returntype(m));
+           setfield_critical(class_method,o,"exceptionTypes", "[Ljava/lang/Class;", jobject, (jobject) exceptiontypes);
+           setfield_critical(class_method,o,"parameterTypes", "[Ljava/lang/Class;", jobject, (jobject) get_parametertypes(m));
+        }           
+
+    return array_method;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getModifiers
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_getModifiers ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+  classinfo *c = (classinfo *) this;
+  return c->flags;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_Class_getName ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+       u4 i;
+       classinfo *c = (classinfo*) this;
+       java_lang_String *s = (java_lang_String*) javastring_new(c->name);
+
+       if (!s) return NULL;
+
+       /* return string where '/' is replaced by '.' */
+       for (i=0; i<s->value->header.size; i++) {
+               if (s->value->data[i] == '/') s->value->data[i] = '.';
+               }
+       
+       return s;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getPrimitiveClass
+ * Signature: (Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getPrimitiveClass ( JNIEnv *env ,  struct java_lang_String* name)
+{
+    classinfo *c;
+    utf *u = javastring_toutf(name, false);
+
+    if (u) {           
+      /* get primitive class */
+      c = loader_load(u);
+      use_class_as_object (c);
+      return (java_lang_Class*) c;      
+    }
+
+    /* illegal primitive classname specified */
+    exceptionptr = native_new_and_init (class_java_lang_ClassNotFoundException);
+    return NULL;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getProtectionDomain0
+ * Signature: ()Ljava/security/ProtectionDomain;
+ */
+JNIEXPORT struct java_security_ProtectionDomain* JNICALL Java_java_lang_Class_getProtectionDomain0 ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+  log_text("Java_java_lang_Class_getProtectionDomain0  called");
+  return NULL;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getSigners
+ * Signature: ()[Ljava/lang/Object;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getSigners ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+  log_text("Java_java_lang_Class_getSigners  called");
+  return NULL;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    getSuperclass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getSuperclass ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+       classinfo *c = ((classinfo*) this) -> super;
+       if (!c) return NULL;
+
+       use_class_as_object (c);
+       return (java_lang_Class*) c;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isArray
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isArray ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+        classinfo *c = (classinfo*) this;
+
+       if (c == class_array || c->name->text[0] == '[')  return true;
+       return false;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isAssignableFrom
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isAssignableFrom ( JNIEnv *env ,  struct java_lang_Class* this, struct java_lang_Class* sup)
+{
+       return env->IsAssignableForm(env, (jclass) this, (jclass) sup);
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isInstance
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isInstance ( JNIEnv *env ,  struct java_lang_Class* this, struct java_lang_Object* obj)
+{
+       classinfo *clazz = (classinfo*) this;
+       return env->IsInstanceOf(env,(jobject) obj,clazz);
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isInterface
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isInterface ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+       classinfo *c = (classinfo*) this;
+       if (c->flags & ACC_INTERFACE) return true;
+       return false;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    isPrimitive
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isPrimitive ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+  int i;
+  classinfo *c = (classinfo *) this;
+
+  /* search table of primitive classes */
+  for (i=0;i<PRIMITIVETYPE_COUNT;i++)
+    if (primitivetype_table[i].class_primitive == c) return true;
+
+  return false;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    newInstance0
+ * Signature: ()Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_Class_newInstance0 ( JNIEnv *env ,  struct java_lang_Class* this)
+{
+       java_objectheader *o;
+
+       if (verbose) {  
+          char buffer[MAXSTRINGSIZE]; 
+         utf_sprint(buffer,((classinfo *) this)->name);      
+         strcat(buffer,"instantiated. ");
+         log_text(buffer);
+       }
+       
+       /* don't allow newInstance for array- and primitive classes */
+
+       if (((classinfo *) this)->name->text[0]=='[')
+         panic("newInstance of array_class");
+
+       if (Java_java_lang_Class_isPrimitive(env,this))
+         panic("newInstance of primitive class");
+
+       o = native_new_and_init ((classinfo*) this);
+       
+       if (!o) {
+               exceptionptr = 
+                       native_new_and_init (class_java_lang_InstantiationException);
+       }
+
+       return (java_lang_Object*) o;
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Class_registerNatives ( JNIEnv *env  )
+{
+    /* empty */
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    setProtectionDomain0
+ * Signature: (Ljava/security/ProtectionDomain;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Class_setProtectionDomain0 ( JNIEnv *env ,  struct java_lang_Class* this, struct java_security_ProtectionDomain* par1)
+{
+  if (verbose)
+    log_text("Java_java_lang_Class_setProtectionDomain0 called");
+}
+
+/*
+ * Class:     java/lang/Class
+ * Method:    setSigners
+ * Signature: ([Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Class_setSigners ( JNIEnv *env ,  struct java_lang_Class* this, java_objectarray* par1)
+{
+  if (verbose)
+    log_text("Java_java_lang_Class_setSigners called");
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/nat/Class.h b/nat/Class.h
new file mode 100644 (file)
index 0000000..09d882f
--- /dev/null
@@ -0,0 +1,170 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Class */
+
+typedef struct java_lang_Class {
+   java_objectheader header;
+} java_lang_Class;
+
+/*
+ * Class:     java/lang/Class
+ * Method:    forName0
+ * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_forName0 (JNIEnv *env , struct java_lang_String* par1, s4 par2, struct java_lang_ClassLoader* par3);
+/*
+ * Class:     java/lang/Class
+ * Method:    getClassLoader0
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT struct java_lang_ClassLoader* JNICALL Java_java_lang_Class_getClassLoader0 (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getComponentType
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getComponentType (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getConstructor0
+ * Signature: ([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT struct java_lang_reflect_Constructor* JNICALL Java_java_lang_Class_getConstructor0 (JNIEnv *env ,  struct java_lang_Class* this , java_objectarray* par1, s4 par2);
+/*
+ * Class:     java/lang/Class
+ * Method:    getConstructors0
+ * Signature: (I)[Ljava/lang/reflect/Constructor;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getConstructors0 (JNIEnv *env ,  struct java_lang_Class* this , s4 par1);
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaredClasses0
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getDeclaredClasses0 (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getDeclaringClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getDeclaringClass (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getField0
+ * Signature: (Ljava/lang/String;I)Ljava/lang/reflect/Field;
+ */
+JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_java_lang_Class_getField0 (JNIEnv *env ,  struct java_lang_Class* this , struct java_lang_String* par1, s4 par2);
+/*
+ * Class:     java/lang/Class
+ * Method:    getFields0
+ * Signature: (I)[Ljava/lang/reflect/Field;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getFields0 (JNIEnv *env ,  struct java_lang_Class* this , s4 par1);
+/*
+ * Class:     java/lang/Class
+ * Method:    getInterfaces
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getInterfaces (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getMethod0
+ * Signature: (Ljava/lang/String;[Ljava/lang/Class;I)Ljava/lang/reflect/Method;
+ */
+JNIEXPORT struct java_lang_reflect_Method* JNICALL Java_java_lang_Class_getMethod0 (JNIEnv *env ,  struct java_lang_Class* this , struct java_lang_String* par1, java_objectarray* par2, s4 par3);
+/*
+ * Class:     java/lang/Class
+ * Method:    getMethods0
+ * Signature: (I)[Ljava/lang/reflect/Method;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getMethods0 (JNIEnv *env ,  struct java_lang_Class* this , s4 par1);
+/*
+ * Class:     java/lang/Class
+ * Method:    getModifiers
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_getModifiers (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_Class_getName (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getPrimitiveClass
+ * Signature: (Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getPrimitiveClass (JNIEnv *env , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/Class
+ * Method:    getProtectionDomain0
+ * Signature: ()Ljava/security/ProtectionDomain;
+ */
+JNIEXPORT struct java_security_ProtectionDomain* JNICALL Java_java_lang_Class_getProtectionDomain0 (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getSigners
+ * Signature: ()[Ljava/lang/Object;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Class_getSigners (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    getSuperclass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Class_getSuperclass (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    isArray
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isArray (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    isAssignableFrom
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isAssignableFrom (JNIEnv *env ,  struct java_lang_Class* this , struct java_lang_Class* par1);
+/*
+ * Class:     java/lang/Class
+ * Method:    isInstance
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isInstance (JNIEnv *env ,  struct java_lang_Class* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/Class
+ * Method:    isInterface
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isInterface (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    isPrimitive
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Class_isPrimitive (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    newInstance0
+ * Signature: ()Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_Class_newInstance0 (JNIEnv *env ,  struct java_lang_Class* this );
+/*
+ * Class:     java/lang/Class
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Class_registerNatives (JNIEnv *env );
+/*
+ * Class:     java/lang/Class
+ * Method:    setProtectionDomain0
+ * Signature: (Ljava/security/ProtectionDomain;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Class_setProtectionDomain0 (JNIEnv *env ,  struct java_lang_Class* this , struct java_security_ProtectionDomain* par1);
+/*
+ * Class:     java/lang/Class
+ * Method:    setSigners
+ * Signature: ([Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Class_setSigners (JNIEnv *env ,  struct java_lang_Class* this , java_objectarray* par1);
diff --git a/nat/ClassLoader.c b/nat/ClassLoader.c
new file mode 100644 (file)
index 0000000..4ce3498
--- /dev/null
@@ -0,0 +1,60 @@
+/* class: java/lang/ClassLoader */
+
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    defineClass0
+ * Signature: (Ljava/lang/String;[BII)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_ClassLoader_defineClass0 ( JNIEnv *env ,  struct java_lang_ClassLoader* this, struct java_lang_String* name, java_bytearray* buf, s4 off, s4 len)
+{
+    classinfo *c;
+
+    /* call JNI-function to load the class */
+    c = env->DefineClass(env, javastring_tochar((java_objectheader*) name), (jobject) this, (const jbyte *) &buf[off], len);
+    use_class_as_object (c);    
+    return (java_lang_Class*) c;
+}
+
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    findBootstrapClass
+ * Signature: (Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_ClassLoader_findBootstrapClass ( JNIEnv *env ,  struct java_lang_ClassLoader* this, struct java_lang_String* name)
+{
+  /* load the class */
+  return Java_java_lang_Class_forName0(env,name,0,this);
+}
+
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    findLoadedClass
+ * Signature: (Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_ClassLoader_findLoadedClass ( JNIEnv *env ,  struct java_lang_ClassLoader* this, struct java_lang_String* name)
+{  
+  return Java_java_lang_Class_forName0(env,name,0,this);
+}
+
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    getCallerClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT struct java_lang_ClassLoader* JNICALL Java_java_lang_ClassLoader_getCallerClassLoader ( JNIEnv *env  )
+{
+  init_systemclassloader();
+  return SystemClassLoader;
+}
+
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    resolveClass0
+ * Signature: (Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ClassLoader_resolveClass0 ( JNIEnv *env ,  struct java_lang_ClassLoader* this, struct java_lang_Class* par1)
+{
+  /* class already linked, so return */
+  return;
+}
+
diff --git a/nat/ClassLoader.h b/nat/ClassLoader.h
new file mode 100644 (file)
index 0000000..c915ce0
--- /dev/null
@@ -0,0 +1,44 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/ClassLoader */
+
+typedef struct java_lang_ClassLoader {
+   java_objectheader header;
+   s4 initialized;
+   struct java_lang_ClassLoader* parent;
+   struct java_util_Vector* classes;
+   struct java_util_HashMap* packages;
+   struct java_security_ProtectionDomain* defaultDomain;
+   struct java_util_Vector* nativeLibraries;
+} java_lang_ClassLoader;
+
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    defineClass0
+ * Signature: (Ljava/lang/String;[BII)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_ClassLoader_defineClass0 (JNIEnv *env ,  struct java_lang_ClassLoader* this , struct java_lang_String* par1, java_bytearray* par2, s4 par3, s4 par4);
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    findBootstrapClass
+ * Signature: (Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_ClassLoader_findBootstrapClass (JNIEnv *env ,  struct java_lang_ClassLoader* this , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    findLoadedClass
+ * Signature: (Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_ClassLoader_findLoadedClass (JNIEnv *env ,  struct java_lang_ClassLoader* this , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    getCallerClassLoader
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT struct java_lang_ClassLoader* JNICALL Java_java_lang_ClassLoader_getCallerClassLoader (JNIEnv *env );
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    resolveClass0
+ * Signature: (Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ClassLoader_resolveClass0 (JNIEnv *env ,  struct java_lang_ClassLoader* this , struct java_lang_Class* par1);
diff --git a/nat/ClassLoader_NativeLibrary.c b/nat/ClassLoader_NativeLibrary.c
new file mode 100644 (file)
index 0000000..5ca1687
--- /dev/null
@@ -0,0 +1,42 @@
+/* class: java/lang/ClassLoader$NativeLibrary */
+
+/*
+ * Class:     java/lang/ClassLoader$NativeLibrary
+ * Method:    find
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_ClassLoader_NativeLibrary_find (JNIEnv *env ,  struct java_lang_ClassLoader_NativeLibrary* this , struct java_lang_String* par1)
+{
+  if (verbose)
+      log_text("Java_java_lang_ClassLoader_NativeLibrary_find called");
+}
+
+/*
+ * Class:     java/lang/ClassLoader$NativeLibrary
+ * Method:    load
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ClassLoader_NativeLibrary_load (JNIEnv *env ,  struct java_lang_ClassLoader_NativeLibrary* this , struct java_lang_String* par1)
+{
+      /* only initialize instance-fields, since native-functions are not loaded dynamically */
+      this->jniVersion = env->GetVersion(env);
+      this->handle     = 1;  /* not 0, so it looks valid */
+}
+
+/*
+ * Class:     java/lang/ClassLoader$NativeLibrary
+ * Method:    unload
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ClassLoader_NativeLibrary_unload (JNIEnv *env ,  struct java_lang_ClassLoader_NativeLibrary* this )
+{
+  if (verbose)
+      log_text("Java_java_lang_ClassLoader_NativeLibrary_unload called");
+}
+
+
+
+
+
+
+
diff --git a/nat/ClassLoader_NativeLibrary.h b/nat/ClassLoader_NativeLibrary.h
new file mode 100644 (file)
index 0000000..d3a58bd
--- /dev/null
@@ -0,0 +1,30 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/ClassLoader_NativeLibrary */
+
+typedef struct java_lang_ClassLoader_NativeLibrary {
+   java_objectheader header;
+   s8 handle;
+   s4 jniVersion;
+   struct java_lang_Class* fromClass;
+   struct java_lang_String* name;
+} java_lang_ClassLoader_NativeLibrary;
+
+/*
+ * Class:     java/lang/ClassLoader_NativeLibrary
+ * Method:    find
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_ClassLoader_NativeLibrary_find (JNIEnv *env ,  struct java_lang_ClassLoader_NativeLibrary* this , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/ClassLoader_NativeLibrary
+ * Method:    load
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ClassLoader_NativeLibrary_load (JNIEnv *env ,  struct java_lang_ClassLoader_NativeLibrary* this , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/ClassLoader_NativeLibrary
+ * Method:    unload
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ClassLoader_NativeLibrary_unload (JNIEnv *env ,  struct java_lang_ClassLoader_NativeLibrary* this );
diff --git a/nat/Compiler.c b/nat/Compiler.c
new file mode 100644 (file)
index 0000000..bdca793
--- /dev/null
@@ -0,0 +1,73 @@
+/* class: java/lang/Compiler */
+
+/*
+ * Class:     java/lang/Compiler
+ * Method:    command
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_Compiler_command ( JNIEnv *env ,  struct java_lang_Object* par1)
+{
+  log_text("Java_java_lang_Compiler_command  called");
+  return NULL;
+}
+/*
+ * Class:     java/lang/Compiler
+ * Method:    compileClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Compiler_compileClass ( JNIEnv *env ,  struct java_lang_Class* par1)
+{
+  log_text("Java_java_lang_Compiler_compileClass  called");
+  return 0;
+}
+/*
+ * Class:     java/lang/Compiler
+ * Method:    compileClasses
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Compiler_compileClasses ( JNIEnv *env ,  struct java_lang_String* par1)
+{
+  log_text("Java_java_lang_Compiler_compileClasses  called");
+  return 0;
+}
+/*
+ * Class:     java/lang/Compiler
+ * Method:    disable
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_disable ( JNIEnv *env  )
+{
+  log_text("Java_java_lang_Compiler_disable  called");
+}
+/*
+ * Class:     java/lang/Compiler
+ * Method:    enable
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_enable ( JNIEnv *env  )
+{
+  log_text("Java_java_lang_Compiler_enable  called");
+}
+/*
+ * Class:     java/lang/Compiler
+ * Method:    initialize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_initialize ( JNIEnv *env  )
+{
+  log_text("Java_java_lang_Compiler_initialize  called");
+}
+/*
+ * Class:     java/lang/Compiler
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_registerNatives ( JNIEnv *env  )
+{
+  /* empty */
+}
+
+
+
+
+
diff --git a/nat/Compiler.h b/nat/Compiler.h
new file mode 100644 (file)
index 0000000..8cb7970
--- /dev/null
@@ -0,0 +1,50 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Compiler */
+
+typedef struct java_lang_Compiler {
+   java_objectheader header;
+} java_lang_Compiler;
+
+/*
+ * Class:     java/lang/Compiler
+ * Method:    command
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_Compiler_command (JNIEnv *env , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/Compiler
+ * Method:    compileClass
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Compiler_compileClass (JNIEnv *env , struct java_lang_Class* par1);
+/*
+ * Class:     java/lang/Compiler
+ * Method:    compileClasses
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Compiler_compileClasses (JNIEnv *env , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/Compiler
+ * Method:    disable
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_disable (JNIEnv *env );
+/*
+ * Class:     java/lang/Compiler
+ * Method:    enable
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_enable (JNIEnv *env );
+/*
+ * Class:     java/lang/Compiler
+ * Method:    initialize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_initialize (JNIEnv *env );
+/*
+ * Class:     java/lang/Compiler
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Compiler_registerNatives (JNIEnv *env );
diff --git a/nat/Constructor.c b/nat/Constructor.c
new file mode 100644 (file)
index 0000000..6415581
--- /dev/null
@@ -0,0 +1,12 @@
+/* class: java/lang/reflect/Constructor */
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    newInstance
+ * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_newInstance ( JNIEnv *env ,  struct java_lang_reflect_Constructor* this, java_objectarray* par1)
+{
+  log_text("Java_java_lang_reflect_Constructor_newInstance called");
+}
diff --git a/nat/Constructor.h b/nat/Constructor.h
new file mode 100644 (file)
index 0000000..8e08c80
--- /dev/null
@@ -0,0 +1,20 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/reflect/Constructor */
+
+typedef struct java_lang_reflect_Constructor {
+   java_objectheader header;
+   s4 override;
+   struct java_lang_Class* clazz;
+   s4 slot;
+   java_objectarray* parameterTypes;
+   java_objectarray* exceptionTypes;
+   s4 modifiers;
+} java_lang_reflect_Constructor;
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    newInstance
+ * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_newInstance (JNIEnv *env ,  struct java_lang_reflect_Constructor* this , java_objectarray* par1);
diff --git a/nat/Date.h b/nat/Date.h
new file mode 100644 (file)
index 0000000..53fc61c
--- /dev/null
@@ -0,0 +1,10 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/Date */
+
+typedef struct java_util_Date {
+   java_objectheader header;
+   struct java_util_Calendar* cal;
+   s8 fastTime;
+} java_util_Date;
+
diff --git a/nat/Deflater.c b/nat/Deflater.c
new file mode 100644 (file)
index 0000000..56b1069
--- /dev/null
@@ -0,0 +1,83 @@
+/* class: java/util/zip/Deflater */
+
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    deflateBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_deflateBytes ( JNIEnv *env ,  struct java_util_zip_Deflater* this, java_bytearray* par1, s4 par2, s4 par3)
+{
+  log_text("Java_java_util_zip_Deflater_deflateBytes  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    end
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_end ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Deflater_end  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    getAdler
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_getAdler ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Deflater_getAdler  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    getTotalIn
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_getTotalIn ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Deflater_getTotalIn  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    getTotalOut
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_getTotalOut ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Deflater_getTotalOut  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    init
+ * Signature: (IIZ)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_Deflater_init ( JNIEnv *env ,  s4 par1, s4 par2, s4 par3)
+{
+  log_text("Java_java_util_zip_Deflater_init  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_initIDs ( JNIEnv *env  )
+{
+  log_text("Java_java_util_zip_Deflater_initIDs  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    reset
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_reset ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Deflater_reset  called");
+}
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    setDictionary
+ * Signature: (J[BII)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_setDictionary ( JNIEnv *env ,  s8 par1, java_bytearray* par2, s4 par3, s4 par4)
+{
+  log_text("Java_java_util_zip_Deflater_setDictionary  called");
+}
diff --git a/nat/Deflater.h b/nat/Deflater.h
new file mode 100644 (file)
index 0000000..77c19cf
--- /dev/null
@@ -0,0 +1,71 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/zip/Deflater */
+
+typedef struct java_util_zip_Deflater {
+   java_objectheader header;
+   s8 strm;
+   java_bytearray* buf;
+   s4 off;
+   s4 len;
+   s4 level;
+   s4 strategy;
+   s4 setParams;
+   s4 finish;
+   s4 finished;
+} java_util_zip_Deflater;
+
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    deflateBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_deflateBytes (JNIEnv *env ,  struct java_util_zip_Deflater* this , java_bytearray* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    end
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_end (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    getAdler
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_getAdler (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    getTotalIn
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_getTotalIn (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    getTotalOut
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Deflater_getTotalOut (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    init
+ * Signature: (IIZ)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_Deflater_init (JNIEnv *env , s4 par1, s4 par2, s4 par3);
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_initIDs (JNIEnv *env );
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    reset
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_reset (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Deflater
+ * Method:    setDictionary
+ * Signature: (J[BII)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Deflater_setDictionary (JNIEnv *env , s8 par1, java_bytearray* par2, s4 par3, s4 par4);
diff --git a/nat/Double.c b/nat/Double.c
new file mode 100644 (file)
index 0000000..7e10dd8
--- /dev/null
@@ -0,0 +1,27 @@
+/* class: java/lang/Double */
+
+/*
+ * Class:     java/lang/Double
+ * Method:    doubleToLongBits
+ * Signature: (D)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Double_doubleToLongBits ( JNIEnv *env ,  double par1)
+{
+       s8 l;
+       double d = par1;
+       memcpy ((u1*) &l, (u1*) &d, 8);
+       return l;
+}
+
+/*
+ * Class:     java/lang/Double
+ * Method:    longBitsToDouble
+ * Signature: (J)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Double_longBitsToDouble ( JNIEnv *env ,  s8 par1)
+{
+       s8 l = par1;
+       double d;
+       memcpy ((u1*) &d, (u1*) &l, 8);
+       return d;
+}
diff --git a/nat/Double.h b/nat/Double.h
new file mode 100644 (file)
index 0000000..588402d
--- /dev/null
@@ -0,0 +1,21 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Double */
+
+typedef struct java_lang_Double {
+   java_objectheader header;
+   double value;
+} java_lang_Double;
+
+/*
+ * Class:     java/lang/Double
+ * Method:    doubleToLongBits
+ * Signature: (D)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Double_doubleToLongBits (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Double
+ * Method:    longBitsToDouble
+ * Signature: (J)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Double_longBitsToDouble (JNIEnv *env , s8 par1);
diff --git a/nat/Exception.h b/nat/Exception.h
new file mode 100644 (file)
index 0000000..9c88774
--- /dev/null
@@ -0,0 +1,10 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Exception */
+
+typedef struct java_lang_Exception {
+   java_objectheader header;
+   struct java_lang_Object* backtrace;
+   struct java_lang_String* detailMessage;
+} java_lang_Exception;
+
diff --git a/nat/Field.c b/nat/Field.c
new file mode 100644 (file)
index 0000000..d93aac9
--- /dev/null
@@ -0,0 +1,626 @@
+/* class: java/lang/reflect/Field */
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    get
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Field_get ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID target_fid;   /* the JNI-fieldid of the wrapping object */
+  jfieldID fid;          /* the JNI-fieldid of the field containing the value */
+  jobject o;            /* the object for wrapping the primitive type */
+  classinfo *c = (classinfo *) this->clazz;
+  int st = (this->modifiers & ACC_STATIC); /* true if field is static */
+
+  /* get the fieldid of the field represented by this Field-object */
+  fid = class_findfield_approx((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+  /* The fieldid is used to retrieve the value, for primitive types a new 
+     object for wrapping the primitive type is created.  */
+  if (st || obj)   
+    switch (this->slot) {
+      case 'I' : {
+                  /* create wrapping class */
+                  c = class_java_lang_Integer;
+                  o = builtin_new(c);
+                  /* get fieldid to store the value */
+                  target_fid = env->GetFieldID(env,c,"value","I");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       /* static field */
+                       SetIntField(env,o,target_fid, env->GetStaticIntField(env, c, fid));
+                   else
+                        /* instance field */
+                       SetIntField(env,o,target_fid, env->GetIntField(env,(jobject) obj, fid));
+
+                  /* return the wrapped object */                 
+                  return (java_lang_Object*) o;
+                 }
+      case 'J' : {
+                  c = class_java_lang_Long;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","J");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetLongField(env,o,target_fid, env->GetStaticLongField(env, c, fid));
+                   else
+                       SetLongField(env,o,target_fid, env->GetLongField(env,(jobject)  obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'F' : {
+                  c = class_java_lang_Float;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","F");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetFloatField(env,o,target_fid, env->GetStaticFloatField(env, c, fid));
+                   else
+                       SetFloatField(env,o,target_fid, env->GetFloatField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'D' : {
+                  c = class_java_lang_Double;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","D");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetDoubleField(env,o,target_fid, env->GetStaticDoubleField(env, c, fid));
+                   else
+                       SetDoubleField(env,o,target_fid, env->GetDoubleField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'B' : {
+                  c = class_java_lang_Byte;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","B");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetByteField(env,o,target_fid, env->GetStaticByteField(env, c, fid));
+                   else
+                       SetByteField(env,o,target_fid, env->GetByteField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'C' : {
+                  c = class_java_lang_Character;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","C");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetCharField(env,o,target_fid, env->GetStaticCharField(env, c, fid));
+                   else
+                       SetCharField(env,o,target_fid, env->GetCharField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'S' : {
+                  c = class_java_lang_Short;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","S");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetShortField(env,o,target_fid, env->GetStaticShortField(env, c, fid));
+                   else
+                       SetShortField(env,o,target_fid, env->GetShortField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'Z' : {
+                  c = class_java_lang_Boolean;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","Z");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetBooleanField(env,o,target_fid, env->GetStaticBooleanField(env, c, fid));
+                   else
+                       SetBooleanField(env,o,target_fid, env->GetBooleanField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case '[' : 
+      case 'L' : {
+                  if (st)
+                       /* static field */
+                       return (java_lang_Object*) env->GetStaticObjectField(env, c, fid);
+                   else
+                        /* instance field */
+                       return (java_lang_Object*) env->GetObjectField(env, (jobject) obj, fid);
+
+                 }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getBoolean ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      /* get the fieldid represented by the field-object */
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+          /* call the JNI-function to retrieve the field */ 
+         return env->GetBooleanField (env, (jobject) obj, fid);
+  }
+
+  /* raise exception */
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;)B
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getByte ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetByteField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;)C
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getChar ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetCharField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetDoubleField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetFloatField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getInt ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetIntField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_reflect_Field_getLong ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetLongField (env, (jobject) obj, fid);
+  }
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;)S
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getShort ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetShortField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    set
+ * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, struct java_lang_Object* val)
+{
+  jfieldID source_fid;  /* the field containing the value to be written */
+  jfieldID fid;         /* the field to be written */
+  classinfo *c;
+  int st = (this->modifiers & ACC_STATIC); /* true if the field is static */
+
+  fid = class_findfield_approx((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+  if (val && (st || obj)) {
+
+    c = val->header.vftbl -> class;
+
+    /* The fieldid is used to set the new value, for primitive types the value
+       has to be retrieved from the wrapping object */  
+    switch (this->slot) {
+      case 'I' : {
+                  /* illegal argument specified */
+                  if (c != class_java_lang_Integer) break;
+                  /* determine the field to read the value */
+                  source_fid = env->GetFieldID(env,c,"value","I");
+                  if (!source_fid) break;
+                                  
+                  /* set the new value */
+                  if (st)
+                       /* static field */
+                       env->SetStaticIntField(env, c, fid, GetIntField(env,(jobject) val,source_fid));
+                   else
+                        /* instance field */
+                       env->SetIntField(env, (jobject) obj, fid, GetIntField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'J' : {
+                  if (c != class_java_lang_Long) break;
+                  source_fid = env->GetFieldID(env,c,"value","J");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticLongField(env, c, fid, GetLongField(env,(jobject) val,source_fid));
+                   else
+                       env->SetLongField(env, (jobject) obj, fid, GetLongField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'F' : {
+                  if (c != class_java_lang_Float) break;
+                  source_fid = env->GetFieldID(env,c,"value","F");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticFloatField(env, c, fid, GetFloatField(env,(jobject) val,source_fid));
+                   else
+                       env->SetFloatField(env, (jobject) obj, fid, GetFloatField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'D' : {
+                  if (c != class_java_lang_Double) break;
+                  source_fid = env->GetFieldID(env,c,"value","D");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticDoubleField(env, c, fid, GetDoubleField(env,(jobject) val,source_fid));
+                   else
+                       env->SetDoubleField(env, (jobject) obj, fid, GetDoubleField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'B' : {
+                  if (c != class_java_lang_Byte) break;
+                  source_fid = env->GetFieldID(env,c,"value","B");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticByteField(env, c, fid, GetByteField(env,(jobject) val,source_fid));
+                   else
+                       env->SetByteField(env, (jobject) obj, fid, GetByteField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'C' : {
+                  if (c != class_java_lang_Character) break;
+                  source_fid = env->GetFieldID(env,c,"value","C");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticCharField(env, c, fid, GetCharField(env,(jobject) val,source_fid));
+                   else
+                       env->SetCharField(env, (jobject) obj, fid, GetCharField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'S' : {
+                  if (c != class_java_lang_Short) break;
+                  source_fid = env->GetFieldID(env,c,"value","S");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticShortField(env, c, fid, GetShortField(env,(jobject) val,source_fid));
+                   else
+                       env->SetShortField(env, (jobject) obj, fid, GetShortField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'Z' : {
+                  if (c != class_java_lang_Boolean) break;
+                  source_fid = env->GetFieldID(env,c,"value","Z");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticBooleanField(env, c, fid, GetBooleanField(env,(jobject) val,source_fid));
+                   else
+                       env->SetBooleanField(env, (jobject) obj, fid, GetBooleanField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case '[' :
+      case 'L' : {
+                  if (st)
+                       env->SetStaticObjectField(env, c, fid, (jobject) val);
+                   else
+                       env->SetObjectField(env, (jobject) obj, fid, (jobject) val);
+
+                  return;
+                 }
+    }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) { 
+         env->SetBooleanField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;B)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetByteField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;C)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetCharField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;D)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, double val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetDoubleField (env, (jobject) obj, fid, val);
+         return;
+      } 
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;F)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, float val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetFloatField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetIntField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s8 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetLongField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;S)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetShortField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+
+
+
+
+
diff --git a/nat/Field.h b/nat/Field.h
new file mode 100644 (file)
index 0000000..1362e89
--- /dev/null
@@ -0,0 +1,122 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/reflect/Field */
+
+typedef struct java_lang_reflect_Field {
+   java_objectheader header;
+   s4 override;
+   struct java_lang_Class* clazz;
+   s4 slot;
+   struct java_lang_String* name;
+   struct java_lang_Class* type;
+   s4 modifiers;
+} java_lang_reflect_Field;
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    get
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Field_get (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getBoolean (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;)B
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getByte (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;)C
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getChar (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getInt (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_reflect_Field_getLong (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;)S
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getShort (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    set
+ * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, struct java_lang_Object* par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;B)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;C)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;D)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, double par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;F)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, float par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, s4 par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, s8 par2);
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;S)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort (JNIEnv *env ,  struct java_lang_reflect_Field* this , struct java_lang_Object* par1, s4 par2);
diff --git a/nat/File.h b/nat/File.h
new file mode 100644 (file)
index 0000000..d9638c4
--- /dev/null
@@ -0,0 +1,10 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/File */
+
+typedef struct java_io_File {
+   java_objectheader header;
+   struct java_lang_String* path;
+   s4 prefixLength;
+} java_io_File;
+
diff --git a/nat/FileDescriptor.c b/nat/FileDescriptor.c
new file mode 100644 (file)
index 0000000..72c64e8
--- /dev/null
@@ -0,0 +1,23 @@
+/* class: java/io/FileDescriptor */
+
+/*
+ * Class:     java/io/FileDescriptor
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileDescriptor_initIDs ( JNIEnv *env  )
+{
+    /* empty since no JNI field IDs required */
+}
+
+/*
+ * Class:     java/io/FileDescriptor
+ * Method:    sync
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileDescriptor_sync ( JNIEnv *env ,  struct java_io_FileDescriptor* this)
+{
+    if (fsync(this->fd)==-1)
+       exceptionptr = native_new_and_init (class_java_io_SyncFailedException);
+}
+
diff --git a/nat/FileDescriptor.h b/nat/FileDescriptor.h
new file mode 100644 (file)
index 0000000..dd8bae7
--- /dev/null
@@ -0,0 +1,21 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/FileDescriptor */
+
+typedef struct java_io_FileDescriptor {
+   java_objectheader header;
+   s4 fd;
+} java_io_FileDescriptor;
+
+/*
+ * Class:     java/io/FileDescriptor
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileDescriptor_initIDs (JNIEnv *env );
+/*
+ * Class:     java/io/FileDescriptor
+ * Method:    sync
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileDescriptor_sync (JNIEnv *env ,  struct java_io_FileDescriptor* this );
diff --git a/nat/FileInputStream.c b/nat/FileInputStream.c
new file mode 100644 (file)
index 0000000..0fe834c
--- /dev/null
@@ -0,0 +1,121 @@
+/* class: java/io/FileInputStream */
+
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    available
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_FileInputStream_available ( JNIEnv *env ,  struct java_io_FileInputStream* this)
+{
+       struct stat buffer;
+       s4 r1,r2;
+       
+       r1 = fstat (this->fd->fd, &buffer);
+       r2 = lseek(this->fd->fd, 0, SEEK_CUR);
+       
+       if ( (r1 >= 0) && (r2 >= 0) )  
+               return buffer.st_size - r2; 
+
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return 0;
+}
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileInputStream_close ( JNIEnv *env ,  struct java_io_FileInputStream* this)
+{
+       if (this->fd->fd >= 0) {
+               s4 r = close (this->fd->fd);
+               this->fd->fd = -1;
+               if (r < 0) 
+                       exceptionptr = native_new_and_init (class_java_io_IOException);
+       }
+}
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileInputStream_initIDs ( JNIEnv *env  )
+{
+    /* no IDs required */
+}
+
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    open
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileInputStream_open ( JNIEnv *env ,  struct java_io_FileInputStream* this, struct java_lang_String* name)
+{
+       s4 fd;
+       char *fname = javastring_tochar ((java_objectheader*)name);
+
+       if (!fname) goto fail;
+
+       fd = open (fname, O_RDONLY, 0);
+       if (fd<0) goto fail;
+       
+       threadedFileDescriptor(fd);
+
+       this->fd->fd = fd;
+       return;
+
+       fail:
+               printf("failed to open: %s\n",fname);          
+
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+               return;
+}
+
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    read
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_FileInputStream_read ( JNIEnv *env ,  struct java_io_FileInputStream* this)
+{
+       s4 r;
+       u1 buffer[1];
+       r = threadedRead (this->fd->fd, (char *) buffer, 1);    
+
+       if (r>0) return buffer[0];
+       if (r==0) return -1;
+       
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return 0;
+}
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    readBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_FileInputStream_readBytes ( JNIEnv *env ,  struct java_io_FileInputStream* this, java_bytearray* buffer, s4 start, s4 len)
+{
+       s4 ret = threadedRead (this->fd->fd, (char *) buffer->data+start, len);
+       if (ret>0) return ret;
+       if (ret==0) return -1;
+       
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return 0;
+}
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    skip
+ * Signature: (J)J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_FileInputStream_skip ( JNIEnv *env ,  struct java_io_FileInputStream* this, s8 numbytes)
+{
+       s4 ret = lseek (this->fd->fd, builtin_l2i(numbytes), SEEK_CUR);
+       if (ret>0) return builtin_i2l(ret);
+       if (ret==0) return builtin_i2l(-1);
+       
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return builtin_i2l(0);
+}
+
+
+
+
diff --git a/nat/FileInputStream.h b/nat/FileInputStream.h
new file mode 100644 (file)
index 0000000..09bc176
--- /dev/null
@@ -0,0 +1,51 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/FileInputStream */
+
+typedef struct java_io_FileInputStream {
+   java_objectheader header;
+   struct java_io_FileDescriptor* fd;
+} java_io_FileInputStream;
+
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    available
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_FileInputStream_available (JNIEnv *env ,  struct java_io_FileInputStream* this );
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileInputStream_close (JNIEnv *env ,  struct java_io_FileInputStream* this );
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileInputStream_initIDs (JNIEnv *env );
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    open
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileInputStream_open (JNIEnv *env ,  struct java_io_FileInputStream* this , struct java_lang_String* par1);
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    read
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_FileInputStream_read (JNIEnv *env ,  struct java_io_FileInputStream* this );
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    readBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_FileInputStream_readBytes (JNIEnv *env ,  struct java_io_FileInputStream* this , java_bytearray* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/io/FileInputStream
+ * Method:    skip
+ * Signature: (J)J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_FileInputStream_skip (JNIEnv *env ,  struct java_io_FileInputStream* this , s8 par1);
diff --git a/nat/FileOutputStream.c b/nat/FileOutputStream.c
new file mode 100644 (file)
index 0000000..8c0a786
--- /dev/null
@@ -0,0 +1,117 @@
+/* class: java/io/FileOutputStream */
+
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_close ( JNIEnv *env ,  struct java_io_FileOutputStream* this)
+{
+       if (this->fd->fd == fileno(stderr))  /* don't close stderr!!! -- phil. */
+               return;
+
+       if (this->fd->fd == fileno(stdout))
+               return;
+
+       if (this->fd->fd >= 0) {
+               s4 r = close (this->fd->fd);
+               this->fd->fd = -1;
+               if (r<0) 
+                       exceptionptr = native_new_and_init (class_java_io_IOException);
+               }
+}
+
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_initIDs ( JNIEnv *env  )
+{
+    /* no IDs required */
+}
+
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    open
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_open ( JNIEnv *env ,  struct java_io_FileOutputStream* this, struct java_lang_String* name)
+{
+       s4 fd;
+       char *fname = javastring_tochar ((java_objectheader*)name);
+       if (!fname) goto fail;
+       
+       fd = creat (fname, 0666);
+       if (fd<0) goto fail;
+       
+       threadedFileDescriptor(fd);
+
+       this->fd->fd = fd;
+       return;
+
+       fail:
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+               return;
+}
+
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    openAppend
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_openAppend ( JNIEnv *env ,  struct java_io_FileOutputStream* this, struct java_lang_String* name)
+{
+       s4 fd;
+       char *fname = javastring_tochar ((java_objectheader*)name);
+       if (!fname) goto fail;
+       
+       fd = open (fname, O_APPEND, 0666);
+       if (fd<0) goto fail;
+       
+       threadedFileDescriptor(fd);
+
+       this->fd->fd = fd;
+       return;
+
+       fail:
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+               return;
+}
+
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    write
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_write ( JNIEnv *env ,  struct java_io_FileOutputStream* this, s4 byte)
+{
+       u1 buffer[1];
+       s4 l;
+
+       buffer[0] = byte;
+       l = threadedWrite (this->fd->fd, (char *) buffer, 1);
+
+       if (l<1) {
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+               }
+}
+
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    writeBytes
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_writeBytes ( JNIEnv *env ,  struct java_io_FileOutputStream* this, java_bytearray* buffer, s4 start, s4 len)
+{
+       s4 o;
+
+       if (len == 0)
+               return;
+       o = threadedWrite (this->fd->fd, (char *) buffer->data+start, len);
+       if (o!=len) 
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+}
+
+
+
diff --git a/nat/FileOutputStream.h b/nat/FileOutputStream.h
new file mode 100644 (file)
index 0000000..fc50982
--- /dev/null
@@ -0,0 +1,45 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/FileOutputStream */
+
+typedef struct java_io_FileOutputStream {
+   java_objectheader header;
+   struct java_io_FileDescriptor* fd;
+} java_io_FileOutputStream;
+
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_close (JNIEnv *env ,  struct java_io_FileOutputStream* this );
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_initIDs (JNIEnv *env );
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    open
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_open (JNIEnv *env ,  struct java_io_FileOutputStream* this , struct java_lang_String* par1);
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    openAppend
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_openAppend (JNIEnv *env ,  struct java_io_FileOutputStream* this , struct java_lang_String* par1);
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    write
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_write (JNIEnv *env ,  struct java_io_FileOutputStream* this , s4 par1);
+/*
+ * Class:     java/io/FileOutputStream
+ * Method:    writeBytes
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_java_io_FileOutputStream_writeBytes (JNIEnv *env ,  struct java_io_FileOutputStream* this , java_bytearray* par1, s4 par2, s4 par3);
diff --git a/nat/FileSystem.c b/nat/FileSystem.c
new file mode 100644 (file)
index 0000000..e62a0de
--- /dev/null
@@ -0,0 +1,12 @@
+/* class: java/io/FileSystem */
+
+/*
+ * Class:     java/io/FileSystem
+ * Method:    getFileSystem
+ * Signature: ()Ljava/io/FileSystem;
+ */
+JNIEXPORT struct java_io_FileSystem* JNICALL Java_java_io_FileSystem_getFileSystem ( JNIEnv *env  )
+{
+   java_io_FileSystem*  o = (java_io_FileSystem*) native_new_and_init(class_java_io_UnixFileSystem);
+   return o;
+}
diff --git a/nat/FileSystem.h b/nat/FileSystem.h
new file mode 100644 (file)
index 0000000..1f8f356
--- /dev/null
@@ -0,0 +1,14 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/FileSystem */
+
+typedef struct java_io_FileSystem {
+   java_objectheader header;
+} java_io_FileSystem;
+
+/*
+ * Class:     java/io/FileSystem
+ * Method:    getFileSystem
+ * Signature: ()Ljava/io/FileSystem;
+ */
+JNIEXPORT struct java_io_FileSystem* JNICALL Java_java_io_FileSystem_getFileSystem (JNIEnv *env );
diff --git a/nat/Finalizer.c b/nat/Finalizer.c
new file mode 100644 (file)
index 0000000..71653fb
--- /dev/null
@@ -0,0 +1,11 @@
+/* class: java/lang/ref/Finalizer */
+
+/*
+ * Class:     java/lang/ref/Finalizer
+ * Method:    invokeFinalizeMethod
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ref_Finalizer_invokeFinalizeMethod ( JNIEnv *env ,  struct java_lang_Object* par1)
+{
+  log_text("Java_java_lang_ref_Finalizer_invokeFinalizeMethod called");
+}
diff --git a/nat/Finalizer.h b/nat/Finalizer.h
new file mode 100644 (file)
index 0000000..3d6501a
--- /dev/null
@@ -0,0 +1,19 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/ref/Finalizer */
+
+typedef struct java_lang_ref_Finalizer {
+   java_objectheader header;
+   struct java_lang_Object* referent;
+   struct java_lang_ref_ReferenceQueue* queue;
+   struct java_lang_ref_Reference* next;
+   struct java_lang_ref_Finalizer* next0;
+   struct java_lang_ref_Finalizer* prev;
+} java_lang_ref_Finalizer;
+
+/*
+ * Class:     java/lang/ref/Finalizer
+ * Method:    invokeFinalizeMethod
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_ref_Finalizer_invokeFinalizeMethod (JNIEnv *env , struct java_lang_Object* par1);
diff --git a/nat/Float.c b/nat/Float.c
new file mode 100644 (file)
index 0000000..01585d3
--- /dev/null
@@ -0,0 +1,27 @@
+/* class: java/lang/Float */
+
+/*
+ * Class:     java/lang/Float
+ * Method:    floatToIntBits
+ * Signature: (F)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Float_floatToIntBits ( JNIEnv *env ,  float par1)
+{
+       s4 i;
+       float f = par1;
+       memcpy ((u1*) &i, (u1*) &f, 4);
+       return i;
+}
+
+/*
+ * Class:     java/lang/Float
+ * Method:    intBitsToFloat
+ * Signature: (I)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_Float_intBitsToFloat ( JNIEnv *env ,  s4 par1)
+{
+       s4 i = par1;
+       float f;
+       memcpy ((u1*) &f, (u1*) &i, 4);
+       return f;
+}
diff --git a/nat/Float.h b/nat/Float.h
new file mode 100644 (file)
index 0000000..cb3c2f0
--- /dev/null
@@ -0,0 +1,21 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Float */
+
+typedef struct java_lang_Float {
+   java_objectheader header;
+   float value;
+} java_lang_Float;
+
+/*
+ * Class:     java/lang/Float
+ * Method:    floatToIntBits
+ * Signature: (F)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Float_floatToIntBits (JNIEnv *env , float par1);
+/*
+ * Class:     java/lang/Float
+ * Method:    intBitsToFloat
+ * Signature: (I)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_Float_intBitsToFloat (JNIEnv *env , s4 par1);
diff --git a/nat/InetAddress.c b/nat/InetAddress.c
new file mode 100644 (file)
index 0000000..0cb1690
--- /dev/null
@@ -0,0 +1,14 @@
+/* class: java/net/InetAddress */
+
+/*
+ * Class:     java/net/InetAddress
+ * Method:    init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_net_InetAddress_init (JNIEnv *env )
+{
+  log_text("Java_java_net_InetAddress_init called");
+
+}
+
+
diff --git a/nat/InetAddress.h b/nat/InetAddress.h
new file mode 100644 (file)
index 0000000..01aa8f0
--- /dev/null
@@ -0,0 +1,17 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/net/InetAddress */
+
+typedef struct java_net_InetAddress {
+   java_objectheader header;
+   struct java_lang_String* hostName;
+   s4 address;
+   s4 family;
+} java_net_InetAddress;
+
+/*
+ * Class:     java/net/InetAddress
+ * Method:    init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_net_InetAddress_init (JNIEnv *env );
diff --git a/nat/InetAddressImpl.c b/nat/InetAddressImpl.c
new file mode 100644 (file)
index 0000000..05614b6
--- /dev/null
@@ -0,0 +1,52 @@
+/* class: java/net/InetAddressImpl */
+
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    getHostByAddr
+ * Signature: (I)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_net_InetAddressImpl_getHostByAddr (JNIEnv *env ,  struct java_net_InetAddressImpl* this , s4 par1)
+{
+  log_text("Java_java_net_InetAddressImpl_getHostByAddr called");
+}
+
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    getInetFamily
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_net_InetAddressImpl_getInetFamily (JNIEnv *env ,  struct java_net_InetAddressImpl* this )
+{
+  log_text("Java_java_net_InetAddressImpl_getInetFamily called");
+}
+
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    getLocalHostName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_net_InetAddressImpl_getLocalHostName (JNIEnv *env ,  struct java_net_InetAddressImpl* this )
+{
+  log_text("Java_java_net_InetAddressImpl_getLocalHostName called");
+}
+
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    lookupAllHostAddr
+ * Signature: (Ljava/lang/String;)[[B
+ */
+JNIEXPORT java_arrayarray* JNICALL Java_java_net_InetAddressImpl_lookupAllHostAddr (JNIEnv *env ,  struct java_net_InetAddressImpl* this , struct java_lang_String* par1)
+{
+  log_text("Java_java_net_InetAddressImpl_lookupAllHostAddr called");
+}
+
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    makeAnyLocalAddress
+ * Signature: (Ljava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_java_net_InetAddressImpl_makeAnyLocalAddress (JNIEnv *env ,  struct java_net_InetAddressImpl* this , struct java_net_InetAddress* par1)
+{
+  log_text("Java_java_net_InetAddressImpl_makeAnyLocalAddress called");
+}
+
diff --git a/nat/InetAddressImpl.h b/nat/InetAddressImpl.h
new file mode 100644 (file)
index 0000000..5ceb686
--- /dev/null
@@ -0,0 +1,38 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/net/InetAddressImpl */
+
+typedef struct java_net_InetAddressImpl {
+   java_objectheader header;
+} java_net_InetAddressImpl;
+
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    getHostByAddr
+ * Signature: (I)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_net_InetAddressImpl_getHostByAddr (JNIEnv *env ,  struct java_net_InetAddressImpl* this , s4 par1);
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    getInetFamily
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_net_InetAddressImpl_getInetFamily (JNIEnv *env ,  struct java_net_InetAddressImpl* this );
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    getLocalHostName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_net_InetAddressImpl_getLocalHostName (JNIEnv *env ,  struct java_net_InetAddressImpl* this );
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    lookupAllHostAddr
+ * Signature: (Ljava/lang/String;)[[B
+ */
+JNIEXPORT java_arrayarray* JNICALL Java_java_net_InetAddressImpl_lookupAllHostAddr (JNIEnv *env ,  struct java_net_InetAddressImpl* this , struct java_lang_String* par1);
+/*
+ * Class:     java/net/InetAddressImpl
+ * Method:    makeAnyLocalAddress
+ * Signature: (Ljava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_java_net_InetAddressImpl_makeAnyLocalAddress (JNIEnv *env ,  struct java_net_InetAddressImpl* this , struct java_net_InetAddress* par1);
diff --git a/nat/Inflater.c b/nat/Inflater.c
new file mode 100644 (file)
index 0000000..830fed2
--- /dev/null
@@ -0,0 +1,84 @@
+/* class: java/util/zip/Inflater */
+
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    end
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_end ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Inflater_end  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    getAdler
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_getAdler ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Inflater_getAdler  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    getTotalIn
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_getTotalIn ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Inflater_getTotalIn  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    getTotalOut
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_getTotalOut ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Inflater_getTotalOut  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    inflateBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_inflateBytes ( JNIEnv *env ,  struct java_util_zip_Inflater* this, java_bytearray* par1, s4 par2, s4 par3)
+{
+  log_text("Java_java_util_zip_Inflater_inflateBytes  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    init
+ * Signature: (Z)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_Inflater_init ( JNIEnv *env ,  s4 par1)
+{
+  log_text("Java_java_util_zip_Inflater_init  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_initIDs ( JNIEnv *env  )
+{
+  if (verbose)
+    log_text("Java_java_util_zip_Inflater_initIDs  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    reset
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_reset ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_Inflater_reset  called");
+}
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    setDictionary
+ * Signature: (J[BII)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_setDictionary ( JNIEnv *env ,  s8 par1, java_bytearray* par2, s4 par3, s4 par4)
+{
+  log_text("Java_java_util_zip_Inflater_setDictionary  called");
+}
diff --git a/nat/Inflater.h b/nat/Inflater.h
new file mode 100644 (file)
index 0000000..019d873
--- /dev/null
@@ -0,0 +1,68 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/zip/Inflater */
+
+typedef struct java_util_zip_Inflater {
+   java_objectheader header;
+   s8 strm;
+   java_bytearray* buf;
+   s4 off;
+   s4 len;
+   s4 finished;
+   s4 needDict;
+} java_util_zip_Inflater;
+
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    end
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_end (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    getAdler
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_getAdler (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    getTotalIn
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_getTotalIn (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    getTotalOut
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_getTotalOut (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    inflateBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_Inflater_inflateBytes (JNIEnv *env ,  struct java_util_zip_Inflater* this , java_bytearray* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    init
+ * Signature: (Z)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_Inflater_init (JNIEnv *env , s4 par1);
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_initIDs (JNIEnv *env );
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    reset
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_reset (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/Inflater
+ * Method:    setDictionary
+ * Signature: (J[BII)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_Inflater_setDictionary (JNIEnv *env , s8 par1, java_bytearray* par2, s4 par3, s4 par4);
diff --git a/nat/InputStream.h b/nat/InputStream.h
new file mode 100644 (file)
index 0000000..a2b2478
--- /dev/null
@@ -0,0 +1,8 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/InputStream */
+
+typedef struct java_io_InputStream {
+   java_objectheader header;
+} java_io_InputStream;
+
diff --git a/nat/JarFile.c b/nat/JarFile.c
new file mode 100644 (file)
index 0000000..5256717
--- /dev/null
@@ -0,0 +1,11 @@
+/* class: java/util/jar/JarFile */
+
+/*
+ * Class:     java/util/jar/JarFile
+ * Method:    getMetaInfEntryNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_util_jar_JarFile_getMetaInfEntryNames ( JNIEnv *env ,  struct java_util_jar_JarFile* this)
+{
+  log_text("Java_java_util_jar_JarFile_getMetaInfEntryNames  called");
+}
diff --git a/nat/JarFile.h b/nat/JarFile.h
new file mode 100644 (file)
index 0000000..5222e66
--- /dev/null
@@ -0,0 +1,24 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/jar/JarFile */
+
+typedef struct java_util_jar_JarFile {
+   java_objectheader header;
+   s8 jzfile;
+   struct java_lang_String* name;
+   s4 total;
+   struct java_util_Vector* inflaters;
+   struct java_util_jar_Manifest* man;
+   struct java_util_jar_JarEntry* manEntry;
+   s4 manLoaded;
+   struct java_util_jar_JarVerifier* jv;
+   s4 jvInitialized;
+   s4 verify;
+} java_util_jar_JarFile;
+
+/*
+ * Class:     java/util/jar/JarFile
+ * Method:    getMetaInfEntryNames
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_util_jar_JarFile_getMetaInfEntryNames (JNIEnv *env ,  struct java_util_jar_JarFile* this );
index 1ecb5bf79f278e6563aad6dcaa9fa82d022e663c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-EXTRA_DIST = io.c lang.c util.c
index 6f50fff21c4e9623212eb0a842db852fa333c4c2..10f318f6f0e541936649fa1f05b45d4c362e9627 100644 (file)
@@ -70,8 +70,6 @@ RANLIB = @RANLIB@
 SYSDEP_DIR = @SYSDEP_DIR@
 THREAD_OBJ = @THREAD_OBJ@
 VERSION = @VERSION@
-
-EXTRA_DIST = io.c lang.c util.c
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = ../config.h
 CONFIG_CLEAN_FILES = 
diff --git a/nat/Math.c b/nat/Math.c
new file mode 100644 (file)
index 0000000..81e876c
--- /dev/null
@@ -0,0 +1,174 @@
+/* class: java/lang/Math */
+
+#define DBL_NAN    (*((double*) (&dbl_nan)))
+
+static u8 dbl_nan    = 0xffffffffffffffffL ;
+
+/*
+ * Class:     java/lang/Math
+ * Method:    IEEEremainder
+ * Signature: (DD)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_IEEEremainder ( JNIEnv *env ,  double a, double b)
+{
+       double d;
+       if (finite(a) && finite(b)) {
+               d = a / b;
+               if (finite(d))
+                       return a - floor(d) * b;
+               return DBL_NAN;
+               }
+       if (isnan(b))
+               return DBL_NAN;
+       if (finite(a))
+               return a;
+       return DBL_NAN;
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    acos
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_acos ( JNIEnv *env ,  double par1)
+{
+       return acos(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    asin
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_asin ( JNIEnv *env ,  double par1)
+{
+       return asin(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    atan
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_atan ( JNIEnv *env ,  double par1)
+{
+       return atan(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    atan2
+ * Signature: (DD)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_atan2 ( JNIEnv *env ,  double par1, double par2)
+{
+       return atan2(par1,par2);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    ceil
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_ceil ( JNIEnv *env ,  double par1)
+{
+       return ceil(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    cos
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_cos ( JNIEnv *env ,  double par1)
+{
+       return cos(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    exp
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_exp ( JNIEnv *env ,  double par1)
+{
+       return exp(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    floor
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_floor ( JNIEnv *env ,  double par1)
+{
+       return floor(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    log
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_log ( JNIEnv *env ,  double par1)
+{
+       if (par1<0.0) {
+               exceptionptr = proto_java_lang_ArithmeticException;
+               return 0.0;
+               }
+       return log(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    pow
+ * Signature: (DD)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_pow ( JNIEnv *env ,  double par1, double par2)
+{
+       return pow(par1,par2);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    rint
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_rint ( JNIEnv *env ,  double par1)
+{
+       return rint(par1); /* phil, 1998/12/12 */
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    sin
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_sin ( JNIEnv *env ,  double par1)
+{
+       return sin(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    sqrt
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_sqrt ( JNIEnv *env ,  double par1)
+{
+       if (par1<0.0) {
+               exceptionptr = proto_java_lang_ArithmeticException;
+               return 0.0;
+               }
+       return sqrt(par1);
+}
+
+/*
+ * Class:     java/lang/Math
+ * Method:    tan
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_tan ( JNIEnv *env ,  double par1)
+{
+       return tan(par1);
+}
diff --git a/nat/Math.h b/nat/Math.h
new file mode 100644 (file)
index 0000000..601d3db
--- /dev/null
@@ -0,0 +1,98 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Math */
+
+typedef struct java_lang_Math {
+   java_objectheader header;
+} java_lang_Math;
+
+/*
+ * Class:     java/lang/Math
+ * Method:    IEEEremainder
+ * Signature: (DD)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_IEEEremainder (JNIEnv *env , double par1, double par2);
+/*
+ * Class:     java/lang/Math
+ * Method:    acos
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_acos (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    asin
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_asin (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    atan
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_atan (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    atan2
+ * Signature: (DD)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_atan2 (JNIEnv *env , double par1, double par2);
+/*
+ * Class:     java/lang/Math
+ * Method:    ceil
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_ceil (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    cos
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_cos (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    exp
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_exp (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    floor
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_floor (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    log
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_log (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    pow
+ * Signature: (DD)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_pow (JNIEnv *env , double par1, double par2);
+/*
+ * Class:     java/lang/Math
+ * Method:    rint
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_rint (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    sin
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_sin (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    sqrt
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_sqrt (JNIEnv *env , double par1);
+/*
+ * Class:     java/lang/Math
+ * Method:    tan
+ * Signature: (D)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_Math_tan (JNIEnv *env , double par1);
diff --git a/nat/Method.c b/nat/Method.c
new file mode 100644 (file)
index 0000000..44c7815
--- /dev/null
@@ -0,0 +1,11 @@
+/* class: java/lang/reflect/Method */
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    invoke
+ * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_invoke ( JNIEnv *env ,  struct java_lang_reflect_Method* this, struct java_lang_Object* par1, java_objectarray* par2)
+{
+  log_text("Java_java_lang_reflect_Method_invoke called");
+}
diff --git a/nat/Method.h b/nat/Method.h
new file mode 100644 (file)
index 0000000..aa7cfa6
--- /dev/null
@@ -0,0 +1,22 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/reflect/Method */
+
+typedef struct java_lang_reflect_Method {
+   java_objectheader header;
+   s4 override;
+   struct java_lang_Class* clazz;
+   s4 slot;
+   struct java_lang_String* name;
+   struct java_lang_Class* returnType;
+   java_objectarray* parameterTypes;
+   java_objectarray* exceptionTypes;
+   s4 modifiers;
+} java_lang_reflect_Method;
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    invoke
+ * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_invoke (JNIEnv *env ,  struct java_lang_reflect_Method* this , struct java_lang_Object* par1, java_objectarray* par2);
diff --git a/nat/Modifier.h b/nat/Modifier.h
new file mode 100644 (file)
index 0000000..618edbd
--- /dev/null
@@ -0,0 +1,8 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/reflect/Modifier */
+
+typedef struct java_lang_reflect_Modifier {
+   java_objectheader header;
+} java_lang_reflect_Modifier;
+
diff --git a/nat/Object.c b/nat/Object.c
new file mode 100644 (file)
index 0000000..78a46d1
--- /dev/null
@@ -0,0 +1,157 @@
+/* class: java/lang/Object */
+
+/*
+ * Class:     java/lang/Object
+ * Method:    clone
+ * Signature: ()Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_Object_clone ( JNIEnv *env ,  struct java_lang_Object* this)
+{
+       classinfo *c;
+       java_lang_Object *new;
+
+       if (((java_objectheader*)this)->vftbl->class == class_array)
+         {
+           static u4 multiplicator[10];
+           static int is_initialized = 0;
+
+           java_arrayheader *array = (java_arrayheader*)this;
+           u4 size;
+
+           if (!is_initialized)
+             {
+               multiplicator[ARRAYTYPE_INT] = sizeof(s4);
+               multiplicator[ARRAYTYPE_LONG] = sizeof(s8);
+               multiplicator[ARRAYTYPE_FLOAT] = sizeof(float);
+               multiplicator[ARRAYTYPE_DOUBLE] = sizeof(double);
+               multiplicator[ARRAYTYPE_BYTE] = sizeof(s1);
+               multiplicator[ARRAYTYPE_CHAR] = sizeof(u2);
+               multiplicator[ARRAYTYPE_SHORT] = sizeof(s2);
+               multiplicator[ARRAYTYPE_BOOLEAN] = sizeof(u1);
+               multiplicator[ARRAYTYPE_OBJECT] = sizeof(void*);
+               multiplicator[ARRAYTYPE_ARRAY] = sizeof(void*);
+               is_initialized = 1;
+             }
+
+           size = sizeof(java_arrayheader)
+             + array->size * multiplicator[array->arraytype];
+
+           if (array->arraytype==ARRAYTYPE_OBJECT || array->arraytype==ARRAYTYPE_OBJECT)
+               size+=sizeof(void*);
+
+           new = (java_lang_Object*)heap_allocate(size, false, NULL);
+           memcpy(new, this, size);
+
+           return new;
+         }
+       else
+         {
+           if (! builtin_instanceof ((java_objectheader*) this, class_java_lang_Cloneable) ) {
+               exceptionptr = native_new_and_init (class_java_lang_CloneNotSupportedException);
+               return NULL;
+               }
+       
+       c = this -> header.vftbl -> class;
+       new = (java_lang_Object*) builtin_new (c);
+       if (!new) {
+               exceptionptr = proto_java_lang_OutOfMemoryError;
+               return NULL;
+               }
+
+           memcpy (new, this, c->instancesize);
+           return new;
+         }
+}
+
+/*
+ * Class:     java/lang/Object
+ * Method:    getClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Object_getClass ( JNIEnv *env ,  struct java_lang_Object* this)
+{
+        classinfo *c = this->header.vftbl -> class;
+       use_class_as_object (c);
+       return (java_lang_Class*) c;
+}
+
+/*
+ * Class:     java/lang/Object
+ * Method:    hashCode
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Object_hashCode ( JNIEnv *env ,  struct java_lang_Object* this)
+{
+       return ((char*) this) - ((char*) 0);    
+}
+
+/*
+ * Class:     java/lang/Object
+ * Method:    notify
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_notify ( JNIEnv *env ,  struct java_lang_Object* this)
+{
+       if (runverbose)
+               log_text ("java_lang_Object_notify called");
+
+        #ifdef USE_THREADS
+                signal_cond_for_object(&this->header);
+        #endif
+}
+
+/*
+ * Class:     java/lang/Object
+ * Method:    notifyAll
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll ( JNIEnv *env ,  struct java_lang_Object* this)
+{
+       if (runverbose)
+               log_text ("java_lang_Object_notifyAll called");
+
+       #ifdef USE_THREADS
+               broadcast_cond_for_object(&this->header);
+       #endif
+}
+
+/*
+ * Class:     java/lang/Object
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_registerNatives ( JNIEnv *env  )
+{
+    /* empty */
+}
+
+/*
+ * Class:     java/lang/Object
+ * Method:    wait
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_wait ( JNIEnv *env ,  struct java_lang_Object* this, s8 time)
+{
+       if (runverbose)
+               log_text ("java_lang_Object_wait called");
+
+       #ifdef USE_THREADS
+               wait_cond_for_object(&this->header, time);
+       #endif
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nat/Object.h b/nat/Object.h
new file mode 100644 (file)
index 0000000..fc1746b
--- /dev/null
@@ -0,0 +1,50 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Object */
+
+typedef struct java_lang_Object {
+   java_objectheader header;
+} java_lang_Object;
+
+/*
+ * Class:     java/lang/Object
+ * Method:    clone
+ * Signature: ()Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_Object_clone (JNIEnv *env ,  struct java_lang_Object* this );
+/*
+ * Class:     java/lang/Object
+ * Method:    getClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_Object_getClass (JNIEnv *env ,  struct java_lang_Object* this );
+/*
+ * Class:     java/lang/Object
+ * Method:    hashCode
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Object_hashCode (JNIEnv *env ,  struct java_lang_Object* this );
+/*
+ * Class:     java/lang/Object
+ * Method:    notify
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_notify (JNIEnv *env ,  struct java_lang_Object* this );
+/*
+ * Class:     java/lang/Object
+ * Method:    notifyAll
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll (JNIEnv *env ,  struct java_lang_Object* this );
+/*
+ * Class:     java/lang/Object
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_registerNatives (JNIEnv *env );
+/*
+ * Class:     java/lang/Object
+ * Method:    wait
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Object_wait (JNIEnv *env ,  struct java_lang_Object* this , s8 par1);
diff --git a/nat/ObjectInputStream.c b/nat/ObjectInputStream.c
new file mode 100644 (file)
index 0000000..d29c807
--- /dev/null
@@ -0,0 +1,34 @@
+/* class: java/io/ObjectInputStream */
+
+/*
+ * Class:     java/io/ObjectInputStream
+ * Method:    allocateNewArray
+ * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_io_ObjectInputStream_allocateNewArray ( JNIEnv *env ,  struct java_lang_Class* componenttype, s4 size)
+{
+  return Java_java_lang_reflect_Array_newArray(env, componenttype, size);
+}
+
+/*
+ * Class:     java/io/ObjectInputStream
+ * Method:    allocateNewObject
+ * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_io_ObjectInputStream_allocateNewObject ( JNIEnv *env ,  struct java_lang_Class* aclass, struct java_lang_Class* initclass)
+{
+  return Java_java_lang_Class_newInstance0(env, aclass);
+}
+
+/*
+ * Class:     java/io/ObjectInputStream
+ * Method:    loadClass0
+ * Signature: (Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_io_ObjectInputStream_loadClass0 ( JNIEnv *env ,  struct java_io_ObjectInputStream* this, struct java_lang_Class* clazz, struct java_lang_String* name)
+{
+  /* class paramter ignored, since there is only the system-classloader */
+
+  return Java_java_lang_Class_forName0(env, name, 0, SystemClassLoader);
+}
+
diff --git a/nat/ObjectInputStream.h b/nat/ObjectInputStream.h
new file mode 100644 (file)
index 0000000..0608a82
--- /dev/null
@@ -0,0 +1,49 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/ObjectInputStream */
+
+typedef struct java_io_ObjectInputStream {
+   java_objectheader header;
+   struct java_io_InputStream* in;
+   s4 count;
+   s4 blockDataMode;
+   java_bytearray* buffer;
+   struct java_io_DataInputStream* dis;
+   struct java_io_IOException* abortIOException;
+   struct java_lang_ClassNotFoundException* abortClassNotFoundException;
+   struct java_lang_Object* currentObject;
+   struct java_io_ObjectStreamClass* currentClassDesc;
+   struct java_lang_Class* currentClass;
+   struct java_lang_Object* currentGetFields;
+   java_bytearray* data;
+   java_objectarray* classdesc;
+   java_objectarray* classes;
+   s4 spClass;
+   struct java_util_ArrayList* wireHandle2Object;
+   s4 nextWireOffset;
+   struct java_util_ArrayList* callbacks;
+   s4 recursionDepth;
+   s4 currCode;
+   s4 enableResolve;
+   s4 enableSubclassImplementation;
+   java_objectarray* readObjectArglist;
+} java_io_ObjectInputStream;
+
+/*
+ * Class:     java/io/ObjectInputStream
+ * Method:    allocateNewArray
+ * Signature: (Ljava/lang/Class;I)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_io_ObjectInputStream_allocateNewArray (JNIEnv *env , struct java_lang_Class* par1, s4 par2);
+/*
+ * Class:     java/io/ObjectInputStream
+ * Method:    allocateNewObject
+ * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_io_ObjectInputStream_allocateNewObject (JNIEnv *env , struct java_lang_Class* par1, struct java_lang_Class* par2);
+/*
+ * Class:     java/io/ObjectInputStream
+ * Method:    loadClass0
+ * Signature: (Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_io_ObjectInputStream_loadClass0 (JNIEnv *env ,  struct java_io_ObjectInputStream* this , struct java_lang_Class* par1, struct java_lang_String* par2);
diff --git a/nat/ObjectStreamClass.c b/nat/ObjectStreamClass.c
new file mode 100644 (file)
index 0000000..24a993a
--- /dev/null
@@ -0,0 +1,18 @@
+/* class: java/io/ObjectStreamClass */
+/*
+ * Class:     java/io/ObjectStreamClass
+ * Method:    hasStaticInitializer
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_ObjectStreamClass_hasStaticInitializer ( JNIEnv *env ,  struct java_lang_Class* clazz)
+{
+    methodinfo *m;
+
+    m = class_findmethod ((classinfo*) clazz, 
+                         utf_new_char ("<clinit>"), 
+                         utf_new_char ("()V"));
+    if (m) return true;
+    return false;
+}
diff --git a/nat/ObjectStreamClass.h b/nat/ObjectStreamClass.h
new file mode 100644 (file)
index 0000000..dc4ed78
--- /dev/null
@@ -0,0 +1,31 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/ObjectStreamClass */
+
+typedef struct java_io_ObjectStreamClass {
+   java_objectheader header;
+   struct java_lang_String* name;
+   struct java_io_ObjectStreamClass* superclass;
+   s4 serializable;
+   s4 externalizable;
+   java_objectarray* fields;
+   struct java_lang_Class* ofClass;
+   s8 suid;
+   s4 primBytes;
+   s4 objFields;
+   s4 hasWriteObjectMethod;
+   s4 hasExternalizableBlockData;
+   struct java_lang_reflect_Method* writeObjectMethod;
+   struct java_lang_reflect_Method* readObjectMethod;
+   struct java_lang_reflect_Method* readResolveMethod;
+   struct java_lang_reflect_Method* writeReplaceMethod;
+   struct java_io_ObjectStreamClass* localClassDesc;
+   s4 disableInstanceDeserialization;
+} java_io_ObjectStreamClass;
+
+/*
+ * Class:     java/io/ObjectStreamClass
+ * Method:    hasStaticInitializer
+ * Signature: (Ljava/lang/Class;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_ObjectStreamClass_hasStaticInitializer (JNIEnv *env , struct java_lang_Class* par1);
diff --git a/nat/Package.c b/nat/Package.c
new file mode 100644 (file)
index 0000000..554cb72
--- /dev/null
@@ -0,0 +1,21 @@
+/* class: java/lang/Package */
+
+/*
+ * Class:     java/lang/Package
+ * Method:    getSystemPackage0
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_Package_getSystemPackage0 ( JNIEnv *env ,  struct java_lang_String* par1)
+{
+  log_text("Java_java_lang_Package_getSystemPackage0  called");
+}
+
+/*
+ * Class:     java/lang/Package
+ * Method:    getSystemPackages0
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Package_getSystemPackages0 ( JNIEnv *env  )
+{
+  log_text("Java_java_lang_Package_getSystemPackages0  called");
+}
diff --git a/nat/Package.h b/nat/Package.h
new file mode 100644 (file)
index 0000000..b1defa9
--- /dev/null
@@ -0,0 +1,28 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Package */
+
+typedef struct java_lang_Package {
+   java_objectheader header;
+   struct java_lang_String* pkgName;
+   struct java_lang_String* specTitle;
+   struct java_lang_String* specVersion;
+   struct java_lang_String* specVendor;
+   struct java_lang_String* implTitle;
+   struct java_lang_String* implVersion;
+   struct java_lang_String* implVendor;
+   struct java_net_URL* sealBase;
+} java_lang_Package;
+
+/*
+ * Class:     java/lang/Package
+ * Method:    getSystemPackage0
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_Package_getSystemPackage0 (JNIEnv *env , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/Package
+ * Method:    getSystemPackages0
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_Package_getSystemPackages0 (JNIEnv *env );
diff --git a/nat/PrintStream.h b/nat/PrintStream.h
new file mode 100644 (file)
index 0000000..5affe50
--- /dev/null
@@ -0,0 +1,14 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/PrintStream */
+
+typedef struct java_io_PrintStream {
+   java_objectheader header;
+   struct java_io_OutputStream* out;
+   s4 autoFlush;
+   s4 trouble;
+   struct java_io_BufferedWriter* textOut;
+   struct java_io_OutputStreamWriter* charOut;
+   s4 closing;
+} java_io_PrintStream;
+
diff --git a/nat/PrivilegedAction.h b/nat/PrivilegedAction.h
new file mode 100644 (file)
index 0000000..6a2373b
--- /dev/null
@@ -0,0 +1,8 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/security/PrivilegedAction */
+
+typedef struct java_security_PrivilegedAction {
+   java_objectheader header;
+} java_security_PrivilegedAction;
+
diff --git a/nat/PrivilegedActionException.h b/nat/PrivilegedActionException.h
new file mode 100644 (file)
index 0000000..6187b3b
--- /dev/null
@@ -0,0 +1,11 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/security/PrivilegedActionException */
+
+typedef struct java_security_PrivilegedActionException {
+   java_objectheader header;
+   struct java_lang_Object* backtrace;
+   struct java_lang_String* detailMessage;
+   struct java_lang_Exception* exception;
+} java_security_PrivilegedActionException;
+
diff --git a/nat/PrivilegedExceptionAction.h b/nat/PrivilegedExceptionAction.h
new file mode 100644 (file)
index 0000000..db01cbb
--- /dev/null
@@ -0,0 +1,8 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/security/PrivilegedExceptionAction */
+
+typedef struct java_security_PrivilegedExceptionAction {
+   java_objectheader header;
+} java_security_PrivilegedExceptionAction;
+
diff --git a/nat/Properties.h b/nat/Properties.h
new file mode 100644 (file)
index 0000000..080a489
--- /dev/null
@@ -0,0 +1,17 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/Properties */
+
+typedef struct java_util_Properties {
+   java_objectheader header;
+   java_objectarray* table;
+   s4 count;
+   s4 threshold;
+   float loadFactor;
+   s4 modCount;
+   struct java_util_Set* keySet;
+   struct java_util_Set* entrySet;
+   struct java_util_Collection* values;
+   struct java_util_Properties* defaults;
+} java_util_Properties;
+
diff --git a/nat/RandomAccessFile.c b/nat/RandomAccessFile.c
new file mode 100644 (file)
index 0000000..1597a55
--- /dev/null
@@ -0,0 +1,170 @@
+/* class: java/io/RandomAccessFile */
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_close ( JNIEnv *env ,  struct java_io_RandomAccessFile* this)
+{
+  if (this->fd->fd >= 0) {
+    s4 r = close (this->fd->fd);
+               this->fd->fd = -1;
+               if (r<0) 
+                       exceptionptr = native_new_and_init (class_java_io_IOException);
+               }
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    getFilePointer
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_RandomAccessFile_getFilePointer ( JNIEnv *env ,  struct java_io_RandomAccessFile* this)
+{
+       s4 p = lseek (this->fd->fd, 0, SEEK_CUR);
+       if (p>=0) return builtin_i2l(p);
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return builtin_i2l(0);
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_initIDs ( JNIEnv *env  )
+{
+    /* no IDs required */
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    length
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_RandomAccessFile_length ( JNIEnv *env ,  struct java_io_RandomAccessFile* this)
+{
+       struct stat buffer;
+       s4 r = fstat(this->fd->fd, &buffer);
+       if (r>=0) return builtin_i2l(buffer.st_size);
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return builtin_i2l(0);
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    open
+ * Signature: (Ljava/lang/String;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_open ( JNIEnv *env ,  struct java_io_RandomAccessFile* this, struct java_lang_String* name, s4 writeable)
+{
+       s4 fd;
+       char *fname = javastring_tochar ((java_objectheader*)name);
+       
+       if (writeable) fd = open (fname, O_RDWR, 0);
+       else           fd = open (fname, O_RDONLY, 0);
+       if (fd==-1) goto fail;
+
+       threadedFileDescriptor(fd);
+       
+       this->fd->fd = fd;
+       return;
+
+       fail:
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+               return;
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    read
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_RandomAccessFile_read ( JNIEnv *env ,  struct java_io_RandomAccessFile* this)
+{
+       s4 r;
+       u1 buffer[1];
+       r = threadedRead (this->fd->fd, (char *) buffer, 1);    
+       if (r>0) return buffer[1];
+       if (r==0) return -1;
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return 0;
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    readBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_RandomAccessFile_readBytes ( JNIEnv *env ,  struct java_io_RandomAccessFile* this, java_bytearray* buffer, s4 start, s4 len)
+{
+       s4 r = threadedRead (this->fd->fd, (char *) buffer->data+start, len);
+       if (r>0) return r;
+       if (r==0) return -1;
+       exceptionptr = native_new_and_init (class_java_io_IOException);
+       return 0;
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    seek
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_seek ( JNIEnv *env ,  struct java_io_RandomAccessFile* this, s8 offset)
+{
+       s4 p = lseek (this->fd->fd, builtin_l2i(offset), SEEK_SET); 
+       if (p<0) {
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+               }
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    setLength
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_setLength ( JNIEnv *env ,  struct java_io_RandomAccessFile* this, s8 length)
+{
+  if (ftruncate(this->fd->fd, length)<0)
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    write
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_write ( JNIEnv *env ,  struct java_io_RandomAccessFile* this, s4 byte)
+{
+       u1 buffer[1];
+       int r;
+       buffer[1] = byte;
+       r = write (this->fd->fd, buffer, 1);
+       if (r<0) {
+               exceptionptr = native_new_and_init (class_java_io_IOException);
+               }
+}
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    writeBytes
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_writeBytes ( JNIEnv *env ,  struct java_io_RandomAccessFile* this, java_bytearray* buffer, s4 start, s4 len)
+{
+       s4 o;
+       if (len == 0)
+               return;
+       o = threadedWrite (this->fd->fd, (char *) buffer->data+start, len);
+       if (o!=len) exceptionptr = native_new_and_init (class_java_io_IOException);
+}
+
+
+
+
+
+
+
+
+
diff --git a/nat/RandomAccessFile.h b/nat/RandomAccessFile.h
new file mode 100644 (file)
index 0000000..ebb5f48
--- /dev/null
@@ -0,0 +1,75 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/RandomAccessFile */
+
+typedef struct java_io_RandomAccessFile {
+   java_objectheader header;
+   struct java_io_FileDescriptor* fd;
+} java_io_RandomAccessFile;
+
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_close (JNIEnv *env ,  struct java_io_RandomAccessFile* this );
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    getFilePointer
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_RandomAccessFile_getFilePointer (JNIEnv *env ,  struct java_io_RandomAccessFile* this );
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_initIDs (JNIEnv *env );
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    length
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_RandomAccessFile_length (JNIEnv *env ,  struct java_io_RandomAccessFile* this );
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    open
+ * Signature: (Ljava/lang/String;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_open (JNIEnv *env ,  struct java_io_RandomAccessFile* this , struct java_lang_String* par1, s4 par2);
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    read
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_RandomAccessFile_read (JNIEnv *env ,  struct java_io_RandomAccessFile* this );
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    readBytes
+ * Signature: ([BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_RandomAccessFile_readBytes (JNIEnv *env ,  struct java_io_RandomAccessFile* this , java_bytearray* par1, s4 par2, s4 par3);
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    seek
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_seek (JNIEnv *env ,  struct java_io_RandomAccessFile* this , s8 par1);
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    setLength
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_setLength (JNIEnv *env ,  struct java_io_RandomAccessFile* this , s8 par1);
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    write
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_write (JNIEnv *env ,  struct java_io_RandomAccessFile* this , s4 par1);
+/*
+ * Class:     java/io/RandomAccessFile
+ * Method:    writeBytes
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_java_io_RandomAccessFile_writeBytes (JNIEnv *env ,  struct java_io_RandomAccessFile* this , java_bytearray* par1, s4 par2, s4 par3);
diff --git a/nat/ResourceBundle.c b/nat/ResourceBundle.c
new file mode 100644 (file)
index 0000000..095fc3b
--- /dev/null
@@ -0,0 +1,19 @@
+/* class: java/util/ResourceBundle */
+
+/*
+ * Class:     java/util/ResourceBundle
+ * Method:    getClassContext
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_util_ResourceBundle_getClassContext ( JNIEnv *env  )
+{
+    /* not implemented */
+
+    java_objectarray *array_class;
+    array_class = builtin_anewarray(3, class_java_lang_Class);
+    use_class_as_object(class_java_lang_Class);
+    array_class->data[0] = (java_objectheader*) class_java_lang_Class;
+    array_class->data[1] = (java_objectheader*) class_java_lang_Class;
+    array_class->data[2] = (java_objectheader*) class_java_lang_Class;
+    return array_class;
+}
diff --git a/nat/ResourceBundle.h b/nat/ResourceBundle.h
new file mode 100644 (file)
index 0000000..73d026c
--- /dev/null
@@ -0,0 +1,15 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/ResourceBundle */
+
+typedef struct java_util_ResourceBundle {
+   java_objectheader header;
+   struct java_util_ResourceBundle* parent;
+} java_util_ResourceBundle;
+
+/*
+ * Class:     java/util/ResourceBundle
+ * Method:    getClassContext
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_util_ResourceBundle_getClassContext (JNIEnv *env );
diff --git a/nat/Runtime.c b/nat/Runtime.c
new file mode 100644 (file)
index 0000000..cf399eb
--- /dev/null
@@ -0,0 +1,86 @@
+/* class: java/lang/Runtime */
+
+/*
+ * Class:     java/lang/Runtime
+ * Method:    execInternal
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Process;
+ */
+JNIEXPORT struct java_lang_Process* JNICALL Java_java_lang_Runtime_execInternal ( JNIEnv *env ,  struct java_lang_Runtime* this, java_objectarray* par1, java_objectarray* par2)
+{
+  log_text("Java_java_lang_Runtime_execInternal  called");
+  return NULL;
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    exitInternal
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal ( JNIEnv *env ,  struct java_lang_Runtime* this, s4 par1)
+{
+       cacao_shutdown (par1);
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    freeMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Runtime_freeMemory ( JNIEnv *env ,  struct java_lang_Runtime* this)
+{
+       log_text ("java_lang_Runtime_freeMemory called");
+       return builtin_i2l (0);
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    gc
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_gc ( JNIEnv *env ,  struct java_lang_Runtime* this)
+{
+       gc_call();
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    runFinalization0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_runFinalization0 ( JNIEnv *env  )
+{
+  log_text("Java_java_lang_Runtime_runFinalization0  called");
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    runFinalizersOnExit0
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_runFinalizersOnExit0 ( JNIEnv *env ,  s4 par1)
+{
+  log_text("Java_java_lang_Runtime_runFinalizersOnExit0  called");
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Runtime_totalMemory ( JNIEnv *env ,  struct java_lang_Runtime* this)
+{
+       log_text ("java_lang_Runtime_totalMemory called");
+       return builtin_i2l (0);
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    traceInstructions
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_traceInstructions ( JNIEnv *env ,  struct java_lang_Runtime* this, s4 par1)
+{
+  log_text("Java_java_lang_Runtime_traceInstructions  called");
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    traceMethodCalls
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_traceMethodCalls ( JNIEnv *env ,  struct java_lang_Runtime* this, s4 par1)
+{
+  log_text("Java_java_lang_Runtime_traceMethodCalls  called");
+}
diff --git a/nat/Runtime.h b/nat/Runtime.h
new file mode 100644 (file)
index 0000000..99cb1c3
--- /dev/null
@@ -0,0 +1,62 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Runtime */
+
+typedef struct java_lang_Runtime {
+   java_objectheader header;
+} java_lang_Runtime;
+
+/*
+ * Class:     java/lang/Runtime
+ * Method:    execInternal
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Process;
+ */
+JNIEXPORT struct java_lang_Process* JNICALL Java_java_lang_Runtime_execInternal (JNIEnv *env ,  struct java_lang_Runtime* this , java_objectarray* par1, java_objectarray* par2);
+/*
+ * Class:     java/lang/Runtime
+ * Method:    exitInternal
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal (JNIEnv *env ,  struct java_lang_Runtime* this , s4 par1);
+/*
+ * Class:     java/lang/Runtime
+ * Method:    freeMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Runtime_freeMemory (JNIEnv *env ,  struct java_lang_Runtime* this );
+/*
+ * Class:     java/lang/Runtime
+ * Method:    gc
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_gc (JNIEnv *env ,  struct java_lang_Runtime* this );
+/*
+ * Class:     java/lang/Runtime
+ * Method:    runFinalization0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_runFinalization0 (JNIEnv *env );
+/*
+ * Class:     java/lang/Runtime
+ * Method:    runFinalizersOnExit0
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_runFinalizersOnExit0 (JNIEnv *env , s4 par1);
+/*
+ * Class:     java/lang/Runtime
+ * Method:    totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Runtime_totalMemory (JNIEnv *env ,  struct java_lang_Runtime* this );
+/*
+ * Class:     java/lang/Runtime
+ * Method:    traceInstructions
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_traceInstructions (JNIEnv *env ,  struct java_lang_Runtime* this , s4 par1);
+/*
+ * Class:     java/lang/Runtime
+ * Method:    traceMethodCalls
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_traceMethodCalls (JNIEnv *env ,  struct java_lang_Runtime* this , s4 par1);
diff --git a/nat/SecurityManager.c b/nat/SecurityManager.c
new file mode 100644 (file)
index 0000000..ba852c9
--- /dev/null
@@ -0,0 +1,56 @@
+/* class: java/lang/SecurityManager */
+
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    classDepth
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_SecurityManager_classDepth ( JNIEnv *env ,  struct java_lang_SecurityManager* this, struct java_lang_String* par1)
+{
+  log_text("Java_java_lang_SecurityManager_classDepth  called");
+  return 0;
+}
+
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    classLoaderDepth0
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_SecurityManager_classLoaderDepth0 ( JNIEnv *env ,  struct java_lang_SecurityManager* this)
+{
+  log_text("Java_java_lang_SecurityManager_classLoaderDepth0  called");
+  return 0;
+}
+
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    currentClassLoader0
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT struct java_lang_ClassLoader* JNICALL Java_java_lang_SecurityManager_currentClassLoader0 ( JNIEnv *env ,  struct java_lang_SecurityManager* this)
+{
+  init_systemclassloader();
+  return SystemClassLoader;
+}
+
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    currentLoadedClass0
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_SecurityManager_currentLoadedClass0 ( JNIEnv *env ,  struct java_lang_SecurityManager* this)
+{
+    log_text("Java_java_lang_SecurityManager_currentLoadedClass0 called");
+    return NULL;
+}
+
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    getClassContext
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_SecurityManager_getClassContext ( JNIEnv *env ,  struct java_lang_SecurityManager* this)
+{
+  log_text("Java_java_lang_SecurityManager_getClassContext  called");
+  return NULL;
+}
diff --git a/nat/SecurityManager.h b/nat/SecurityManager.h
new file mode 100644 (file)
index 0000000..82a3d3f
--- /dev/null
@@ -0,0 +1,40 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/SecurityManager */
+
+typedef struct java_lang_SecurityManager {
+   java_objectheader header;
+   s4 inCheck;
+   s4 initialized;
+} java_lang_SecurityManager;
+
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    classDepth
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_SecurityManager_classDepth (JNIEnv *env ,  struct java_lang_SecurityManager* this , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    classLoaderDepth0
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_SecurityManager_classLoaderDepth0 (JNIEnv *env ,  struct java_lang_SecurityManager* this );
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    currentClassLoader0
+ * Signature: ()Ljava/lang/ClassLoader;
+ */
+JNIEXPORT struct java_lang_ClassLoader* JNICALL Java_java_lang_SecurityManager_currentClassLoader0 (JNIEnv *env ,  struct java_lang_SecurityManager* this );
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    currentLoadedClass0
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_SecurityManager_currentLoadedClass0 (JNIEnv *env ,  struct java_lang_SecurityManager* this );
+/*
+ * Class:     java/lang/SecurityManager
+ * Method:    getClassContext
+ * Signature: ()[Ljava/lang/Class;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_SecurityManager_getClassContext (JNIEnv *env ,  struct java_lang_SecurityManager* this );
diff --git a/nat/String.c b/nat/String.c
new file mode 100644 (file)
index 0000000..d093648
--- /dev/null
@@ -0,0 +1,17 @@
+/* class: java/lang/String */
+
+/*
+ * Class:     java/lang/String
+ * Method:    intern
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_String_intern ( JNIEnv *env ,  struct java_lang_String* this)
+{
+  if (this)
+    /* search table so identical strings will get identical pointers */
+    return (java_lang_String*) literalstring_u2 (this->value, this->count, true);
+  else
+    return NULL;
+}
+
+
diff --git a/nat/String.h b/nat/String.h
new file mode 100644 (file)
index 0000000..d406260
--- /dev/null
@@ -0,0 +1,17 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/String */
+
+typedef struct java_lang_String {
+   java_objectheader header;
+   java_chararray* value;
+   s4 offset;
+   s4 count;
+} java_lang_String;
+
+/*
+ * Class:     java/lang/String
+ * Method:    intern
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_String_intern (JNIEnv *env ,  struct java_lang_String* this );
diff --git a/nat/System.c b/nat/System.c
new file mode 100644 (file)
index 0000000..4cc8a8c
--- /dev/null
@@ -0,0 +1,383 @@
+/* class: java/lang/System */
+
+/*
+ * Class:     java/lang/System
+ * Method:    currentTimeMillis
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_System_currentTimeMillis ( JNIEnv *env )
+{
+       struct timeval tv;
+
+       (void) gettimeofday(&tv, NULL);
+       return ((s8) tv.tv_sec) * 1000 + tv.tv_usec / 1000;
+}
+
+/*
+ * Class:     java/lang/System
+ * Method:    arraycopy
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_arraycopy (JNIEnv *env, struct java_lang_Object* source, s4 sp, struct java_lang_Object* dest, s4 dp, s4 len)
+{
+       s4 i;
+       java_arrayheader *s = (java_arrayheader*) source;
+       java_arrayheader *d = (java_arrayheader*) dest;
+
+       if (((s == NULL) | (d == NULL)) != 0) { 
+               exceptionptr = proto_java_lang_NullPointerException; 
+               return; 
+               }
+
+       if (s->objheader.vftbl->class != class_array) {
+               exceptionptr = proto_java_lang_ArrayStoreException; 
+               return; 
+               }
+
+       if (((sp<0) | (sp+len > s->size) | (dp<0) | (dp+len > d->size)) != 0) {
+               exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException; 
+               return; 
+               }
+
+       switch (s->arraytype) {
+       case ARRAYTYPE_BYTE:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_bytearray*) d)->data + dp,
+                       ((java_bytearray*) s)->data + sp,
+                       (size_t) len);
+               return;
+       case ARRAYTYPE_BOOLEAN:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_booleanarray*) d)->data + dp,
+                       ((java_booleanarray*) s)->data + sp,
+                       (size_t) len);
+               return;
+       case ARRAYTYPE_CHAR:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_chararray*) d)->data + dp,
+                       ((java_chararray*) s)->data + sp,
+                       (size_t) len * sizeof(u2));
+               return;
+       case ARRAYTYPE_SHORT:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_shortarray*) d)->data + dp,
+                       ((java_shortarray*) s)->data + sp,
+                       (size_t) len * sizeof(s2));
+               return;
+       case ARRAYTYPE_INT:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_intarray*) d)->data + dp,
+                       ((java_intarray*) s)->data + sp,
+                       (size_t) len * sizeof(s4));
+               return;
+       case ARRAYTYPE_LONG:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_longarray*) d)->data + dp,
+                       ((java_longarray*) s)->data + sp,
+                       (size_t) len * sizeof(s8));
+               return;
+       case ARRAYTYPE_FLOAT:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_floatarray*) d)->data + dp,
+                       ((java_floatarray*) s)->data + sp,
+                       (size_t) len * sizeof(float));
+               return;
+       case ARRAYTYPE_DOUBLE:
+               if (s->objheader.vftbl != d->objheader.vftbl) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               memmove(((java_doublearray*) d)->data + dp,
+                       ((java_doublearray*) s)->data + sp,
+                       (size_t) len * sizeof(double));
+               return;
+       case ARRAYTYPE_OBJECT:
+               {
+               java_objectarray *oas = (java_objectarray*) s;
+               java_objectarray *oad = (java_objectarray*) d;
+
+               if (d->objheader.vftbl->class != class_array) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               if (s->arraytype != d->arraytype) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+
+               if (dp<=sp) 
+                       for (i=0; i<len; i++) {
+                               java_objectheader *o = oas->data[sp+i];
+                               if (!builtin_canstore(oad, o)) {
+                                       exceptionptr = proto_java_lang_ArrayStoreException;
+                                       return;
+                                       }
+                               oad->data[dp+i] = o;
+                               }
+               else 
+                       for (i=len-1; i>=0; i--) {
+                               java_objectheader *o = oas->data[sp+i];
+                               if (!builtin_canstore(oad, o)) {
+                                       exceptionptr = proto_java_lang_ArrayStoreException;
+                                       return;
+                                       }
+                               oad->data[dp+i] = o;
+                               }
+               
+               }
+               break;
+       case ARRAYTYPE_ARRAY:
+               {
+               java_arrayarray *aas = (java_arrayarray*) s;
+               java_arrayarray *aad = (java_arrayarray*) d;
+
+               if (d->objheader.vftbl->class != class_array) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+               if (s->arraytype != d->arraytype) {
+                       exceptionptr = proto_java_lang_ArrayStoreException; 
+                       return; 
+                       }
+
+               if (dp<=sp) 
+                       for (i=0; i<len; i++) {
+                               java_arrayheader *o = aas->data[sp+i];
+                               if (!builtin_canstore( (java_objectarray*)aad, 
+                                       (java_objectheader*)o )) {
+                                       exceptionptr = proto_java_lang_ArrayStoreException;
+                                       return;
+                                       }
+                               aad->data[dp+i] = o;
+                               }
+               else
+                       for (i=len-1; i>=0; i--) {
+                               java_arrayheader *o = aas->data[sp+i];
+                               if (!builtin_canstore( (java_objectarray*)aad, 
+                                       (java_objectheader*)o )) {
+                                       exceptionptr = proto_java_lang_ArrayStoreException;
+                                       return;
+                                       }
+                               aad->data[dp+i] = o;
+                               }
+
+               }
+               break;
+
+       default:
+               panic ("Unknown data type for arraycopy");
+       }
+}
+
+#define MAXPROPS 100
+static int activeprops = 16;
+
+static char *proplist[MAXPROPS][2] = {
+       { "java.class.path", NULL },
+       { "java.home", NULL }, 
+       { "user.home", NULL }, 
+       { "user.name", NULL }, 
+       { "user.dir",  NULL }, 
+          
+       { "impl.prefix", "" },
+
+       { "java.class.version", "45.3" },
+       { "java.version", "cacao:0.3" },
+       { "java.vendor", "CACAO Team" },
+       { "java.vendor.url", "http://www.complang.tuwien.ac.at/java/cacao/" },
+       { "os.arch", "Alpha" },
+       { "os.name", "Linux/Digital Unix" },
+       { "os.version", "4.0/3.2C/V4.0" },
+       { "path.separator", ":" },
+       { "file.separator", "/" },
+       { "line.separator", "\n" }
+};     
+
+void attach_property (char *name, char *value)
+{
+       if (activeprops >= MAXPROPS) panic ("Too many properties defined");
+       proplist[activeprops][0] = name;
+       proplist[activeprops][1] = value;
+       activeprops++;
+}
+
+/*
+ * Class:     java/lang/System
+ * Method:    initProperties
+ * Signature: (Ljava/util/Properties;)Ljava/util/Properties;
+ */
+JNIEXPORT struct java_util_Properties* JNICALL Java_java_lang_System_initProperties (JNIEnv *env,struct java_util_Properties* p)
+{
+       #define BUFFERSIZE 200
+       u4 i;
+       methodinfo *m;
+       char buffer[BUFFERSIZE];
+       java_objectheader *o;
+       
+       proplist[0][1] = classpath;
+       proplist[1][1] = getenv("JAVA_HOME");
+       proplist[2][1] = getenv("HOME");
+       proplist[3][1] = getenv("USER");
+       proplist[4][1] = getcwd(buffer,BUFFERSIZE);
+       
+       if (!p) panic ("initProperties called with NULL-Argument");
+
+       /* search for method to add properties */
+       m = class_resolvemethod (
+               p->header.vftbl->class, 
+               utf_new_char ("put"), 
+               utf_new_char ("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;")
+       );
+
+       if (!m) panic ("Can not find method 'put' for class Properties");
+       
+               /* add the properties */
+       for (i=0; i<activeprops; i++) {
+
+           if (proplist[i][1]==NULL) proplist[i][1]=""; 
+               
+           asm_calljavamethod(m,  p, 
+                               javastring_new_char(proplist[i][0]),
+                               javastring_new_char(proplist[i][1]),  
+                                       NULL
+                               );
+       }
+
+       return p;
+
+}
+
+
+JNIEXPORT void JNICALL Java_java_lang_System_registerNatives (JNIEnv *env )
+{
+    /* empty */
+}
+
+/*
+ * Class:     java/lang/System
+ * Method:    setErr0
+ * Signature: (Ljava/io/PrintStream;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_setErr0 (JNIEnv *env , struct java_io_PrintStream* stream)
+{
+    /* set static field 'err' of class java.lang.System */      
+       
+    jfieldID fid =
+        env->GetStaticFieldID(env,class_java_lang_System,"err","Ljava/io/PrintStream;");
+
+    if (!fid) panic("unable to access static field of class System");
+
+    env->SetStaticObjectField(env,class_java_lang_System,fid,(jobject) stream);
+}
+
+/*
+ * Class:     java/lang/System
+ * Method:    setIn0
+ * Signature: (Ljava/io/InputStream;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_setIn0 (JNIEnv *env , struct java_io_InputStream* stream)
+{
+    /* set static field 'in' of class java.lang.System */       
+       
+    jfieldID fid =
+        env->GetStaticFieldID(env,class_java_lang_System,"in","Ljava/io/InputStream;");
+
+    if (!fid) panic("unable to access static field of class System");
+
+    env->SetStaticObjectField(env,class_java_lang_System,fid,(jobject) stream);
+}
+
+/*
+ * Class:     java/lang/System
+ * Method:    setOut0
+ * Signature: (Ljava/io/PrintStream;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_setOut0 (JNIEnv *env , struct java_io_PrintStream* stream)
+{
+    /* set static field 'out' of class java.lang.System */             
+       
+    jfieldID fid =
+        env->GetStaticFieldID(env,class_java_lang_System,"out","Ljava/io/PrintStream;");
+
+    if (!fid) panic("unable to access static field of class System");
+
+    env->SetStaticObjectField(env,class_java_lang_System,fid,(jobject) stream);
+}
+
+/*
+ * Class:     java/lang/System
+ * Method:    mapLibraryName
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_System_mapLibraryName (JNIEnv *env , struct java_lang_String* s)
+{
+  char somefile[MAXSTRINGSIZE];
+
+  /* return name of any file that exists (relative to root),
+     so ClassLoader believes we dynamically load the native library */ 
+
+  if (strlen(classpath)+24>MAXSTRINGSIZE)
+    panic("filename too long");
+
+  strcpy(somefile,getenv("JAVA_HOME"));
+  strcat(somefile,"/dummy");
+
+  return (java_lang_String* ) javastring_new_char(&somefile[1]);
+}
+
+
+
+/*
+ * Class:     java/lang/System
+ * Method:    getCallerClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_System_getCallerClass (JNIEnv *env )
+{
+  /* determine the callerclass by getting the method which called getCallerClass */
+  classinfo *c;
+  methodinfo *m = asm_getcallingmethod(); 
+
+  if (m && (c = m->class)) {
+         use_class_as_object (c);
+         return (java_lang_Class*) c;
+  }
+
+  /* caller class could not be determined */
+  return NULL;
+}
+
+/*
+ * Class:     java/lang/System
+ * Method:    identityHashCode
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_System_identityHashCode (JNIEnv *env , struct java_lang_Object* par1)
+{
+       return ((char*) par1) - ((char*) 0);    
+}
+
+
+
+
diff --git a/nat/System.h b/nat/System.h
new file mode 100644 (file)
index 0000000..8a02a83
--- /dev/null
@@ -0,0 +1,68 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/System */
+
+typedef struct java_lang_System {
+   java_objectheader header;
+} java_lang_System;
+
+/*
+ * Class:     java/lang/System
+ * Method:    arraycopy
+ * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_arraycopy (JNIEnv *env , struct java_lang_Object* par1, s4 par2, struct java_lang_Object* par3, s4 par4, s4 par5);
+/*
+ * Class:     java/lang/System
+ * Method:    currentTimeMillis
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_System_currentTimeMillis (JNIEnv *env );
+/*
+ * Class:     java/lang/System
+ * Method:    getCallerClass
+ * Signature: ()Ljava/lang/Class;
+ */
+JNIEXPORT struct java_lang_Class* JNICALL Java_java_lang_System_getCallerClass (JNIEnv *env );
+/*
+ * Class:     java/lang/System
+ * Method:    identityHashCode
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_System_identityHashCode (JNIEnv *env , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/System
+ * Method:    initProperties
+ * Signature: (Ljava/util/Properties;)Ljava/util/Properties;
+ */
+JNIEXPORT struct java_util_Properties* JNICALL Java_java_lang_System_initProperties (JNIEnv *env , struct java_util_Properties* par1);
+/*
+ * Class:     java/lang/System
+ * Method:    mapLibraryName
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_System_mapLibraryName (JNIEnv *env , struct java_lang_String* par1);
+/*
+ * Class:     java/lang/System
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_registerNatives (JNIEnv *env );
+/*
+ * Class:     java/lang/System
+ * Method:    setErr0
+ * Signature: (Ljava/io/PrintStream;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_setErr0 (JNIEnv *env , struct java_io_PrintStream* par1);
+/*
+ * Class:     java/lang/System
+ * Method:    setIn0
+ * Signature: (Ljava/io/InputStream;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_setIn0 (JNIEnv *env , struct java_io_InputStream* par1);
+/*
+ * Class:     java/lang/System
+ * Method:    setOut0
+ * Signature: (Ljava/io/PrintStream;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_System_setOut0 (JNIEnv *env , struct java_io_PrintStream* par1);
diff --git a/nat/Thread.c b/nat/Thread.c
new file mode 100644 (file)
index 0000000..737034c
--- /dev/null
@@ -0,0 +1,223 @@
+/* class: java/lang/Thread */
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    countStackFrames
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_countStackFrames ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  log_text ("java_lang_Thread_countStackFrames called");
+  return 0;         /* not yet implemented */
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    currentThread
+ * Signature: ()Ljava/lang/Thread;
+ */
+JNIEXPORT struct java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread ( JNIEnv *env  )
+{
+  struct java_lang_Thread* t;
+
+  if (runverbose)
+    log_text ("java_lang_Thread_currentThread called");
+
+
+  #ifdef USE_THREADS
+
+        t = (struct java_lang_Thread*) currentThread; 
+  
+        if (!t->group) {
+
+               /* ThreadGroup of currentThread is not initialized */
+
+               t->group = (java_lang_ThreadGroup *) 
+                       native_new_and_init(loader_load(utf_new_char("java/lang/ThreadGroup")));
+
+               if (t->group == 0) 
+                       log_text("unable to create ThreadGroup");
+       }
+
+
+       return (struct java_lang_Thread*) currentThread;
+  #else
+       return 0;       
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    interrupt0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0 ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  log_text("Java_java_lang_Thread_interrupt0  called");
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    isAlive
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_isAlive ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_isAlive called");
+
+  #ifdef USE_THREADS
+       return aliveThread((thread*)this);
+  #else
+       return 0;
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    isInterrupted
+ * Signature: (Z)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_isInterrupted ( JNIEnv *env ,  struct java_lang_Thread* this, s4 par1)
+{
+  log_text("Java_java_lang_Thread_isInterrupted  called");
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_registerNatives ( JNIEnv *env  )
+{
+  /* empty */
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    resume0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_resume0 ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_resume0 called");
+
+  #ifdef USE_THREADS
+       resumeThread((thread*)this);
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    setPriority0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0 ( JNIEnv *env ,  struct java_lang_Thread* this, s4 par1)
+{
+  if (runverbose) 
+    log_text ("java_lang_Thread_setPriority0 called");
+
+  #ifdef USE_THREADS
+  setPriorityThread((thread*)this, par1);
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    sleep
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_sleep ( JNIEnv *env ,  s8 par1)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_sleep called");
+
+  #ifdef USE_THREADS
+       yieldThread();
+  #endif
+       
+  /* not yet implemented */
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_start ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose) 
+    log_text ("java_lang_Thread_start called");
+
+  #ifdef USE_THREADS
+       startThread((thread*)this);
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    stop0
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_stop0 ( JNIEnv *env ,  struct java_lang_Thread* this, struct java_lang_Object* par1)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_stop0 called");
+
+
+  #ifdef USE_THREADS
+       if (currentThread == (thread*)this)
+       {
+           log_text("killing");
+           killThread(0);
+           /*
+               exceptionptr = proto_java_lang_ThreadDeath;
+               return;
+           */
+       }
+       else
+       {
+               CONTEXT((thread*)this).flags |= THREAD_FLAGS_KILLED;
+               resumeThread((thread*)this);
+       }
+   #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    suspend0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_suspend0 ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_suspend0 called");
+
+  #ifdef USE_THREADS
+       suspendThread((thread*)this);
+  #endif
+
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    yield
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_yield ( JNIEnv *env  )
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_yield called");
+  #ifdef USE_THREADS
+       yieldThread();
+  #endif
+}
+
+
+
+
+
+
+
+
diff --git a/nat/Thread.h b/nat/Thread.h
new file mode 100644 (file)
index 0000000..16391a8
--- /dev/null
@@ -0,0 +1,98 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Thread */
+
+typedef struct java_lang_Thread {
+   java_objectheader header;
+   java_chararray* name;
+   s4 priority;
+   struct java_lang_Thread* threadQ;
+   s8 eetop;
+   s4 single_step;
+   s4 daemon;
+   s4 stillborn;
+   struct java_lang_Runnable* target;
+   struct java_lang_ThreadGroup* group;
+   struct java_lang_ClassLoader* contextClassLoader;
+   struct java_security_AccessControlContext* inheritedAccessControlContext;
+   struct java_lang_InheritableThreadLocal_Entry* values;
+} java_lang_Thread;
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    countStackFrames
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_countStackFrames (JNIEnv *env ,  struct java_lang_Thread* this );
+/*
+ * Class:     java/lang/Thread
+ * Method:    currentThread
+ * Signature: ()Ljava/lang/Thread;
+ */
+JNIEXPORT struct java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread (JNIEnv *env );
+/*
+ * Class:     java/lang/Thread
+ * Method:    interrupt0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0 (JNIEnv *env ,  struct java_lang_Thread* this );
+/*
+ * Class:     java/lang/Thread
+ * Method:    isAlive
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_isAlive (JNIEnv *env ,  struct java_lang_Thread* this );
+/*
+ * Class:     java/lang/Thread
+ * Method:    isInterrupted
+ * Signature: (Z)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_isInterrupted (JNIEnv *env ,  struct java_lang_Thread* this , s4 par1);
+/*
+ * Class:     java/lang/Thread
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_registerNatives (JNIEnv *env );
+/*
+ * Class:     java/lang/Thread
+ * Method:    resume0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_resume0 (JNIEnv *env ,  struct java_lang_Thread* this );
+/*
+ * Class:     java/lang/Thread
+ * Method:    setPriority0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0 (JNIEnv *env ,  struct java_lang_Thread* this , s4 par1);
+/*
+ * Class:     java/lang/Thread
+ * Method:    sleep
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_sleep (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/lang/Thread
+ * Method:    start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_start (JNIEnv *env ,  struct java_lang_Thread* this );
+/*
+ * Class:     java/lang/Thread
+ * Method:    stop0
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_stop0 (JNIEnv *env ,  struct java_lang_Thread* this , struct java_lang_Object* par1);
+/*
+ * Class:     java/lang/Thread
+ * Method:    suspend0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_suspend0 (JNIEnv *env ,  struct java_lang_Thread* this );
+/*
+ * Class:     java/lang/Thread
+ * Method:    yield
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_yield (JNIEnv *env );
diff --git a/nat/ThreadGroup.h b/nat/ThreadGroup.h
new file mode 100644 (file)
index 0000000..b14a5ec
--- /dev/null
@@ -0,0 +1,18 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/ThreadGroup */
+
+typedef struct java_lang_ThreadGroup {
+   java_objectheader header;
+   struct java_lang_ThreadGroup* parent;
+   struct java_lang_String* name;
+   s4 maxPriority;
+   s4 destroyed;
+   s4 daemon;
+   s4 vmAllowSuspension;
+   s4 nthreads;
+   java_objectarray* threads;
+   s4 ngroups;
+   java_objectarray* groups;
+} java_lang_ThreadGroup;
+
diff --git a/nat/Throwable.c b/nat/Throwable.c
new file mode 100644 (file)
index 0000000..9ad5184
--- /dev/null
@@ -0,0 +1,27 @@
+/* class: java/lang/Throwable */
+
+/*
+ * Class:     java/lang/Throwable
+ * Method:    fillInStackTrace
+ * Signature: ()Ljava/lang/Throwable;
+ */
+JNIEXPORT struct java_lang_Throwable* JNICALL Java_java_lang_Throwable_fillInStackTrace ( JNIEnv *env ,  struct java_lang_Throwable* this)
+{
+       this -> detailMessage = 
+         (java_lang_String*) (javastring_new_char ("no backtrace info!") );
+       return this;
+}
+
+/*
+ * Class:     java/lang/Throwable
+ * Method:    printStackTrace0
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace0 ( JNIEnv *env ,  struct java_lang_Throwable* this, struct java_lang_Object* par1)
+{
+  panic("Java_java_lang_Throwable_printStackTrace0 called");
+}
+
+
+
+
diff --git a/nat/Throwable.h b/nat/Throwable.h
new file mode 100644 (file)
index 0000000..3880037
--- /dev/null
@@ -0,0 +1,22 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/lang/Throwable */
+
+typedef struct java_lang_Throwable {
+   java_objectheader header;
+   struct java_lang_Object* backtrace;
+   struct java_lang_String* detailMessage;
+} java_lang_Throwable;
+
+/*
+ * Class:     java/lang/Throwable
+ * Method:    fillInStackTrace
+ * Signature: ()Ljava/lang/Throwable;
+ */
+JNIEXPORT struct java_lang_Throwable* JNICALL Java_java_lang_Throwable_fillInStackTrace (JNIEnv *env ,  struct java_lang_Throwable* this );
+/*
+ * Class:     java/lang/Throwable
+ * Method:    printStackTrace0
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace0 (JNIEnv *env ,  struct java_lang_Throwable* this , struct java_lang_Object* par1);
diff --git a/nat/UnixFileSystem.c b/nat/UnixFileSystem.c
new file mode 100644 (file)
index 0000000..5b9b76a
--- /dev/null
@@ -0,0 +1,324 @@
+/* Structure information for class: java/io/UnixFileSystem */
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    canonicalize
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_io_UnixFileSystem_canonicalize (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_lang_String* par1) 
+{
+    return par1;
+}
+
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_isAbsolute (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+  java_lang_String* s = file->path;
+  java_chararray *a = s->value;
+
+  /* absolute filenames start with '/' */
+  if (a->data[s->offset]=='/') return 1;
+  return 0;
+}
+
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    getBooleanAttributes0
+ * Signature: (Ljava/io/File;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_getBooleanAttributes0 (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+       struct stat buffer;
+       char *path;
+       int err;
+       s4 attrib = 0;
+       
+       path = javastring_tochar( (java_objectheader*) (file->path));
+       err  = stat (path, &buffer);
+
+       if (err==0) {
+
+           attrib = 0x01;  /* file exists */
+
+           if (S_ISREG(buffer.st_mode)) attrib |= 0x02;
+           if (S_ISDIR(buffer.st_mode)) attrib |= 0x04;
+       }
+
+       
+       /* printf("getBooleanAttributes called for file: %s (%d)\n",path,attrib); */
+
+       return attrib;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    checkAccess
+ * Signature: (Ljava/io/File;Z)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_checkAccess (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file, s4 write)
+{
+       struct stat buffer;
+       char *path;
+       int err;
+       
+       /* get file-attributes */
+       path = javastring_tochar( (java_objectheader*) (file->path));
+       err  = stat (path, &buffer);
+
+       if (err==0) {
+
+           /* check access rights */
+           if (((write)  && (buffer.st_mode & S_IWUSR)) ||
+               ((!write) && (buffer.st_mode & S_IRUSR))    )
+             return 1;         
+       }
+
+       /* no access rights */
+       return 0;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    getLastModifiedTime
+ * Signature: (Ljava/io/File;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_UnixFileSystem_getLastModifiedTime (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+       struct stat buffer;
+       int err;
+       
+       /* check argument */
+       if (!file) {
+           log_text("Warning: invalid call of native function getLastModifiedTime");
+           return 0;
+       }
+
+       /* get file-attributes */
+       err = stat (javastring_tochar( (java_objectheader*) (file->path)),  &buffer);
+       if (err!=0) return builtin_i2l(0);
+       return builtin_lmul (builtin_i2l(buffer.st_mtime), builtin_i2l(1000) );
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    getLength
+ * Signature: (Ljava/io/File;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_UnixFileSystem_getLength (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+       struct stat buffer;
+       int err;
+       
+       if (!file) {
+           log_text("Warning: invalid call of native function getLength");
+           return 0;
+       }
+
+       /* get file-attributes */
+       err = stat (javastring_tochar( (java_objectheader*) (file->path)),  &buffer);
+       if (err!=0) return builtin_i2l(0);
+       return builtin_i2l(buffer.st_size);
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    createFileExclusively
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_createFileExclusively (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_lang_String* name)
+{
+       s4 fd;
+       char *fname = javastring_tochar ((java_objectheader*)name);
+
+       if (!fname) return 0;
+       
+       /* create new file */
+       fd = creat (fname, 0666);
+       if (fd<0) return 0;
+       
+       threadedFileDescriptor(fd);
+       close (fd);
+
+       return 1;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    delete
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_delete (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+       int err;
+       /* delete the file */
+       err = remove (javastring_tochar ( (java_objectheader*) (file->path) ) );
+       if (err==0) return 1;
+       
+       /* not successful */
+       return 0; 
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    deleteOnExit
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_deleteOnExit (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+    log_text("Java_java_io_UnixFileSystem_deleteOnExit called");
+
+    return 1;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    list
+ * Signature: (Ljava/io/File;)[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_io_UnixFileSystem_list (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file) 
+{
+       char *name;
+       DIR *d;
+       int i,len, namlen;
+       java_objectarray *a;
+       struct dirent *ent;
+       struct java_lang_String *n;
+       char entbuffer[257];
+       
+       name = javastring_tochar ( (java_objectheader*) (file->path) );
+       d = opendir(name);
+       if (!d) return NULL;
+       
+       len=0;
+       while (readdir(d) != NULL) len++;
+       rewinddir (d);
+       
+       a = builtin_anewarray (len, class_java_lang_String);
+       if (!a) {
+               closedir(d);
+               return NULL;
+               }
+               
+       for (i=0; i<len; i++) {
+               if ( (ent = readdir(d)) != NULL) {
+                       namlen = strlen(ent->d_name);
+                       memcpy (entbuffer, ent->d_name, namlen);
+                       entbuffer[namlen] = '\0';
+                       
+                       n = (struct java_lang_String*) 
+                               javastring_new_char (entbuffer);
+                       
+                       a -> data[i] = (java_objectheader*) n;
+                       }
+               }
+
+
+       closedir(d);
+       return a;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    createDirectory
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_createDirectory (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+       char *name;
+       int err;
+
+       if (file) {
+
+           name = javastring_tochar ( (java_objectheader*) (file->path) );
+           err = mkdir (name, 0777);
+
+           if (err==0) return 1;
+       }
+
+       return 0;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    rename
+ * Signature: (Ljava/io/File;Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_rename (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file, struct java_io_File* new)
+{
+
+#define MAXPATHLEN 200
+
+       char newname[MAXPATHLEN];
+       char *n; 
+       int err;
+
+       if (file && new) {
+           n = javastring_tochar ( (java_objectheader*) (new->path) );
+           if (strlen(n)>=MAXPATHLEN) return 0;
+           strcpy (newname, n);
+           n = javastring_tochar ( (java_objectheader*) (file->path) );
+           err = rename (n, newname);
+           if (err==0) return 1;
+       }
+
+       return 0;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    setLastModifiedTime
+ * Signature: (Ljava/io/File;J)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_setLastModifiedTime (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file, s8 time)
+{
+        log_text("Java_java_io_FileSystemImpl_setLastModifiedTime called");
+
+       if (!utime(javastring_tochar( (java_objectheader*) (file->path)), time / 1000))
+           return 1;
+       else
+           return 0;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    setReadOnly
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_setReadOnly (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* file)
+{
+       struct stat buffer;
+       char *path;
+       int err;
+       s4 attrib = 0;
+       
+        log_text("Java_java_io_FileSystemImpl_setReadOnly called");
+
+       path = javastring_tochar( (java_objectheader*) (file->path));
+       /* get file-attributes */
+       err  = stat (path, &buffer);
+
+       if (!err) {
+
+           buffer.st_mode &=  ~( 0x00002 |      /* write by others */
+                                 0x00200 );     /* write by owner  */
+
+           /* set file-attributes */
+           chmod(path,buffer.st_mode);
+
+           if (!err) return 1;
+       }
+
+       return 0;
+}
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_UnixFileSystem_initIDs (JNIEnv *env )
+{
+    /* empty */
+}
+
+
diff --git a/nat/UnixFileSystem.h b/nat/UnixFileSystem.h
new file mode 100644 (file)
index 0000000..e517664
--- /dev/null
@@ -0,0 +1,100 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/io/UnixFileSystem */
+
+typedef struct java_io_UnixFileSystem {
+   java_objectheader header;
+   s4 slash;
+   s4 colon;
+} java_io_UnixFileSystem;
+
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    isAbsolute
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_isAbsolute (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    canonicalize
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_io_UnixFileSystem_canonicalize (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_lang_String* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    getBooleanAttributes0
+ * Signature: (Ljava/io/File;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_getBooleanAttributes0 (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    checkAccess
+ * Signature: (Ljava/io/File;Z)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_checkAccess (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1, s4 par2);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    getLastModifiedTime
+ * Signature: (Ljava/io/File;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_UnixFileSystem_getLastModifiedTime (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    getLength
+ * Signature: (Ljava/io/File;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_io_UnixFileSystem_getLength (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    createFileExclusively
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_createFileExclusively (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_lang_String* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    delete
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_delete (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    deleteOnExit
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_deleteOnExit (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    list
+ * Signature: (Ljava/io/File;)[Ljava/lang/String;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_io_UnixFileSystem_list (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    createDirectory
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_createDirectory (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    rename
+ * Signature: (Ljava/io/File;Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_rename (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1, struct java_io_File* par2);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    setLastModifiedTime
+ * Signature: (Ljava/io/File;J)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_setLastModifiedTime (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1, s8 par2);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    setReadOnly
+ * Signature: (Ljava/io/File;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_io_UnixFileSystem_setReadOnly (JNIEnv *env ,  struct java_io_UnixFileSystem* this , struct java_io_File* par1);
+/*
+ * Class:     java/io/UnixFileSystem
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_io_UnixFileSystem_initIDs (JNIEnv *env );
diff --git a/nat/ZipEntry.c b/nat/ZipEntry.c
new file mode 100644 (file)
index 0000000..bc189a6
--- /dev/null
@@ -0,0 +1,22 @@
+/* class: java/util/zip/ZipEntry */
+
+/*
+ * Class:     java/util/zip/ZipEntry
+ * Method:    initFields
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipEntry_initFields ( JNIEnv *env ,  struct java_util_zip_ZipEntry* this, s8 par1)
+{
+  log_text("Java_java_util_zip_ZipEntry_initFields  called");
+}
+/*
+ * Class:     java/util/zip/ZipEntry
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipEntry_initIDs ( JNIEnv *env  )
+{
+  if (verbose)
+    log_text("Java_java_util_zip_ZipEntry_initIDs  called");
+}
+
diff --git a/nat/ZipEntry.h b/nat/ZipEntry.h
new file mode 100644 (file)
index 0000000..cd5b0f8
--- /dev/null
@@ -0,0 +1,31 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/zip/ZipEntry */
+
+typedef struct java_util_zip_ZipEntry {
+   java_objectheader header;
+   struct java_lang_String* name;
+   s8 time;
+   s8 crc;
+   s8 size;
+   s8 csize;
+   s4 method;
+   java_bytearray* extra;
+   struct java_lang_String* comment;
+   s4 flag;
+   s4 version;
+   s8 offset;
+} java_util_zip_ZipEntry;
+
+/*
+ * Class:     java/util/zip/ZipEntry
+ * Method:    initFields
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipEntry_initFields (JNIEnv *env ,  struct java_util_zip_ZipEntry* this , s8 par1);
+/*
+ * Class:     java/util/zip/ZipEntry
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipEntry_initIDs (JNIEnv *env );
diff --git a/nat/ZipFile.c b/nat/ZipFile.c
new file mode 100644 (file)
index 0000000..899c125
--- /dev/null
@@ -0,0 +1,98 @@
+/* class: java/util/zip/ZipFile */
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    close
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_close ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_ZipFile_close  called");
+}
+
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getCSize
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_getCSize ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_ZipFile_getCSize  called");
+}
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getEntry
+ * Signature: (JLjava/lang/String;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_ZipFile_getEntry ( JNIEnv *env ,  s8 par1, struct java_lang_String* par2)
+{
+  log_text("Java_java_util_zip_ZipFile_getEntry  called");
+}
+
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getMethod
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_getMethod ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_ZipFile_getMethod  called");
+}
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getNextEntry
+ * Signature: (JI)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_ZipFile_getNextEntry ( JNIEnv *env ,  s8 par1, s4 par2)
+{
+  log_text("Java_java_util_zip_ZipFile_getNextEntry  called");
+}
+
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getTotal
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_getTotal ( JNIEnv *env ,  s8 par1)
+{
+  log_text("Java_java_util_zip_ZipFile_getTotal  called");
+}
+
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_initIDs ( JNIEnv *env  )
+{
+  if (verbose)
+    log_text("Java_java_util_zip_ZipFile_initIDs  called");
+}
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    open
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_ZipFile_open ( JNIEnv *env ,  struct java_lang_String* par1)
+{
+  log_text("Java_java_util_zip_ZipFile_open  called");
+}
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    read
+ * Signature: (JJI[BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_read ( JNIEnv *env ,  s8 par1, s8 par2, s4 par3, java_bytearray* par4, s4 par5, s4 par6)
+{
+  log_text("Java_java_util_zip_ZipFile_read  called");
+}
+
+
diff --git a/nat/ZipFile.h b/nat/ZipFile.h
new file mode 100644 (file)
index 0000000..e2cbdbd
--- /dev/null
@@ -0,0 +1,66 @@
+/* This file is machine generated, don't edit it !*/
+
+/* Structure information for class: java/util/zip/ZipFile */
+
+typedef struct java_util_zip_ZipFile {
+   java_objectheader header;
+   s8 jzfile;
+   struct java_lang_String* name;
+   s4 total;
+   struct java_util_Vector* inflaters;
+} java_util_zip_ZipFile;
+
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    close
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_close (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getCSize
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_getCSize (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getEntry
+ * Signature: (JLjava/lang/String;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_ZipFile_getEntry (JNIEnv *env , s8 par1, struct java_lang_String* par2);
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getMethod
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_getMethod (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getNextEntry
+ * Signature: (JI)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_ZipFile_getNextEntry (JNIEnv *env , s8 par1, s4 par2);
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    getTotal
+ * Signature: (J)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_getTotal (JNIEnv *env , s8 par1);
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_util_zip_ZipFile_initIDs (JNIEnv *env );
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    open
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_util_zip_ZipFile_open (JNIEnv *env , struct java_lang_String* par1);
+/*
+ * Class:     java/util/zip/ZipFile
+ * Method:    read
+ * Signature: (JJI[BII)I
+ */
+JNIEXPORT s4 JNICALL Java_java_util_zip_ZipFile_read (JNIEnv *env , s8 par1, s8 par2, s4 par3, java_bytearray* par4, s4 par5, s4 par6);
diff --git a/nat/io.c b/nat/io.c
deleted file mode 100644 (file)
index 7f28498..0000000
--- a/nat/io.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/****************************** nat/io.c ***************************************
-
-       Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
-
-       See file COPYRIGHT for information on usage and disclaimer of warranties
-
-       Contains the native functions for class java.io.
-
-       Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
-                Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
-
-       Last Change: 1997/10/22
-
-*******************************************************************************/
-
-#include <fcntl.h>
-#include <dirent.h>
-#include <sys/types.h>
-#ifdef _OSF_SOURCE 
-#include <sys/mode.h>
-#endif
-#include <sys/stat.h>
-
-#include "../threads/threadio.h"                    /* schani */
-
-/*
- * io is performed through the threaded... functions, since io operations may
- * block and the corresponding thread must, in this case, be suspended.
- *
- * schani
- */
-
-/********************* java.io.FileDescriptor ********************************/
-
-s4 java_io_FileDescriptor_valid (struct java_io_FileDescriptor* this)
-{
-       if (this->fd >= 0) return 1;
-       return 0;
-}
-
-struct java_io_FileDescriptor* java_io_FileDescriptor_initSystemFD 
-        (struct java_io_FileDescriptor* fd, s4 handle)
-{
-       switch (handle) {
-       case 0:  fd -> fd = fileno(stdin); 
-                break;
-       case 1:  fd -> fd = fileno(stdout);
-                break;
-       case 2:  fd -> fd = fileno(stderr);
-                break;
-       default: panic ("Invalid file descriptor number");
-       }
-
-       threadedFileDescriptor(fd->fd);
-
-       return fd;
-}
-
-
-/************************* java.io.FileInputStream ***************************/
-
-
-void java_io_FileInputStream_open 
-       (struct java_io_FileInputStream* this, struct java_lang_String* name)
-{
-       s4 fd;
-       char *fname = javastring_tochar ((java_objectheader*)name);
-
-       if (!fname) goto fail;
-
-       fd = open (fname, O_RDONLY, 0);
-       if (fd<0) goto fail;
-       
-       threadedFileDescriptor(fd);
-
-       this->fd->fd = fd;
-       return;
-
-       fail:
-               exceptionptr = native_new_and_init (class_java_io_IOException);
-               return;
-}
-
-s4 java_io_FileInputStream_read (struct java_io_FileInputStream* this)
-{
-       s4 r;
-       u1 buffer[1];
-       r = threadedRead (this->fd->fd, (char *) buffer, 1);    
-
-       if (r>0) return buffer[0];
-       if (r==0) return -1;
-       
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return 0;
-}
-
-
-s4 java_io_FileInputStream_readBytes (struct java_io_FileInputStream* this, 
-     java_bytearray* buffer, s4 start, s4 len)
-{
-       s4 ret = threadedRead (this->fd->fd, (char *) buffer->data+start, len);
-       if (ret>0) return ret;
-       if (ret==0) return -1;
-       
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return 0;
-}
-
-
-s8 java_io_FileInputStream_skip 
-       (struct java_io_FileInputStream* this, s8 numbytes)
-{
-       s4 ret = lseek (this->fd->fd, builtin_l2i(numbytes), SEEK_CUR);
-       if (ret>0) return builtin_i2l(ret);
-       if (ret==0) return builtin_i2l(-1);
-       
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return builtin_i2l(0);
-}
-
-s4 java_io_FileInputStream_available (struct java_io_FileInputStream* this)
-{
-       struct stat buffer;
-       s4 r1,r2;
-       
-       r1 = fstat (this->fd->fd, &buffer);
-       r2 = lseek(this->fd->fd, 0, SEEK_CUR);
-       
-       if ( (r1 >= 0) && (r2 >= 0) )  
-               return buffer.st_size - r2; 
-
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return 0;
-}
-
-void java_io_FileInputStream_close (struct java_io_FileInputStream* this)
-{
-       if (this->fd->fd >= 0) {
-               s4 r = close (this->fd->fd);
-               this->fd->fd = -1;
-               if (r < 0) 
-                       exceptionptr = native_new_and_init (class_java_io_IOException);
-       }
-}
-
-
-
-
-
-/*************************** java.io.FileOutputStream ************************/
-
-
-void java_io_FileOutputStream_open (struct java_io_FileOutputStream* this, 
-                                  struct java_lang_String* name)
-{
-       s4 fd;
-       char *fname = javastring_tochar ((java_objectheader*)name);
-       if (!fname) goto fail;
-       
-       fd = creat (fname, 0666);
-       if (fd<0) goto fail;
-       
-       threadedFileDescriptor(fd);
-
-       this->fd->fd = fd;
-       return;
-
-       fail:
-               exceptionptr = native_new_and_init (class_java_io_IOException);
-               return;
-}
-
-                                
-void java_io_FileOutputStream_write
-          (struct java_io_FileOutputStream* this, s4 byte)
-{
-       u1 buffer[1];
-       s4 l;
-
-       buffer[0] = byte;
-       l = threadedWrite (this->fd->fd, (char *) buffer, 1);
-
-       if (l<1) {
-               exceptionptr = native_new_and_init (class_java_io_IOException);
-               }
-}
-       
-void java_io_FileOutputStream_writeBytes (struct java_io_FileOutputStream* this,
-                            java_bytearray* buffer, s4 start, s4 len)
-{
-       s4 o;
-
-       if (len == 0)
-               return;
-       o = threadedWrite (this->fd->fd, (char *) buffer->data+start, len);
-       if (o!=len) 
-               exceptionptr = native_new_and_init (class_java_io_IOException);
-}
-                            
-void java_io_FileOutputStream_close (struct java_io_FileOutputStream* this)
-{
-       if (this->fd->fd == fileno(stderr))  /* don't close stderr!!! -- phil. */
-               return;
-
-       if (this->fd->fd == fileno(stdout))
-               return;
-
-       if (this->fd->fd >= 0) {
-               s4 r = close (this->fd->fd);
-               this->fd->fd = -1;
-               if (r<0) 
-                       exceptionptr = native_new_and_init (class_java_io_IOException);
-               }
-}
-
-
-
-/************************** java.io.File **************************************/
-
-s4 java_io_File_exists0 (struct java_io_File* this)
-{
-       struct stat buffer;
-       char *path;
-       int err;
-       
-       path = javastring_tochar( (java_objectheader*) (this->path));
-       
-       err = stat (path, &buffer);
-       if (err==0) return 1;
-       return 0;
-}      
-
-s4 java_io_File_canWrite0 (struct java_io_File* this) 
-{
-       int err;
-       err = access (javastring_tochar( (java_objectheader*) (this->path)), W_OK);
-       if (err==0) return 1;
-       return 0;
-}
-
-s4 java_io_File_canRead0 (struct java_io_File* this)
-{
-       int err;
-       err = access (javastring_tochar( (java_objectheader*) (this->path)), R_OK);
-       if (err==0) return 1;
-       return 0;
-}
-
-s4 java_io_File_isFile0 (struct java_io_File* this)
-{
-       struct stat buffer;
-       char *path;
-       int err;
-       
-       path = javastring_tochar( (java_objectheader*) (this->path));
-       
-       err = stat (path, &buffer);
-       if (err!=0) return 0;
-       if (S_ISREG(buffer.st_mode)) return 1;
-       return 0;
-}
-
-s4 java_io_File_isDirectory0 (struct java_io_File* this)
-{
-       struct stat buffer;
-       char *path;
-       int err;
-       
-       path = javastring_tochar( (java_objectheader*) (this->path));
-       
-       err = stat (path, &buffer);
-       if (err!=0) return 0;
-       if (S_ISDIR(buffer.st_mode)) return 1;
-       return 0;
-}
-s8 java_io_File_lastModified0 (struct java_io_File* this) 
-{
-       struct stat buffer;
-       int err;
-       err = stat (javastring_tochar( (java_objectheader*) (this->path)),  &buffer);
-       if (err!=0) return builtin_i2l(0);
-       return builtin_lmul (builtin_i2l(buffer.st_mtime), builtin_i2l(1000) );
-}
-
-s8 java_io_File_length0 (struct java_io_File* this)
-{
-       struct stat buffer;
-       int err;
-       err = stat (javastring_tochar( (java_objectheader*) (this->path)),  &buffer);
-       if (err!=0) return builtin_i2l(0);
-       return builtin_i2l(buffer.st_size);
-}
-
-s4 java_io_File_mkdir0 (struct java_io_File* this) 
-{ 
-       char *name = javastring_tochar ( (java_objectheader*) (this->path) );
-       int err = mkdir (name, 0777);
-       if (err==0) return 1;
-       return 0;
-}
-
-s4 java_io_File_renameTo0 (struct java_io_File* this, struct java_io_File* new) 
-{ 
-#define MAXPATHLEN 200
-       char newname[MAXPATHLEN];
-       char *n = javastring_tochar ( (java_objectheader*) (new->path) );
-       int err;
-       
-       if (strlen(n)>=MAXPATHLEN) return 0;
-       strcpy (newname, n);
-       n = javastring_tochar ( (java_objectheader*) (this->path) );
-       err = rename (n, newname);
-       if (err==0) return 1;
-       return 0;
-}
-
-s4 java_io_File_delete0 (struct java_io_File* this) 
-{ 
-       int err;
-       err = remove (javastring_tochar ( (java_objectheader*) (this->path) ) );
-       if (err==0) return 1;
-       return 0; 
-}
-
-java_objectarray* java_io_File_list0 (struct java_io_File* this) 
-{ 
-       char *name;
-       DIR *d;
-       int i,len, namlen;
-       java_objectarray *a;
-       struct dirent *ent;
-       struct java_lang_String *n;
-       char entbuffer[257];
-       
-       name = javastring_tochar ( (java_objectheader*) (this->path) );
-       d = opendir(name);
-       if (!d) return NULL;
-       
-       len=0;
-       while (readdir(d) != NULL) len++;
-       rewinddir (d);
-       
-       a = builtin_anewarray (len, class_java_lang_String);
-       if (!a) {
-               closedir(d);
-               return NULL;
-               }
-               
-       for (i=0; i<len; i++) {
-               if ( (ent = readdir(d)) != NULL) {
-                       namlen = strlen(ent->d_name);
-                       memcpy (entbuffer, ent->d_name, namlen);
-                       entbuffer[namlen] = '\0';
-                       
-                       n = (struct java_lang_String*) 
-                               javastring_new_char (entbuffer);
-                       
-                       a -> data[i] = (java_objectheader*) n;
-                       }
-               }
-
-
-       closedir(d);
-       return a;
-}
-
-s4 java_io_File_isAbsolute (struct java_io_File* this) 
-{ 
-       char *name = javastring_tochar ( (java_objectheader*) (this->path) );
-       if (name[0] == '/') return 1;
-       return 0;
-}
-
-
-
-
-/********************** java.io.RandomAccessFile *****************************/
-
-void java_io_RandomAccessFile_open (struct java_io_RandomAccessFile* this, 
-               struct java_lang_String* name, s4 writeable)
-{
-       s4 fd;
-       char *fname = javastring_tochar ((java_objectheader*)name);
-       
-       if (writeable) fd = open (fname, O_RDWR, 0);
-       else           fd = open (fname, O_RDONLY, 0);
-       if (fd==-1) goto fail;
-
-       threadedFileDescriptor(fd);
-       
-       this->fd->fd = fd;
-       return;
-
-       fail:
-               exceptionptr = native_new_and_init (class_java_io_IOException);
-               return;
-}
-
-s4 java_io_RandomAccessFile_read (struct java_io_RandomAccessFile* this)
-{ 
-       s4 r;
-       u1 buffer[1];
-       r = threadedRead (this->fd->fd, (char *) buffer, 1);    
-       if (r>0) return buffer[1];
-       if (r==0) return -1;
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return 0;
-}
-
-s4 java_io_RandomAccessFile_readBytes (struct java_io_RandomAccessFile* this, 
-     java_bytearray* buffer, s4 start, s4 len)
-{
-       s4 r = threadedRead (this->fd->fd, (char *) buffer->data+start, len);
-       if (r>0) return r;
-       if (r==0) return -1;
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return 0;
-}
-
-void java_io_RandomAccessFile_write 
-       (struct java_io_RandomAccessFile* this, s4 byte)
-{ 
-       u1 buffer[1];
-       int r;
-       buffer[1] = byte;
-       r = write (this->fd->fd, buffer, 1);
-       if (r<0) {
-               exceptionptr = native_new_and_init (class_java_io_IOException);
-               }
-}
-
-void java_io_RandomAccessFile_writeBytes (struct java_io_RandomAccessFile* this, 
-                            java_bytearray* buffer, s4 start, s4 len)
-{
-       s4 o;
-       if (len == 0)
-               return;
-       o = threadedWrite (this->fd->fd, (char *) buffer->data+start, len);
-       if (o!=len) exceptionptr = native_new_and_init (class_java_io_IOException);
-}
-               
-s8 java_io_RandomAccessFile_getFilePointer 
-        (struct java_io_RandomAccessFile* this)
-{
-       s4 p = lseek (this->fd->fd, 0, SEEK_CUR);
-       if (p>=0) return builtin_i2l(p);
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return builtin_i2l(0);
-}
-
-void java_io_RandomAccessFile_seek 
-           (struct java_io_RandomAccessFile* this, s8 offset)
-{
-       s4 p = lseek (this->fd->fd, builtin_l2i(offset), SEEK_SET); 
-       if (p<0) {
-               exceptionptr = native_new_and_init (class_java_io_IOException);
-               }
-}
-
-s8 java_io_RandomAccessFile_length (struct java_io_RandomAccessFile* this)
-{
-       struct stat buffer;
-       s4 r = fstat(this->fd->fd, &buffer);
-       if (r>=0) return builtin_i2l(buffer.st_size);
-       exceptionptr = native_new_and_init (class_java_io_IOException);
-       return builtin_i2l(0);
-}
-
-void java_io_RandomAccessFile_close (struct java_io_RandomAccessFile* this)
-{      
-  if (this->fd->fd >= 0) {
-    s4 r = close (this->fd->fd);
-               this->fd->fd = -1;
-               if (r<0) 
-                       exceptionptr = native_new_and_init (class_java_io_IOException);
-               }
-}
-
-
-
-
-/*
- * 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/nat/lang.c b/nat/lang.c
deleted file mode 100644 (file)
index 3f760e4..0000000
+++ /dev/null
@@ -1,927 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 4 -*- */
-/****************************** nat/lang.c *************************************
-
-       Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
-
-       See file COPYRIGHT for information on usage and disclaimer of warranties
-
-       Contains the native functions for class java.lang.
-
-       Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
-                Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
-                        Philipp Tomsich         EMAIL: cacao@complang.tuwien.ac.at
-
-       Last Change: $Id: lang.c 115 1999-01-20 01:52:45Z phil $
-
-*******************************************************************************/
-
-#include <math.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/time.h>
-
-#include "../threads/thread.h"                       /* schani */
-#include "../threads/locks.h"
-
-static void use_class_as_object (classinfo *c) 
-{
-       c->header.vftbl = class_java_lang_Class -> vftbl;
-}
-
-
-/************************************** java.lang.Object ***********************************/
-
-struct java_lang_Class* java_lang_Object_getClass (struct java_lang_Object* this)
-{
-       classinfo *c = this->header.vftbl -> class;
-       use_class_as_object (c);
-       return (java_lang_Class*) c;
-}
-
-s4 java_lang_Object_hashCode (struct java_lang_Object* this)
-{
-       return ((char*) this) - ((char*) 0);    
-}
-
-
-struct java_lang_Object* java_lang_Object_clone (struct java_lang_Object* this)
-{
-       classinfo *c;
-       java_lang_Object *new;
-
-       if (((java_objectheader*)this)->vftbl->class == class_array)
-         {
-           static u4 multiplicator[10];
-           static int is_initialized = 0;
-
-           java_arrayheader *array = (java_arrayheader*)this;
-           u4 size;
-
-           if (!is_initialized)
-             {
-               multiplicator[ARRAYTYPE_INT] = sizeof(s4);
-               multiplicator[ARRAYTYPE_LONG] = sizeof(s8);
-               multiplicator[ARRAYTYPE_FLOAT] = sizeof(float);
-               multiplicator[ARRAYTYPE_DOUBLE] = sizeof(double);
-               multiplicator[ARRAYTYPE_BYTE] = sizeof(s1);
-               multiplicator[ARRAYTYPE_CHAR] = sizeof(u2);
-               multiplicator[ARRAYTYPE_SHORT] = sizeof(s2);
-               multiplicator[ARRAYTYPE_BOOLEAN] = sizeof(u1);
-               multiplicator[ARRAYTYPE_OBJECT] = sizeof(void*);
-               multiplicator[ARRAYTYPE_ARRAY] = sizeof(void*);
-               is_initialized = 1;
-             }
-           
-           size = sizeof(java_arrayheader)
-             + array->size * multiplicator[array->arraytype];
-
-           new = (java_lang_Object*)heap_allocate(size, false, NULL);
-           memcpy(new, this, size);
-
-           return new;
-         }
-       else
-         {
-           if (! builtin_instanceof ((java_objectheader*) this, class_java_lang_Cloneable) ) {
-               exceptionptr = native_new_and_init (class_java_lang_CloneNotSupportedException);
-               return NULL;
-               }
-       
-       c = this -> header.vftbl -> class;
-       new = (java_lang_Object*) builtin_new (c);
-       if (!new) {
-               exceptionptr = proto_java_lang_OutOfMemoryError;
-               return NULL;
-               }
-
-           memcpy (new, this, c->instancesize);
-           return new;
-         }
-}
-       
-void java_lang_Object_notify (struct java_lang_Object* this)
-{
-       if (runverbose)
-               log_text ("java_lang_Object_notify called");
-
-#ifdef USE_THREADS
-    signal_cond_for_object(&this->header);
-#endif
-}
-
-void java_lang_Object_notifyAll (struct java_lang_Object* this)
-{
-       if (runverbose)
-               log_text ("java_lang_Object_notifyAll called");
-
-#ifdef USE_THREADS
-       broadcast_cond_for_object(&this->header);
-#endif
-}
-
-void java_lang_Object_wait (struct java_lang_Object* this, s8 time)
-{
-       if (runverbose)
-               log_text ("java_lang_Object_wait called");
-
-#ifdef USE_THREADS
-       wait_cond_for_object(&this->header, time);
-#endif
-}
-
-
-/********************************** java.lang.Class **************************************/
-
-
-struct java_lang_Class* java_lang_Class_forName (struct java_lang_String* s)
-{
-       java_chararray *a,*b;
-       u4 i;
-       unicode *u;
-       classinfo *c;
-       
-       if (!s) return NULL;
-       if (!(a = s->value) ) return NULL;
-       b = builtin_newarray_char (s->count);
-       if (!b) return NULL;
-       for (i=0; i<s->count; i++) {
-               if (a->data[s->offset+i]=='.') b->data[i] = '/';
-           else                           b->data[i] = a->data[s->offset+i];
-           }
-       u = unicode_new_u2 (b->data, b->header.size);
-       c = u->class;
-       if (!c) {
-               c = loader_load (u);
-               loader_initclasses ();
-
-               if (!c) {       
-                       exceptionptr = 
-                       native_new_and_init (class_java_lang_ClassNotFoundException);
-       
-                       return NULL;
-                       }
-
-               }
-       
-       use_class_as_object (c);
-       return (java_lang_Class*) c;
-}
-
-struct java_lang_Object* java_lang_Class_newInstance (struct java_lang_Class* this)
-{
-       java_objectheader *o = native_new_and_init ((classinfo*) this);
-       if (!o) {
-               exceptionptr = 
-                       native_new_and_init (class_java_lang_InstantiationException);
-               }
-       return (java_lang_Object*) o;
-}
-
-struct java_lang_String* java_lang_Class_getName (struct java_lang_Class* this)
-{
-       u4 i;
-       classinfo *c = (classinfo*) this;
-       java_lang_String *s = (java_lang_String*) javastring_new(c->name);
-
-       if (!s) return NULL;
-
-       for (i=0; i<s->value->header.size; i++) {
-               if (s->value->data[i] == '/') s->value->data[i] = '.';
-               }
-       
-       return s;
-}
-
-struct java_lang_Class* java_lang_Class_getSuperclass (struct java_lang_Class* this)
-{
-       classinfo *c = ((classinfo*) this) -> super;
-       if (!c) return NULL;
-
-       use_class_as_object (c);
-       return (java_lang_Class*) c;
-}
-
-java_objectarray* java_lang_Class_getInterfaces (struct java_lang_Class* this)
-{
-       classinfo *c = (classinfo*) this;
-       u4 i;
-       java_objectarray *a = builtin_anewarray (c->interfacescount, class_java_lang_Class);
-       if (!a) return NULL;
-       for (i=0; i<c->interfacescount; i++) {
-               use_class_as_object (c->interfaces[i]);
-
-               a->data[i] = (java_objectheader*) c->interfaces[i];
-               }
-       return a;
-}
-
-struct java_lang_ClassLoader* java_lang_Class_getClassLoader (struct java_lang_Class* this)
-{
-       log_text ("java_lang_Class_getClassLoader called");
-       return NULL;
-}
-
-s4 java_lang_Class_isInterface (struct java_lang_Class* this)
-{
-       classinfo *c = (classinfo*) this;
-       if (c->flags & ACC_INTERFACE) return 1;
-       return 0;
-}
-
-/************************************ java.lang.ClassLoader *******************************/
-
-
-struct java_lang_Class* java_lang_ClassLoader_defineClass (struct java_lang_ClassLoader* this, java_bytearray* par1, s4 par2, s4 par3)
-{
-       log_text ("java_lang_ClassLoader_defineClass called");
-       return NULL;
-}
-void java_lang_ClassLoader_resolveClass (struct java_lang_ClassLoader* this, struct java_lang_Class* par1)
-{
-       log_text ("java_lang_ClassLoader_resolveClass called");
-}
-struct java_lang_Class* java_lang_ClassLoader_findSystemClass (struct java_lang_ClassLoader* this, struct java_lang_String* par1)
-{
-       log_text ("java_lang_ClassLoader_findSystemClass called");
-       return NULL;
-}      
-void java_lang_ClassLoader_init (struct java_lang_ClassLoader* this)
-{
-       log_text ("java_lang_ClassLoader_init called");
-}
-struct java_lang_Class* java_lang_ClassLoader_findSystemClass0 (struct java_lang_ClassLoader* this, struct java_lang_String* par1)
-{
-       log_text ("java_lang_ClassLoader_findSystemClass0 called");
-       return NULL;
-}
-
-struct java_lang_Class* java_lang_ClassLoader_defineClass0 (struct java_lang_ClassLoader* this, java_bytearray* par1, s4 par2, s4 par3)
-{
-       log_text ("java_lang_ClassLoader_defineClass0 called");
-       return NULL;
-}
-void java_lang_ClassLoader_resolveClass0 (struct java_lang_ClassLoader* this, struct java_lang_Class* par1)
-{
-       log_text ("java_lang_ClassLoader_resolveClass0 called");
-       return;
-}
-
-/************************************** java.lang.Compiler  *******************************/
-
-void java_lang_Compiler_initialize ()
-{
-       log_text ("java_lang_Compiler_initialize called");
-}
-s4 java_lang_Compiler_compileClass (struct java_lang_Class* par1) 
-{
-       log_text ("java_lang_Compiler_compileClass called");
-       return 0;
-}
-s4 java_lang_Compiler_compileClasses (struct java_lang_String* par1)
-{
-       log_text ("java_lang_Compiler_compileClasses called");
-       return 0;
-}
-struct java_lang_Object* java_lang_Compiler_command (struct java_lang_Object* par1)
-{
-       log_text ("java_lang_Compiler_command called");
-       return NULL;
-}
-void java_lang_Compiler_enable ()
-{
-       log_text ("java_lang_Compiler_enable called");
-}
-void java_lang_Compiler_disable ()
-{
-       log_text ("java_lang_Compiler_disable called");
-}
-
-
-/******************************** java.lang.Double **************************************/
-
-struct java_lang_String* java_lang_Double_toString (double par1)
-{
-       char b[400];
-       sprintf (b, "%-.6g", par1);
-       return (java_lang_String*) javastring_new_char (b);
-}
-struct java_lang_Double* java_lang_Double_valueOf (struct java_lang_String* par1)
-{      
-       float val;
-       java_lang_Double *d = (java_lang_Double*) builtin_new (class_java_lang_Double);
-       if (d) {        
-               sscanf (javastring_tochar((java_objectheader*) par1), "%f", &val);
-               d->value = val;
-               return d;
-       }
-       return NULL;
-}
-s8 java_lang_Double_doubleToLongBits (double par1)
-{
-       s8 l;
-       double d = par1;
-       memcpy ((u1*) &l, (u1*) &d, 8);
-       return l;
-}
-double java_lang_Double_longBitsToDouble (s8 par1)
-{
-       s8 l = par1;
-       double d;
-       memcpy ((u1*) &d, (u1*) &l, 8);
-       return d;
-}
-
-/******************************** java.lang.Float ***************************************/
-
-struct java_lang_String* java_lang_Float_toString (float par1)
-{
-       char b[50];
-       sprintf (b, "%-.6g", (double) par1);
-       return (java_lang_String*) javastring_new_char (b);
-}
-struct java_lang_Float* java_lang_Float_valueOf (struct java_lang_String* par1)
-{
-       float val;
-       java_lang_Float *d = (java_lang_Float*) builtin_new (class_java_lang_Float);
-       if (d) {        
-               sscanf (javastring_tochar((java_objectheader*) par1), "%f", &val);
-               d->value = val;
-               return d;
-       }
-       return NULL;
-}
-s4 java_lang_Float_floatToIntBits (float par1)
-{
-       s4 i;
-       float f = par1;
-       memcpy ((u1*) &i, (u1*) &f, 4);
-       return i;
-}
-float java_lang_Float_intBitsToFloat (s4 par1)
-{
-       s4 i = par1;
-       float f;
-       memcpy ((u1*) &f, (u1*) &i, 4);
-       return f;
-}
-
-
-/******************************** java.lang.Math ****************************************/
-
-double java_lang_Math_sin (double par1)
-{
-       return sin(par1);
-}
-
-double java_lang_Math_cos (double par1)
-{
-       return cos(par1);
-}
-
-double java_lang_Math_tan (double par1)
-{
-       return tan(par1);
-}
-
-double java_lang_Math_asin (double par1)
-{
-       return asin(par1);
-}
-
-double java_lang_Math_acos (double par1)
-{
-       return acos(par1);
-}
-
-double java_lang_Math_atan (double par1)
-{
-       return atan(par1);
-}
-
-double java_lang_Math_exp (double par1)
-{
-       return exp(par1);
-}
-
-double java_lang_Math_log (double par1)
-{
-       if (par1<0.0) {
-               exceptionptr = proto_java_lang_ArithmeticException;
-               return 0.0;
-               }
-       return log(par1);
-}
-
-double java_lang_Math_sqrt (double par1)
-{
-       if (par1<0.0) {
-               exceptionptr = proto_java_lang_ArithmeticException;
-               return 0.0;
-               }
-       return sqrt(par1);
-}
-
-static u8 dbl_nan    = 0xffffffffffffffffL ;
-
-#define DBL_NAN    (*((double*) (&dbl_nan)))
-
-double java_lang_Math_IEEEremainder (double a, double b)
-{
-       double d;
-       if (finite(a) && finite(b)) {
-               d = a / b;
-               if (finite(d))
-                       return a - floor(d) * b;
-               return DBL_NAN;
-               }
-       if (isnan(b))
-               return DBL_NAN;
-       if (finite(a))
-               return a;
-       return DBL_NAN;
-}
-
-double java_lang_Math_ceil (double par1)
-{
-       return ceil(par1);
-}
-
-double java_lang_Math_floor (double par1)
-{
-       return floor(par1);
-}
-
-double java_lang_Math_rint (double par1)
-{
-       return rint(par1); /* phil, 1998/12/12 */
-}
-
-double java_lang_Math_atan2 (double par1, double par2)
-{
-       return atan2(par1,par2);
-}
-
-double java_lang_Math_pow (double par1, double par2)
-{
-       return pow(par1,par2);
-}
-
-
-/******************************* java.lang.Runtime **************************************/
-
-void java_lang_Runtime_exitInternal (struct java_lang_Runtime* this, s4 par1)
-{
-       cacao_shutdown (par1);
-}
-struct java_lang_Process* java_lang_Runtime_execInternal (struct java_lang_Runtime* this, java_objectarray* par1, java_objectarray* par2)
-{
-       log_text ("java_lang_Runtime_execInternal called");
-       return NULL;
-}
-s8 java_lang_Runtime_freeMemory (struct java_lang_Runtime* this)
-{
-       log_text ("java_lang_Runtime_freeMemory called");
-       return builtin_i2l (0);
-}
-s8 java_lang_Runtime_totalMemory (struct java_lang_Runtime* this)
-{
-       log_text ("java_lang_Runtime_totalMemory called");
-       return builtin_i2l (0);
-}
-void java_lang_Runtime_gc (struct java_lang_Runtime* this)
-{
-       gc_call();
-}
-void java_lang_Runtime_runFinalization (struct java_lang_Runtime* this)
-{
-       log_text ("java_lang_Runtime_runFinalization called");
-}
-void java_lang_Runtime_traceInstructions (struct java_lang_Runtime* this, s4 par1)
-{
-       log_text ("java_lang_Runtime_traceInstructions called");
-}
-void java_lang_Runtime_traceMethodCalls (struct java_lang_Runtime* this, s4 par1)
-{
-       log_text ("java_lang_Runtime_traceMethodCalls called");
-}
-struct java_lang_String* java_lang_Runtime_initializeLinkerInternal (struct java_lang_Runtime* this)
-{      
-       log_text ("java_lang_Runtime_initializeLinkerInternal called");
-       return (java_lang_String*)javastring_new_char(".");
-}
-struct java_lang_String* java_lang_Runtime_buildLibName (struct java_lang_Runtime* this, struct java_lang_String* par1, struct java_lang_String* par2)
-{
-       log_text ("java_lang_Runtime_buildLibName called");
-       return NULL;
-}
-s4 java_lang_Runtime_loadFileInternal (struct java_lang_Runtime* this, struct java_lang_String* par1)
-{
-       log_text ("java_lang_Runtime_loadFileInternal called");
-       return 1;
-}
-
-
-/**************************************** java.lang.SecurityManager ***********************/
-
-java_objectarray* java_lang_SecurityManager_getClassContext (struct java_lang_SecurityManager* this)
-{
-       log_text ("called: java_lang_SecurityManager_getClassContext");
-       return NULL;
-}
-struct java_lang_ClassLoader* java_lang_SecurityManager_currentClassLoader (struct java_lang_SecurityManager* this)
-{
-       log_text ("called: java_lang_SecurityManager_currentClassLoader");
-       return NULL;
-}
-s4 java_lang_SecurityManager_classDepth (struct java_lang_SecurityManager* this, struct java_lang_String* par1)
-{
-       log_text ("called: java_lang_SecurityManager_classDepth");
-       return 0;
-}
-s4 java_lang_SecurityManager_classLoaderDepth (struct java_lang_SecurityManager* this)
-{
-       log_text ("called: java_lang_SecurityManager_classLoaderDepth");
-       return 0;
-}
-
-
-
-/*********************************** java.lang.System ************************************/
-
-s8 java_lang_System_currentTimeMillis ()
-{
-       struct timeval tv;
-
-       (void) gettimeofday(&tv, NULL);
-       return ((s8) tv.tv_sec) * 1000 + tv.tv_usec / 1000;
-}
-
-
-void java_lang_System_arraycopy (struct java_lang_Object* source, s4 sp, 
-                                 struct java_lang_Object* dest, s4 dp, s4 len)
-{
-       s4 i;
-       java_arrayheader *s = (java_arrayheader*) source;
-       java_arrayheader *d = (java_arrayheader*) dest;
-
-       if (((s == NULL) | (d == NULL)) != 0) { 
-               exceptionptr = proto_java_lang_NullPointerException; 
-               return; 
-               }
-
-       if (s->objheader.vftbl->class != class_array) {
-               exceptionptr = proto_java_lang_ArrayStoreException; 
-               return; 
-               }
-
-       if (((sp<0) | (sp+len > s->size) | (dp<0) | (dp+len > d->size)) != 0) {
-               exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException; 
-               return; 
-               }
-
-       switch (s->arraytype) {
-       case ARRAYTYPE_BYTE:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_bytearray*) d)->data + dp,
-                       ((java_bytearray*) s)->data + sp,
-                       (size_t) len);
-               return;
-       case ARRAYTYPE_BOOLEAN:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_booleanarray*) d)->data + dp,
-                       ((java_booleanarray*) s)->data + sp,
-                       (size_t) len);
-               return;
-       case ARRAYTYPE_CHAR:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_chararray*) d)->data + dp,
-                       ((java_chararray*) s)->data + sp,
-                       (size_t) len * sizeof(u2));
-               return;
-       case ARRAYTYPE_SHORT:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_shortarray*) d)->data + dp,
-                       ((java_shortarray*) s)->data + sp,
-                       (size_t) len * sizeof(s2));
-               return;
-       case ARRAYTYPE_INT:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_intarray*) d)->data + dp,
-                       ((java_intarray*) s)->data + sp,
-                       (size_t) len * sizeof(s4));
-               return;
-       case ARRAYTYPE_LONG:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_longarray*) d)->data + dp,
-                       ((java_longarray*) s)->data + sp,
-                       (size_t) len * sizeof(s8));
-               return;
-       case ARRAYTYPE_FLOAT:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_floatarray*) d)->data + dp,
-                       ((java_floatarray*) s)->data + sp,
-                       (size_t) len * sizeof(float));
-               return;
-       case ARRAYTYPE_DOUBLE:
-               if (s->objheader.vftbl != d->objheader.vftbl) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               memmove(((java_doublearray*) d)->data + dp,
-                       ((java_doublearray*) s)->data + sp,
-                       (size_t) len * sizeof(double));
-               return;
-       case ARRAYTYPE_OBJECT:
-               {
-               java_objectarray *oas = (java_objectarray*) s;
-               java_objectarray *oad = (java_objectarray*) d;
-
-               if (d->objheader.vftbl->class != class_array) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               if (s->arraytype != d->arraytype) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-
-               if (dp<=sp) 
-                       for (i=0; i<len; i++) {
-                               java_objectheader *o = oas->data[sp+i];
-                               if (!builtin_canstore(oad, o)) {
-                                       exceptionptr = proto_java_lang_ArrayStoreException;
-                                       return;
-                                       }
-                               oad->data[dp+i] = o;
-                               }
-               else 
-                       for (i=len-1; i>=0; i--) {
-                               java_objectheader *o = oas->data[sp+i];
-                               if (!builtin_canstore(oad, o)) {
-                                       exceptionptr = proto_java_lang_ArrayStoreException;
-                                       return;
-                                       }
-                               oad->data[dp+i] = o;
-                               }
-               
-               }
-               break;
-       case ARRAYTYPE_ARRAY:
-               {
-               java_arrayarray *aas = (java_arrayarray*) s;
-               java_arrayarray *aad = (java_arrayarray*) d;
-
-               if (d->objheader.vftbl->class != class_array) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-               if (s->arraytype != d->arraytype) {
-                       exceptionptr = proto_java_lang_ArrayStoreException; 
-                       return; 
-                       }
-
-               if (dp<=sp) 
-                       for (i=0; i<len; i++) {
-                               java_arrayheader *o = aas->data[sp+i];
-                               if (!builtin_canstore( (java_objectarray*)aad, 
-                                       (java_objectheader*)o )) {
-                                       exceptionptr = proto_java_lang_ArrayStoreException;
-                                       return;
-                                       }
-                               aad->data[dp+i] = o;
-                               }
-               else
-                       for (i=len-1; i>=0; i--) {
-                               java_arrayheader *o = aas->data[sp+i];
-                               if (!builtin_canstore( (java_objectarray*)aad, 
-                                       (java_objectheader*)o )) {
-                                       exceptionptr = proto_java_lang_ArrayStoreException;
-                                       return;
-                                       }
-                               aad->data[dp+i] = o;
-                               }
-
-               }
-               break;
-
-       default:
-               panic ("Unknown data type for arraycopy");
-       }
-
-}
-
-
-#define MAXPROPS 100
-static int activeprops = 15;
-
-static char *proplist[MAXPROPS][2] = {
-       { "java.class.path", NULL },
-       { "java.home", NULL }, 
-       { "user.home", NULL }, 
-       { "user.name", NULL }, 
-       { "user.dir",  NULL }, 
-       
-       { "java.class.version", "45.3" },
-       { "java.version", "cacao:0.3" },
-       { "java.vendor", "CACAO Team" },
-       { "java.vendor.url", "http://www.complang.tuwien.ac.at/java/cacao/" },
-       { "os.arch", "Alpha" },
-       { "os.name", "Linux/Digital Unix" },
-       { "os.version", "4.0/3.2C/V4.0" },
-       { "path.separator", ":" },
-       { "file.separator", "/" },
-       { "line.separator", "\n" }
-};     
-
-void attach_property (char *name, char *value)
-{
-       if (activeprops >= MAXPROPS) panic ("Too many properties defined");
-       proplist[activeprops][0] = name;
-       proplist[activeprops][1] = value;
-       activeprops++;
-}
-
-
-struct java_util_Properties* java_lang_System_initProperties (struct java_util_Properties* p)
-{
-       u4 i;
-       methodinfo *m;
-#define BUFFERSIZE 200
-       char buffer[BUFFERSIZE];
-       
-       proplist[0][1] = classpath;
-       proplist[1][1] = getenv("JAVA_HOME");
-       proplist[2][1] = getenv("HOME");
-       proplist[3][1] = getenv("USER");
-       proplist[4][1] = getcwd(buffer,BUFFERSIZE);
-       
-       if (!p) panic ("initProperties called with NULL-Argument");
-
-       m = class_resolvemethod (
-               p->header.vftbl->class, 
-               unicode_new_char ("put"), 
-               unicode_new_char ("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;")
-       );
-    if (!m) panic ("Can not find method 'put' for class Properties");
-    
-    for (i=0; i<activeprops; i++) {
-       if (proplist[i][1]==NULL) proplist[i][1]="";
-               
-       asm_calljavamethod (m,  p, 
-                               javastring_new_char(proplist[i][0]),
-                               javastring_new_char(proplist[i][1]),  
-                                       NULL
-                          );
-       }
-
-       return p;
-}
-
-
-
-
-/*********************************** java.lang.Thread ***********************************/
-
-struct java_lang_Thread* java_lang_Thread_currentThread ()
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_currentThread called");
-#ifdef USE_THREADS
-       return (struct java_lang_Thread*)currentThread;
-#else
-       return 0;
-#endif
-}
-
-void java_lang_Thread_yield ()
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_yield called");
-#ifdef USE_THREADS
-       yieldThread();
-#endif
-}
-
-void java_lang_Thread_sleep (s8 par1)
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_sleep called");
-#ifdef USE_THREADS
-       yieldThread();
-#endif
-       /* not yet implemented */
-}
-
-void java_lang_Thread_start (struct java_lang_Thread* this)
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_start called");
-#ifdef USE_THREADS
-       startThread((thread*)this);
-#endif
-}
-
-s4 java_lang_Thread_isAlive (struct java_lang_Thread* this)
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_isAlive called");
-#ifdef USE_THREADS
-       return aliveThread((thread*)this);
-#else
-       return 0;
-#endif
-}
-
-s4 java_lang_Thread_countStackFrames (struct java_lang_Thread* this)
-{
-  log_text ("java_lang_Thread_countStackFrames called");
-  return 0;         /* not yet implemented */
-}
-
-void java_lang_Thread_setPriority0 (struct java_lang_Thread* this, s4 par1)
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_setPriority0 called");
-#ifdef USE_THREADS
-  setPriorityThread((thread*)this, par1);
-#endif
-}
-
-void java_lang_Thread_stop0 (struct java_lang_Thread* this, struct java_lang_Object* par1)
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_stop0 called");
-#ifdef USE_THREADS
-       if (currentThread == (thread*)this)
-       {
-           log_text("killing");
-           killThread(0);
-           /*
-               exceptionptr = proto_java_lang_ThreadDeath;
-               return;
-           */
-       }
-       else
-       {
-               CONTEXT((thread*)this).flags |= THREAD_FLAGS_KILLED;
-               resumeThread((thread*)this);
-       }
-#endif
-}
-
-void java_lang_Thread_suspend0 (struct java_lang_Thread* this)
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_suspend0 called");
-#ifdef USE_THREADS
-       suspendThread((thread*)this);
-#endif
-}
-
-void java_lang_Thread_resume0 (struct java_lang_Thread* this)
-{
-  if (runverbose)
-    log_text ("java_lang_Thread_resume0 called");
-#ifdef USE_THREADS
-       resumeThread((thread*)this);
-#endif
-}
-
-
-
-/************************************ java.lang.Throwable *********************************/
-
-void java_lang_Throwable_printStackTrace0 (struct java_lang_Throwable* this, struct java_io_PrintStream* par1)
-{
-       log_text ("java_lang_Throwable_printStackTrace0 called");
-       return;
-}
-
-struct java_lang_Throwable* java_lang_Throwable_fillInStackTrace (struct java_lang_Throwable *this)
-{
-       this -> detailMessage = 
-         (java_lang_String*) (javastring_new_char ("no backtrace info!") );
-       return this;
-}
-
diff --git a/nat/util.c b/nat/util.c
deleted file mode 100644 (file)
index 968496c..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/***************************** nat/util.c **************************************
-
-       Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
-
-       See file COPYRIGHT for information on usage and disclaimer of warranties
-
-       Contains the native functions for class java.util.
-
-       Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
-
-       Last Change: 1996/11/14
-
-*******************************************************************************/
-
-#include <time.h>
-
-/**************************** java.util.Date **********************************/
-
-
-struct java_lang_String* java_util_Date_toString 
-       (struct java_util_Date* this) 
-{
-       time_t tt;
-       char *buffer;
-       int l;
-       
-       if (!this->valueValid) java_util_Date_computeValue(this);
-       tt = builtin_l2i ( builtin_ldiv(this->value, builtin_i2l(1000) ) );
-
-       buffer = ctime (&tt);
-       l = strlen(buffer);
-       while (l>1 && buffer[l-1]=='\n') l--;
-       buffer[l] = '\0';
-       
-       return (java_lang_String*) javastring_new_char( buffer );
-}
-
-
-struct java_lang_String* java_util_Date_toLocaleString 
-       (struct java_util_Date* this)
-{
-       time_t tt;
-       char *buffer;
-       int l;
-
-       if (!this->valueValid) java_util_Date_computeValue(this);
-       tt = builtin_l2i ( builtin_ldiv(this->value, builtin_i2l(1000) ) );
-
-       buffer = asctime (localtime(&tt));
-       l = strlen(buffer);
-       while (l>1 && buffer[l-1]=='\n') l--;
-       buffer[l] = '\0';
-
-       return (java_lang_String*) javastring_new_char ( buffer );
-}
-
-struct java_lang_String* java_util_Date_toGMTString 
-       (struct java_util_Date* this)
-{
-       time_t tt;
-       char *buffer;
-       int l;
-
-       if (!this->valueValid) java_util_Date_computeValue(this);
-       tt = builtin_l2i ( builtin_ldiv(this->value, builtin_i2l(1000) ) );
-
-       buffer = asctime (gmtime(&tt));
-       l = strlen(buffer);
-       while (l>1 && buffer[l-1]=='\n') l--;
-       buffer[l] = '\0';
-       
-       
-       return (java_lang_String*) javastring_new_char ( buffer );
-}
-
-
-
-void java_util_Date_expand (struct java_util_Date* this)
-{
-       struct tm *t;
-       time_t tt;
-       
-       if (this->expanded) return;
-
-       tt = builtin_l2i ( builtin_ldiv(this->value, builtin_i2l(1000) ) );
-       t = gmtime (&tt);
-       this->tm_millis = 
-         builtin_l2i( builtin_lrem (this->value, builtin_i2l(1000) ) );
-       this->tm_sec = t->tm_sec;
-       this->tm_min = t->tm_min;
-       this->tm_hour = t->tm_hour;
-       this->tm_mday = t->tm_mday;
-       this->tm_mon = t->tm_mon;
-       this->tm_wday = t->tm_wday;
-       this->tm_yday = t->tm_yday;
-       this->tm_year = t->tm_year;
-       this->tm_isdst = t->tm_isdst;
-       this->expanded = 1;
-}
-
-void java_util_Date_computeValue (struct java_util_Date* this)
-{
-       struct tm t;
-       
-       if (this->valueValid) return;
-       t.tm_sec = this->tm_sec;
-       t.tm_min = this->tm_min;
-       t.tm_hour = this->tm_hour;
-       t.tm_mday = this->tm_mday;
-       t.tm_mon = this->tm_mon;
-       t.tm_wday = this->tm_wday;
-       t.tm_yday = this->tm_yday;
-       t.tm_year = this->tm_year;
-       t.tm_isdst = this->tm_isdst;
-       this->value = 
-         builtin_ladd( 
-          builtin_lmul( builtin_i2l(mktime(&t)), builtin_i2l(1000)), 
-          builtin_i2l(this->tm_millis)
-         );
-       this->valueValid = 1;   
-}
index 98594cf5e52c81b1a289ad367a675ab30af89d2b..51307463038fef01ef13241f48884ab14d1e736a 100644 (file)
--- a/native.c
+++ b/native.c
@@ -9,7 +9,7 @@
        eingebunden, und ebenso alle C-Funktionen, mit denen diese
        Methoden implementiert werden.
 
-       Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
+       Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at 
 
        Last Change: 1996/11/14
 
 
 #include <unistd.h>
 #include <time.h>
-
 #include "global.h"
 #include "native.h"
-
-#include "builtin.h"
 #include "nativetypes.hh"
+#include "builtin.h"
 #include "asmpart.h"
 #include "tables.h"
 #include "loader.h"
+#include <math.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/time.h>
 
+#include "../threads/thread.h"                       /* schani */
+#include "../threads/locks.h"
 
-java_objectheader* exceptionptr = NULL;
+/* INCLUDE-Files fuer IO-Funktionen */
 
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/types.h>
+#ifdef _OSF_SOURCE 
+#include <sys/mode.h>
+#endif
+#include <sys/stat.h>
 
+#include "../threads/threadio.h"                    
 
+/* searchpath for classfiles */
 static char *classpath;
 
+/* for java-string to char conversion */
+#define MAXSTRINGSIZE 1000                          
 
-/******************** die f"r die native-Methoden n"otigen Systemklassen *****/
+/******************** systemclasses required for native methods *****/
 
 static classinfo *class_java_lang_Class;
 static classinfo *class_java_lang_Cloneable;
 static classinfo *class_java_lang_CloneNotSupportedException;
-static classinfo *class_java_lang_Double;
-static classinfo *class_java_lang_Float;
-static classinfo *class_java_io_IOException;
+static classinfo *class_java_lang_System;
+static classinfo *class_java_lang_ClassLoader;
 static classinfo *class_java_lang_ClassNotFoundException;
 static classinfo *class_java_lang_InstantiationException;
+static classinfo *class_java_lang_NoSuchMethodError;   
+static classinfo *class_java_lang_NoSuchFieldError;
+static classinfo *class_java_lang_ClassFormatError;
+static classinfo *class_java_lang_IllegalArgumentException;
+static classinfo *class_java_lang_ArrayIndexOutOfBoundsException;
+static classinfo *class_java_lang_NoSuchFieldException;
+static classinfo *class_java_io_SyncFailedException;
+static classinfo *class_java_io_IOException;
+static classinfo *class_java_io_UnixFileSystem;
+static classinfo *class_java_security_PrivilegedActionException;
+static classinfo *class_java_lang_NoSuchMethodException;
+static classinfo *class_java_lang_Double;
+static classinfo *class_java_lang_Float;
+static classinfo *class_java_lang_Long;
+static classinfo *class_java_lang_Byte;
+static classinfo *class_java_lang_Short;
+static classinfo *class_java_lang_Boolean;
+static classinfo *class_java_lang_Void;
+static classinfo *class_java_lang_Character;
+static classinfo *class_java_lang_Integer;
+
+/* the system classloader object */
+struct java_lang_ClassLoader *SystemClassLoader = NULL;
+
+/* for raising exceptions from native methods */
+java_objectheader* exceptionptr = NULL;
 
+/************* use classinfo structure as java.lang.Class object *************/
 
+static void use_class_as_object (classinfo *c) 
+{
+       c->header.vftbl = class_java_lang_Class -> vftbl;
+}
 
-/************************** alle Funktionen einbinden ************************/ 
-
-#include "nat/lang.c"
-#include "nat/io.c"
-#include "nat/util.c"
-
-
-/********************** Tabellen f"ur die Methoden ***************************/
-
+/*********************** include Java Native Interface ***********************/ 
+
+#include "jni.c"
+
+/*************************** include native methods **************************/ 
+
+#include "nat/Object.c"
+#include "nat/String.c"
+#include "nat/ClassLoader.c"
+#include "nat/Class.c"
+#include "nat/Compiler.c"
+#include "nat/Double.c"
+#include "nat/Float.c"
+#include "nat/Math.c"
+#include "nat/Package.c"
+#include "nat/Runtime.c"
+#include "nat/SecurityManager.c"
+#include "nat/System.c"
+#include "nat/Thread.c"
+#include "nat/Throwable.c"
+#include "nat/Finalizer.c"
+#include "nat/Array.c"
+#include "nat/Constructor.c"
+#include "nat/Field.c"
+#include "nat/Method.c"
+#include "nat/FileDescriptor.c"
+#include "nat/FileInputStream.c"
+#include "nat/FileOutputStream.c"
+#include "nat/FileSystem.c"
+#include "nat/ObjectInputStream.c"
+#include "nat/ObjectStreamClass.c"
+#include "nat/RandomAccessFile.c"
+#include "nat/ResourceBundle.c"
+#include "nat/JarFile.c"
+#include "nat/Adler32.c"
+#include "nat/CRC32.c"
+#include "nat/Deflater.c"
+#include "nat/Inflater.c"
+#include "nat/ZipEntry.c"
+#include "nat/ZipFile.c"
+#include "nat/BigInteger.c"
+#include "nat/InetAddress.c"
+#include "nat/InetAddressImpl.c"
+#include "nat/AccessController.c"
+#include "nat/ClassLoader_NativeLibrary.c"
+#include "nat/UnixFileSystem.c"
+
+/************************** tables for methods *******************************/
+
+/* table for locating native methods */
 static struct nativeref {
        char *classname;
        char *methodname;
@@ -72,51 +158,210 @@ static struct nativeref {
 
 #define NATIVETABLESIZE  (sizeof(nativetable)/sizeof(struct nativeref))
 
+/* table for fast string comparison */
 static struct nativecompref {
-       unicode *classname;
-       unicode *methodname;
-       unicode *descriptor;
+       utf *classname;
+       utf *methodname;
+       utf *descriptor;
        bool isstatic;
        functionptr func;
        } nativecomptable [NATIVETABLESIZE];
 
+/* string comparsion table initialized */
 static bool nativecompdone = false;
 
 
-/*********************** Funktion: native_loadclasses **************************
+/*********************** function: native_loadclasses ************************
 
-       L"adt alle Klassen, die die native Methoden zus"atzlich ben"otigen 
+       load classes required for native methods        
 
-*******************************************************************************/
+******************************************************************************/
 
 void native_loadclasses()
 {
+       /* class_new adds the class to the list of classes to be loaded */
        class_java_lang_Cloneable = 
-               loader_load ( unicode_new_char ("java/lang/Cloneable") );
+               class_new ( utf_new_char ("java/lang/Cloneable") );
        class_java_lang_CloneNotSupportedException = 
-               loader_load ( unicode_new_char ("java/lang/CloneNotSupportedException") );
+               class_new ( utf_new_char ("java/lang/CloneNotSupportedException") );
        class_java_lang_Class =
-               loader_load ( unicode_new_char ("java/lang/Class") );
-       class_java_lang_Double =
-               loader_load ( unicode_new_char ("java/lang/Double") );
-       class_java_lang_Float =
-               loader_load ( unicode_new_char ("java/lang/Float") );
+               class_new ( utf_new_char ("java/lang/Class") );
        class_java_io_IOException = 
-               loader_load ( unicode_new_char ("java/io/IOException") );
+               class_new ( utf_new_char ("java/io/IOException") );
        class_java_lang_ClassNotFoundException =
-               loader_load ( unicode_new_char ("java/lang/ClassNotFoundException") );
-       class_java_lang_InstantiationException=
-               loader_load ( unicode_new_char ("java/lang/InstantiationException") );
+               class_new ( utf_new_char ("java/lang/ClassNotFoundException") );
+       class_java_lang_InstantiationException =
+               class_new ( utf_new_char ("java/lang/InstantiationException") );
+       class_java_lang_NoSuchMethodError =
+               class_new ( utf_new_char ("java/lang/NoSuchMethodError") );
+       class_java_lang_NoSuchFieldError =
+               class_new ( utf_new_char ("java/lang/NoSuchFieldError") );      
+       class_java_lang_ClassFormatError =
+               class_new ( utf_new_char ("java/lang/ClassFormatError") );      
+       class_java_io_SyncFailedException =
+               class_new ( utf_new_char ("java/io/SyncFailedException") );
+       class_java_io_UnixFileSystem =
+               class_new ( utf_new_char ("java/io/UnixFileSystem") );
+       class_java_lang_System =
+               class_new ( utf_new_char ("java/lang/System") );
+       class_java_lang_ClassLoader =
+               class_new ( utf_new_char ("java/lang/ClassLoader") );   
+       class_java_security_PrivilegedActionException =
+               class_new( utf_new_char("java/security/PrivilegedActionException"));
+       class_java_lang_IllegalArgumentException =
+               class_new( utf_new_char("java/lang/IllegalArgumentException"));
+       class_java_lang_ArrayIndexOutOfBoundsException =
+               class_new( utf_new_char ("java/lang/ArrayIndexOutOfBoundsException") );
+       class_java_lang_NoSuchFieldException =
+               class_new( utf_new_char ("java/lang/NoSuchFieldException") );       
+       class_java_lang_NoSuchMethodException = 
+               class_new( utf_new_char ("java/lang/NoSuchMethodException") );      
+
+       /* load classes for wrapping primitive types */
+       class_java_lang_Double =
+               class_new( utf_new_char ("java/lang/Double") );
+       class_java_lang_Float =
+               class_new( utf_new_char ("java/lang/Float") );
+       class_java_lang_Character =
+               class_new( utf_new_char ("java/lang/Character") );
+       class_java_lang_Integer =
+               class_new( utf_new_char ("java/lang/Integer") );
+       class_java_lang_Long =
+               class_new( utf_new_char ("java/lang/Long") );
+       class_java_lang_Byte =
+               class_new( utf_new_char ("java/lang/Byte") );
+       class_java_lang_Short =
+               class_new( utf_new_char ("java/lang/Short") );
+       class_java_lang_Boolean =
+               class_new( utf_new_char ("java/lang/Boolean") );
+       class_java_lang_Void =
+               class_new( utf_new_char ("java/lang/Void") );
+
+       /* load to avoid dynamic classloading */
+       class_new(utf_new_char("sun/net/www/protocol/file/Handler"));
+       class_new(utf_new_char("sun/net/www/protocol/jar/Handler"));    
+       class_new(utf_new_char("sun/io/CharToByteISO8859_1"));
        
+       /* start classloader */
+       loader_load(utf_new_char("sun/io/ByteToCharISO8859_1")); 
 }
 
-/********************* Funktion: native_setclasspath ***************************/
+
+/*************** adds a class to the vector of loaded classes ****************/
+
+void systemclassloader_addclass(classinfo *c)
+{
+        methodinfo *m;
+
+       /* find method addClass of java.lang.ClassLoader */
+       m = class_resolvemethod (
+               class_java_lang_ClassLoader, 
+               utf_new_char("addClass"),
+               utf_new_char("(Ljava/lang/Class;)")
+           );
+
+       if (!m) panic("warning: cannot initialize classloader");
+
+       /* prepare class to be passed as argument */
+       use_class_as_object (c);
+
+       /* call 'addClass' */
+       asm_calljavamethod(m,
+                           (java_objectheader*) SystemClassLoader, 
+                          (java_objectheader*) c,
+                          NULL,  
+                          NULL
+                         );       
+}
+
+/*************** adds a library to the vector of loaded libraries ************/
+
+void systemclassloader_addlibrary(java_objectheader *o)
+{
+        methodinfo *m;
+
+       /* find method addElement of java.util.Vector */
+       m = class_resolvemethod (
+               loader_load ( utf_new_char ("java/util/Vector") ),
+               utf_new_char("addElement"),
+               utf_new_char("(Ljava/lang/Object;)V")
+           );
+
+       if (!m) panic("cannot initialize classloader");
+
+       /* call 'addElement' */
+       asm_calljavamethod(m,
+                          SystemClassLoader->nativeLibraries,
+                          o,
+                          NULL,  
+                          NULL
+                         );       
+}
+
+/*****************************************************************************
+
+       create systemclassloader object and initialize instance fields  
+
+******************************************************************************/
+
+void init_systemclassloader() 
+{
+  if (!SystemClassLoader) {
+
+       /* create object and call initializer */
+       SystemClassLoader = (java_lang_ClassLoader*) native_new_and_init(class_java_lang_ClassLoader);  
+
+       /* systemclassloader has no parent */
+       SystemClassLoader->parent      = NULL;
+       SystemClassLoader->initialized = true;
+  }
+}
+
+
+/********************* add loaded library name  ******************************/
+
+void systemclassloader_addlibname(java_objectheader *o)
+{
+        methodinfo *m;
+       java_objectheader *LibraryNameVector;
+       jfieldID id;
+
+       m = class_resolvemethod (
+               loader_load ( utf_new_char ("java/util/Vector") ),
+               utf_new_char("addElement"),
+               utf_new_char("(Ljava/lang/Object;)V")
+           );
+
+       if (!m) panic("cannot initialize classloader");
+
+       id = env.GetStaticFieldID(&env,class_java_lang_ClassLoader,"loadedLibraryNames","Ljava/util/Vector;");
+       if (!id) panic("can not access ClassLoader");
+
+       asm_calljavamethod(m,
+                          GetStaticObjectField(&env,class_java_lang_ClassLoader,id),
+                          o,
+                          NULL,  
+                          NULL
+                         );       
+}
+
+
+/********************* function: native_setclasspath *************************/
  
 void native_setclasspath (char *path)
 {
+       /* set searchpath for classfiles */
        classpath = path;
 }
 
+/***************** function: throw_classnotfoundexception ********************/
+
+void throw_classnotfoundexception()
+{
+       /* throws a ClassNotFoundException */
+       exceptionptr = native_new_and_init (class_java_lang_ClassNotFoundException);
+}
+
 
 /*********************** Funktion: native_findfunction ************************
 
@@ -131,22 +376,26 @@ void native_setclasspath (char *path)
 
 *******************************************************************************/
 
-functionptr native_findfunction (unicode *cname, unicode *mname, 
-                                 unicode *desc, bool isstatic)
+functionptr native_findfunction (utf *cname, utf *mname, 
+                                 utf *desc, bool isstatic)
 {
        u4 i;
+       /* entry of table for fast string comparison */
        struct nativecompref *n;
+        /* for warning message if no function is found */
+       char *buffer;                   
+       int buffer_len,pos;
 
        isstatic = isstatic ? true : false;
 
        if (!nativecompdone) {
                for (i=0; i<NATIVETABLESIZE; i++) {
                        nativecomptable[i].classname   = 
-                                       unicode_new_char(nativetable[i].classname);
+                                       utf_new_char(nativetable[i].classname);
                        nativecomptable[i].methodname  = 
-                                       unicode_new_char(nativetable[i].methodname);
+                                       utf_new_char(nativetable[i].methodname);
                        nativecomptable[i].descriptor  = 
-                                       unicode_new_char(nativetable[i].descriptor);
+                                       utf_new_char(nativetable[i].descriptor);
                        nativecomptable[i].isstatic    = 
                                        nativetable[i].isstatic;
                        nativecomptable[i].func        = 
@@ -162,38 +411,62 @@ functionptr native_findfunction (unicode *cname, unicode *mname,
                    desc==n->descriptor && isstatic==n->isstatic)  return n->func;
                }
 
+       /* no function was found, display warning */
+
+       buffer_len = 
+         utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
+
+       buffer = MNEW(char, buffer_len);
+
+       strcpy(buffer,"warning: native function ");
+        utf_sprint(buffer+strlen(buffer),mname);
+       strcpy(buffer+strlen(buffer),": ");
+        utf_sprint(buffer+strlen(buffer),desc);
+       strcpy(buffer+strlen(buffer)," not found in class ");
+        utf_sprint(buffer+strlen(buffer),cname);
+
+       log_text(buffer);       
+
+       MFREE(buffer,char,buffer_len);
+
        return NULL;
 }
 
 
-/********************** Funktion: javastring_new *****************************
+/********************** function: javastring_new *****************************
 
-       Legt ein neues Objekt vom Typ java/lang/String an, und tr"agt als Text
-       das "ubergebene unicode-Symbol ein. 
-       Return: Zeiger auf den String, oder NULL (wenn Speicher aus)
+       creates a new object of type java/lang/String with the text of 
+       the specified utf8-string
+       
+       return: pointer to the string or NULL (no memory)       
 
 *****************************************************************************/
 
-java_objectheader *javastring_new (unicode *text)
+java_objectheader *javastring_new (utf *u)
 {
-       u4 i;
-       java_lang_String *s;
+        char *utf_ptr = u->text;         /* pointer to current unicode character in utf string */
+       u4 utflength  = utf_strlen(u);   /* length of utf-string if uncompressed */
+       java_lang_String *s;             /* result-string */
        java_chararray *a;
+       u4 i;
        
        s = (java_lang_String*) builtin_new (class_java_lang_String);
-       a = builtin_newarray_char (text->length);
+       a = builtin_newarray_char (utflength);
 
+       /* javastring or character-array could not be created */
        if ( (!a) || (!s) ) return NULL;
 
-       for (i=0; i<text->length; i++) a->data[i] = text->text[i];
-       s -> value = a;
+       /* decompress utf-string */
+       for (i=0; i<utflength; i++) a->data[i] = utf_nextu2(&utf_ptr);
+       
+       /* set fields of the javastring-object */
+       s -> value  = a;
        s -> offset = 0;
-       s -> count = text->length;
+       s -> count  = utflength;
 
        return (java_objectheader*) s;
 }
 
-
 /********************** Funktion: javastring_new_char ************************
 
        Legt ein neues Objekt vom Typ java/lang/String an, und tr"agt als Text
@@ -205,16 +478,20 @@ java_objectheader *javastring_new (unicode *text)
 java_objectheader *javastring_new_char (char *text)
 {
        u4 i;
-       u4 len = strlen(text);
-       java_lang_String *s;
+       u4 len = strlen(text); /* length of the string */
+       java_lang_String *s;   /* result-string */
        java_chararray *a;
        
        s = (java_lang_String*) builtin_new (class_java_lang_String);
        a = builtin_newarray_char (len);
 
+       /* javastring or character-array could not be created */
        if ( (!a) || (!s) ) return NULL;
 
+       /* copy text */
        for (i=0; i<len; i++) a->data[i] = text[i];
+       
+       /* set fields of the javastring-object */
        s -> value = a;
        s -> offset = 0;
        s -> count = len;
@@ -232,7 +509,6 @@ java_objectheader *javastring_new_char (char *text)
        
 ***********************************************************************************/
 
-#define MAXSTRINGSIZE 1000
 char stringbuffer[MAXSTRINGSIZE];
 
 char *javastring_tochar (java_objectheader *so) 
@@ -250,6 +526,27 @@ char *javastring_tochar (java_objectheader *so)
        return stringbuffer;
 }
 
+/****************** function class_findfield_approx ***************************
+       
+       searches in 'classinfo'-structure for a field with the
+       specified name
+
+*******************************************************************************/
+fieldinfo *class_findfield_approx (classinfo *c, utf *name)
+{
+       s4 i;
+       for (i = 0; i < c->fieldscount; i++) {
+               /* compare field names */
+               if ((c->fields[i].name == name))
+                       return &(c->fields[i]);
+               }
+
+       /* field was not found, raise exception */      
+       exceptionptr = native_new_and_init(class_java_lang_NoSuchFieldException);
+       return NULL;
+}
+
 
 /******************** Funktion: native_new_and_init *************************
 
@@ -263,66 +560,319 @@ char *javastring_tochar (java_objectheader *so)
 java_objectheader *native_new_and_init (classinfo *c)
 {
        methodinfo *m;
-       java_objectheader *o = builtin_new (c);
+       java_objectheader *o = builtin_new (c); /* create object */
 
        if (!o) return NULL;
        
+       /* find initializer */
        m = class_findmethod (c, 
-                             unicode_new_char ("<init>"), 
-                             unicode_new_char ("()V"));
+                             utf_new_char ("<init>"), 
+                             utf_new_char ("()V"));
+                                                     
        if (!m) {
+               /* initializer not ofund */
                log_text ("warning: class has no instance-initializer:");
-               unicode_sprint (logtext, c->name);
+               utf_sprint (logtext, c->name);
                dolog();
                return o;
                }
 
+       /* call initializer */
        asm_calljavamethod (m, o,NULL,NULL,NULL);
        return o;
 }
 
+/******************** function: stringtable_update ****************************
+
+       traverses the javastring hashtable and sets the vftbl-entries of
+       javastrings which were temporarily set to NULL, because 
+       java.lang.Object was not yet loaded
+
+*******************************************************************************/
+void stringtable_update ()
+{
+       java_lang_String *js;   
+       java_chararray *a;
+       literalstring *s;       /* hashtable entry */
+       u4 i;
+
+       for (i=0; i<string_hash.size; i++) {
+               s = string_hash.ptr[i];
+               if (s) {
+                       while (s) {
+                                                               
+                               js = (java_lang_String *) s->string;
+                               
+                               if (!js || !(a = js->value)) 
+                                 /* error in hashtable found */
+                                 panic("invalid literalstring in hashtable");
+
+                               if (!js->header.vftbl) 
+                                 /* vftbl of javastring is NULL */ 
+                                 js->header.vftbl = class_java_lang_String -> vftbl;
+
+                               if (!a->header.objheader.vftbl) 
+                                 /* vftbl of character-array is NULL */ 
+                                 a->header.objheader.vftbl = class_array -> vftbl;
+
+                               /* follow link in external hash chain */
+                               s = s->hashlink;
+                       }       
+               }               
+       }
+}
+
 
-/********************* Funktion: literalstring_new ****************************
+/************************* function: u2_utflength ***************************
 
-       erzeugt einen Java-String mit dem angegebenen Text, allerdings nicht
-       auf dem HEAP, sondern in einem anderen Speicherbereich (der String
-       muss dann sp"ater explizit wieder freigegeben werden).
-       Alle Strings, die auf diese Art erzeugt werden, werden in einer
-       gemeinsamen Struktur gespeichert (n"amlich auch "uber die
-       Unicode-Hashtabelle), sodass identische Strings auch wirklich den
-       gleichen Zeiger liefern.
+       returns the utf length in bytes of a u2 array 
+
+*****************************************************************************/
+
+
+u4 u2_utflength(u2 *text, u4 u2_length)
+{
+       u4 result_len =  0;  /* utf length in bytes  */
+       u2 ch;               /* current unicode character */
+       u4 len;
        
-******************************************************************************/
+        for (len = 0; len < u2_length; len++) {
+         
+         /* next unicode character */
+         ch = *text++;
+         
+         /* determine bytes required to store unicode character as utf */
+         if (ch && (ch < 0x80)) 
+           result_len++;
+         else if (ch < 0x800)
+           result_len += 2;    
+         else 
+           result_len += 3;    
+       }
+
+    return result_len;
+}
+
+/********************* function: utf_new_u2 ***********************************
+
+       make utf symbol from u2 array, 
+       if isclassname is true '.' is replaced by '/'
+
+*******************************************************************************/
 
-java_objectheader *literalstring_new (unicode *text)
+utf *utf_new_u2(u2 *unicode_pos, u4 unicode_length, bool isclassname)
 {
-       u4 i;
-       java_lang_String *s;
-       java_chararray *a;
+       char *buffer; /* memory buffer for  unicode characters */
+       char *pos;    /* pointer to current position in buffer */
+       u4 left;      /* unicode characters left */
+       u4 buflength; /* utf length in bytes of the u2 array  */
+       utf *result;  /* resulting utf-string */
+       int i;          
+
+       /* determine utf length in bytes and allocate memory */         
+       buflength = u2_utflength(unicode_pos, unicode_length); 
+       buffer    = MNEW(char,buflength);
+       /* memory allocation failed */
+       if (!buffer) return NULL;
+
+       left = buflength;
+       pos  = buffer;
+
+       for (i = 0; i++ < unicode_length; unicode_pos++) {
+               /* next unicode character */
+               u2 c = *unicode_pos;
+               
+               if ((c != 0) && (c < 0x80)) {
+               /* 1 character */       
+               left--;
+               if ((int) left < 0) break;
+               /* convert classname */
+               if (isclassname && c=='.') 
+                 *pos++ = '/';
+               else
+                 *pos++ = (char) c;
+               } else if (c < 0x800) {             
+               /* 2 characters */                              
+               unsigned char high = c >> 6;
+               unsigned char low  = c & 0x3F;
+               left = left - 2;
+               if ((int) left < 0) break;
+               *pos++ = high | 0xC0; 
+               *pos++ = low  | 0x80;     
+               } else {         
+               /* 3 characters */                              
+               char low  = c & 0x3f;
+               char mid  = (c >> 6) & 0x3F;
+               char high = c >> 12;
+               left = left - 3;
+               if ((int) left < 0) break;
+               *pos++ = high | 0xE0; 
+               *pos++ = mid  | 0x80;  
+               *pos++ = low  | 0x80;   
+               }
+       }
+       
+       /* insert utf-string into symbol-table */
+       result = utf_new(buffer,buflength);
+       MFREE(buffer, char, buflength);
+       return result;
+}
+
+/********************* function: javastring_toutf *****************************
+
+       make utf symbol from javastring
 
-       if (text->string) return text->string;
+*******************************************************************************/
+
+utf *javastring_toutf(java_lang_String *string, bool isclassname)
+{
+        java_lang_String *str = (java_lang_String *) string;
+       return utf_new_u2(str->value->data,str->count, isclassname);
+}
+
+/********************* function: literalstring_u2 *****************************
+
+    searches for the javastring with the specified u2-array in 
+    the string hashtable, if there is no such string a new one is 
+    created 
+
+    if copymode is true a copy of the u2-array is made
+
+*******************************************************************************/
+
+java_objectheader *literalstring_u2 (java_chararray *a, u4 length, bool copymode )
+{
+    literalstring *s;                /* hashtable element */
+    java_lang_String *js;            /* u2-array wrapped in javastring */
+    java_chararray *stringdata;      /* copy of u2-array */      
+    u4 key;   
+    u4 slot;  
+    u2 i;
+
+    /* find location in hashtable */
+    key  = unicode_hashkey (a->data, length);
+    slot = key & (string_hash.size-1);
+    s    = string_hash.ptr[slot];
+
+    while (s) {
        
-       a = lit_mem_alloc (sizeof(java_chararray) + sizeof(u2)*(text->length-1) );
-       a -> header.objheader.vftbl = class_array -> vftbl;
-       a -> header.size = text->length;
-       a -> header.arraytype = ARRAYTYPE_CHAR;
-       for (i=0; i<text->length; i++) a->data[i] = text->text[i];
-
-       s = LNEW (java_lang_String);
-       s -> header.vftbl = class_java_lang_String -> vftbl;
-       s -> value = a;
-       s -> offset = 0;
-       s -> count = text->length;
+      js = (java_lang_String *) s->string;
+       
+      if (js->count == length) {
+       /* compare text */
+       for (i=0; i<length; i++) 
+         if (js->value->data[i] != a->data[i]) goto nomatch;
+                                       
+       /* string already in hashtable, free memory */
+       if (!copymode)
+         lit_mem_free(a, sizeof(java_chararray) + sizeof(u2)*(length-1)+10);
+
+       return (java_objectheader *) js;
+      }
+
+      nomatch:
+      /* follow link in external hash chain */
+      s = s->hashlink;
+    }
+
+    if (copymode) {
+      /* create copy of u2-array for new javastring */
+      u4 arraysize = sizeof(java_chararray) + sizeof(u2)*(length-1)+10;
+      stringdata = lit_mem_alloc ( arraysize );        
+      memcpy(stringdata, a, arraysize );       
+    }  
+    else
+      stringdata = a;
+
+    /* location in hashtable found, complete arrayheader */
+    if (class_array==NULL) panic("class_array not initialized");
+    stringdata -> header.objheader.vftbl = class_array -> vftbl;
+    stringdata -> header.size = length;        
+    stringdata -> header.arraytype = ARRAYTYPE_CHAR;   
+
+    /* create new javastring */
+    js = LNEW (java_lang_String);
+    js -> header.vftbl = class_java_lang_String -> vftbl;
+    js -> value  = stringdata;
+    js -> offset = 0;
+    js -> count  = length;
+
+    /* create new literalstring */
+    s = NEW (literalstring);
+    s->hashlink = string_hash.ptr[slot];
+    s->string   = (java_objectheader *) js;
+    string_hash.ptr[slot] = s;
+
+    /* update numbe of hashtable entries */
+    string_hash.entries++;
+
+    /* reorganization of hashtable */       
+    if ( string_hash.entries > (string_hash.size*2)) {
+
+      /* reorganization of hashtable, average length of 
+         the external chains is approx. 2                */  
+
+      u4 i;
+      literalstring *s;     
+      hashtable newhash; /* the new hashtable */
+      
+      /* create new hashtable, double the size */
+      init_hashtable(&newhash, string_hash.size*2);
+      newhash.entries=string_hash.entries;
+      
+      /* transfer elements to new hashtable */
+      for (i=0; i<string_hash.size; i++) {
+       s = string_hash.ptr[i];
+       while (s) {
+         literalstring *nexts = s -> hashlink;  
+         js   = (java_lang_String*) s->string;
+         slot = (unicode_hashkey(js->value->data,js->count)) & (newhash.size-1);
+         
+         s->hashlink = newhash.ptr[slot];
+         newhash.ptr[slot] = s;
+       
+         /* follow link in external hash chain */  
+         s = nexts;
+       }
+      }
+       
+      /* dispose old table */  
+      MFREE (string_hash.ptr, void*, string_hash.size);
+      string_hash = newhash;
+    }
+                       
+    return (java_objectheader *) js;
+}
 
-       unicode_setstringlink (text, (java_objectheader*) s);
-       return (java_objectheader*) s;
+/******************** Funktion: literalstring_new *****************************
+
+    creates a new javastring with the text of the utf-symbol
+    and inserts it into the string hashtable
+
+*******************************************************************************/
+
+java_objectheader *literalstring_new (utf *u)
+{
+    char *utf_ptr = u->text;         /* pointer to current unicode character in utf string */
+    u4 utflength  = utf_strlen(u);   /* length of utf-string if uncompressed */
+    java_chararray *a;               /* u2-array constructed from utf string */
+    java_objectheader *js;
+    u4 i;
+    
+    /* allocate memory */ 
+    a = lit_mem_alloc (sizeof(java_chararray) + sizeof(u2)*(utflength-1)+10 ); 
+    /* convert utf-string to u2-array */
+    for (i=0; i<utflength; i++) a->data[i] = utf_nextu2(&utf_ptr);     
+
+    return literalstring_u2(a, utflength, false);
 }
 
 
-/********************** Funktion: literalstring_free **************************
+/********************** function: literalstring_free **************************
 
-       L"oscht einen Java-String wieder aus dem Speicher (wird zu Systemende
-       vom Hashtabellen-Verwalter aufgerufen)
+        removes a javastring from memory                      
 
 ******************************************************************************/
 
@@ -330,10 +880,17 @@ void literalstring_free (java_objectheader* sobj)
 {
        java_lang_String *s = (java_lang_String*) sobj;
        java_chararray *a = s->value;
+
+       log_text("literalstring_free called");
        
+       /* dispose memory of java.lang.String object */
        LFREE (s, java_lang_String);
-       LFREE (a, sizeof(java_chararray) + sizeof(u2)*(a->header.size-1));
+       /* dispose memory of java-characterarray */
+       LFREE (a, sizeof(java_chararray) + sizeof(u2)*(a->header.size-1)); /* +10 ?? */
 }
 
 
 
+
+
+
index c484642b441e89a2cb6af674d0a6c246409a74c9..26da5d597f6782296343897742bd06c63a5e2790 100644 (file)
--- a/native.h
+++ b/native.h
 
 *******************************************************************************/
 
+/* Java Native Interface */
+#include "jni.h"
 
+/* structure for class java.lang.String */
+struct java_lang_String;
+
+/* for raising exceptions from native methods */
 extern java_objectheader* exceptionptr;
 
+/* javastring-hashtable */
+extern hashtable string_hash; 
+
+/* load classes required for native methods */
 void native_loadclasses ();
+
+/* set searchpath for classfiles */
 void native_setclasspath (char *path);
 
-functionptr native_findfunction (unicode *cname, unicode *mname, 
-                                 unicode *desc, bool isstatic);
+/* find native function */
+functionptr native_findfunction (utf *cname, utf *mname, 
+                                 utf *desc, bool isstatic);
 
-java_objectheader *javastring_new (unicode *text);
+/* creates a new object of type java/lang/String from a utf-text */
+java_objectheader *javastring_new (utf *text);
+
+/* creates a new object of type java/lang/String from a c-string */
 java_objectheader *javastring_new_char (char *text);
+
+/* make c-string from a javastring (debugging) */
 char *javastring_tochar (java_objectheader *s);
 
+/* create new object on the heap and call the initializer */
 java_objectheader *native_new_and_init (classinfo *c);
 
-java_objectheader *literalstring_new (unicode *text);
+/* add property to system-property vector */
+void attach_property(char *name, char *value);
+
+/* correct vftbl-entries of javastring-hash */
+void stringtable_update();
+
+/* throw classnotfoundexcetion */
+void throw_classnotfoundexception();
+
+/* make utf symbol from javastring */
+utf *javastring_toutf(struct java_lang_String *string, bool isclassname);
+
+/* make utf symbol from u2 array */
+utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
+
+/* determine utf length in bytes of a u2 array */
+u4 u2_utflength(u2 *text, u4 u2_length);
+
+/* create systemclassloader object and initialize its instance fields  */
+void init_systemclassloader();
+
+/* search 'classinfo'-structure for a field with the specified name */
+fieldinfo *class_findfield_approx (classinfo *c, utf *name);
+
+/* creates a new javastring with the text of the utf-symbol */
+java_objectheader *literalstring_new (utf *u);
+
+/* creates a new javastring with the text of the u2-array */
+java_objectheader *literalstring_u2 (java_chararray *a, u4 length, bool copymode);
+
+/* dispose a javastring */
 void literalstring_free (java_objectheader*);
 
-void attach_property(char *name, char *value);
+void systemclassloader_addlibname(java_objectheader *o);
+void systemclassloader_addlibrary(java_objectheader *o);
+
index 82ce1e0783fd23de1e6030ca6767adfb337c3156..bfb734b3919f72ec0a91cab75fe8bff1e90cabf4 100644 (file)
@@ -17,7 +17,7 @@
                 Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
                         Philipp Tomsich     EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: cacao.c 132 1999-09-27 15:54:42Z chris $
+       Last Change: $Id: cacao.c 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
@@ -45,7 +45,7 @@ bool new_gc = false;
 
 static bool showmethods = false;
 static bool showconstantpool = false;
-static bool showunicode = false;
+static bool showutf = false;
 static classinfo *topclass;
 
 #ifndef USE_THREADS
@@ -220,7 +220,7 @@ static void print_usage()
 #ifdef OLD_COMPILER
        printf ("                 s(tack) ....... show stack for every javaVM-command\n");
 #endif
-       printf ("                 u(nicode) ..... show the unicode - hash\n");
+       printf ("                 u(tf) ......... show the utf - hash\n");
 }   
 
 
@@ -381,7 +381,7 @@ static void print_stats()
        sprintf (logtext, "Distribution of basic block sizes");
        dolog();
        sprintf (logtext,
-       "  1    2    3    4   5   6   7   8   9  10 <13 <15 <17 <19 <21 <26 <31 >30");
+       "  0    1    2    3    4   5   6   7   8   9 <13 <15 <17 <19 <21 <26 <31 >30");
        dolog();
        sprintf (logtext, "%3d%5d%5d%5d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d",
                count_block_size_distribution[0], count_block_size_distribution[1], count_block_size_distribution[2],
@@ -397,7 +397,7 @@ static void print_stats()
        dolog();
        sprintf (logtext, "Size of Class Infos (Kb):%10.3f", (float) (count_class_infos) / 1024);
        dolog();
-       sprintf (logtext, "Size of Const Pool (Kb): %10.3f", (float) (count_const_pool_len + count_unicode_len) / 1024);
+       sprintf (logtext, "Size of Const Pool (Kb): %10.3f", (float) (count_const_pool_len + count_utf_len) / 1024);
        dolog();
        sprintf (logtext, "Size of Vftbl (Kb):      %10.3f", (float) count_vftbl_len / 1024);
        dolog();
@@ -405,7 +405,7 @@ static void print_stats()
        dolog();
        sprintf (logtext, "Size of native stub (Kb):%10.3f", (float) count_nstub_len / 1024);
        dolog();
-       sprintf (logtext, "Size of Unicode (Kb):    %10.3f", (float) count_unicode_len / 1024);
+       sprintf (logtext, "Size of Utf (Kb):        %10.3f", (float) count_utf_len / 1024);
        dolog();
        sprintf (logtext, "Size of VMCode (Kb):     %10.3f(%d)", (float) count_vmcode_len / 1024,
                                                      count_vmcode_len - 18 * count_all_methods);
@@ -414,6 +414,11 @@ static void print_stats()
        dolog();
        sprintf (logtext, "Number of loaded Methods: %d\n\n", count_all_methods);
        dolog();
+
+       sprintf (logtext, "Calls of utf_new: %22d", count_utf_new);
+       dolog();
+       sprintf (logtext, "Calls of utf_new (element found): %6d\n\n", count_utf_new_found);
+       dolog();
 }
 
 
@@ -457,7 +462,7 @@ void exit_handler(void)
                                
        if (showmethods) class_showmethods (topclass);
        if (showconstantpool)  class_showconstantpool (topclass);
-       if (showunicode)       unicode_show ();
+       if (showutf)           utf_show ();
 
 #ifdef USE_THREADS
        clear_thread_flags();           /* restores standard file descriptor
@@ -474,7 +479,7 @@ void exit_handler(void)
        compiler_close ();
 #endif
        loader_close ();
-       unicode_close ( literalstring_free );
+       tables_close ( literalstring_free );
 
        if (verbose || getcompilingtime || statistics) {
                log_text ("CACAO terminated");
@@ -671,7 +676,7 @@ int main(int argc, char **argv)
 #ifdef OLD_COMPILER
                                case 's':  showstack=true; compileverbose=true; break;
 #endif
-                               case 'u':  showunicode=true; break;
+                               case 'u':  showutf=true; break;
                                default:   print_usage();
                                        exit(10);
                                }
@@ -708,7 +713,7 @@ int main(int argc, char **argv)
        suck_init (classpath);
        native_setclasspath (classpath);
                
-       unicode_init();
+       tables_init();
        heap_init(heapsize, heapstartsize, &dummy);
        loader_init();
 #ifdef OLD_COMPILER
@@ -726,7 +731,7 @@ int main(int argc, char **argv)
                if (cp[i]=='.') cp[i]='/';        /* auf slashes umbauen */
        }
 
-       topclass = loader_load ( unicode_new_char (cp) );
+       topclass = loader_load ( utf_new_char (cp) );
 
        loader_compute_subclasses();
 
@@ -746,21 +751,21 @@ int main(int argc, char **argv)
 
                mainmethod = class_findmethod (
                                                                           topclass,
-                                                                          unicode_new_char ("main"), 
-                                                                          unicode_new_char ("([Ljava/lang/String;)V")
+                                                                          utf_new_char ("main"), 
+                                                                          utf_new_char ("([Ljava/lang/String;)V")
                                                                           );
                if (!mainmethod) panic ("Can not find method 'void main(String[])'");
                if ((mainmethod->flags & ACC_STATIC) != ACC_STATIC) panic ("main is not static!");
                        
                a = builtin_anewarray (argc - opt_ind, class_java_lang_String);
                for (i=opt_ind; i<argc; i++) {
-                       a->data[i-opt_ind] = javastring_new (unicode_new_char (argv[i]) );
+                       a->data[i-opt_ind] = javastring_new (utf_new_char (argv[i]) );
                }
                exceptionptr = asm_calljavamethod (mainmethod, a, NULL,NULL,NULL );
        
                if (exceptionptr) {
                        printf ("#### Program has thrown: ");
-                       unicode_display (exceptionptr->vftbl->class->name);
+                       utf_display (exceptionptr->vftbl->class->name);
                        printf ("\n");
                }
 
@@ -783,11 +788,11 @@ int main(int argc, char **argv)
                methodinfo *m;
                if (specificsignature)
                        m = class_findmethod(topclass, 
-                                                                unicode_new_char(specificmethodname),
-                                                                unicode_new_char(specificsignature));
+                                                                utf_new_char(specificmethodname),
+                                                                utf_new_char(specificsignature));
                else
                        m = class_findmethod(topclass, 
-                                                                unicode_new_char(specificmethodname), NULL);
+                                                                utf_new_char(specificmethodname), NULL);
                if (!m) panic ("Specific method not found");
 #ifdef OLD_COMPILER
                if (newcompiler)
index 76f6d510c7b178c0869b8b379c57057232f3007c..134276556ab9f90eb2b9725a1210d3b443b0af32 100644 (file)
        Changes: Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
                 Philipp Tomsich     EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: headers.c 115 1999-01-20 01:52:45Z phil $
+       Last Change: $Id: headers.c 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
 #include "config.h" /* phil */
-
 #include "global.h"
-
 #include "tables.h"
 #include "loader.h"
 
 
-/******* verschiedene externe Funktionen "faelschen" (=durch Dummys ersetzen), 
-  damit der Linker zufrieden ist *********/
+/******* replace some external functions  *********/
  
-functionptr native_findfunction 
-  (unicode *cname, unicode *mname, unicode *desc, bool isstatic)
+functionptr native_findfunction (utf *cname, utf *mname, utf *desc, bool isstatic)
 { return NULL; }
 
-java_objectheader *literalstring_new (unicode *text)
+java_objectheader *javastring_new (utf *text)         /* schani */
 { return NULL; }
 
-java_objectheader *javastring_new (unicode *text)         /* schani */
-{ return NULL; }
+void throw_classnotfoundexception() 
+{ 
+       panic("class not found"); 
+}
 
+java_objectheader *literalstring_new (utf *u)
+{ return NULL; }  
+
+void literalstring_free (java_objectheader *o) { }
+void stringtable_update () { }
 void synchronize_caches() { }
 void asm_call_jit_compiler () { }
 void asm_calljavamethod () { }
 void asm_dumpregistersandcall () { }
+s4 asm_builtin_checkcast(java_objectheader *obj, classinfo *class) { return 0; }
 
 s4 asm_builtin_idiv (s4 a, s4 b) {return 0;}
 s4 asm_builtin_irem (s4 a, s4 b) {return 0;}
@@ -75,14 +79,18 @@ void asm_switchstackandcall () { }
 
 java_objectheader *native_new_and_init (void *p) { return NULL; }
 
-/************************ globale Variablen **********************/
+/************************ global variables **********************/
 
 java_objectheader *exceptionptr;                       /* schani */
 int  newcompiler = true;
 bool verbose =  false;
 
-static chain *nativechain;
+static chain *nativemethod_chain;                             /* chain with native methods     */
+static chain *nativeclass_chain;                              /* chain with processed classes  */      
+static chain *ident_chain;        /* chain with method and field names in current class */
 static FILE *file = NULL;
+static u4 outputsize;
+static bool dopadding;
 
 static void printIDpart (int c) 
 {
@@ -95,17 +103,14 @@ static void printIDpart (int c)
 
 }
 
-static void printID (unicode *name)
+static void printID (utf *u)
 {
+       char *utf_ptr = u->text;
        int i;
-       for (i=0; i<name->length; i++) {
-               printIDpart (name->text[i]);
-       }
-}
 
-
-u4 outputsize;
-bool dopadding;
+       for (i=0; i<utf_strlen(u); i++) 
+               printIDpart (utf_nextu2(&utf_ptr));
+}
 
 static void addoutputsize (int len)
 {
@@ -119,11 +124,11 @@ static void addoutputsize (int len)
 }
 
 
-static u2 *printtype (u2 *desc)
+static char *printtype (char *utf_ptr)
 {
        u2 c;
 
-       switch (*(desc++)) {
+       switch (utf_nextu2(&utf_ptr)) {
                case 'V': fprintf (file, "void");
                          break;
                case 'I':
@@ -144,7 +149,7 @@ static u2 *printtype (u2 *desc)
                   break;
                case '[':
                        addoutputsize ( sizeof(java_arrayheader*) ); 
-                       switch (*(desc++)) {
+                       switch (utf_nextu2(&utf_ptr)) {
                                case 'I':  fprintf (file, "java_intarray*"); break;
                                case 'J':  fprintf (file, "java_longarray*"); break;
                                case 'Z':  fprintf (file, "java_booleanarray*"); break;
@@ -154,14 +159,14 @@ static u2 *printtype (u2 *desc)
                                case 'F':  fprintf (file, "java_floatarray*"); break;
                                case 'D':  fprintf (file, "java_doublearray*"); break;
                                
-                               case '[':  fprintf (file, "java_arrayarray*");
-                                          while ((*desc) == '[') desc++;
-                                          if ((*desc)!='L') desc++;
-                                          else while (*(desc++) != ';');
+                               case '[':  fprintf (file, "java_arrayarray*");                                         
+                                          while ((c = utf_nextu2(&utf_ptr)) == '[') ;
+                                          if (c=='L') 
+                                                          while (utf_nextu2(&utf_ptr) != ';');
                            break;
                            
                                case 'L':  fprintf (file, "java_objectarray*");
-                                          while ( *(desc++) != ';');
+                                          while ( utf_nextu2(&utf_ptr) != ';');
                                           break;
                                default: panic ("invalid type descriptor");
                                }
@@ -170,22 +175,38 @@ static u2 *printtype (u2 *desc)
                case 'L': 
                        addoutputsize ( sizeof(java_objectheader*));
             fprintf (file, "struct ");
-            while ( (c = *(desc++)) != ';' ) printIDpart (c);           
+            while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c);        
             fprintf (file, "*");
                        break;
                                        
                default:  panic ("Unknown type in field descriptor");
        }
        
-       return (desc);
+       return utf_ptr;
 }
 
+/******* determine the number of entries of a utf string in the ident chain *****/
 
+static int searchidentchain_utf(utf *ident) 
+{
+       utf *u = chain_first(ident_chain);     /* first element of list */
+       int count = 0;
+
+       while (u) {
+               if (u==ident) count++;         /* string found */
+               u = chain_next(ident_chain);   /* next element in list */ 
+       }
+
+       return count;
+}
+
+/**************** print structure for direct access to objects ******************/     
 
 static void printfields (classinfo *c)
 {
        u4 i;
        fieldinfo *f;
+       int ident_count;
        
        if (!c) {
                addoutputsize ( sizeof(java_objectheader) );
@@ -202,106 +223,189 @@ static void printfields (classinfo *c)
                        fprintf (file,"   ");
                        printtype (f->descriptor->text);
                        fprintf (file, " ");
-                       unicode_fprint (file, f->name);
-                       fprintf (file, ";\n");
-                       }
-               }
-}
-
-
-
-
-static void remembermethods (classinfo *c)
-{
-       u2 i;
-       methodinfo *m;
+                       utf_fprint (file, f->name);
 
-       for (i=0; i<c->methodscount; i++) {
-               m = &(c->methods[i]);
+                       /* rename multiple fieldnames */
+                       if (ident_count = searchidentchain_utf(f->name))
+                               fprintf(file,"%d",ident_count - 1);             
+                       chain_addlast(ident_chain,f->name);     
 
-               if (m->flags & ACC_NATIVE) {
-                       chain_addlast (nativechain, m);
+                       fprintf (file, ";\n");
                        }
-                                       
                }
 }
 
-
-
+/***************** store prototype for native method in file ******************/
 
 static void printmethod (methodinfo *m)
 {
-       u2 *d;
+       char *utf_ptr;
        u2 paramnum=1;
-       
-       d = m->descriptor->text;
-       while (*(d++) != ')');
-                               
-       printtype (d);
-       fprintf (file," ");
-       printID (m->class->name);
+       u2 ident_count;
+
+       /* search for return-type in descriptor */      
+       utf_ptr = m->descriptor->text;
+       while (utf_nextu2(&utf_ptr) != ')');
+
+       /* create remarks */
+       fprintf (file,"/*\n * Class:     ");
+       utf_fprint (file, m->class->name);
+       fprintf (file,"\n * Method:    ");
+       utf_fprint (file, m->name);
+       fprintf (file,"\n * Signature: ");
+       utf_fprint (file, m->descriptor);
+       fprintf (file,"\n */\n");       
+
+       /* create prototype */                  
+       fprintf (file,"JNIEXPORT ");                            
+       printtype (utf_ptr);
+       fprintf (file," JNICALL Java_");
+       printID (m->class->name);           
+
+       /* rename overloaded method */
+       if (ident_count = searchidentchain_utf(m->name))
+               fprintf(file,"%d",ident_count - 1);             
+       chain_addlast(ident_chain,m->name);     
+
        fprintf (file,"_");
        printID (m->name);
-       fprintf (file," (");
-                                       
-       d = m->descriptor->text+1;
+       fprintf (file," (JNIEnv *env ");
+       
+       utf_ptr = m->descriptor->text+1;
                        
        if (! (m->flags & ACC_STATIC) ) {
-               fprintf (file, "struct ");
+       
+               fprintf (file, ",  struct ");
                printID (m->class->name);
-               fprintf (file, "* this");
-               if ((*d)!=')') fprintf (file, ", ");
-               }
+               fprintf (file, "* this ");
+
+           };
+
+       if ((*utf_ptr)!=')') fprintf (file, ", "); 
                        
-       while ((*d)!=')') {
-               d = printtype (d);
+       while ((*utf_ptr)!=')') {
+               utf_ptr = printtype (utf_ptr);
                fprintf (file, " par%d", paramnum++);
-               if ((*d)!=')') fprintf (file, ", ");
+               if ((*utf_ptr)!=')') fprintf (file, ", ");
                }
                        
        fprintf (file, ");\n");
 }
 
 
-static void headers_generate (classinfo *c)
+/****************** remove package-name in fully-qualified classname *********************/
+
+static void simple_classname(char *buffer, utf *u)
+{
+  u2 i, simplename_start;
+
+  for (i=utf_strlen(u); i>0; i--) { 
+
+       if (u->text[i] == '$') u->text[i] = '_'; else /* convert '$' to '_' */
+    if (u->text[i] == '/') {
+       /* beginning of simple name */
+        simplename_start = i+1;
+               break;
+       }
+  }
+
+  for (i=simplename_start; i < utf_strlen(u); i++) 
+                 buffer[i-simplename_start] = u->text[i];
+
+  buffer[i-simplename_start] = '\0';                
+}
+
+/*********** create headerfile for classes and store native methods in chain ************/
+
+static void headerfile_generate (classinfo *c)
 {
+       char header_filename[1024] = "";
+       char classname[1024]; 
+       u2 i;
+       methodinfo *m;                  
+                     
+       /* store class in chain */                    
+       chain_addlast (nativeclass_chain, c);                                                           
+                               
+       /* open headerfile for class */
+       simple_classname(classname,c->name);                                                                                                                                            
+
+       /* create chain for renaming fields */
+       ident_chain = chain_new ();
+       
+       sprintf(header_filename, "nat/%s.h", classname);
+       file = fopen (header_filename, "w");
+       if (!file) panic ("Can not open file to store header information");                                                                                     
+       fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n"); 
+
+       /* create structure for direct access to objects */     
        fprintf (file, "/* Structure information for class: ");
-       unicode_fprint (file, c->name);
+       utf_fprint (file, c->name);
        fprintf (file, " */\n\n");
-
        fprintf (file, "typedef struct ");
-       printID (c->name);
+       printID (c->name);                                                      
        fprintf (file, " {\n");
-       
        outputsize=0;
        dopadding=true;
-       printfields (c);
-
+       printfields (c);                                                        
        fprintf (file, "} ");
        printID (c->name);
-       fprintf (file, ";\n\n");
+       fprintf (file, ";\n\n");                            
 
-       remembermethods (c);
-       
+       /* create chain for renaming overloaded methods */
+       chain_free(ident_chain);                                        
+       ident_chain = chain_new ();
+
+       /* create method-prototypes */
+                               
+       for (i=0; i<c->methodscount; i++) {
+
+               m = &(c->methods[i]);
 
-       fprintf (file, "\n\n");
+               if (m->flags & ACC_NATIVE) {
+                       chain_addlast (nativemethod_chain, m);     
+                       printmethod(m);                                             
+                       }                                                       
+               }
+                               
+
+       chain_free(ident_chain);                                 
+       fclose(file);
 }
 
+/******** print classname, '$' used to seperate inner-class name ***********/
+
+void print_classname (classinfo *clazz)
+{
+       utf *u = clazz->name;
+    char *endpos  = u->text + u->blength;
+    char *utf_ptr = u->text; 
+       u2 c;
+
+    while (utf_ptr<endpos) {
+               if ((c=utf_nextu2(&utf_ptr)) == '_')
+                       putc ('$',file);
+               else
+                       putc (c,file);
+       }
+} 
+
 
+/*************** create table for locating native functions ****************/
 
 static void printnativetableentry (methodinfo *m)
 {
        fprintf (file, "   { \"");
-       unicode_fprint (file, m->class->name);
+       print_classname(m->class);
        fprintf (file, "\",\n     \"");
-       unicode_fprint (file, m->name);
+       utf_fprint (file, m->name);
        fprintf (file, "\",\n     \"");
-       unicode_fprint (file, m->descriptor);
+       utf_fprint (file, m->descriptor);
        fprintf (file, "\",\n     ");
        if ( (m->flags & ACC_STATIC) !=0)  fprintf (file, "true");
                                      else fprintf (file, "false");
        fprintf (file, ",\n     ");
-       fprintf (file, "(functionptr) ");
+       fprintf (file, "(functionptr) Java_");
        printID (m->class->name);
        fprintf (file,"_");
        printID (m->name);
@@ -309,35 +413,39 @@ static void printnativetableentry (methodinfo *m)
 }
 
 
+/***************************************************************************
 
+       create the nativetypes-headerfile which includes 
+       the headerfiles of the classes stored in the classes-chain 
 
+****************************************************************************/
 
-static void headers_start ()
+static void headers_finish ()
 {
+       methodinfo *m;
+       classinfo *c;
+       char classname[1024];
+       
        file = fopen ("nativetypes.hh", "w");
        if (!file) panic ("Can not open file 'native.h' to store header information");
        
        fprintf (file, "/* Headerfile for native methods: nativetypes.hh */\n");
-       fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n"); 
-
-       nativechain = chain_new ();
-}
-
-
-static void headers_finish ()
-{
-       methodinfo *m;
-       
-       fprintf (file, "\n/* Prototypes for native methods */\n\n");
+       fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n");     
+       fprintf (file, "\n/* include native-Headerfiles */\n\n");
+                       
+       c = chain_first (nativeclass_chain);
+       while (c) {
        
-       m = chain_first (nativechain);
-       while (m) {
-               dopadding=false;                
-               printmethod (m);
-               
-               m = chain_next (nativechain);
-               }
+               dopadding=false;
+               simple_classname(classname,c->name);                                                                                                                                                                                    
+               fprintf(file,"#include \"nat/%s.h\"\n",classname);              
+               c = chain_next (nativeclass_chain);             
+       }
 
+    fclose(file);
+       chain_free (nativeclass_chain);
+       
+       /* create table of native-methods */
 
        file = fopen ("nativetable.hh", "w");
        if (!file) panic ("Can not open file 'nativetable' to store native-link-table");
@@ -345,19 +453,15 @@ static void headers_finish ()
        fprintf (file, "/* Table of native methods: nativetables.hh */\n");
        fprintf (file, "/* This file is machine generated, don't edit it !*/\n\n"); 
 
-       while ( (m = chain_first (nativechain)) != NULL) {
-               chain_remove (nativechain);
-               
+       while ( (m = chain_first (nativemethod_chain)) != NULL) {
+               chain_remove (nativemethod_chain);              
                printnativetableentry (m);
+       }
                
-               }
-               
-       chain_free (nativechain);
+       chain_free (nativemethod_chain);
        fclose (file);
-}
-
-
 
+}
 
 
 /******************** interne Funktion: print_usage ************************
@@ -373,7 +477,6 @@ static void print_usage()
 
 
 
-
 /************************** Funktion: main *******************************
 
    Das Hauptprogramm.
@@ -417,7 +520,7 @@ int main(int argc, char **argv)
    /**************************** Programmstart *****************************/
 
        log_init (NULL);
-       log_text ("Java - header-generator started");
+       log_text ("Java - header-generator started"); 
        
        sprintf(offsets_filename, "%s/offsets.h", SYSDEP_DIR); /* phil */
        file = fopen(offsets_filename, "w");
@@ -435,39 +538,43 @@ int main(int argc, char **argv)
        fprintf (file, "#define offdiffval     %3d\n", (int) OFFSET(vftbl, diffval));
 
        fclose (file);
-       
+
        suck_init (classpath);
-       
-       unicode_init ();
+   
+       tables_init ();
        heap_init (heapsize, heapsize, &dummy);
        loader_init ();
 
 
    /*********************** JAVA-Klassen laden  ***************************/
-   
-       headers_start ();
-
+       
+       nativemethod_chain = chain_new ();
+       nativeclass_chain = chain_new ();
        
        for (a=1; a<argc; a++) {   
-               cp = argv[a];
-               for (i=strlen(cp)-1; i>=0; i--) {     /* Punkte im Klassennamen */
-                       if (cp[i]=='.') cp[i]='/';        /* auf slashes umbauen */
+               cp = argv[a];
+
+               /* convert classname */
+               for (i=strlen(cp)-1; i>=0; i--)    
+                       switch (cp[i]) {
+                         case '.': cp[i]='/';
+                                       break;
+                         case '_': cp[i]='$';    
                        }
-
-               topclass = loader_load ( unicode_new_char (cp) );
-               
-               headers_generate (topclass);
-               }
        
+               topclass = loader_load ( utf_new_char (cp) );
+               
+        headerfile_generate (topclass);
+       }
 
        headers_finish ();
 
-
    /************************ Freigeben aller Resourcen *******************/
 
        loader_close ();
        heap_close ();
-       unicode_close (NULL);
+       tables_close ( literalstring_free );
        
 
    /* Endemeldung ausgeben und mit entsprechendem exit-Status terminieren */
diff --git a/src/native/jni.c b/src/native/jni.c
new file mode 100644 (file)
index 0000000..d743272
--- /dev/null
@@ -0,0 +1,2156 @@
+/********************************** jni.c *****************************************
+
+       implementation of the Java Native Interface functions                             
+       which are used in the JNI function table                                         
+
+***********************************************************************************/
+
+
+#define JNI_VERSION       0x00010002
+
+
+/********************* accessing instance-fields **********************************/
+
+#define setField(obj,typ,var,val) *((typ*) ((long int) obj + (long int) var->offset))=val;  
+#define getField(obj,typ,var)     *((typ*) ((long int) obj + (long int) var->offset))
+#define setfield_critical(clazz,obj,name,sig,jdatatype,val) setField(obj,jdatatype,getFieldID_critical(env,clazz,name,sig),val); 
+
+/*************************** function: jclass_findfield ****************************
+       
+       searches for field with specified name and type in a 'classinfo'-structur
+       if no such field is found NULL is returned 
+
+************************************************************************************/
+
+fieldinfo *jclass_findfield (classinfo *c, utf *name, utf *desc)
+{
+       s4 i;
+       for (i = 0; i < c->fieldscount; i++) {
+               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc))
+                       return &(c->fields[i]);
+               }
+
+       return NULL;
+}
+
+/********************* returns version of native method interface *****************/
+
+jint GetVersion (JNIEnv* env)
+{
+       return JNI_VERSION;
+}
+
+/****************** loads a class from a buffer of raw class data *****************/
+
+jclass DefineClass(JNIEnv* env, const char *name, jobject loader, const jbyte *buf, jsize len) 
+{
+        jclass clazz; 
+
+       /* change suck-mode, so subsequent class_load will read from memory-buffer */
+       classload_buffer( (u1*) buf,len);
+
+        clazz = loader_load(utf_new_char ((char *) name));
+
+       /* restore old suck-mode */
+       classload_buffer(NULL,0);
+
+       return clazz;
+}
+
+
+/*************** loads locally defined class with the specified name **************/
+
+jclass FindClass (JNIEnv* env, const char *name) 
+{
+       classinfo *c;  
+  
+       c = loader_load(utf_new_char ((char *) name));
+
+       if (!c) exceptionptr = native_new_and_init(class_java_lang_ClassFormatError);
+
+       return c;
+}
+  
+
+/*********************************************************************************** 
+
+       converts java.lang.reflect.Method or 
+       java.lang.reflect.Constructor object to a method ID  
+  
+ **********************************************************************************/   
+  
+jmethodID FromReflectedMethod (JNIEnv* env, jobject method)
+{
+       log_text("JNI-Call: FromReflectedMethod");
+}
+
+
+/*************** return superclass of the class represented by sub ****************/
+jclass GetSuperclass (JNIEnv* env, jclass sub) 
+{
+       classinfo *c;
+
+       c = ((classinfo*) sub) -> super;
+
+       if (!c) return NULL; 
+       use_class_as_object (c);
+       return c;               
+}
+  
+/*********************** check whether sub can be cast to sup  ********************/
+  
+jboolean IsAssignableForm (JNIEnv* env, jclass sub, jclass sup)
+{
+        return builtin_isanysubclass(sub,sup);
+}
+
+
+/***** converts a field ID derived from cls to a java.lang.reflect.Field object ***/
+
+jobject ToReflectedField (JNIEnv* env, jclass cls, jfieldID fieldID, jboolean isStatic)
+{
+       log_text("JNI-Call: ToReflectedField");
+}
+
+
+/***************** throw java.lang.Throwable object  ******************************/
+
+jint Throw (JNIEnv* env, jthrowable obj)
+{
+       exceptionptr = (java_objectheader*) obj;
+       return 0;
+}
+
+
+/*********************************************************************************** 
+
+       create exception object from the class clazz with the 
+       specified message and cause it to be thrown
+
+ **********************************************************************************/   
+
+
+jint ThrowNew (JNIEnv* env, jclass clazz, const char *msg) 
+{
+       java_lang_Throwable *o;
+
+       /* instantiate exception object */
+       o = (java_lang_Throwable *) native_new_and_init ((classinfo*) clazz);
+
+       if (!o) return (-1);
+
+       o->detailMessage = (java_lang_String*) javastring_new_char((char *) msg);
+
+       exceptionptr = (java_objectheader*) o;  
+       return 0;
+}
+
+/************************* check if exception occured *****************************/
+
+jthrowable ExceptionOccurred (JNIEnv* env) 
+{
+       return (jthrowable) exceptionptr;
+}
+
+/********** print exception and a backtrace of the stack (for debugging) **********/
+
+void ExceptionDescribe (JNIEnv* env) 
+{
+       utf_display(exceptionptr->vftbl->class->name);
+       printf ("\n");
+       fflush (stdout);        
+}
+
+
+/******************* clear any exception currently being thrown *******************/
+
+void ExceptionClear (JNIEnv* env) 
+{
+       exceptionptr = NULL;    
+}
+
+
+/********** raises a fatal error and does not expect the VM to recover ************/
+
+void FatalError (JNIEnv* env, const char *msg)
+{
+       panic((char *) msg);    
+}
+
+/******************* creates a new local reference frame **************************/ 
+
+jint PushLocalFrame (JNIEnv* env, jint capacity)
+{
+       /* empty */
+}
+
+/**************** Pops off the current local reference frame **********************/
+
+jobject PopLocalFrame (JNIEnv* env, jobject result)
+{
+       /* empty */
+}
+    
+
+/** Creates a new global reference to the object referred to by the obj argument **/
+    
+jobject NewGlobalRef (JNIEnv* env, jobject lobj)
+{
+       heap_addreference ( (void**) &lobj);
+       return lobj;
+}
+
+/*************  Deletes the global reference pointed to by globalRef **************/
+
+void DeleteGlobalRef (JNIEnv* env, jobject gref)
+{
+       /* empty */
+}
+
+
+/*************** Deletes the local reference pointed to by localRef ***************/
+
+void DeleteLocalRef (JNIEnv* env, jobject localRef)
+{
+       /* empty */
+}
+
+/********** Tests whether two references refer to the same Java object ************/
+
+jboolean IsSameObject (JNIEnv* env, jobject obj1, jobject obj2)
+{
+       return (obj1==obj2);
+}
+
+/***** Creates a new local reference that refers to the same object as ref  *******/
+
+jobject NewLocalRef (JNIEnv* env, jobject ref)
+{
+       return ref;
+}
+
+/*********************************************************************************** 
+
+       Ensures that at least a given number of local references can 
+       be created in the current thread
+
+ **********************************************************************************/   
+
+jint EnsureLocalCapacity (JNIEnv* env, jint capacity)
+{
+       return 0; /* return 0 on success */
+}
+
+
+/********* Allocates a new Java object without invoking a constructor *************/
+
+jobject AllocObject (JNIEnv* env, jclass clazz)
+{
+        java_objectheader *o = builtin_new(clazz);     
+       return o;
+}
+
+
+/*********************************************************************************** 
+
+       Constructs a new Java object
+       arguments that are to be passed to the constructor are placed after methodID
+
+***********************************************************************************/
+
+jobject NewObject (JNIEnv* env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: NewObject");
+}
+
+/*********************************************************************************** 
+
+       Constructs a new Java object
+       arguments that are to be passed to the constructor are placed in va_list args 
+
+***********************************************************************************/
+
+jobject NewObjectV (JNIEnv* env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: NewObjectV");
+}
+
+/*********************************************************************************** 
+
+       Constructs a new Java object
+       arguments that are to be passed to the constructor are placed in 
+       args array of jvalues 
+
+***********************************************************************************/
+
+jobject NewObjectA (JNIEnv* env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: NewObjectA");
+}
+
+
+/************************ returns the class of an object **************************/ 
+
+jclass GetObjectClass (JNIEnv* env, jobject obj)
+{
+       classinfo *c = obj->vftbl -> class;
+       use_class_as_object (c);
+       return c;
+}
+
+/************* tests whether an object is an instance of a class ******************/
+
+jboolean IsInstanceOf (JNIEnv* env, jobject obj, jclass clazz)
+{
+        return builtin_instanceof(obj,clazz);
+}
+
+
+/***************** converts a java.lang.reflect.Field to a field ID ***************/
+jfieldID FromReflectedField (JNIEnv* env, jobject field)
+{
+       log_text("JNI-Call: FromReflectedField");
+}
+
+/**********************************************************************************
+
+       converts a method ID to a java.lang.reflect.Method or 
+       java.lang.reflect.Constructor object
+
+**********************************************************************************/
+
+jobject ToReflectedMethod (JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic)
+{
+       log_text("JNI-Call: ToReflectedMethod");
+}
+
+/**************** returns the method ID for an instance method ********************/
+
+jmethodID GetMethodID (JNIEnv* env, jclass clazz, const char *name, const char *sig)
+{
+       jmethodID m;
+
+       m = class_resolvemethod (
+               clazz, 
+               utf_new_char ((char*) name), 
+               utf_new_char ((char*) sig)
+       );
+
+       if (!m) exceptionptr = native_new_and_init(class_java_lang_NoSuchMethodError);          
+
+       return m;
+}
+
+/******************** JNI-functions for calling instance methods ******************/
+
+jobject CallObjectMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallObjectMethod");
+
+       return NULL;
+}
+
+
+jobject CallObjectMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallObjectMethodV");
+
+       return NULL;
+}
+
+
+jobject CallObjectMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallObjectMethodA");
+
+       return NULL;
+}
+
+
+jboolean CallBooleanMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallBooleanMethod");
+
+       return 0;
+}
+
+jboolean CallBooleanMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallBooleanMethodV");
+
+       return 0;
+}
+
+jboolean CallBooleanMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallBooleanMethodA");
+
+       return 0;
+}
+
+jbyte CallByteMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallByteMethod");
+
+       return 0;
+}
+
+jbyte CallByteMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallByteMethodV");
+
+       return 0;
+}
+
+
+jbyte CallByteMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallByteMethodA");
+
+       return 0;
+}
+
+
+jchar CallCharMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallCharMethod");
+
+       return 0;
+}
+
+jchar CallCharMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallCharMethodV");
+
+       return 0;
+}
+
+
+jchar CallCharMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallCharMethodA");
+
+       return 0;
+}
+
+
+jshort CallShortMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallShortMethod");
+
+       return 0;
+}
+
+
+jshort CallShortMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallShortMethodV");
+
+       return 0;
+}
+
+
+jshort CallShortMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallShortMethodA");
+
+       return 0;
+}
+
+
+
+jint CallIntMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallIntMethod");
+
+       return 0;
+}
+
+
+jint CallIntMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallIntMethodV");
+
+       return 0;
+}
+
+
+jint CallIntMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallIntMethodA");
+
+       return 0;
+}
+
+
+
+jlong CallLongMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallLongMethod");
+
+       return 0;
+}
+
+
+jlong CallLongMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallLongMethodV");
+
+       return 0;
+}
+
+
+jlong CallLongMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallLongMethodA");
+
+       return 0;
+}
+
+
+
+jfloat CallFloatMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallFloatMethod");
+
+       return 0;
+}
+
+
+jfloat CallFloatMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallFloatMethodV");
+
+       return 0;
+}
+
+
+jfloat CallFloatMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallFloatMethodA");
+
+       return 0;
+}
+
+
+
+jdouble CallDoubleMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallDoubleMethod");
+
+       return 0;
+}
+
+
+jdouble CallDoubleMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallDoubleMethodV");
+
+       return 0;
+}
+
+
+jdouble CallDoubleMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallDoubleMethodA");
+
+       return 0;
+}
+
+
+
+void CallVoidMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallVoidMethod");
+
+}
+
+
+void CallVoidMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallVoidMethodV");
+
+}
+
+
+void CallVoidMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallVoidMethodA");
+
+}
+
+
+
+jobject CallNonvirtualObjectMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualObjectMethod");
+
+       return NULL;
+}
+
+
+jobject CallNonvirtualObjectMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualObjectMethodV");
+
+       return NULL;
+}
+
+
+jobject CallNonvirtualObjectMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallNonvirtualObjectMethodA");
+
+       return NULL;
+}
+
+
+
+jboolean CallNonvirtualBooleanMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualBooleanMethod");
+
+       return 0;
+}
+
+
+jboolean CallNonvirtualBooleanMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualBooleanMethodV");
+
+       return 0;
+}
+
+
+jboolean CallNonvirtualBooleanMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallNonvirtualBooleanMethodA");
+
+       return 0;
+}
+
+
+
+jbyte CallNonvirtualByteMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualByteMethod");
+
+       return 0;
+}
+
+
+jbyte CallNonvirtualByteMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualByteMethodV");
+
+       return 0;
+}
+
+
+jbyte CallNonvirtualByteMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualByteMethodA");
+
+       return 0;
+}
+
+
+
+jchar CallNonvirtualCharMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualCharMethod");
+
+       return 0;
+}
+
+
+jchar CallNonvirtualCharMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualCharMethodV");
+
+       return 0;
+}
+
+
+jchar CallNonvirtualCharMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualCharMethodA");
+
+       return 0;
+}
+
+
+
+jshort CallNonvirtualShortMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualShortMethod");
+
+       return 0;
+}
+
+
+jshort CallNonvirtualShortMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualShortMethodV");
+
+       return 0;
+}
+
+
+jshort CallNonvirtualShortMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualShortMethodA");
+
+       return 0;
+}
+
+
+
+jint CallNonvirtualIntMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualIntMethod");
+
+       return 0;
+}
+
+
+jint CallNonvirtualIntMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualIntMethodV");
+
+       return 0;
+}
+
+
+jint CallNonvirtualIntMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualIntMethodA");
+
+       return 0;
+}
+
+
+
+jlong CallNonvirtualLongMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualLongMethod");
+
+       return 0;
+}
+
+
+jlong CallNonvirtualLongMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualLongMethodV");
+
+       return 0;
+}
+
+
+jlong CallNonvirtualLongMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualLongMethodA");
+
+       return 0;
+}
+
+
+
+jfloat CallNonvirtualFloatMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualFloatMethod");
+
+       return 0;
+}
+
+
+jfloat CallNonvirtualFloatMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualFloatMethodV");
+
+       return 0;
+}
+
+
+jfloat CallNonvirtualFloatMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualFloatMethodA");
+
+       return 0;
+}
+
+
+
+jdouble CallNonvirtualDoubleMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualDoubleMethod");
+
+       return 0;
+}
+
+
+jdouble CallNonvirtualDoubleMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualDoubleMethodV");
+
+       return 0;
+}
+
+
+jdouble CallNonvirtualDoubleMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallNonvirtualDoubleMethodA");
+
+       return 0;
+}
+
+
+
+void CallNonvirtualVoidMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallNonvirtualVoidMethod");
+}
+
+
+void CallNonvirtualVoidMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallNonvirtualVoidMethodV");
+}
+
+
+void CallNonvirtualVoidMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallNonvirtualVoidMethodA");
+}
+
+/************************* JNI-functions for accessing fields ************************/
+
+jfieldID GetFieldID (JNIEnv *env, jclass clazz, const char *name, const char *sig) 
+{
+       jfieldID f;
+
+       f = jclass_findfield(clazz,
+                           utf_new_char ((char*) name), 
+                           utf_new_char ((char*) sig)
+                           ); 
+       
+       if (!f) exceptionptr =  native_new_and_init(class_java_lang_NoSuchFieldError);  
+
+       return f;
+}
+
+/*************************** retrieve fieldid, abort on error ************************/
+
+jfieldID getFieldID_critical(JNIEnv *env,jclass clazz,const char *name,const char *sig)
+{
+    jfieldID id = env->GetFieldID(env,clazz,name,sig);     
+    if (!id) panic("setfield_critical failed"); 
+    return id;
+}
+
+jobject GetObjectField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jobject,fieldID);
+}
+
+jboolean GetBooleanField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jboolean,fieldID);
+}
+
+
+jbyte GetByteField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+               return getField(obj,jbyte,fieldID);
+}
+
+
+jchar GetCharField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jchar,fieldID);
+}
+
+
+jshort GetShortField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jshort,fieldID);
+}
+
+
+jint GetIntField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jint,fieldID);
+}
+
+
+jlong GetLongField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jlong,fieldID);
+}
+
+
+jfloat GetFloatField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jfloat,fieldID);
+}
+
+
+jdouble GetDoubleField (JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+       return getField(obj,jdouble,fieldID);
+}
+
+void SetObjectField (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val)
+{
+        setField(obj,jobject,fieldID,val);
+}
+
+
+void SetBooleanField (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val)
+{
+        setField(obj,jboolean,fieldID,val);
+}
+
+
+void SetByteField (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val)
+{
+        setField(obj,jbyte,fieldID,val);
+}
+
+
+void SetCharField (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val)
+{
+        setField(obj,jchar,fieldID,val);
+}
+
+
+void SetShortField (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val)
+{
+        setField(obj,jshort,fieldID,val);
+}
+
+
+void SetIntField (JNIEnv *env, jobject obj, jfieldID fieldID, jint val)
+{
+        setField(obj,jint,fieldID,val);
+}
+
+
+void SetLongField (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val)
+{
+        setField(obj,jlong,fieldID,val);
+}
+
+
+void SetFloatField (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val)
+{
+        setField(obj,jfloat,fieldID,val);
+}
+
+
+void SetDoubleField (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val)
+{
+        setField(obj,jdouble,fieldID,val);
+}
+
+/**************** JNI-functions for calling static methods **********************/ 
+
+jmethodID GetStaticMethodID (JNIEnv *env, jclass clazz, const char *name, const char *sig)
+{
+       jmethodID m;
+
+       m = class_resolvemethod (
+               clazz, 
+               utf_new_char ((char*) name), 
+               utf_new_char ((char*) sig)
+       );
+
+       if (!m) exceptionptr =  native_new_and_init(class_java_lang_NoSuchMethodError);  
+
+       return m;
+}
+
+jobject CallStaticObjectMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticObjectMethod");
+
+       return NULL;
+}
+
+
+jobject CallStaticObjectMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticObjectMethodV");
+
+       return NULL;
+}
+
+
+jobject CallStaticObjectMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticObjectMethodA");
+
+       return NULL;
+}
+
+
+jboolean CallStaticBooleanMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticBooleanMethod");
+
+       return 0;
+}
+
+
+jboolean CallStaticBooleanMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticBooleanMethodV");
+
+       return 0;
+}
+
+
+jboolean CallStaticBooleanMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticBooleanMethodA");
+
+       return 0;
+}
+
+
+jbyte CallStaticByteMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticByteMethod");
+
+       return 0;
+}
+
+
+jbyte CallStaticByteMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticByteMethodV");
+
+       return 0;
+}
+
+
+jbyte CallStaticByteMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticByteMethodA");
+
+       return 0;
+}
+
+jchar CallStaticCharMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticCharMethod");
+
+       return 0;
+}
+
+
+jchar CallStaticCharMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticCharMethodV");
+
+       return 0;
+}
+
+
+jchar CallStaticCharMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticCharMethodA");
+
+       return 0;
+}
+
+
+
+jshort CallStaticShortMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticShortMethod");
+
+       return 0;
+}
+
+
+jshort CallStaticShortMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticShortMethodV");
+
+       return 0;
+}
+
+
+jshort CallStaticShortMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticShortMethodA");
+
+       return 0;
+}
+
+
+
+jint CallStaticIntMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticIntMethod");
+
+       return 0;
+}
+
+
+jint CallStaticIntMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticIntMethodV");
+
+       return 0;
+}
+
+
+jint CallStaticIntMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticIntMethodA");
+
+       return 0;
+}
+
+
+
+jlong CallStaticLongMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticLongMethod");
+
+       return 0;
+}
+
+
+jlong CallStaticLongMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticLongMethodV");
+
+       return 0;
+}
+
+
+jlong CallStaticLongMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticLongMethodA");
+
+       return 0;
+}
+
+
+
+jfloat CallStaticFloatMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticFloatMethod");
+
+       return 0;
+}
+
+
+jfloat CallStaticFloatMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticFloatMethodV");
+
+       return 0;
+}
+
+
+jfloat CallStaticFloatMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticFloatMethodA");
+
+       return 0;
+}
+
+
+
+jdouble CallStaticDoubleMethod (JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticDoubleMethod");
+
+       return 0;
+}
+
+
+jdouble CallStaticDoubleMethodV (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticDoubleMethodV");
+
+       return 0;
+}
+
+
+jdouble CallStaticDoubleMethodA (JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+{
+       log_text("JNI-Call: CallStaticDoubleMethodA");
+
+       return 0;
+}
+
+
+
+void CallStaticVoidMethod (JNIEnv *env, jclass cls, jmethodID methodID, ...)
+{
+       log_text("JNI-Call: CallStaticVoidMethod");
+
+}
+
+
+void CallStaticVoidMethodV (JNIEnv *env, jclass cls, jmethodID methodID, va_list args)
+{
+       log_text("JNI-Call: CallStaticVoidMethodV");
+
+}
+
+
+void CallStaticVoidMethodA (JNIEnv *env, jclass cls, jmethodID methodID, jvalue * args)
+{
+       log_text("JNI-Call: CallStaticVoidMethodA");
+
+}
+
+/****************** JNI-functions for accessing static fields ********************/
+
+jfieldID GetStaticFieldID (JNIEnv *env, jclass clazz, const char *name, const char *sig) 
+{
+       jfieldID f;
+
+       f = jclass_findfield(clazz,
+                           utf_new_char ((char*) name), 
+                           utf_new_char ((char*) sig)
+                           ); 
+       
+       if (!f) exceptionptr =  native_new_and_init(class_java_lang_NoSuchFieldError);  
+
+       return f;
+}
+
+
+jobject GetStaticObjectField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.a;       
+}
+
+
+jboolean GetStaticBooleanField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jbyte GetStaticByteField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jchar GetStaticCharField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jshort GetStaticShortField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jint GetStaticIntField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.i;       
+}
+
+
+jlong GetStaticLongField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.l;
+}
+
+
+jfloat GetStaticFloatField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.f;
+}
+
+
+jdouble GetStaticDoubleField (JNIEnv *env, jclass clazz, jfieldID fieldID)
+{
+       return fieldID->value.d;
+}
+
+
+
+void SetStaticObjectField (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)
+{
+       fieldID->value.a = value;
+}
+
+
+void SetStaticBooleanField (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticByteField (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticCharField (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticShortField (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticIntField (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value)
+{
+       fieldID->value.i = value;
+}
+
+
+void SetStaticLongField (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value)
+{
+       fieldID->value.l = value;
+}
+
+
+void SetStaticFloatField (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value)
+{
+       fieldID->value.f = value;
+}
+
+
+void SetStaticDoubleField (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value)
+{
+       fieldID->value.d = value;
+}
+
+
+/*****  create new java.lang.String object from an array of Unicode characters ****/ 
+
+jstring NewString (JNIEnv *env, const jchar *buf, jsize len)
+{
+       u4 i;
+       java_lang_String *s;
+       java_chararray *a;
+       
+       s = (java_lang_String*) builtin_new (class_java_lang_String);
+       a = builtin_newarray_char (len);
+
+       /* javastring or characterarray could not be created */
+       if ( (!a) || (!s) ) return NULL;
+
+       /* copy text */
+       for (i=0; i<len; i++) a->data[i] = buf[i];
+       s -> value = a;
+       s -> offset = 0;
+       s -> count = len;
+
+       return (jstring) s;
+}
+
+/******************* returns the length of a Java string ***************************/
+
+jsize GetStringLength (JNIEnv *env, jstring str)
+{
+       return ((java_lang_String*) str)->count;
+}
+
+
+/********************  convertes javastring to u2-array ****************************/
+       
+u2 *javastring_tou2 (jstring so) 
+{
+       java_lang_String *s = (java_lang_String*) so;
+       java_chararray *a;
+       u4 i;
+       u2 *stringbuffer;
+       
+       if (!s) return NULL;
+
+       a = s->value;
+       if (!a) return NULL;
+
+       /* allocate memory */
+       stringbuffer = MNEW( u2 , s->count + 1 );
+
+       /* copy text */
+       for (i=0; i<s->count; i++) stringbuffer[i] = a->data[s->offset+i];
+       
+       /* terminate string */
+       stringbuffer[i] = '\0';
+
+       return stringbuffer;
+}
+
+/********* returns a pointer to an array of Unicode characters of the string *******/
+
+const jchar *GetStringChars (JNIEnv *env, jstring str, jboolean *isCopy)
+{      
+       return javastring_tou2(str);
+}
+
+/**************** native code no longer needs access to chars **********************/
+
+void ReleaseStringChars (JNIEnv *env, jstring str, const jchar *chars)
+{
+       MFREE(((jchar*) chars),jchar,((java_lang_String*) str)->count);
+}
+
+/************ create new java.lang.String object from utf8-characterarray **********/
+
+jstring NewStringUTF (JNIEnv *env, const char *utf)
+{
+    log_text("NewStringUTF called");
+}
+
+/****************** returns the utf8 length in bytes of a string *******************/
+
+jsize GetStringUTFLength (JNIEnv *env, jstring string)
+{   
+    java_lang_String *s = (java_lang_String*) string;
+
+    return (jsize) u2_utflength(s->value->data, s->count); 
+}
+
+/************ converts a Javastring to an array of UTF-8 characters ****************/
+
+const char* GetStringUTFChars (JNIEnv *env, jstring string, jboolean *isCopy)
+{
+    return javastring_toutf((java_lang_String*) string,false)->text;
+}
+
+/***************** native code no longer needs access to utf ***********************/
+
+void ReleaseStringUTFChars (JNIEnv *env, jstring str, const char* chars)
+{
+    log_text("JNI-Call: ReleaseStringUTFChars");
+}
+
+/************************** array operations ***************************************/
+
+jsize GetArrayLength (JNIEnv *env, jarray array)
+{
+    return array->size;
+}
+
+jobjectArray NewObjectArray (JNIEnv *env, jsize len, jclass clazz, jobject init)
+{
+    java_objectarray *j = builtin_anewarray (len, clazz);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+jobject GetObjectArrayElement (JNIEnv *env, jobjectArray array, jsize index)
+{
+    jobject j = NULL;
+
+    if (index<array->header.size)      
+       j = array->data[index];
+    else
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    
+    return j;
+}
+
+void SetObjectArrayElement (JNIEnv *env, jobjectArray array, jsize index, jobject val)
+{
+    if (index>=array->header.size)     
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else {
+
+       /* check if the class of value is a subclass of the element class of the array */
+
+       if (!builtin_instanceof(val, array->elementtype))
+           exceptionptr = proto_java_lang_ArrayStoreException;
+       else
+           array->data[index] = val;
+    }
+}
+
+
+
+jbooleanArray NewBooleanArray (JNIEnv *env, jsize len)
+{
+    java_booleanarray *j = builtin_newarray_boolean(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jbyteArray NewByteArray (JNIEnv *env, jsize len)
+{
+    java_bytearray *j = builtin_newarray_byte(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jcharArray NewCharArray (JNIEnv *env, jsize len)
+{
+    java_chararray *j = builtin_newarray_char(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jshortArray NewShortArray (JNIEnv *env, jsize len)
+{
+    java_shortarray *j = builtin_newarray_short(len);   
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jintArray NewIntArray (JNIEnv *env, jsize len)
+{
+    java_intarray *j = builtin_newarray_int(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jlongArray NewLongArray (JNIEnv *env, jsize len)
+{
+    java_longarray *j = builtin_newarray_long(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jfloatArray NewFloatArray (JNIEnv *env, jsize len)
+{
+    java_floatarray *j = builtin_newarray_float(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jdoubleArray NewDoubleArray (JNIEnv *env, jsize len)
+{
+    java_doublearray *j = builtin_newarray_double(len);
+    if (!j) exceptionptr = proto_java_lang_OutOfMemoryError;
+    return j;
+}
+
+
+jboolean * GetBooleanArrayElements (JNIEnv *env, jbooleanArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jbyte * GetByteArrayElements (JNIEnv *env, jbyteArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jchar * GetCharArrayElements (JNIEnv *env, jcharArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jshort * GetShortArrayElements (JNIEnv *env, jshortArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jint * GetIntArrayElements (JNIEnv *env, jintArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jlong * GetLongArrayElements (JNIEnv *env, jlongArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jfloat * GetFloatArrayElements (JNIEnv *env, jfloatArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+jdouble * GetDoubleArrayElements (JNIEnv *env, jdoubleArray array, jboolean *isCopy)
+{
+    if (isCopy) *isCopy = JNI_FALSE;
+    return array->data;
+}
+
+
+
+void ReleaseBooleanArrayElements (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseByteArrayElements (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseCharArrayElements (JNIEnv *env, jcharArray array, jchar *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseShortArrayElements (JNIEnv *env, jshortArray array, jshort *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseIntArrayElements (JNIEnv *env, jintArray array, jint *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseLongArrayElements (JNIEnv *env, jlongArray array, jlong *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseFloatArrayElements (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode)
+{
+    /* empty */
+}
+
+
+void ReleaseDoubleArrayElements (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode)
+{
+    /* empty */
+}
+
+void GetBooleanArrayRegion (JNIEnv* env, jbooleanArray array, jsize start, jsize len, jboolean *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetByteArrayRegion (JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size) 
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));
+}
+
+
+void GetCharArrayRegion (JNIEnv* env, jcharArray array, jsize start, jsize len, jchar *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetShortArrayRegion (JNIEnv* env, jshortArray array, jsize start, jsize len, jshort *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else       
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetIntArrayRegion (JNIEnv* env, jintArray array, jsize start, jsize len, jint *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)      
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetLongArrayRegion (JNIEnv* env, jlongArray array, jsize start, jsize len, jlong *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)      
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetFloatArrayRegion (JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)      
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void GetDoubleArrayRegion (JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size) 
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(buf,&array->data[start],len*sizeof(array->data[0]));     
+}
+
+
+void SetBooleanArrayRegion (JNIEnv* env, jbooleanArray array, jsize start, jsize len, jboolean *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+
+void SetByteArrayRegion (JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+
+void SetCharArrayRegion (JNIEnv* env, jcharArray array, jsize start, jsize len, jchar *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+
+void SetShortArrayRegion (JNIEnv* env, jshortArray array, jsize start, jsize len, jshort *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+
+void SetIntArrayRegion (JNIEnv* env, jintArray array, jsize start, jsize len, jint *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+void SetLongArrayRegion (JNIEnv* env, jlongArray array, jsize start, jsize len, jlong *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+void SetFloatArrayRegion (JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+
+}
+
+void SetDoubleArrayRegion (JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble *buf)
+{
+    if (start<0 || len<0 || start+len>array->header.size)
+       exceptionptr = proto_java_lang_ArrayIndexOutOfBoundsException;
+    else
+       memcpy(&array->data[start],buf,len*sizeof(array->data[0]));     
+}
+
+jint RegisterNatives (JNIEnv* env, jclass clazz, const JNINativeMethod *methods, jint nMethods)
+{
+    log_text("JNI-Call: RegisterNatives");
+    return 0;
+}
+
+
+jint UnregisterNatives (JNIEnv* env, jclass clazz)
+{
+    log_text("JNI-Call: UnregisterNatives");
+    return 0;
+}
+
+/******************************* monitor operations ********************************/
+
+jint MonitorEnter (JNIEnv* env, jobject obj)
+{
+    builtin_monitorenter(obj);
+    return 0;
+}
+
+
+jint MonitorExit (JNIEnv* env, jobject obj)
+{
+    builtin_monitorexit(obj);
+    return 0;
+}
+
+
+/************************************* JavaVM interface ****************************/
+
+jint GetJavaVM (JNIEnv* env, JavaVM **vm)
+{
+    log_text("JNI-Call: GetJavaVM");
+    return 0;
+}
+
+void GetStringRegion (JNIEnv* env, jstring str, jsize start, jsize len, jchar *buf)
+{
+    log_text("JNI-Call: GetStringRegion");
+
+}
+
+void GetStringUTFRegion (JNIEnv* env, jstring str, jsize start, jsize len, char *buf)
+{
+    log_text("JNI-Call: GetStringUTFRegion");
+
+}
+
+/****************** obtain direct pointer to array elements ***********************/
+
+void * GetPrimitiveArrayCritical (JNIEnv* env, jarray array, jboolean *isCopy)
+{
+       java_arrayheader *s = (java_arrayheader*) array;
+
+       switch (s->arraytype) {
+               case ARRAYTYPE_BYTE:    return (((java_bytearray*)    array)->data);
+               case ARRAYTYPE_BOOLEAN: return (((java_booleanarray*) array)->data);
+               case ARRAYTYPE_CHAR:    return (((java_chararray*)    array)->data);
+               case ARRAYTYPE_SHORT:   return (((java_shortarray*)   array)->data);
+               case ARRAYTYPE_INT:     return (((java_intarray*)     array)->data);
+               case ARRAYTYPE_LONG:    return (((java_longarray*)    array)->data);
+               case ARRAYTYPE_FLOAT:   return (((java_floatarray*)   array)->data);
+               case ARRAYTYPE_DOUBLE:  return (((java_doublearray*)  array)->data);
+               case ARRAYTYPE_OBJECT:  return (((java_objectarray*)  array)->data); 
+               case ARRAYTYPE_ARRAY:   return (((java_arrayarray*)   array)->data);
+       }
+
+       return NULL;
+}
+
+
+void ReleasePrimitiveArrayCritical (JNIEnv* env, jarray array, void *carray, jint mode)
+{
+       log_text("JNI-Call: ReleasePrimitiveArrayCritical");
+
+       /* empty */
+}
+
+/********* returns a pointer to an array of Unicode characters of the string *******/
+
+const jchar * GetStringCritical (JNIEnv* env, jstring string, jboolean *isCopy)
+{
+       log_text("JNI-Call: GetStringCritical");
+
+       return GetStringChars(env,string,isCopy);
+}
+
+/**************** native code no longer needs access to chars **********************/
+
+void ReleaseStringCritical (JNIEnv* env, jstring string, const jchar *cstring)
+{
+       log_text("JNI-Call: ReleaseStringCritical");
+
+       ReleaseStringChars(env,string,cstring);
+}
+
+
+jweak NewWeakGlobalRef (JNIEnv* env, jobject obj)
+{
+       log_text("JNI-Call: NewWeakGlobalRef");
+
+       return obj;
+}
+
+
+void DeleteWeakGlobalRef (JNIEnv* env, jweak ref)
+{
+       log_text("JNI-Call: DeleteWeakGlobalRef");
+
+       /* empty */
+}
+
+
+/******************************* check for pending exception ***********************/
+
+
+jboolean ExceptionCheck (JNIEnv* env)
+{
+       log_text("JNI-Call: ExceptionCheck");
+
+       return exceptionptr ? JNI_TRUE : JNI_FALSE;
+}
+       
+/********************************* JNI function table ******************************/
+
+JNIEnv env =     
+   {   
+    NULL,
+    NULL,
+    NULL,
+    NULL,    
+    &GetVersion,
+    &DefineClass,
+    &FindClass,
+    &FromReflectedMethod,
+    &FromReflectedField,
+    &ToReflectedMethod,
+    &GetSuperclass,
+    &IsAssignableForm,
+    &ToReflectedField,
+    &Throw,
+    &ThrowNew,
+    &ExceptionOccurred,
+    &ExceptionDescribe,
+    &ExceptionClear,
+    &FatalError,
+    &PushLocalFrame,
+    &PopLocalFrame,
+    &NewGlobalRef,
+    &DeleteGlobalRef,
+    &DeleteLocalRef,
+    &IsSameObject,
+    &NewLocalRef,
+    &EnsureLocalCapacity,
+    &AllocObject,
+    &NewObject,
+    &NewObjectV,
+    &NewObjectA,
+    &GetObjectClass,
+    &IsInstanceOf,
+    &GetMethodID,
+    &CallObjectMethod,
+    &CallObjectMethodV,
+    &CallObjectMethodA,
+    &CallBooleanMethod,
+    &CallBooleanMethodV,
+    &CallBooleanMethodA,
+    &CallByteMethod,
+    &CallByteMethodV,
+    &CallByteMethodA,
+    &CallCharMethod,
+    &CallCharMethodV,
+    &CallCharMethodA,
+    &CallShortMethod,
+    &CallShortMethodV,
+    &CallShortMethodA,
+    &CallIntMethod,
+    &CallIntMethodV,
+    &CallIntMethodA,
+    &CallLongMethod,
+    &CallLongMethodV,
+    &CallLongMethodA,
+    &CallFloatMethod,
+    &CallFloatMethodV,
+    &CallFloatMethodA,
+    &CallDoubleMethod,
+    &CallDoubleMethodV,
+    &CallDoubleMethodA,
+    &CallVoidMethod,
+    &CallVoidMethodV,
+    &CallVoidMethodA,
+    &CallNonvirtualObjectMethod,
+    &CallNonvirtualObjectMethodV,
+    &CallNonvirtualObjectMethodA,
+    &CallNonvirtualBooleanMethod,
+    &CallNonvirtualBooleanMethodV,
+    &CallNonvirtualBooleanMethodA,
+    &CallNonvirtualByteMethod,
+    &CallNonvirtualByteMethodV,
+    &CallNonvirtualByteMethodA,
+    &CallNonvirtualCharMethod,
+    &CallNonvirtualCharMethodV,
+    &CallNonvirtualCharMethodA,
+    &CallNonvirtualShortMethod,
+    &CallNonvirtualShortMethodV,
+    &CallNonvirtualShortMethodA,
+    &CallNonvirtualIntMethod,
+    &CallNonvirtualIntMethodV,
+    &CallNonvirtualIntMethodA,
+    &CallNonvirtualLongMethod,
+    &CallNonvirtualLongMethodV,
+    &CallNonvirtualLongMethodA,
+    &CallNonvirtualFloatMethod,
+    &CallNonvirtualFloatMethodV,
+    &CallNonvirtualFloatMethodA,
+    &CallNonvirtualDoubleMethod,
+    &CallNonvirtualDoubleMethodV,
+    &CallNonvirtualDoubleMethodA,
+    &CallNonvirtualVoidMethod,
+    &CallNonvirtualVoidMethodV,
+    &CallNonvirtualVoidMethodA,
+    &GetFieldID,
+    &GetObjectField,
+    &GetBooleanField,
+    &GetByteField,
+    &GetCharField,
+    &GetShortField,
+    &GetIntField,
+    &GetLongField,
+    &GetFloatField,
+    &GetDoubleField,
+    &SetObjectField,
+    &SetBooleanField,
+    &SetByteField,
+    &SetCharField,
+    &SetShortField,
+    &SetIntField,
+    &SetLongField,
+    &SetFloatField,
+    &SetDoubleField,
+    &GetStaticMethodID,
+    &CallStaticObjectMethod,
+    &CallStaticObjectMethodV,
+    &CallStaticObjectMethodA,
+    &CallStaticBooleanMethod,
+    &CallStaticBooleanMethodV,
+    &CallStaticBooleanMethodA,
+    &CallStaticByteMethod,
+    &CallStaticByteMethodV,
+    &CallStaticByteMethodA,
+    &CallStaticCharMethod,
+    &CallStaticCharMethodV,
+    &CallStaticCharMethodA,
+    &CallStaticShortMethod,
+    &CallStaticShortMethodV,
+    &CallStaticShortMethodA,
+    &CallStaticIntMethod,
+    &CallStaticIntMethodV,
+    &CallStaticIntMethodA,
+    &CallStaticLongMethod,
+    &CallStaticLongMethodV,
+    &CallStaticLongMethodA,
+    &CallStaticFloatMethod,
+    &CallStaticFloatMethodV,
+    &CallStaticFloatMethodA,
+    &CallStaticDoubleMethod,
+    &CallStaticDoubleMethodV,
+    &CallStaticDoubleMethodA,
+    &CallStaticVoidMethod,
+    &CallStaticVoidMethodV,
+    &CallStaticVoidMethodA,
+    &GetStaticFieldID,
+    &GetStaticObjectField,
+    &GetStaticBooleanField,
+    &GetStaticByteField,
+    &GetStaticCharField,
+    &GetStaticShortField,
+    &GetStaticIntField,
+    &GetStaticLongField,
+    &GetStaticFloatField,
+    &GetStaticDoubleField,
+    &SetStaticObjectField,
+    &SetStaticBooleanField,
+    &SetStaticByteField,
+    &SetStaticCharField,
+    &SetStaticShortField,
+    &SetStaticIntField,
+    &SetStaticLongField,
+    &SetStaticFloatField,
+    &SetStaticDoubleField,
+    &NewString,
+    &GetStringLength,
+    &GetStringChars,
+    &ReleaseStringChars,
+    &NewStringUTF,
+    &GetStringUTFLength,
+    &GetStringUTFChars,
+    &ReleaseStringUTFChars,
+    &GetArrayLength,
+    &NewObjectArray,
+    &GetObjectArrayElement,
+    &SetObjectArrayElement,
+    &NewBooleanArray,
+    &NewByteArray,
+    &NewCharArray,
+    &NewShortArray,
+    &NewIntArray,
+    &NewLongArray,
+    &NewFloatArray,
+    &NewDoubleArray,
+    &GetBooleanArrayElements,
+    &GetByteArrayElements,
+    &GetCharArrayElements,
+    &GetShortArrayElements,
+    &GetIntArrayElements,
+    &GetLongArrayElements,
+    &GetFloatArrayElements,
+    &GetDoubleArrayElements,
+    &ReleaseBooleanArrayElements,
+    &ReleaseByteArrayElements,
+    &ReleaseCharArrayElements,
+    &ReleaseShortArrayElements,
+    &ReleaseIntArrayElements,
+    &ReleaseLongArrayElements,
+    &ReleaseFloatArrayElements,
+    &ReleaseDoubleArrayElements,
+    &GetBooleanArrayRegion,
+    &GetByteArrayRegion,
+    &GetCharArrayRegion,
+    &GetShortArrayRegion,
+    &GetIntArrayRegion,
+    &GetLongArrayRegion,
+    &GetFloatArrayRegion,
+    &GetDoubleArrayRegion,
+    &SetBooleanArrayRegion,
+    &SetByteArrayRegion,
+    &SetCharArrayRegion,
+    &SetShortArrayRegion,
+    &SetIntArrayRegion,
+    &SetLongArrayRegion,
+    &SetFloatArrayRegion,
+    &SetDoubleArrayRegion,
+    &RegisterNatives,
+    &UnregisterNatives,
+    &MonitorEnter,
+    &MonitorExit,
+    &GetJavaVM,
+    &GetStringRegion,
+    &GetStringUTFRegion,
+    &GetPrimitiveArrayCritical,
+    &ReleasePrimitiveArrayCritical,
+    &GetStringCritical,
+    &ReleaseStringCritical,
+    &NewWeakGlobalRef,
+    &DeleteWeakGlobalRef,
+    &ExceptionCheck
+    };
diff --git a/src/native/jni.h b/src/native/jni.h
new file mode 100644 (file)
index 0000000..183fcda
--- /dev/null
@@ -0,0 +1,425 @@
+/******************************** jni.h ***************************************
+
+       contains Java Native Interface types and data structures 
+       includes layout of the JNI function table
+       
+*******************************************************************************/
+
+#include <stdarg.h>
+
+#define JNIEXPORT
+#define JNICALL
+
+/* JNI datatypes */
+
+#define jobject         java_objectheader*
+#define jclass          struct classinfo*
+#define jthrowable                        jobject
+#define jweak                     jobject
+#define jarray          java_arrayheader*
+#define jlongArray        java_longarray*
+#define jbooleanArray  java_booleanarray*
+#define jintArray           java_intarray*
+#define jcharArray        java_chararray*
+#define jbyteArray        java_bytearray*
+#define jshortArray      java_shortarray*
+#define jdoubleArray    java_doublearray*
+#define jfloatArray      java_floatarray*
+#define jobjectArray    java_objectarray*
+#define jstring                           jobject
+#define jint                           s4
+#define jchar                          s2
+#define jboolean                       u1
+#define jbyte                          s1
+#define jshort                         s2
+#define jlong                          s8
+#define jfloat                      float
+#define jdouble                    double
+#define jsize                        jint
+#define jfieldID               fieldinfo*
+#define jmethodID             methodinfo*      
+
+struct _JavaVM;                                     /* opaque structure */
+typedef struct _JavaVM* JavaVM;
+
+typedef union jvalue {
+    jboolean z;
+    jbyte    b;
+    jchar    c;
+    jshort   s;
+    jint     i;
+    jlong    j;
+    jfloat   f;
+    jdouble  d;
+    jobject  l;
+} jvalue;
+
+/* JNI-Boolean */
+
+#define JNI_FALSE 0
+#define JNI_TRUE  1
+
+/* native method name, signature and function pointer for use in RegisterNatives */
+
+typedef struct {
+    char *name;
+    char *signature;
+    void *fnPtr;
+} JNINativeMethod;
+
+
+/* 
+       JNI function table, contains functions for the following usages:        
+       
+       Version Information 
+       Class Operations 
+       Exceptions 
+       Global and Local References 
+       Object Operations 
+       Accessing Fields of Objects 
+       Calling Instance Methods 
+       Accessing Static Fields 
+       Calling Static Methods 
+       String Operations 
+       Array Operations 
+       Registering Native Methods 
+       Monitor Operations 
+       Java VM Interface 
+*/
+
+typedef struct JNI_Table JNIEnv;
+
+struct JNI_Table {
+    
+    /* reserverd for future JNI-functions */
+    void *unused0;
+    void *unused1;
+    void *unused2;
+    void *unused3;
+    
+    /* version information */
+    
+    jint (*GetVersion) (JNIEnv*);
+
+    /* class operations */
+
+    jclass (*DefineClass) (JNIEnv*, const char *name, jobject loader, const jbyte *buf, jsize len);
+    jclass (*FindClass) (JNIEnv*, const char *name);
+
+    jmethodID (*FromReflectedMethod) (JNIEnv*, jobject method);
+    jfieldID (*FromReflectedField) (JNIEnv*, jobject field);
+
+    jobject (*ToReflectedMethod) (JNIEnv*, jclass cls, jmethodID methodID, jboolean isStatic);
+
+    jclass (*GetSuperclass) (JNIEnv*, jclass sub);
+    jboolean (*IsAssignableForm) (JNIEnv*, jclass sub, jclass sup);
+
+    jobject (*ToReflectedField) (JNIEnv*, jclass cls, jfieldID fieldID, jboolean isStatic);
+
+    /* exceptions */ 
+
+    jint (*Throw) (JNIEnv*, jthrowable obj);
+    jint (*ThrowNew) (JNIEnv*, jclass clazz, const char *msg);
+    jthrowable (*ExceptionOccurred) (JNIEnv*);
+    void (*ExceptionDescribe) (JNIEnv*);
+    void (*ExceptionClear) (JNIEnv*);
+    void (*FatalError) (JNIEnv*, const char *msg);
+
+    /* global and local references */
+
+    jint (*PushLocalFrame) (JNIEnv*, jint capacity);
+    jobject (*PopLocalFrame) (JNIEnv*, jobject result);
+    
+    jobject (*NewGlobalRef) (JNIEnv*, jobject lobj);
+    void (*DeleteGlobalRef) (JNIEnv*, jobject gref);
+    void (*DeleteLocalRef) (JNIEnv*, jobject obj);
+    jboolean (*IsSameObject) (JNIEnv*, jobject obj1, jobject obj2);
+    jobject (*NewLocalRef) (JNIEnv*, jobject ref);
+    jint (*EnsureLocalCapacity) (JNIEnv*, jint capacity);
+
+    /* object operations */ 
+
+    jobject (*AllocObject) (JNIEnv*, jclass clazz);
+    jobject (*NewObject) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jobject (*NewObjectV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jobject (*NewObjectA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jclass (*GetObjectClass) (JNIEnv*, jobject obj);
+    jboolean (*IsInstanceOf) (JNIEnv*, jobject obj, jclass clazz);
+
+    jmethodID (*GetMethodID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+
+    /* calling instance methods */ 
+
+    jobject (*CallObjectMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jobject (*CallObjectMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jobject (*CallObjectMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
+
+    jboolean (*CallBooleanMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jboolean (*CallBooleanMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jboolean (*CallBooleanMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
+
+    jbyte (*CallByteMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jbyte (*CallByteMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jbyte (*CallByteMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jchar (*CallCharMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jchar (*CallCharMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jchar (*CallCharMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jshort (*CallShortMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jshort (*CallShortMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jshort (*CallShortMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jint (*CallIntMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jint (*CallIntMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jint (*CallIntMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jlong (*CallLongMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jlong (*CallLongMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jlong (*CallLongMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jfloat (*CallFloatMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jfloat (*CallFloatMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jfloat (*CallFloatMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    jdouble (*CallDoubleMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    jdouble (*CallDoubleMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    jdouble (*CallDoubleMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
+
+    void (*CallVoidMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
+    void (*CallVoidMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
+    void (*CallVoidMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
+
+    jobject (*CallNonvirtualObjectMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jobject (*CallNonvirtualObjectMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jobject (*CallNonvirtualObjectMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
+
+    jboolean (*CallNonvirtualBooleanMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jboolean (*CallNonvirtualBooleanMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jboolean (*CallNonvirtualBooleanMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
+
+    jbyte (*CallNonvirtualByteMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jbyte (*CallNonvirtualByteMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jbyte (*CallNonvirtualByteMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jchar (*CallNonvirtualCharMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jchar (*CallNonvirtualCharMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jchar (*CallNonvirtualCharMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jshort (*CallNonvirtualShortMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jshort (*CallNonvirtualShortMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jshort (*CallNonvirtualShortMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jint (*CallNonvirtualIntMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jint (*CallNonvirtualIntMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jint (*CallNonvirtualIntMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jlong (*CallNonvirtualLongMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jlong (*CallNonvirtualLongMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jlong (*CallNonvirtualLongMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jfloat (*CallNonvirtualFloatMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jfloat (*CallNonvirtualFloatMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jfloat (*CallNonvirtualFloatMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jdouble (*CallNonvirtualDoubleMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    jdouble (*CallNonvirtualDoubleMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    jdouble (*CallNonvirtualDoubleMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
+
+    void (*CallNonvirtualVoidMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
+    void (*CallNonvirtualVoidMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+    void (*CallNonvirtualVoidMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
+
+    /* accessing fields */
+
+    jfieldID (*GetFieldID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+
+    jobject (*GetObjectField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jboolean (*GetBooleanField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jbyte (*GetByteField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jchar (*GetCharField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jshort (*GetShortField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jint (*GetIntField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jlong (*GetLongField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jfloat (*GetFloatField) (JNIEnv*, jobject obj, jfieldID fieldID);
+    jdouble (*GetDoubleField) (JNIEnv*, jobject obj, jfieldID fieldID);
+
+    void (*SetObjectField) (JNIEnv*, jobject obj, jfieldID fieldID, jobject val);
+    void (*SetBooleanField) (JNIEnv*, jobject obj, jfieldID fieldID, jboolean val);
+    void (*SetByteField) (JNIEnv*, jobject obj, jfieldID fieldID, jbyte val);
+    void (*SetCharField) (JNIEnv*, jobject obj, jfieldID fieldID, jchar val);
+    void (*SetShortField) (JNIEnv*, jobject obj, jfieldID fieldID, jshort val);
+    void (*SetIntField) (JNIEnv*, jobject obj, jfieldID fieldID, jint val);
+    void (*SetLongField) (JNIEnv*, jobject obj, jfieldID fieldID, jlong val);
+    void (*SetFloatField) (JNIEnv*, jobject obj, jfieldID fieldID, jfloat val);
+    void (*SetDoubleField) (JNIEnv*, jobject obj, jfieldID fieldID, jdouble val);
+
+    /* calling static methods */ 
+    
+    jmethodID (*GetStaticMethodID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+
+    jobject (*CallStaticObjectMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jobject (*CallStaticObjectMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jobject (*CallStaticObjectMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jboolean (*CallStaticBooleanMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jboolean (*CallStaticBooleanMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jboolean (*CallStaticBooleanMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jbyte (*CallStaticByteMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jbyte (*CallStaticByteMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jbyte (*CallStaticByteMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jchar (*CallStaticCharMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jchar (*CallStaticCharMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jchar (*CallStaticCharMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jshort (*CallStaticShortMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jshort (*CallStaticShortMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jshort (*CallStaticShortMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jint (*CallStaticIntMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jint (*CallStaticIntMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jint (*CallStaticIntMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jlong (*CallStaticLongMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jlong (*CallStaticLongMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jlong (*CallStaticLongMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jfloat (*CallStaticFloatMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jfloat (*CallStaticFloatMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jfloat (*CallStaticFloatMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    jdouble (*CallStaticDoubleMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
+    jdouble (*CallStaticDoubleMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
+    jdouble (*CallStaticDoubleMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+
+    void (*CallStaticVoidMethod) (JNIEnv*, jclass cls, jmethodID methodID, ...);
+    void (*CallStaticVoidMethodV) (JNIEnv*, jclass cls, jmethodID methodID, va_list args);
+    void (*CallStaticVoidMethodA) (JNIEnv*, jclass cls, jmethodID methodID, jvalue * args);
+
+    /* accessing static fields */
+
+    jfieldID (*GetStaticFieldID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
+    jobject (*GetStaticObjectField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jboolean (*GetStaticBooleanField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jbyte (*GetStaticByteField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jchar (*GetStaticCharField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jshort (*GetStaticShortField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jint (*GetStaticIntField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jlong (*GetStaticLongField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jfloat (*GetStaticFloatField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+    jdouble (*GetStaticDoubleField) (JNIEnv*, jclass clazz, jfieldID fieldID);
+
+    void (*SetStaticObjectField) (JNIEnv*, jclass clazz, jfieldID fieldID, jobject value);
+    void (*SetStaticBooleanField) (JNIEnv*, jclass clazz, jfieldID fieldID, jboolean value);
+    void (*SetStaticByteField) (JNIEnv*, jclass clazz, jfieldID fieldID, jbyte value);
+    void (*SetStaticCharField) (JNIEnv*, jclass clazz, jfieldID fieldID, jchar value);
+    void (*SetStaticShortField) (JNIEnv*, jclass clazz, jfieldID fieldID, jshort value);
+    void (*SetStaticIntField) (JNIEnv*, jclass clazz, jfieldID fieldID, jint value);
+    void (*SetStaticLongField) (JNIEnv*, jclass clazz, jfieldID fieldID, jlong value);
+    void (*SetStaticFloatField) (JNIEnv*, jclass clazz, jfieldID fieldID, jfloat value);
+    void (*SetStaticDoubleField) (JNIEnv*, jclass clazz, jfieldID fieldID, jdouble value);
+
+    /* string operations */ 
+
+    jstring (*NewString) (JNIEnv*, const jchar *unicode, jsize len);
+    jsize (*GetStringLength) (JNIEnv*, jstring str);
+    const jchar *(*GetStringChars) (JNIEnv*, jstring str, jboolean *isCopy);
+    void (*ReleaseStringChars) (JNIEnv*, jstring str, const jchar *chars);
+
+    jstring (*NewStringUTF) (JNIEnv*, const char *utf);
+    jsize (*GetStringUTFLength) (JNIEnv*, jstring str);
+    const char* (*GetStringUTFChars) (JNIEnv*, jstring str, jboolean *isCopy);
+    void (*ReleaseStringUTFChars) (JNIEnv*, jstring str, const char* chars);
+
+    /* array operations */
+
+    jsize (*GetArrayLength) (JNIEnv*, jarray array);
+
+    jobjectArray (*NewObjectArray) (JNIEnv*, jsize len, jclass clazz, jobject init);
+    jobject (*GetObjectArrayElement) (JNIEnv*, jobjectArray array, jsize index);
+    void (*SetObjectArrayElement) (JNIEnv*, jobjectArray array, jsize index, jobject val);
+
+    jbooleanArray (*NewBooleanArray) (JNIEnv*, jsize len);
+    jbyteArray (*NewByteArray) (JNIEnv*, jsize len);
+    jcharArray (*NewCharArray) (JNIEnv*, jsize len);
+    jshortArray (*NewShortArray) (JNIEnv*, jsize len);
+    jintArray (*NewIntArray) (JNIEnv*, jsize len);
+    jlongArray (*NewLongArray) (JNIEnv*, jsize len);
+    jfloatArray (*NewFloatArray) (JNIEnv*, jsize len);
+    jdoubleArray (*NewDoubleArray) (JNIEnv*, jsize len);
+
+    jboolean * (*GetBooleanArrayElements) (JNIEnv*, jbooleanArray array, jboolean *isCopy);
+    jbyte * (*GetByteArrayElements) (JNIEnv*, jbyteArray array, jboolean *isCopy);
+    jchar * (*GetCharArrayElements) (JNIEnv*, jcharArray array, jboolean *isCopy);
+    jshort * (*GetShortArrayElements) (JNIEnv*, jshortArray array, jboolean *isCopy);
+    jint * (*GetIntArrayElements) (JNIEnv*, jintArray array, jboolean *isCopy);
+    jlong * (*GetLongArrayElements) (JNIEnv*, jlongArray array, jboolean *isCopy);
+    jfloat * (*GetFloatArrayElements) (JNIEnv*, jfloatArray array, jboolean *isCopy);
+    jdouble * (*GetDoubleArrayElements) (JNIEnv*, jdoubleArray array, jboolean *isCopy);
+
+    void (*ReleaseBooleanArrayElements) (JNIEnv*, jbooleanArray array, jboolean *elems, jint mode);
+    void (*ReleaseByteArrayElements) (JNIEnv*, jbyteArray array, jbyte *elems, jint mode);
+    void (*ReleaseCharArrayElements) (JNIEnv*, jcharArray array, jchar *elems, jint mode);
+    void (*ReleaseShortArrayElements) (JNIEnv*, jshortArray array, jshort *elems, jint mode);
+    void (*ReleaseIntArrayElements) (JNIEnv*, jintArray array, jint *elems, jint mode);
+    void (*ReleaseLongArrayElements) (JNIEnv*, jlongArray array, jlong *elems, jint mode);
+    void (*ReleaseFloatArrayElements) (JNIEnv*, jfloatArray array, jfloat *elems, jint mode);
+    void (*ReleaseDoubleArrayElements) (JNIEnv*, jdoubleArray array, jdouble *elems, jint mode);
+
+    void (*GetBooleanArrayRegion) (JNIEnv*, jbooleanArray array, jsize start, jsize l, jboolean *buf);
+    void (*GetByteArrayRegion) (JNIEnv*, jbyteArray array, jsize start, jsize len, jbyte *buf);
+    void (*GetCharArrayRegion) (JNIEnv*, jcharArray array, jsize start, jsize len, jchar *buf);
+    void (*GetShortArrayRegion) (JNIEnv*, jshortArray array, jsize start, jsize len, jshort *buf);
+    void (*GetIntArrayRegion) (JNIEnv*, jintArray array, jsize start, jsize len, jint *buf);
+    void (*GetLongArrayRegion) (JNIEnv*, jlongArray array, jsize start, jsize len, jlong *buf);
+    void (*GetFloatArrayRegion) (JNIEnv*, jfloatArray array, jsize start, jsize len, jfloat *buf);
+    void (*GetDoubleArrayRegion) (JNIEnv*, jdoubleArray array, jsize start, jsize len, jdouble *buf);
+
+    void (*SetBooleanArrayRegion) (JNIEnv*, jbooleanArray array, jsize start, jsize l, jboolean *buf);
+    void (*SetByteArrayRegion) (JNIEnv*, jbyteArray array, jsize start, jsize len, jbyte *buf);
+    void (*SetCharArrayRegion) (JNIEnv*, jcharArray array, jsize start, jsize len, jchar *buf);
+    void (*SetShortArrayRegion) (JNIEnv*, jshortArray array, jsize start, jsize len, jshort *buf);
+    void (*SetIntArrayRegion) (JNIEnv*, jintArray array, jsize start, jsize len, jint *buf);
+    void (*SetLongArrayRegion) (JNIEnv*, jlongArray array, jsize start, jsize len, jlong *buf);
+    void (*SetFloatArrayRegion) (JNIEnv*, jfloatArray array, jsize start, jsize len, jfloat *buf);
+    void (*SetDoubleArrayRegion) (JNIEnv*, jdoubleArray array, jsize start, jsize len, jdouble *buf);
+
+    /* registering native methods */
+
+    jint (*RegisterNatives) (JNIEnv*, jclass clazz, const JNINativeMethod *methods, jint nMethods);
+    jint (*UnregisterNatives) (JNIEnv*, jclass clazz);
+
+    /* monitor operations */
+
+    jint (*MonitorEnter) (JNIEnv*, jobject obj);
+    jint (*MonitorExit) (JNIEnv*, jobject obj);
+
+    /* JavaVM interface */
+
+    jint (*GetJavaVM) (JNIEnv*, JavaVM **vm);
+
+    void (*GetStringRegion) (JNIEnv*, jstring str, jsize start, jsize len, jchar *buf);
+    void (*GetStringUTFRegion) (JNIEnv*, jstring str, jsize start, jsize len, char *buf);
+
+    void * (*GetPrimitiveArrayCritical) (JNIEnv*, jarray array, jboolean *isCopy);
+    void (*ReleasePrimitiveArrayCritical) (JNIEnv*, jarray array, void *carray, jint mode);
+
+    const jchar * (*GetStringCritical) (JNIEnv*, jstring string, jboolean *isCopy);
+    void (*ReleaseStringCritical) (JNIEnv*, jstring string, const jchar *cstring);
+
+    jweak (*NewWeakGlobalRef) (JNIEnv*, jobject obj);
+    void (*DeleteWeakGlobalRef) (JNIEnv*, jweak ref);
+
+    jboolean (*ExceptionCheck) (JNIEnv*);
+};
+
+
+/* the active JNI function table */
+
+extern JNIEnv env;
+
+
+
index 98594cf5e52c81b1a289ad367a675ab30af89d2b..51307463038fef01ef13241f48884ab14d1e736a 100644 (file)
@@ -9,7 +9,7 @@
        eingebunden, und ebenso alle C-Funktionen, mit denen diese
        Methoden implementiert werden.
 
-       Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
+       Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at 
 
        Last Change: 1996/11/14
 
 
 #include <unistd.h>
 #include <time.h>
-
 #include "global.h"
 #include "native.h"
-
-#include "builtin.h"
 #include "nativetypes.hh"
+#include "builtin.h"
 #include "asmpart.h"
 #include "tables.h"
 #include "loader.h"
+#include <math.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/time.h>
 
+#include "../threads/thread.h"                       /* schani */
+#include "../threads/locks.h"
 
-java_objectheader* exceptionptr = NULL;
+/* INCLUDE-Files fuer IO-Funktionen */
 
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/types.h>
+#ifdef _OSF_SOURCE 
+#include <sys/mode.h>
+#endif
+#include <sys/stat.h>
 
+#include "../threads/threadio.h"                    
 
+/* searchpath for classfiles */
 static char *classpath;
 
+/* for java-string to char conversion */
+#define MAXSTRINGSIZE 1000                          
 
-/******************** die f"r die native-Methoden n"otigen Systemklassen *****/
+/******************** systemclasses required for native methods *****/
 
 static classinfo *class_java_lang_Class;
 static classinfo *class_java_lang_Cloneable;
 static classinfo *class_java_lang_CloneNotSupportedException;
-static classinfo *class_java_lang_Double;
-static classinfo *class_java_lang_Float;
-static classinfo *class_java_io_IOException;
+static classinfo *class_java_lang_System;
+static classinfo *class_java_lang_ClassLoader;
 static classinfo *class_java_lang_ClassNotFoundException;
 static classinfo *class_java_lang_InstantiationException;
+static classinfo *class_java_lang_NoSuchMethodError;   
+static classinfo *class_java_lang_NoSuchFieldError;
+static classinfo *class_java_lang_ClassFormatError;
+static classinfo *class_java_lang_IllegalArgumentException;
+static classinfo *class_java_lang_ArrayIndexOutOfBoundsException;
+static classinfo *class_java_lang_NoSuchFieldException;
+static classinfo *class_java_io_SyncFailedException;
+static classinfo *class_java_io_IOException;
+static classinfo *class_java_io_UnixFileSystem;
+static classinfo *class_java_security_PrivilegedActionException;
+static classinfo *class_java_lang_NoSuchMethodException;
+static classinfo *class_java_lang_Double;
+static classinfo *class_java_lang_Float;
+static classinfo *class_java_lang_Long;
+static classinfo *class_java_lang_Byte;
+static classinfo *class_java_lang_Short;
+static classinfo *class_java_lang_Boolean;
+static classinfo *class_java_lang_Void;
+static classinfo *class_java_lang_Character;
+static classinfo *class_java_lang_Integer;
+
+/* the system classloader object */
+struct java_lang_ClassLoader *SystemClassLoader = NULL;
+
+/* for raising exceptions from native methods */
+java_objectheader* exceptionptr = NULL;
 
+/************* use classinfo structure as java.lang.Class object *************/
 
+static void use_class_as_object (classinfo *c) 
+{
+       c->header.vftbl = class_java_lang_Class -> vftbl;
+}
 
-/************************** alle Funktionen einbinden ************************/ 
-
-#include "nat/lang.c"
-#include "nat/io.c"
-#include "nat/util.c"
-
-
-/********************** Tabellen f"ur die Methoden ***************************/
-
+/*********************** include Java Native Interface ***********************/ 
+
+#include "jni.c"
+
+/*************************** include native methods **************************/ 
+
+#include "nat/Object.c"
+#include "nat/String.c"
+#include "nat/ClassLoader.c"
+#include "nat/Class.c"
+#include "nat/Compiler.c"
+#include "nat/Double.c"
+#include "nat/Float.c"
+#include "nat/Math.c"
+#include "nat/Package.c"
+#include "nat/Runtime.c"
+#include "nat/SecurityManager.c"
+#include "nat/System.c"
+#include "nat/Thread.c"
+#include "nat/Throwable.c"
+#include "nat/Finalizer.c"
+#include "nat/Array.c"
+#include "nat/Constructor.c"
+#include "nat/Field.c"
+#include "nat/Method.c"
+#include "nat/FileDescriptor.c"
+#include "nat/FileInputStream.c"
+#include "nat/FileOutputStream.c"
+#include "nat/FileSystem.c"
+#include "nat/ObjectInputStream.c"
+#include "nat/ObjectStreamClass.c"
+#include "nat/RandomAccessFile.c"
+#include "nat/ResourceBundle.c"
+#include "nat/JarFile.c"
+#include "nat/Adler32.c"
+#include "nat/CRC32.c"
+#include "nat/Deflater.c"
+#include "nat/Inflater.c"
+#include "nat/ZipEntry.c"
+#include "nat/ZipFile.c"
+#include "nat/BigInteger.c"
+#include "nat/InetAddress.c"
+#include "nat/InetAddressImpl.c"
+#include "nat/AccessController.c"
+#include "nat/ClassLoader_NativeLibrary.c"
+#include "nat/UnixFileSystem.c"
+
+/************************** tables for methods *******************************/
+
+/* table for locating native methods */
 static struct nativeref {
        char *classname;
        char *methodname;
@@ -72,51 +158,210 @@ static struct nativeref {
 
 #define NATIVETABLESIZE  (sizeof(nativetable)/sizeof(struct nativeref))
 
+/* table for fast string comparison */
 static struct nativecompref {
-       unicode *classname;
-       unicode *methodname;
-       unicode *descriptor;
+       utf *classname;
+       utf *methodname;
+       utf *descriptor;
        bool isstatic;
        functionptr func;
        } nativecomptable [NATIVETABLESIZE];
 
+/* string comparsion table initialized */
 static bool nativecompdone = false;
 
 
-/*********************** Funktion: native_loadclasses **************************
+/*********************** function: native_loadclasses ************************
 
-       L"adt alle Klassen, die die native Methoden zus"atzlich ben"otigen 
+       load classes required for native methods        
 
-*******************************************************************************/
+******************************************************************************/
 
 void native_loadclasses()
 {
+       /* class_new adds the class to the list of classes to be loaded */
        class_java_lang_Cloneable = 
-               loader_load ( unicode_new_char ("java/lang/Cloneable") );
+               class_new ( utf_new_char ("java/lang/Cloneable") );
        class_java_lang_CloneNotSupportedException = 
-               loader_load ( unicode_new_char ("java/lang/CloneNotSupportedException") );
+               class_new ( utf_new_char ("java/lang/CloneNotSupportedException") );
        class_java_lang_Class =
-               loader_load ( unicode_new_char ("java/lang/Class") );
-       class_java_lang_Double =
-               loader_load ( unicode_new_char ("java/lang/Double") );
-       class_java_lang_Float =
-               loader_load ( unicode_new_char ("java/lang/Float") );
+               class_new ( utf_new_char ("java/lang/Class") );
        class_java_io_IOException = 
-               loader_load ( unicode_new_char ("java/io/IOException") );
+               class_new ( utf_new_char ("java/io/IOException") );
        class_java_lang_ClassNotFoundException =
-               loader_load ( unicode_new_char ("java/lang/ClassNotFoundException") );
-       class_java_lang_InstantiationException=
-               loader_load ( unicode_new_char ("java/lang/InstantiationException") );
+               class_new ( utf_new_char ("java/lang/ClassNotFoundException") );
+       class_java_lang_InstantiationException =
+               class_new ( utf_new_char ("java/lang/InstantiationException") );
+       class_java_lang_NoSuchMethodError =
+               class_new ( utf_new_char ("java/lang/NoSuchMethodError") );
+       class_java_lang_NoSuchFieldError =
+               class_new ( utf_new_char ("java/lang/NoSuchFieldError") );      
+       class_java_lang_ClassFormatError =
+               class_new ( utf_new_char ("java/lang/ClassFormatError") );      
+       class_java_io_SyncFailedException =
+               class_new ( utf_new_char ("java/io/SyncFailedException") );
+       class_java_io_UnixFileSystem =
+               class_new ( utf_new_char ("java/io/UnixFileSystem") );
+       class_java_lang_System =
+               class_new ( utf_new_char ("java/lang/System") );
+       class_java_lang_ClassLoader =
+               class_new ( utf_new_char ("java/lang/ClassLoader") );   
+       class_java_security_PrivilegedActionException =
+               class_new( utf_new_char("java/security/PrivilegedActionException"));
+       class_java_lang_IllegalArgumentException =
+               class_new( utf_new_char("java/lang/IllegalArgumentException"));
+       class_java_lang_ArrayIndexOutOfBoundsException =
+               class_new( utf_new_char ("java/lang/ArrayIndexOutOfBoundsException") );
+       class_java_lang_NoSuchFieldException =
+               class_new( utf_new_char ("java/lang/NoSuchFieldException") );       
+       class_java_lang_NoSuchMethodException = 
+               class_new( utf_new_char ("java/lang/NoSuchMethodException") );      
+
+       /* load classes for wrapping primitive types */
+       class_java_lang_Double =
+               class_new( utf_new_char ("java/lang/Double") );
+       class_java_lang_Float =
+               class_new( utf_new_char ("java/lang/Float") );
+       class_java_lang_Character =
+               class_new( utf_new_char ("java/lang/Character") );
+       class_java_lang_Integer =
+               class_new( utf_new_char ("java/lang/Integer") );
+       class_java_lang_Long =
+               class_new( utf_new_char ("java/lang/Long") );
+       class_java_lang_Byte =
+               class_new( utf_new_char ("java/lang/Byte") );
+       class_java_lang_Short =
+               class_new( utf_new_char ("java/lang/Short") );
+       class_java_lang_Boolean =
+               class_new( utf_new_char ("java/lang/Boolean") );
+       class_java_lang_Void =
+               class_new( utf_new_char ("java/lang/Void") );
+
+       /* load to avoid dynamic classloading */
+       class_new(utf_new_char("sun/net/www/protocol/file/Handler"));
+       class_new(utf_new_char("sun/net/www/protocol/jar/Handler"));    
+       class_new(utf_new_char("sun/io/CharToByteISO8859_1"));
        
+       /* start classloader */
+       loader_load(utf_new_char("sun/io/ByteToCharISO8859_1")); 
 }
 
-/********************* Funktion: native_setclasspath ***************************/
+
+/*************** adds a class to the vector of loaded classes ****************/
+
+void systemclassloader_addclass(classinfo *c)
+{
+        methodinfo *m;
+
+       /* find method addClass of java.lang.ClassLoader */
+       m = class_resolvemethod (
+               class_java_lang_ClassLoader, 
+               utf_new_char("addClass"),
+               utf_new_char("(Ljava/lang/Class;)")
+           );
+
+       if (!m) panic("warning: cannot initialize classloader");
+
+       /* prepare class to be passed as argument */
+       use_class_as_object (c);
+
+       /* call 'addClass' */
+       asm_calljavamethod(m,
+                           (java_objectheader*) SystemClassLoader, 
+                          (java_objectheader*) c,
+                          NULL,  
+                          NULL
+                         );       
+}
+
+/*************** adds a library to the vector of loaded libraries ************/
+
+void systemclassloader_addlibrary(java_objectheader *o)
+{
+        methodinfo *m;
+
+       /* find method addElement of java.util.Vector */
+       m = class_resolvemethod (
+               loader_load ( utf_new_char ("java/util/Vector") ),
+               utf_new_char("addElement"),
+               utf_new_char("(Ljava/lang/Object;)V")
+           );
+
+       if (!m) panic("cannot initialize classloader");
+
+       /* call 'addElement' */
+       asm_calljavamethod(m,
+                          SystemClassLoader->nativeLibraries,
+                          o,
+                          NULL,  
+                          NULL
+                         );       
+}
+
+/*****************************************************************************
+
+       create systemclassloader object and initialize instance fields  
+
+******************************************************************************/
+
+void init_systemclassloader() 
+{
+  if (!SystemClassLoader) {
+
+       /* create object and call initializer */
+       SystemClassLoader = (java_lang_ClassLoader*) native_new_and_init(class_java_lang_ClassLoader);  
+
+       /* systemclassloader has no parent */
+       SystemClassLoader->parent      = NULL;
+       SystemClassLoader->initialized = true;
+  }
+}
+
+
+/********************* add loaded library name  ******************************/
+
+void systemclassloader_addlibname(java_objectheader *o)
+{
+        methodinfo *m;
+       java_objectheader *LibraryNameVector;
+       jfieldID id;
+
+       m = class_resolvemethod (
+               loader_load ( utf_new_char ("java/util/Vector") ),
+               utf_new_char("addElement"),
+               utf_new_char("(Ljava/lang/Object;)V")
+           );
+
+       if (!m) panic("cannot initialize classloader");
+
+       id = env.GetStaticFieldID(&env,class_java_lang_ClassLoader,"loadedLibraryNames","Ljava/util/Vector;");
+       if (!id) panic("can not access ClassLoader");
+
+       asm_calljavamethod(m,
+                          GetStaticObjectField(&env,class_java_lang_ClassLoader,id),
+                          o,
+                          NULL,  
+                          NULL
+                         );       
+}
+
+
+/********************* function: native_setclasspath *************************/
  
 void native_setclasspath (char *path)
 {
+       /* set searchpath for classfiles */
        classpath = path;
 }
 
+/***************** function: throw_classnotfoundexception ********************/
+
+void throw_classnotfoundexception()
+{
+       /* throws a ClassNotFoundException */
+       exceptionptr = native_new_and_init (class_java_lang_ClassNotFoundException);
+}
+
 
 /*********************** Funktion: native_findfunction ************************
 
@@ -131,22 +376,26 @@ void native_setclasspath (char *path)
 
 *******************************************************************************/
 
-functionptr native_findfunction (unicode *cname, unicode *mname, 
-                                 unicode *desc, bool isstatic)
+functionptr native_findfunction (utf *cname, utf *mname, 
+                                 utf *desc, bool isstatic)
 {
        u4 i;
+       /* entry of table for fast string comparison */
        struct nativecompref *n;
+        /* for warning message if no function is found */
+       char *buffer;                   
+       int buffer_len,pos;
 
        isstatic = isstatic ? true : false;
 
        if (!nativecompdone) {
                for (i=0; i<NATIVETABLESIZE; i++) {
                        nativecomptable[i].classname   = 
-                                       unicode_new_char(nativetable[i].classname);
+                                       utf_new_char(nativetable[i].classname);
                        nativecomptable[i].methodname  = 
-                                       unicode_new_char(nativetable[i].methodname);
+                                       utf_new_char(nativetable[i].methodname);
                        nativecomptable[i].descriptor  = 
-                                       unicode_new_char(nativetable[i].descriptor);
+                                       utf_new_char(nativetable[i].descriptor);
                        nativecomptable[i].isstatic    = 
                                        nativetable[i].isstatic;
                        nativecomptable[i].func        = 
@@ -162,38 +411,62 @@ functionptr native_findfunction (unicode *cname, unicode *mname,
                    desc==n->descriptor && isstatic==n->isstatic)  return n->func;
                }
 
+       /* no function was found, display warning */
+
+       buffer_len = 
+         utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
+
+       buffer = MNEW(char, buffer_len);
+
+       strcpy(buffer,"warning: native function ");
+        utf_sprint(buffer+strlen(buffer),mname);
+       strcpy(buffer+strlen(buffer),": ");
+        utf_sprint(buffer+strlen(buffer),desc);
+       strcpy(buffer+strlen(buffer)," not found in class ");
+        utf_sprint(buffer+strlen(buffer),cname);
+
+       log_text(buffer);       
+
+       MFREE(buffer,char,buffer_len);
+
        return NULL;
 }
 
 
-/********************** Funktion: javastring_new *****************************
+/********************** function: javastring_new *****************************
 
-       Legt ein neues Objekt vom Typ java/lang/String an, und tr"agt als Text
-       das "ubergebene unicode-Symbol ein. 
-       Return: Zeiger auf den String, oder NULL (wenn Speicher aus)
+       creates a new object of type java/lang/String with the text of 
+       the specified utf8-string
+       
+       return: pointer to the string or NULL (no memory)       
 
 *****************************************************************************/
 
-java_objectheader *javastring_new (unicode *text)
+java_objectheader *javastring_new (utf *u)
 {
-       u4 i;
-       java_lang_String *s;
+        char *utf_ptr = u->text;         /* pointer to current unicode character in utf string */
+       u4 utflength  = utf_strlen(u);   /* length of utf-string if uncompressed */
+       java_lang_String *s;             /* result-string */
        java_chararray *a;
+       u4 i;
        
        s = (java_lang_String*) builtin_new (class_java_lang_String);
-       a = builtin_newarray_char (text->length);
+       a = builtin_newarray_char (utflength);
 
+       /* javastring or character-array could not be created */
        if ( (!a) || (!s) ) return NULL;
 
-       for (i=0; i<text->length; i++) a->data[i] = text->text[i];
-       s -> value = a;
+       /* decompress utf-string */
+       for (i=0; i<utflength; i++) a->data[i] = utf_nextu2(&utf_ptr);
+       
+       /* set fields of the javastring-object */
+       s -> value  = a;
        s -> offset = 0;
-       s -> count = text->length;
+       s -> count  = utflength;
 
        return (java_objectheader*) s;
 }
 
-
 /********************** Funktion: javastring_new_char ************************
 
        Legt ein neues Objekt vom Typ java/lang/String an, und tr"agt als Text
@@ -205,16 +478,20 @@ java_objectheader *javastring_new (unicode *text)
 java_objectheader *javastring_new_char (char *text)
 {
        u4 i;
-       u4 len = strlen(text);
-       java_lang_String *s;
+       u4 len = strlen(text); /* length of the string */
+       java_lang_String *s;   /* result-string */
        java_chararray *a;
        
        s = (java_lang_String*) builtin_new (class_java_lang_String);
        a = builtin_newarray_char (len);
 
+       /* javastring or character-array could not be created */
        if ( (!a) || (!s) ) return NULL;
 
+       /* copy text */
        for (i=0; i<len; i++) a->data[i] = text[i];
+       
+       /* set fields of the javastring-object */
        s -> value = a;
        s -> offset = 0;
        s -> count = len;
@@ -232,7 +509,6 @@ java_objectheader *javastring_new_char (char *text)
        
 ***********************************************************************************/
 
-#define MAXSTRINGSIZE 1000
 char stringbuffer[MAXSTRINGSIZE];
 
 char *javastring_tochar (java_objectheader *so) 
@@ -250,6 +526,27 @@ char *javastring_tochar (java_objectheader *so)
        return stringbuffer;
 }
 
+/****************** function class_findfield_approx ***************************
+       
+       searches in 'classinfo'-structure for a field with the
+       specified name
+
+*******************************************************************************/
+fieldinfo *class_findfield_approx (classinfo *c, utf *name)
+{
+       s4 i;
+       for (i = 0; i < c->fieldscount; i++) {
+               /* compare field names */
+               if ((c->fields[i].name == name))
+                       return &(c->fields[i]);
+               }
+
+       /* field was not found, raise exception */      
+       exceptionptr = native_new_and_init(class_java_lang_NoSuchFieldException);
+       return NULL;
+}
+
 
 /******************** Funktion: native_new_and_init *************************
 
@@ -263,66 +560,319 @@ char *javastring_tochar (java_objectheader *so)
 java_objectheader *native_new_and_init (classinfo *c)
 {
        methodinfo *m;
-       java_objectheader *o = builtin_new (c);
+       java_objectheader *o = builtin_new (c); /* create object */
 
        if (!o) return NULL;
        
+       /* find initializer */
        m = class_findmethod (c, 
-                             unicode_new_char ("<init>"), 
-                             unicode_new_char ("()V"));
+                             utf_new_char ("<init>"), 
+                             utf_new_char ("()V"));
+                                                     
        if (!m) {
+               /* initializer not ofund */
                log_text ("warning: class has no instance-initializer:");
-               unicode_sprint (logtext, c->name);
+               utf_sprint (logtext, c->name);
                dolog();
                return o;
                }
 
+       /* call initializer */
        asm_calljavamethod (m, o,NULL,NULL,NULL);
        return o;
 }
 
+/******************** function: stringtable_update ****************************
+
+       traverses the javastring hashtable and sets the vftbl-entries of
+       javastrings which were temporarily set to NULL, because 
+       java.lang.Object was not yet loaded
+
+*******************************************************************************/
+void stringtable_update ()
+{
+       java_lang_String *js;   
+       java_chararray *a;
+       literalstring *s;       /* hashtable entry */
+       u4 i;
+
+       for (i=0; i<string_hash.size; i++) {
+               s = string_hash.ptr[i];
+               if (s) {
+                       while (s) {
+                                                               
+                               js = (java_lang_String *) s->string;
+                               
+                               if (!js || !(a = js->value)) 
+                                 /* error in hashtable found */
+                                 panic("invalid literalstring in hashtable");
+
+                               if (!js->header.vftbl) 
+                                 /* vftbl of javastring is NULL */ 
+                                 js->header.vftbl = class_java_lang_String -> vftbl;
+
+                               if (!a->header.objheader.vftbl) 
+                                 /* vftbl of character-array is NULL */ 
+                                 a->header.objheader.vftbl = class_array -> vftbl;
+
+                               /* follow link in external hash chain */
+                               s = s->hashlink;
+                       }       
+               }               
+       }
+}
+
 
-/********************* Funktion: literalstring_new ****************************
+/************************* function: u2_utflength ***************************
 
-       erzeugt einen Java-String mit dem angegebenen Text, allerdings nicht
-       auf dem HEAP, sondern in einem anderen Speicherbereich (der String
-       muss dann sp"ater explizit wieder freigegeben werden).
-       Alle Strings, die auf diese Art erzeugt werden, werden in einer
-       gemeinsamen Struktur gespeichert (n"amlich auch "uber die
-       Unicode-Hashtabelle), sodass identische Strings auch wirklich den
-       gleichen Zeiger liefern.
+       returns the utf length in bytes of a u2 array 
+
+*****************************************************************************/
+
+
+u4 u2_utflength(u2 *text, u4 u2_length)
+{
+       u4 result_len =  0;  /* utf length in bytes  */
+       u2 ch;               /* current unicode character */
+       u4 len;
        
-******************************************************************************/
+        for (len = 0; len < u2_length; len++) {
+         
+         /* next unicode character */
+         ch = *text++;
+         
+         /* determine bytes required to store unicode character as utf */
+         if (ch && (ch < 0x80)) 
+           result_len++;
+         else if (ch < 0x800)
+           result_len += 2;    
+         else 
+           result_len += 3;    
+       }
+
+    return result_len;
+}
+
+/********************* function: utf_new_u2 ***********************************
+
+       make utf symbol from u2 array, 
+       if isclassname is true '.' is replaced by '/'
+
+*******************************************************************************/
 
-java_objectheader *literalstring_new (unicode *text)
+utf *utf_new_u2(u2 *unicode_pos, u4 unicode_length, bool isclassname)
 {
-       u4 i;
-       java_lang_String *s;
-       java_chararray *a;
+       char *buffer; /* memory buffer for  unicode characters */
+       char *pos;    /* pointer to current position in buffer */
+       u4 left;      /* unicode characters left */
+       u4 buflength; /* utf length in bytes of the u2 array  */
+       utf *result;  /* resulting utf-string */
+       int i;          
+
+       /* determine utf length in bytes and allocate memory */         
+       buflength = u2_utflength(unicode_pos, unicode_length); 
+       buffer    = MNEW(char,buflength);
+       /* memory allocation failed */
+       if (!buffer) return NULL;
+
+       left = buflength;
+       pos  = buffer;
+
+       for (i = 0; i++ < unicode_length; unicode_pos++) {
+               /* next unicode character */
+               u2 c = *unicode_pos;
+               
+               if ((c != 0) && (c < 0x80)) {
+               /* 1 character */       
+               left--;
+               if ((int) left < 0) break;
+               /* convert classname */
+               if (isclassname && c=='.') 
+                 *pos++ = '/';
+               else
+                 *pos++ = (char) c;
+               } else if (c < 0x800) {             
+               /* 2 characters */                              
+               unsigned char high = c >> 6;
+               unsigned char low  = c & 0x3F;
+               left = left - 2;
+               if ((int) left < 0) break;
+               *pos++ = high | 0xC0; 
+               *pos++ = low  | 0x80;     
+               } else {         
+               /* 3 characters */                              
+               char low  = c & 0x3f;
+               char mid  = (c >> 6) & 0x3F;
+               char high = c >> 12;
+               left = left - 3;
+               if ((int) left < 0) break;
+               *pos++ = high | 0xE0; 
+               *pos++ = mid  | 0x80;  
+               *pos++ = low  | 0x80;   
+               }
+       }
+       
+       /* insert utf-string into symbol-table */
+       result = utf_new(buffer,buflength);
+       MFREE(buffer, char, buflength);
+       return result;
+}
+
+/********************* function: javastring_toutf *****************************
+
+       make utf symbol from javastring
 
-       if (text->string) return text->string;
+*******************************************************************************/
+
+utf *javastring_toutf(java_lang_String *string, bool isclassname)
+{
+        java_lang_String *str = (java_lang_String *) string;
+       return utf_new_u2(str->value->data,str->count, isclassname);
+}
+
+/********************* function: literalstring_u2 *****************************
+
+    searches for the javastring with the specified u2-array in 
+    the string hashtable, if there is no such string a new one is 
+    created 
+
+    if copymode is true a copy of the u2-array is made
+
+*******************************************************************************/
+
+java_objectheader *literalstring_u2 (java_chararray *a, u4 length, bool copymode )
+{
+    literalstring *s;                /* hashtable element */
+    java_lang_String *js;            /* u2-array wrapped in javastring */
+    java_chararray *stringdata;      /* copy of u2-array */      
+    u4 key;   
+    u4 slot;  
+    u2 i;
+
+    /* find location in hashtable */
+    key  = unicode_hashkey (a->data, length);
+    slot = key & (string_hash.size-1);
+    s    = string_hash.ptr[slot];
+
+    while (s) {
        
-       a = lit_mem_alloc (sizeof(java_chararray) + sizeof(u2)*(text->length-1) );
-       a -> header.objheader.vftbl = class_array -> vftbl;
-       a -> header.size = text->length;
-       a -> header.arraytype = ARRAYTYPE_CHAR;
-       for (i=0; i<text->length; i++) a->data[i] = text->text[i];
-
-       s = LNEW (java_lang_String);
-       s -> header.vftbl = class_java_lang_String -> vftbl;
-       s -> value = a;
-       s -> offset = 0;
-       s -> count = text->length;
+      js = (java_lang_String *) s->string;
+       
+      if (js->count == length) {
+       /* compare text */
+       for (i=0; i<length; i++) 
+         if (js->value->data[i] != a->data[i]) goto nomatch;
+                                       
+       /* string already in hashtable, free memory */
+       if (!copymode)
+         lit_mem_free(a, sizeof(java_chararray) + sizeof(u2)*(length-1)+10);
+
+       return (java_objectheader *) js;
+      }
+
+      nomatch:
+      /* follow link in external hash chain */
+      s = s->hashlink;
+    }
+
+    if (copymode) {
+      /* create copy of u2-array for new javastring */
+      u4 arraysize = sizeof(java_chararray) + sizeof(u2)*(length-1)+10;
+      stringdata = lit_mem_alloc ( arraysize );        
+      memcpy(stringdata, a, arraysize );       
+    }  
+    else
+      stringdata = a;
+
+    /* location in hashtable found, complete arrayheader */
+    if (class_array==NULL) panic("class_array not initialized");
+    stringdata -> header.objheader.vftbl = class_array -> vftbl;
+    stringdata -> header.size = length;        
+    stringdata -> header.arraytype = ARRAYTYPE_CHAR;   
+
+    /* create new javastring */
+    js = LNEW (java_lang_String);
+    js -> header.vftbl = class_java_lang_String -> vftbl;
+    js -> value  = stringdata;
+    js -> offset = 0;
+    js -> count  = length;
+
+    /* create new literalstring */
+    s = NEW (literalstring);
+    s->hashlink = string_hash.ptr[slot];
+    s->string   = (java_objectheader *) js;
+    string_hash.ptr[slot] = s;
+
+    /* update numbe of hashtable entries */
+    string_hash.entries++;
+
+    /* reorganization of hashtable */       
+    if ( string_hash.entries > (string_hash.size*2)) {
+
+      /* reorganization of hashtable, average length of 
+         the external chains is approx. 2                */  
+
+      u4 i;
+      literalstring *s;     
+      hashtable newhash; /* the new hashtable */
+      
+      /* create new hashtable, double the size */
+      init_hashtable(&newhash, string_hash.size*2);
+      newhash.entries=string_hash.entries;
+      
+      /* transfer elements to new hashtable */
+      for (i=0; i<string_hash.size; i++) {
+       s = string_hash.ptr[i];
+       while (s) {
+         literalstring *nexts = s -> hashlink;  
+         js   = (java_lang_String*) s->string;
+         slot = (unicode_hashkey(js->value->data,js->count)) & (newhash.size-1);
+         
+         s->hashlink = newhash.ptr[slot];
+         newhash.ptr[slot] = s;
+       
+         /* follow link in external hash chain */  
+         s = nexts;
+       }
+      }
+       
+      /* dispose old table */  
+      MFREE (string_hash.ptr, void*, string_hash.size);
+      string_hash = newhash;
+    }
+                       
+    return (java_objectheader *) js;
+}
 
-       unicode_setstringlink (text, (java_objectheader*) s);
-       return (java_objectheader*) s;
+/******************** Funktion: literalstring_new *****************************
+
+    creates a new javastring with the text of the utf-symbol
+    and inserts it into the string hashtable
+
+*******************************************************************************/
+
+java_objectheader *literalstring_new (utf *u)
+{
+    char *utf_ptr = u->text;         /* pointer to current unicode character in utf string */
+    u4 utflength  = utf_strlen(u);   /* length of utf-string if uncompressed */
+    java_chararray *a;               /* u2-array constructed from utf string */
+    java_objectheader *js;
+    u4 i;
+    
+    /* allocate memory */ 
+    a = lit_mem_alloc (sizeof(java_chararray) + sizeof(u2)*(utflength-1)+10 ); 
+    /* convert utf-string to u2-array */
+    for (i=0; i<utflength; i++) a->data[i] = utf_nextu2(&utf_ptr);     
+
+    return literalstring_u2(a, utflength, false);
 }
 
 
-/********************** Funktion: literalstring_free **************************
+/********************** function: literalstring_free **************************
 
-       L"oscht einen Java-String wieder aus dem Speicher (wird zu Systemende
-       vom Hashtabellen-Verwalter aufgerufen)
+        removes a javastring from memory                      
 
 ******************************************************************************/
 
@@ -330,10 +880,17 @@ void literalstring_free (java_objectheader* sobj)
 {
        java_lang_String *s = (java_lang_String*) sobj;
        java_chararray *a = s->value;
+
+       log_text("literalstring_free called");
        
+       /* dispose memory of java.lang.String object */
        LFREE (s, java_lang_String);
-       LFREE (a, sizeof(java_chararray) + sizeof(u2)*(a->header.size-1));
+       /* dispose memory of java-characterarray */
+       LFREE (a, sizeof(java_chararray) + sizeof(u2)*(a->header.size-1)); /* +10 ?? */
 }
 
 
 
+
+
+
index c484642b441e89a2cb6af674d0a6c246409a74c9..26da5d597f6782296343897742bd06c63a5e2790 100644 (file)
 
 *******************************************************************************/
 
+/* Java Native Interface */
+#include "jni.h"
 
+/* structure for class java.lang.String */
+struct java_lang_String;
+
+/* for raising exceptions from native methods */
 extern java_objectheader* exceptionptr;
 
+/* javastring-hashtable */
+extern hashtable string_hash; 
+
+/* load classes required for native methods */
 void native_loadclasses ();
+
+/* set searchpath for classfiles */
 void native_setclasspath (char *path);
 
-functionptr native_findfunction (unicode *cname, unicode *mname, 
-                                 unicode *desc, bool isstatic);
+/* find native function */
+functionptr native_findfunction (utf *cname, utf *mname, 
+                                 utf *desc, bool isstatic);
 
-java_objectheader *javastring_new (unicode *text);
+/* creates a new object of type java/lang/String from a utf-text */
+java_objectheader *javastring_new (utf *text);
+
+/* creates a new object of type java/lang/String from a c-string */
 java_objectheader *javastring_new_char (char *text);
+
+/* make c-string from a javastring (debugging) */
 char *javastring_tochar (java_objectheader *s);
 
+/* create new object on the heap and call the initializer */
 java_objectheader *native_new_and_init (classinfo *c);
 
-java_objectheader *literalstring_new (unicode *text);
+/* add property to system-property vector */
+void attach_property(char *name, char *value);
+
+/* correct vftbl-entries of javastring-hash */
+void stringtable_update();
+
+/* throw classnotfoundexcetion */
+void throw_classnotfoundexception();
+
+/* make utf symbol from javastring */
+utf *javastring_toutf(struct java_lang_String *string, bool isclassname);
+
+/* make utf symbol from u2 array */
+utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname);
+
+/* determine utf length in bytes of a u2 array */
+u4 u2_utflength(u2 *text, u4 u2_length);
+
+/* create systemclassloader object and initialize its instance fields  */
+void init_systemclassloader();
+
+/* search 'classinfo'-structure for a field with the specified name */
+fieldinfo *class_findfield_approx (classinfo *c, utf *name);
+
+/* creates a new javastring with the text of the utf-symbol */
+java_objectheader *literalstring_new (utf *u);
+
+/* creates a new javastring with the text of the u2-array */
+java_objectheader *literalstring_u2 (java_chararray *a, u4 length, bool copymode);
+
+/* dispose a javastring */
 void literalstring_free (java_objectheader*);
 
-void attach_property(char *name, char *value);
+void systemclassloader_addlibname(java_objectheader *o);
+void systemclassloader_addlibrary(java_objectheader *o);
+
diff --git a/src/native/vm/Constructor.c b/src/native/vm/Constructor.c
new file mode 100644 (file)
index 0000000..6415581
--- /dev/null
@@ -0,0 +1,12 @@
+/* class: java/lang/reflect/Constructor */
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    newInstance
+ * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_newInstance ( JNIEnv *env ,  struct java_lang_reflect_Constructor* this, java_objectarray* par1)
+{
+  log_text("Java_java_lang_reflect_Constructor_newInstance called");
+}
diff --git a/src/native/vm/Field.c b/src/native/vm/Field.c
new file mode 100644 (file)
index 0000000..d93aac9
--- /dev/null
@@ -0,0 +1,626 @@
+/* class: java/lang/reflect/Field */
+
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    get
+ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Field_get ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID target_fid;   /* the JNI-fieldid of the wrapping object */
+  jfieldID fid;          /* the JNI-fieldid of the field containing the value */
+  jobject o;            /* the object for wrapping the primitive type */
+  classinfo *c = (classinfo *) this->clazz;
+  int st = (this->modifiers & ACC_STATIC); /* true if field is static */
+
+  /* get the fieldid of the field represented by this Field-object */
+  fid = class_findfield_approx((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+  /* The fieldid is used to retrieve the value, for primitive types a new 
+     object for wrapping the primitive type is created.  */
+  if (st || obj)   
+    switch (this->slot) {
+      case 'I' : {
+                  /* create wrapping class */
+                  c = class_java_lang_Integer;
+                  o = builtin_new(c);
+                  /* get fieldid to store the value */
+                  target_fid = env->GetFieldID(env,c,"value","I");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       /* static field */
+                       SetIntField(env,o,target_fid, env->GetStaticIntField(env, c, fid));
+                   else
+                        /* instance field */
+                       SetIntField(env,o,target_fid, env->GetIntField(env,(jobject) obj, fid));
+
+                  /* return the wrapped object */                 
+                  return (java_lang_Object*) o;
+                 }
+      case 'J' : {
+                  c = class_java_lang_Long;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","J");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetLongField(env,o,target_fid, env->GetStaticLongField(env, c, fid));
+                   else
+                       SetLongField(env,o,target_fid, env->GetLongField(env,(jobject)  obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'F' : {
+                  c = class_java_lang_Float;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","F");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetFloatField(env,o,target_fid, env->GetStaticFloatField(env, c, fid));
+                   else
+                       SetFloatField(env,o,target_fid, env->GetFloatField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'D' : {
+                  c = class_java_lang_Double;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","D");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetDoubleField(env,o,target_fid, env->GetStaticDoubleField(env, c, fid));
+                   else
+                       SetDoubleField(env,o,target_fid, env->GetDoubleField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'B' : {
+                  c = class_java_lang_Byte;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","B");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetByteField(env,o,target_fid, env->GetStaticByteField(env, c, fid));
+                   else
+                       SetByteField(env,o,target_fid, env->GetByteField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'C' : {
+                  c = class_java_lang_Character;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","C");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetCharField(env,o,target_fid, env->GetStaticCharField(env, c, fid));
+                   else
+                       SetCharField(env,o,target_fid, env->GetCharField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'S' : {
+                  c = class_java_lang_Short;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","S");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetShortField(env,o,target_fid, env->GetStaticShortField(env, c, fid));
+                   else
+                       SetShortField(env,o,target_fid, env->GetShortField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case 'Z' : {
+                  c = class_java_lang_Boolean;
+                  o = builtin_new(c);
+                  target_fid = env->GetFieldID(env,c,"value","Z");
+                  if (!target_fid) break;
+                                  
+                  if (st)
+                       SetBooleanField(env,o,target_fid, env->GetStaticBooleanField(env, c, fid));
+                   else
+                       SetBooleanField(env,o,target_fid, env->GetBooleanField(env, (jobject) obj, fid));
+
+                  return (java_lang_Object*) o;
+                 }
+      case '[' : 
+      case 'L' : {
+                  if (st)
+                       /* static field */
+                       return (java_lang_Object*) env->GetStaticObjectField(env, c, fid);
+                   else
+                        /* instance field */
+                       return (java_lang_Object*) env->GetObjectField(env, (jobject) obj, fid);
+
+                 }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getBoolean ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      /* get the fieldid represented by the field-object */
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+          /* call the JNI-function to retrieve the field */ 
+         return env->GetBooleanField (env, (jobject) obj, fid);
+  }
+
+  /* raise exception */
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;)B
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getByte ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetByteField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;)C
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getChar ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetCharField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getDouble
+ * Signature: (Ljava/lang/Object;)D
+ */
+JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetDoubleField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getFloat
+ * Signature: (Ljava/lang/Object;)F
+ */
+JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetFloatField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getInt
+ * Signature: (Ljava/lang/Object;)I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getInt ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetIntField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getLong
+ * Signature: (Ljava/lang/Object;)J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_reflect_Field_getLong ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetLongField (env, (jobject) obj, fid);
+  }
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    getShort
+ * Signature: (Ljava/lang/Object;)S
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getShort ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) 
+         return env->GetShortField (env, (jobject) obj, fid);
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    set
+ * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, struct java_lang_Object* val)
+{
+  jfieldID source_fid;  /* the field containing the value to be written */
+  jfieldID fid;         /* the field to be written */
+  classinfo *c;
+  int st = (this->modifiers & ACC_STATIC); /* true if the field is static */
+
+  fid = class_findfield_approx((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+  if (val && (st || obj)) {
+
+    c = val->header.vftbl -> class;
+
+    /* The fieldid is used to set the new value, for primitive types the value
+       has to be retrieved from the wrapping object */  
+    switch (this->slot) {
+      case 'I' : {
+                  /* illegal argument specified */
+                  if (c != class_java_lang_Integer) break;
+                  /* determine the field to read the value */
+                  source_fid = env->GetFieldID(env,c,"value","I");
+                  if (!source_fid) break;
+                                  
+                  /* set the new value */
+                  if (st)
+                       /* static field */
+                       env->SetStaticIntField(env, c, fid, GetIntField(env,(jobject) val,source_fid));
+                   else
+                        /* instance field */
+                       env->SetIntField(env, (jobject) obj, fid, GetIntField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'J' : {
+                  if (c != class_java_lang_Long) break;
+                  source_fid = env->GetFieldID(env,c,"value","J");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticLongField(env, c, fid, GetLongField(env,(jobject) val,source_fid));
+                   else
+                       env->SetLongField(env, (jobject) obj, fid, GetLongField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'F' : {
+                  if (c != class_java_lang_Float) break;
+                  source_fid = env->GetFieldID(env,c,"value","F");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticFloatField(env, c, fid, GetFloatField(env,(jobject) val,source_fid));
+                   else
+                       env->SetFloatField(env, (jobject) obj, fid, GetFloatField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'D' : {
+                  if (c != class_java_lang_Double) break;
+                  source_fid = env->GetFieldID(env,c,"value","D");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticDoubleField(env, c, fid, GetDoubleField(env,(jobject) val,source_fid));
+                   else
+                       env->SetDoubleField(env, (jobject) obj, fid, GetDoubleField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'B' : {
+                  if (c != class_java_lang_Byte) break;
+                  source_fid = env->GetFieldID(env,c,"value","B");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticByteField(env, c, fid, GetByteField(env,(jobject) val,source_fid));
+                   else
+                       env->SetByteField(env, (jobject) obj, fid, GetByteField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'C' : {
+                  if (c != class_java_lang_Character) break;
+                  source_fid = env->GetFieldID(env,c,"value","C");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticCharField(env, c, fid, GetCharField(env,(jobject) val,source_fid));
+                   else
+                       env->SetCharField(env, (jobject) obj, fid, GetCharField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'S' : {
+                  if (c != class_java_lang_Short) break;
+                  source_fid = env->GetFieldID(env,c,"value","S");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticShortField(env, c, fid, GetShortField(env,(jobject) val,source_fid));
+                   else
+                       env->SetShortField(env, (jobject) obj, fid, GetShortField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case 'Z' : {
+                  if (c != class_java_lang_Boolean) break;
+                  source_fid = env->GetFieldID(env,c,"value","Z");
+                  if (!source_fid) break;
+                                  
+                  if (st)
+                       env->SetStaticBooleanField(env, c, fid, GetBooleanField(env,(jobject) val,source_fid));
+                   else
+                       env->SetBooleanField(env, (jobject) obj, fid, GetBooleanField(env,(jobject) val,source_fid));
+
+                  return;
+                 }
+      case '[' :
+      case 'L' : {
+                  if (st)
+                       env->SetStaticObjectField(env, c, fid, (jobject) val);
+                   else
+                       env->SetObjectField(env, (jobject) obj, fid, (jobject) val);
+
+                  return;
+                 }
+    }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setBoolean
+ * Signature: (Ljava/lang/Object;Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) { 
+         env->SetBooleanField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setByte
+ * Signature: (Ljava/lang/Object;B)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetByteField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setChar
+ * Signature: (Ljava/lang/Object;C)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetCharField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setDouble
+ * Signature: (Ljava/lang/Object;D)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, double val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetDoubleField (env, (jobject) obj, fid, val);
+         return;
+      } 
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setFloat
+ * Signature: (Ljava/lang/Object;F)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, float val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetFloatField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setInt
+ * Signature: (Ljava/lang/Object;I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetIntField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setLong
+ * Signature: (Ljava/lang/Object;J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s8 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetLongField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+/*
+ * Class:     java/lang/reflect/Field
+ * Method:    setShort
+ * Signature: (Ljava/lang/Object;S)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort ( JNIEnv *env ,  struct java_lang_reflect_Field* this, struct java_lang_Object* obj, s4 val)
+{
+  jfieldID fid;
+
+  if (this->clazz && obj) {
+
+      fid = class_findfield_approx ((classinfo *) this->clazz,javastring_toutf(this->name, false));
+
+      if (fid) {
+         env->SetShortField (env, (jobject) obj, fid, val);
+         return;
+      }
+  }
+
+  exceptionptr = native_new_and_init(class_java_lang_IllegalArgumentException);
+}
+
+
+
+
+
+
index 1ecb5bf79f278e6563aad6dcaa9fa82d022e663c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-EXTRA_DIST = io.c lang.c util.c
diff --git a/src/native/vm/Method.c b/src/native/vm/Method.c
new file mode 100644 (file)
index 0000000..44c7815
--- /dev/null
@@ -0,0 +1,11 @@
+/* class: java/lang/reflect/Method */
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    invoke
+ * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_invoke ( JNIEnv *env ,  struct java_lang_reflect_Method* this, struct java_lang_Object* par1, java_objectarray* par2)
+{
+  log_text("Java_java_lang_reflect_Method_invoke called");
+}
diff --git a/src/native/vm/VMRuntime.c b/src/native/vm/VMRuntime.c
new file mode 100644 (file)
index 0000000..cf399eb
--- /dev/null
@@ -0,0 +1,86 @@
+/* class: java/lang/Runtime */
+
+/*
+ * Class:     java/lang/Runtime
+ * Method:    execInternal
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Process;
+ */
+JNIEXPORT struct java_lang_Process* JNICALL Java_java_lang_Runtime_execInternal ( JNIEnv *env ,  struct java_lang_Runtime* this, java_objectarray* par1, java_objectarray* par2)
+{
+  log_text("Java_java_lang_Runtime_execInternal  called");
+  return NULL;
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    exitInternal
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal ( JNIEnv *env ,  struct java_lang_Runtime* this, s4 par1)
+{
+       cacao_shutdown (par1);
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    freeMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Runtime_freeMemory ( JNIEnv *env ,  struct java_lang_Runtime* this)
+{
+       log_text ("java_lang_Runtime_freeMemory called");
+       return builtin_i2l (0);
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    gc
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_gc ( JNIEnv *env ,  struct java_lang_Runtime* this)
+{
+       gc_call();
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    runFinalization0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_runFinalization0 ( JNIEnv *env  )
+{
+  log_text("Java_java_lang_Runtime_runFinalization0  called");
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    runFinalizersOnExit0
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_runFinalizersOnExit0 ( JNIEnv *env ,  s4 par1)
+{
+  log_text("Java_java_lang_Runtime_runFinalizersOnExit0  called");
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_Runtime_totalMemory ( JNIEnv *env ,  struct java_lang_Runtime* this)
+{
+       log_text ("java_lang_Runtime_totalMemory called");
+       return builtin_i2l (0);
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    traceInstructions
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_traceInstructions ( JNIEnv *env ,  struct java_lang_Runtime* this, s4 par1)
+{
+  log_text("Java_java_lang_Runtime_traceInstructions  called");
+}
+/*
+ * Class:     java/lang/Runtime
+ * Method:    traceMethodCalls
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_traceMethodCalls ( JNIEnv *env ,  struct java_lang_Runtime* this, s4 par1)
+{
+  log_text("Java_java_lang_Runtime_traceMethodCalls  called");
+}
diff --git a/src/native/vm/VMThread.c b/src/native/vm/VMThread.c
new file mode 100644 (file)
index 0000000..737034c
--- /dev/null
@@ -0,0 +1,223 @@
+/* class: java/lang/Thread */
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    countStackFrames
+ * Signature: ()I
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_countStackFrames ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  log_text ("java_lang_Thread_countStackFrames called");
+  return 0;         /* not yet implemented */
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    currentThread
+ * Signature: ()Ljava/lang/Thread;
+ */
+JNIEXPORT struct java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread ( JNIEnv *env  )
+{
+  struct java_lang_Thread* t;
+
+  if (runverbose)
+    log_text ("java_lang_Thread_currentThread called");
+
+
+  #ifdef USE_THREADS
+
+        t = (struct java_lang_Thread*) currentThread; 
+  
+        if (!t->group) {
+
+               /* ThreadGroup of currentThread is not initialized */
+
+               t->group = (java_lang_ThreadGroup *) 
+                       native_new_and_init(loader_load(utf_new_char("java/lang/ThreadGroup")));
+
+               if (t->group == 0) 
+                       log_text("unable to create ThreadGroup");
+       }
+
+
+       return (struct java_lang_Thread*) currentThread;
+  #else
+       return 0;       
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    interrupt0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0 ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  log_text("Java_java_lang_Thread_interrupt0  called");
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    isAlive
+ * Signature: ()Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_isAlive ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_isAlive called");
+
+  #ifdef USE_THREADS
+       return aliveThread((thread*)this);
+  #else
+       return 0;
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    isInterrupted
+ * Signature: (Z)Z
+ */
+JNIEXPORT s4 JNICALL Java_java_lang_Thread_isInterrupted ( JNIEnv *env ,  struct java_lang_Thread* this, s4 par1)
+{
+  log_text("Java_java_lang_Thread_isInterrupted  called");
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_registerNatives ( JNIEnv *env  )
+{
+  /* empty */
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    resume0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_resume0 ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_resume0 called");
+
+  #ifdef USE_THREADS
+       resumeThread((thread*)this);
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    setPriority0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0 ( JNIEnv *env ,  struct java_lang_Thread* this, s4 par1)
+{
+  if (runverbose) 
+    log_text ("java_lang_Thread_setPriority0 called");
+
+  #ifdef USE_THREADS
+  setPriorityThread((thread*)this, par1);
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    sleep
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_sleep ( JNIEnv *env ,  s8 par1)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_sleep called");
+
+  #ifdef USE_THREADS
+       yieldThread();
+  #endif
+       
+  /* not yet implemented */
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_start ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose) 
+    log_text ("java_lang_Thread_start called");
+
+  #ifdef USE_THREADS
+       startThread((thread*)this);
+  #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    stop0
+ * Signature: (Ljava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_stop0 ( JNIEnv *env ,  struct java_lang_Thread* this, struct java_lang_Object* par1)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_stop0 called");
+
+
+  #ifdef USE_THREADS
+       if (currentThread == (thread*)this)
+       {
+           log_text("killing");
+           killThread(0);
+           /*
+               exceptionptr = proto_java_lang_ThreadDeath;
+               return;
+           */
+       }
+       else
+       {
+               CONTEXT((thread*)this).flags |= THREAD_FLAGS_KILLED;
+               resumeThread((thread*)this);
+       }
+   #endif
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    suspend0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_suspend0 ( JNIEnv *env ,  struct java_lang_Thread* this)
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_suspend0 called");
+
+  #ifdef USE_THREADS
+       suspendThread((thread*)this);
+  #endif
+
+}
+
+/*
+ * Class:     java/lang/Thread
+ * Method:    yield
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Thread_yield ( JNIEnv *env  )
+{
+  if (runverbose)
+    log_text ("java_lang_Thread_yield called");
+  #ifdef USE_THREADS
+       yieldThread();
+  #endif
+}
+
+
+
+
+
+
+
+
index e9a766e250d1b28f1458562454e111007053ac0d..805690b48cdf9032f833d3c1a614036e95130c38 100644 (file)
@@ -101,7 +101,7 @@ initLocks (void)
 
        /* Load exception classes */
        class_java_lang_IllegalMonitorStateException =
-               loader_load(unicode_new_char("java/lang/IllegalMonitorStateException"));
+               loader_load(utf_new_char("java/lang/IllegalMonitorStateException"));
 }
 
 /*
index fed33a70bfc0e140a8f5ea4e9b73d5ec0005a8de..16b647d50d6561faf857633b05f4b54ccf3a693c 100644 (file)
@@ -209,7 +209,7 @@ threadedAccept(int fd, struct sockaddr* addr, int* len)
 #if defined(BLOCKING_CALLS)
        blockOnFile(fd, TH_ACCEPT);
 #endif
-       r = accept(fd, addr, (size_t*)len);
+       r = accept(fd, addr, (int*)len);
        if (r >= 0
            || !(errno == EINPROGRESS || errno == EALREADY
                 || errno == EWOULDBLOCK))
index a473fb9653a6d13ebeb2ddfeaa399f85ef684282..a9f45512e3feb2398f51c5995d6a1594df64b48e 100644 (file)
@@ -137,14 +137,14 @@ initThreads(u1 *stackbottom)
        }
 
     /* Allocate a thread to be the main thread */
-    liveThreads = the_main_thread = (thread*)builtin_new(loader_load(unicode_new_char("java/lang/Thread")));
+    liveThreads = the_main_thread = (thread*)builtin_new(loader_load(utf_new_char("java/lang/Thread")));
     assert(the_main_thread != 0);
        /* heap_addreference((void **) &liveThreads); */
     
     the_main_thread->PrivateInfo = 1;
     CONTEXT(the_main_thread).free = false;
 
-    the_main_thread->name = javastring_new(unicode_new_char("main"));
+    the_main_thread->name = javastring_new(utf_new_char("main"));
     the_main_thread->priority = NORM_THREAD_PRIO;
     CONTEXT(the_main_thread).priority = (u1)the_main_thread->priority;
     CONTEXT(the_main_thread).exceptionptr = 0;
@@ -167,14 +167,14 @@ initThreads(u1 *stackbottom)
        the_main_thread->target = 0;
        the_main_thread->interruptRequested = 0;
        the_main_thread->group =
-               (threadGroup*)builtin_new(loader_load(unicode_new_char("java/lang/ThreadGroup")));
+               (threadGroup*)builtin_new(loader_load(utf_new_char("java/lang/ThreadGroup")));
        /* we should call the constructor */
        assert(the_main_thread->group != 0);
 
        talive++;
 
        /* Load exception classes */
-       class_java_lang_ThreadDeath = loader_load(unicode_new_char("java/lang/ThreadDeath"));
+       class_java_lang_ThreadDeath = loader_load(utf_new_char("java/lang/ThreadDeath"));
 
        DBG( fprintf(stderr, "finishing initThreads\n"); );
 
@@ -242,7 +242,7 @@ startDaemon(void* func, char* nm, int stackSize)
 
     DBG( printf("startDaemon %s\n", nm); );
 
-       tid = (thread*)builtin_new(loader_load(unicode_new_char("java/lang/Thread")));
+       tid = (thread*)builtin_new(loader_load(utf_new_char("java/lang/Thread")));
        assert(tid != 0);
 
        for (i = 0; i < MAXTHREADS; ++i)
@@ -292,7 +292,7 @@ firstStartThread(void)
 
        /* Find the run()V method and call it */
        method = class_findmethod(currentThread->header.vftbl->class,
-                                                         unicode_new_char("run"), unicode_new_char("()V"));
+                                                         utf_new_char("run"), utf_new_char("()V"));
        if (method == 0)
                panic("Cannot find method \'void run ()\'");
        asm_calljavamethod(method, currentThread, NULL, NULL, NULL);
@@ -515,6 +515,7 @@ killThread(thread* tid)
                /* If we only have daemons left, then everyone is dead. */
                if (talive == tdaemon) {
                        /* atexit functions get called to clean things up */
+                       intsRestore();
                        exit(0);
                }
 
index dd1fa71d6946a918bd58f2bb676a46c8aacc22da..ab89cc25eb7344df25b6d24a22bd487a634ffeb8 100644 (file)
@@ -33,6 +33,7 @@
 builtin_descriptor builtin_desc[] = {
        {(functionptr) builtin_instanceof,         "instanceof"},
        {(functionptr) builtin_checkcast,          "checkcast"},
+    {(functionptr) asm_builtin_checkcast,      "checkcast"},
        {(functionptr) builtin_arrayinstanceof,    "arrayinstanceof"},
        {(functionptr) builtin_checkarraycast,     "checkarraycast"},
        {(functionptr) asm_builtin_checkarraycast, "checkarraycast"},
@@ -121,14 +122,24 @@ builtin_descriptor builtin_desc[] = {
                        
 *****************************************************************************/                 
 
-static s4 builtin_isanysubclass (classinfo *sub, classinfo *super)
-{
+s4 builtin_isanysubclass (classinfo *sub, classinfo *super)
+{ 
        if (super->flags & ACC_INTERFACE)
                return (sub->vftbl->interfacetablelength > super->index) &&
                       (sub->vftbl->interfacetable[-super->index] != NULL);
 
+    while (sub != 0)
+               if (sub == super)
+                       return 1;
+               else
+                       sub = sub->super;
+       
+       return 0;
+
+       /*
        return (unsigned) (sub->vftbl->baseval - super->vftbl->baseval) <=
               (unsigned) (super->vftbl->diffval);
+       */
 }
 
 
@@ -144,9 +155,9 @@ static s4 builtin_isanysubclass (classinfo *sub, classinfo *super)
 
 s4 builtin_instanceof(java_objectheader *obj, classinfo *class)
 {
-#ifdef DEBUG
+       #ifdef DEBUG
        log_text ("builtin_instanceof called");
-#endif
+       #endif
        
        if (!obj) return 0;
        return builtin_isanysubclass (obj->vftbl->class, class);
@@ -166,22 +177,22 @@ s4 builtin_instanceof(java_objectheader *obj, classinfo *class)
 
 s4 builtin_checkcast(java_objectheader *obj, classinfo *class)
 {
-#ifdef DEBUG
+       #ifdef DEBUG
        log_text ("builtin_checkcast called");
-#endif
+       #endif
 
        if (obj == NULL)
                return 1;
        if (builtin_isanysubclass (obj->vftbl->class, class))
                return 1;
 
-#if DEBUG
+       #if DEBUG
        printf ("#### checkcast failed ");
-       unicode_display (obj->vftbl->class->name);
+       utf_display (obj->vftbl->class->name);
        printf (" -> ");
-       unicode_display (class->name);
+       utf_display (class->name);
        printf ("\n");
-#endif
+       #endif
 
        return 0;
 }
@@ -275,11 +286,12 @@ s4 builtin_arrayinstanceof
 
 ******************************************************************************/
 
-java_objectheader *builtin_throw_exception (java_objectheader *exceptionptr) {
-       unicode_display (exceptionptr->vftbl->class->name);
+java_objectheader *builtin_throw_exception (java_objectheader *local_exceptionptr) {
+       exceptionptr = local_exceptionptr;
+       utf_display (local_exceptionptr->vftbl->class->name);
        printf ("\n");
        fflush (stdout);
-       return exceptionptr;
+       return local_exceptionptr;
 }
 
 
@@ -798,12 +810,12 @@ java_objectheader *builtin_trace_exception (java_objectheader *exceptionptr,
                methodindent--;
        if (verbose || runverbose) {
                printf("Exception ");
-               unicode_display (exceptionptr->vftbl->class->name);
+               utf_display (exceptionptr->vftbl->class->name);
                printf(" thrown in ");
                if (method) {
-                       unicode_display (method->class->name);
+                       utf_display (method->class->name);
                        printf(".");
-                       unicode_display (method->name);
+                       utf_display (method->name);
                        if (method->flags & ACC_SYNCHRONIZED)
                                printf("(SYNC)");
                        else
@@ -823,10 +835,10 @@ void builtin_trace_args(long a0, long a1, long a2, long a3, long a4, long a5,
 {
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "called: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        sprintf (logtext+strlen(logtext), "(");
        switch (method->paramcount) {
                case 6:
@@ -861,10 +873,10 @@ void builtin_displaymethodstart(methodinfo *method)
 {
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "called: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        dolog ();
        methodindent++;
 }
@@ -874,10 +886,10 @@ void builtin_displaymethodstop(methodinfo *method, long l, double d)
        methodindent--;
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "finished: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        switch (method->returntype) {
                case TYPE_INT:
                case TYPE_LONG:
@@ -898,10 +910,10 @@ void builtin_displaymethodexception(methodinfo *method)
 {
        sprintf (logtext, "                                             ");
        sprintf (logtext+methodindent, "exception abort: ");
-       unicode_sprint (logtext+strlen(logtext), method->class->name);
+       utf_sprint (logtext+strlen(logtext), method->class->name);
        sprintf (logtext+strlen(logtext), ".");
-       unicode_sprint (logtext+strlen(logtext), method->name);
-       unicode_sprint (logtext+strlen(logtext), method->descriptor);
+       utf_sprint (logtext+strlen(logtext), method->name);
+       utf_sprint (logtext+strlen(logtext), method->descriptor);
        dolog ();
 }
 
index 9fcae7dddc0d6a4de1fd64dcc5c4cd54f4f2c3d6..e760e21c772aca42089a8d0a1e640bb8a0617229 100644 (file)
@@ -22,9 +22,12 @@ typedef struct builtin_descriptor {
        } builtin_descriptor;
 
 extern builtin_descriptor builtin_desc[];
+extern java_objectheader* exceptionptr;
 
 s4 builtin_instanceof(java_objectheader *obj, classinfo *class);
+s4 builtin_isanysubclass (classinfo *sub, classinfo *super);
 s4 builtin_checkcast(java_objectheader *obj, classinfo *class);
+s4 asm_builtin_checkcast(java_objectheader *obj, classinfo *class);
 s4 builtin_arrayinstanceof
        (java_objectheader *obj, constant_arraydescriptor *desc);
 s4 builtin_checkarraycast
index a5e7c0db879d7fcae87584ac23648ccb3b2a7956..c4497031a0383d257752e38c34c98adf308e00c6 100644 (file)
@@ -12,7 +12,7 @@
        Changes: Mark     Probst  (schani)   EMAIL: cacao@complang.tuwien.ac.at
                         Philipp  Tomsich (phil)     EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: global.h 132 1999-09-27 15:54:42Z chris $
+       Last Change: $Id: global.h 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
@@ -61,6 +61,8 @@ typedef int   bool;             /* boolean data type */
 #define true  1
 #define false 0
 
+#define PRIMITIVETYPE_COUNT  9  /* number of primitive types */
+
 typedef void (*functionptr) (); /* generic function pointer */
 
 
@@ -119,7 +121,8 @@ void cacao_shutdown(s4 status);
 
 /* resolve typedef cycles *****************************************************/
 
-typedef struct unicode unicode;
+typedef struct utf utf;
+typedef struct literalstring literalstring;
 typedef struct java_objectheader java_objectheader; 
 typedef struct classinfo classinfo; 
 typedef struct vftbl vftbl;
@@ -150,28 +153,86 @@ typedef u1* methodptr;
 
 *******************************************************************************/
 
-/* data structures of Unicode symbol *******************************************
+/* data structures for hashtables ********************************************
+
+
+       All utf-symbols, javastrings and classes are stored in global hashtables,
+       so every symbol exists only once. Equal symbols have identical pointers.
+       The functions for adding hashtable elements search the table for the 
+       element with the specified name/text and return it on success. Otherwise a 
+       new hashtable element is created.
+
+    The hashtables use external linking for handling collisions. The hashtable 
+       structure contains a pointer <ptr> to the array of hashtable slots. The 
+       number of hashtable slots and therefore the size of this array is specified 
+       by the element <size> of hashtable structure. <entries> contains the number
+       of all hashtable elements stored in the table, including those in the 
+       external chains.
+       The hashtable element structures (utf, literalstring, classinfo) contain
+       both a pointer to the next hashtable element as a link for the external hash 
+       chain and the key of the element. The key is computed from the text of
+       the string or the classname by using up to 8 characters.
+       
+       If the number of entries in the hashtable exceeds twice the size of the 
+       hashtableslot-array it is supposed that the average length of the 
+       external chains has reached a value beyond 2. Therefore the functions for
+       adding hashtable elements (utf_new, class_new, literalstring_new) double
+       the hashtableslot-array. In this restructuring process all elements have
+       to be inserted into the new hashtable and new external chains must be built.
+
+
+example for the layout of a hashtable:
+
+hashtable.ptr-->  +-------------------+
+                  |                   |
+                           ...
+                  |                   |
+                  +-------------------+   +-------------------+   +-------------------+
+                  | hashtable element |-->| hashtable element |-->| hashtable element |-->NULL
+                  +-------------------+   +-------------------+   +-------------------+
+                  | hashtable element |
+                  +-------------------+   +-------------------+   
+                  | hashtable element |-->| hashtable element |-->NULL
+                  +-------------------+   +-------------------+   
+                  | hashtable element |-->NULL
+                  +-------------------+
+                  |                   |
+                           ...
+                  |                   |
+                  +-------------------+
 
-       All Unicode symbols are stored in one global (hash) table, every symbol
-       exists only once. Equal symbols have identical pointers.
 */
 
-struct unicode {
-       unicode   *hashlink;        /* link for external hash chain               */
-       u4         key;             /* hash key (computed from text)              */
-       int        length;          /* text length                                */           
-       u2        *text;            /* pointer to text (each character is 16 Bit) */
-       classinfo *class;           /* class pointer if it exists, otherwise NULL */
-       java_objectheader *string;  /* string pointer if it exists, otherwise NULL*/ 
+
+/* data structure for utf8 symbols ********************************************/
+
+struct utf {
+       utf        *hashlink;       /* link for external hash chain               */
+       int         blength;        /* text length in bytes                       */           
+       char       *text;           /* pointer to text                            */
 };
 
+/* data structure of internal javastrings stored in global hashtable **********/
+
+struct literalstring {
+       literalstring     *hashlink;     /* link for external hash chain          */
+       java_objectheader *string;  
+};
+
+/* data structure for accessing hashtables ************************************/
+
+typedef struct {            
+  u4 size;
+  u4 entries;        /* number of entries in the table */
+  void **ptr;        /* pointer to hashtable */
+} hashtable;
 
 /* data structures of remaining constant pool entries *************************/
 
-typedef struct {            /* Fieldref, Methodref and InterfaceMethodref     */
+typedef struct {                /* Fieldref, Methodref and InterfaceMethodref     */
        classinfo *class;       /* class containing this field/method/interface   */
-       unicode   *name;        /* field/method/interface name                    */
-       unicode   *descriptor;  /* field/method/interface type descriptor string  */
+       utf       *name;        /* field/method/interface name                    */
+       utf       *descriptor;  /* field/method/interface type descriptor string  */
 } constant_FMIref;
 
 typedef struct {            /* Integer                                        */
@@ -191,8 +252,8 @@ typedef struct {            /* Double                                         */
 } constant_double;
 
 typedef struct {            /* NameAndType (Field or Method)                  */
-       unicode *name;          /* field/method name                              */
-       unicode *descriptor;    /* field/method type descriptor string            */
+       utf *name;              /* field/method name                              */
+       utf *descriptor;        /* field/method type descriptor string            */
 } constant_nameandtype;
 
 /*  arraydescriptor describes array types. Basic array types contain their
@@ -314,6 +375,16 @@ typedef struct java_arrayarray {
 } java_arrayarray;
 
 
+/* structure for primitive classes ********************************************/
+
+typedef struct primitivetypeinfo {
+       classinfo *class_wrap;               /* class for wrapping primitive type */
+       classinfo *class_primitive;          /* primitive class                   */
+       char *wrapname;                      /* name of class for wrapping        */
+       char typesig;                        /* one character type signature      */
+       char *name;                          /* name of primitive class           */
+} primitivetypeinfo;
+
 /* field, method and class structures *****************************************/
 
 /* fieldinfo ******************************************************************/
@@ -321,8 +392,8 @@ typedef struct java_arrayarray {
 typedef struct fieldinfo {/* field of a class                                 */
        s4       flags;       /* ACC flags                                        */
        s4       type;        /* basic data type                                  */
-       unicode *name;        /* name of field                                    */
-       unicode *descriptor;  /* JavaVM descriptor string of field                */
+       utf *name;            /* name of field                                    */
+       utf *descriptor;      /* JavaVM descriptor string of field                */
        
        s4       offset;      /* offset from start of object (instance variables) */
 
@@ -369,8 +440,8 @@ typedef struct exceptiontable { /* exceptiontable entry in a method           */
 
 typedef struct methodinfo {         /* method structure                       */
        s4             flags;               /* ACC flags                              */
-       unicode   *name;                /* name of method                         */
-       unicode   *descriptor;          /* JavaVM descriptor string of method     */
+       utf       *name;                /* name of method                         */
+       utf       *descriptor;          /* JavaVM descriptor string of method     */
        s4         returntype;          /* only temporary valid, return type      */
        s4         paramcount;          /* only temporary valid, parameter count  */
        u1        *paramtypes;          /* only temporary valid, parameter types  */
@@ -394,13 +465,22 @@ typedef struct methodinfo {         /* method structure                       */
 } methodinfo;
 
 
+/* innerclassinfo *************************************************************/
+
+typedef struct innerclassinfo {
+       classinfo *inner_class;       /* inner class pointer                      */
+       classinfo *outer_class;       /* outer class pointer                      */
+       utf *name;                    /* innerclass name                          */ 
+       s4 flags;                     /* ACC flags                                */
+} innerclassinfo;
+
 /* classinfo ******************************************************************/
 
 struct classinfo {                /* class structure                          */
        java_objectheader header;     /* classes are also objects                 */
 
        s4          flags;            /* ACC flags                                */
-       unicode    *name;             /* class name                               */ 
+       utf        *name;             /* class name                               */ 
 
        s4          cpcount;          /* number of entries in constant pool       */
        u1         *cptags;           /* constant pool tags                       */
@@ -437,6 +517,11 @@ struct classinfo {                /* class structure                          */
 #ifdef JIT_MARKER_SUPPORT
        methodinfo *marker; 
 #endif
+
+    u2             innerclasscount;   /* number of inner classes              */
+    innerclassinfo *innerclass;
+
+    classinfo      *hashlink;         /* link for external hash chain         */
 };
 
 
@@ -527,10 +612,8 @@ extern classinfo *class_java_lang_OutOfMemoryError;
 extern classinfo *class_java_lang_ArithmeticException;
 extern classinfo *class_java_lang_ArrayStoreException;
 extern classinfo *class_java_lang_ThreadDeath;
 extern classinfo *class_array;
 
-
 /* instances of some system classes *******************************************/
 
 extern java_objectheader *proto_java_lang_ClassCastException;
@@ -555,10 +638,16 @@ extern bool verbose;
 extern int count_class_infos;
 extern int count_const_pool_len;
 extern int count_vftbl_len;
-extern int count_unicode_len;
+extern int count_utf_len;
 extern int count_all_methods;
 extern int count_vmcode_len;
 extern int count_extable_len;
+extern int count_utf_new;
+extern int count_utf_new_found;
+
+/* table of primitive types ***************************************************/
+
+extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
 
 #endif
 
index a9d2136250be9a0ed75c5560c3dcc28c5a1bf294..66a7e9b13ccb81cf3f407dd6a0d2962c7139d8ac 100644 (file)
@@ -34,6 +34,15 @@ java_objectheader *asm_calljavamethod (methodinfo *m, void *arg1, void*arg2,
           with up to 4 parameters. This function calls a Java-method (which
           possibly needs compilation) with up to 4 parameters. */
 
+java_objectheader *asm_calljavafunction (methodinfo *m, void *arg1, void*arg2,
+                                         void*arg3, void*arg4);
+       /* This function calls a Java-method (which possibly needs compilation)
+          with up to 4 parameters. This function calls a Java-method (which
+          possibly needs compilation) with up to 4 parameters. 
+          also supports a return value */
+
+methodinfo *asm_getcallingmethod ();
+        /* gets the class of the caller from the stack frame */
 
 void asm_dumpregistersandcall ( functionptr f);
        /* This funtion saves all callee saved registers and calls the function
@@ -41,3 +50,7 @@ void asm_dumpregistersandcall ( functionptr f);
           This function is needed by the garbage collector, which needs to access
           all registers which are stored on the stack. Unused registers are
           cleared to avoid interferances with the GC. */
+
+
+
+
index 958068eb3b8b424da749681b4ce8741b08fec16a..eb7a9f31d7692d7e53af4e2806c1a4e80959815b 100644 (file)
@@ -8,7 +8,7 @@
        
        Author: Andreas  Krall      EMAIL: cacao@complang.tuwien.ac.at
 
-       Last Change: $Id: parse.c 132 1999-09-27 15:54:42Z chris $
+       Last Change: $Id: parse.c 135 1999-10-04 10:35:09Z roman $
 
 *******************************************************************************/
 
@@ -54,7 +54,7 @@ static void compiler_addinitclass (classinfo *c)
                if (cl == NULL) {
                        if (runverbose) {
                                sprintf(logtext, "compiler_addinitclass: ");
-                               unicode_sprint(logtext+strlen(logtext), c->name);
+                               utf_sprint(logtext+strlen(logtext), c->name);
                                dolog();
                                }
                        chain_addlast(uninitializedclasses, c);
@@ -63,7 +63,7 @@ static void compiler_addinitclass (classinfo *c)
                if (c < cl) {
                        if (runverbose) {
                                sprintf(logtext, "compiler_addinitclass: ");
-                               unicode_sprint(logtext+strlen(logtext), c->name);
+                               utf_sprint(logtext+strlen(logtext), c->name);
                                dolog();
                                }
                        chain_addbefore(uninitializedclasses, c);
@@ -85,20 +85,19 @@ static void descriptor2types (methodinfo *m)
 {
        u1 *types, *tptr;
        int pcount, c;
-       u2 *cptr;
-
+       char *utf_ptr;
        pcount = 0;
-       types = DMNEW (u1, m->descriptor->length);
-       
+       types = DMNEW (u1, m->descriptor->blength); 
+       
        tptr = types;
        if (!(m->flags & ACC_STATIC)) {
                *tptr++ = TYPE_ADR;
                pcount++;
                }
 
-       cptr = m->descriptor->text;
-       cptr++;
-       while ((c = *cptr++) != ')') {
+       utf_ptr = m->descriptor->text + 1;
+   
+       while ((c = *utf_ptr++) != ')') {
                pcount++;
                switch (c) {
                        case 'B':
@@ -114,13 +113,13 @@ static void descriptor2types (methodinfo *m)
                        case 'D':  *tptr++ = TYPE_DBL;
                                   break;
                        case 'L':  *tptr++ = TYPE_ADR;
-                                  while (*cptr++ != ';');
+                                  while (*utf_ptr++ != ';');
                                   break;
                        case '[':  *tptr++ = TYPE_ADR;
                                   while (c == '[')
-                                      c = *cptr++;
+                                      c = *utf_ptr++;
                                   if (c == 'L')
-                                      while (*cptr++ != ';') /* skip */;
+                                      while (*utf_ptr++ != ';') /* skip */;
                                   break;
                        default:   panic ("Ill formed methodtype-descriptor");
                        }
@@ -128,7 +127,7 @@ static void descriptor2types (methodinfo *m)
 
        /* compute return type */
 
-       switch (*cptr) {
+       switch (*utf_ptr++) {
                case 'B':
                case 'C':
                case 'I':
@@ -170,7 +169,7 @@ static void allocate_literals()
        int     p, nextp;
        int     opcode, i;
        s4      num;
-       unicode *s;
+       utf     *s;
 
        for (p = 0; p < jcodelength; p = nextp) {
 
@@ -402,7 +401,7 @@ static void parse()
                                                             (class->cpinfos[i]))->value);
                                                break;
                                        case CONSTANT_String:
-                                               LOADCONST_A(literalstring_new((unicode*)
+                                               LOADCONST_A(literalstring_new((utf*)
                                                                              (class->cpinfos[i])));
                                                break;
                                        default: panic("Invalid constant type to push");
index dd9fc35dd1a73d2ffc16bd7d1cda4a2a6a34001f..5af4e7e8ae491813c4d4f860f2ad55804989fe45 100644 (file)
@@ -1110,7 +1110,7 @@ icmd_lconst_lcmp_tail:
                                                /* pop 3 push 4 dup */
                                                
                                                case ICMD_DUP_X2:
-                                                       if (IS_2_WORD_TYPE(curstack[-1].type)) {
+                                                       if (IS_2_WORD_TYPE(curstack->prev->type)) {
                                                                iptr->opc = ICMD_DUP_X1;
                                                                DUP_X1;
                                                                }
@@ -1121,7 +1121,7 @@ icmd_lconst_lcmp_tail:
 
                                                case ICMD_DUP2_X2:
                                                        if (IS_2_WORD_TYPE(curstack->type)) {
-                                                               if (IS_2_WORD_TYPE(curstack[-1].type)) {
+                                                               if (IS_2_WORD_TYPE(curstack->prev->type)) {
                                                                        iptr->opc = ICMD_DUP_X1;
                                                                        DUP_X1;
                                                                        }
@@ -1131,7 +1131,7 @@ icmd_lconst_lcmp_tail:
                                                                        }
                                                                }
                                                        else
-                                                               if (IS_2_WORD_TYPE(curstack[-2].type)) {
+                                                               if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
                                                                        iptr->opc = ICMD_DUP2_X1;
                                                                        DUP2_X1;
                                                                        }
@@ -1719,11 +1719,11 @@ static void show_icmd_method()
        xtable *ex;
 
        printf("\n");
-       unicode_fprint(stdout, class->name);
+       utf_fprint(stdout, class->name);
        printf(".");
-       unicode_fprint(stdout, method->name);
+       utf_fprint(stdout, method->name);
        printf(" ");
-       unicode_fprint(stdout, method->descriptor);
+       utf_fprint(stdout, method->descriptor);
        printf ("\n\nMax locals: %d\n", (int) maxlocals);
        printf ("Max stack:  %d\n", (int) maxstack);
 
@@ -1864,7 +1864,7 @@ static void show_icmd_method()
                                case ICMD_PUTSTATIC:
                                case ICMD_GETSTATIC:
                                        printf(" ");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                        ((fieldinfo *) iptr->val.a)->name);
                                        break;
                                case ICMD_IINC:
@@ -1907,7 +1907,7 @@ static void show_icmd_method()
                                        break;
                                case ICMD_NEW:
                                        printf(" ");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                       ((classinfo *) iptr->val.a)->name);
                                        break;
                                case ICMD_NEWARRAY:
@@ -1941,7 +1941,7 @@ static void show_icmd_method()
                                case ICMD_ANEWARRAY:
                                        if (iptr->op1) {
                                                printf(" ");
-                                               unicode_fprint(stdout,
+                                               utf_fprint(stdout,
                                                               ((classinfo *) iptr->val.a)->name);
                                                }
                                        break;
@@ -1953,7 +1953,7 @@ static void show_icmd_method()
                                                        printf(" (INTERFACE) ");
                                                else
                                                        printf(" (CLASS,%3d) ", c->vftbl->diffval);
-                                               unicode_fprint(stdout, c->name);
+                                               utf_fprint(stdout, c->name);
                                                }
                                        break;
                                case ICMD_BUILTIN3:
@@ -1966,10 +1966,10 @@ static void show_icmd_method()
                                case ICMD_INVOKESTATIC:
                                case ICMD_INVOKEINTERFACE:
                                        printf(" ");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                       ((methodinfo *) iptr->val.a)->class->name);
                                        printf(".");
-                                       unicode_fprint(stdout,
+                                       utf_fprint(stdout,
                                                       ((methodinfo *) iptr->val.a)->name);
                                        break;
                                case ICMD_IFEQ:
index 9b58781060b1e91090a6343d6c6b9dceef55c842..d40b095cd0e197322426dc892b83c69904a5293f 100644 (file)
@@ -1,3 +1,4 @@
+
 /* loader.c ********************************************************************
 
        Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
@@ -18,9 +19,8 @@
 
 #include "global.h"
 #include "loader.h"
-
-#include "tables.h"
 #include "native.h"
+#include "tables.h"
 #include "builtin.h"
 #include "jit.h"
 #ifdef OLD_COMPILER
@@ -29,7 +29,7 @@
 #include "asmpart.h"
 
 #include "threads/thread.h"                        /* schani */
-
+#include <sys/stat.h>
 
 /* global variables ***********************************************************/
 
@@ -48,17 +48,26 @@ bool initverbose = false;
 
 bool makeinitializations = true;
 
-bool getloadingtime = false;
+bool getloadingtime  = false;   /* to measure the runtime                     */
 long int loadingtime = 0;
 
-
 static s4 interfaceindex;    /* sequential numbering of interfaces            */ 
 
-static list unloadedclasses; /* list of all referenced but not loaded classes */
-static list unlinkedclasses; /* list of all loaded but not linked classes     */
-       list linkedclasses;   /* list of all completely linked classes         */
+list unloadedclasses; /* list of all referenced but not loaded classes */
+list unlinkedclasses; /* list of all loaded but not linked classes     */
+list linkedclasses;   /* list of all completely linked classes         */
+
 
+/* utf-symbols for pointer comparison of frequently used strings */
 
+static utf *utf_innerclasses;          /* InnerClasses                    */
+static utf *utf_constantvalue;                 /* ConstantValue                   */
+static utf *utf_code;                      /* Code                            */
+static utf *utf_finalize;                  /* finalize                            */
+static utf *utf_fidesc;                    /* ()V                                     */
+static utf *utf_clinit;                    /* <clinit>                            */
+static utf *utf_initsystemclass;       /* initializeSystemClass   */
+static utf *utf_systemclass;           /* java/lang/System        */
 
 /* important system classes ***************************************************/
 
@@ -72,9 +81,26 @@ classinfo *class_java_lang_OutOfMemoryError;
 classinfo *class_java_lang_ArithmeticException;
 classinfo *class_java_lang_ArrayStoreException;
 classinfo *class_java_lang_ThreadDeath;                 /* schani */
+classinfo *class_array = NULL;
 
-classinfo *class_array;
+/******************************************************************************
 
+   structure for primitive classes: contains the class for wrapping the 
+   primitive type, the primitive class, the name of the class for wrapping, 
+   the one character type signature and the name of the primitive class
+ ******************************************************************************/
+primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT] = { 
+               { NULL, NULL, "java/lang/Double",    'D', "double"  },
+               { NULL, NULL, "java/lang/Float",     'F', "float"   },
+               { NULL, NULL, "java/lang/Character", 'C', "char"    },
+               { NULL, NULL, "java/lang/Integer",   'I', "int"     },
+               { NULL, NULL, "java/lang/Long",      'J', "long"    },
+               { NULL, NULL, "java/lang/Byte",      'B', "byte"    },
+               { NULL, NULL, "java/lang/Short",     'S', "short"   },
+               { NULL, NULL, "java/lang/Boolean",   'Z', "boolean" },
+               { NULL, NULL, "java/lang/Void",      'V', "void"    }};
 
 /* instances of important system classes **************************************/
 
@@ -88,7 +114,209 @@ java_objectheader *proto_java_lang_ArrayStoreException;
 java_objectheader *proto_java_lang_ThreadDeath;         /* schani */
 
 
+/************* functions for reading classdata ********************************
+
+    getting classdata in blocks of variable size
+    (8,16,32,64-bit integer or float)
+
+*******************************************************************************/
+
+static char *classpath    = "";     /* searchpath for classfiles              */
+static u1 *classbuffer    = NULL;   /* pointer to buffer with classfile-data  */
+static u1 *classbuf_pos;            /* current position in classfile buffer   */
+static int classbuffer_size;        /* size of classfile-data                 */
+
+/* transfer block of classfile data into a buffer */
+#define suck_nbytes(buffer,len) memcpy(buffer,classbuf_pos+1,len);classbuf_pos+=len;
+
+/* skip block of classfile data */
+#define skip_nbytes(len) classbuf_pos += len;
+
+#define suck_u1() (*++classbuf_pos)
+#define suck_s8() (s8) suck_u8()
+#define suck_s2() (s2) suck_u2()
+#define suck_s4() (s4) suck_u4()
+#define suck_s1() (s1) suck_u1()
+#define suck_u2() (u2) ((suck_u1()<<8)+suck_u1())
+#define suck_u4() (u4) ((((u4)suck_u1())<<24)+(((u4)suck_u1())<<16)+(((u4)suck_u1())<<8)+((u4)suck_u1()))
+
+/* get u8 from classfile data */
+static u8 suck_u8 ()
+{
+#if U8_AVAILABLE
+       u8 lo,hi;
+       hi = suck_u4();
+       lo = suck_u4();
+       return (hi<<32) + lo;
+#else
+       u8 v;
+       v.high = suck_u4();
+       v.low = suck_u4();
+       return v;
+#endif
+}
+
+/* get float from classfile data */
+static float suck_float ()
+{
+       float f;
+
+#if !WORDS_BIGENDIAN 
+               u1 buffer[4];
+               u2 i;
+               for (i=0; i<4; i++) buffer[3-i] = suck_u1 ();
+               memcpy ( (u1*) (&f), buffer, 4);
+#else 
+               suck_nbytes ( (u1*) (&f), 4 );
+#endif
+
+       PANICIF (sizeof(float) != 4, "Incompatible float-format");
+       
+       return f;
+}
+
+/* get double from classfile data */
+static double suck_double ()
+{
+       double d;
+
+#if !WORDS_BIGENDIAN 
+               u1 buffer[8];
+               u2 i;   
+               for (i=0; i<8; i++) buffer[7-i] = suck_u1 ();
+               memcpy ( (u1*) (&d), buffer, 8);
+#else 
+               suck_nbytes ( (u1*) (&d), 8 );
+#endif
+
+       PANICIF (sizeof(double) != 8, "Incompatible double-format" );
+       
+       return d;
+}
+
+/************************** function: suck_init ******************************
+
+       called once at startup, sets the searchpath for the classfiles
+
+******************************************************************************/
+
+void suck_init (char *cpath)
+{
+       classpath   = cpath;
+       classbuffer = NULL;
+}
+
+
+/************************** function: suck_start ******************************
+
+       open file for the specified class and the read classfile data,
+       all directory of the searchpath are used to find the classfile
+       ( <classname>.class)
+       
+******************************************************************************/
+
+
+bool suck_start (utf *classname)
+{
+#define MAXFILENAME 1000              /* maximum length of a filename */
+       
+       char filename[MAXFILENAME+10]; /* room for '.class' */  
+       char *pathpos;                 /* position in searchpath */
+       FILE *classfile;
+       u2 filenamelen;
+       u2 c;
+
+       if (classbuffer)               /* classbuffer already valid */
+               return true;
+
+       pathpos = classpath;
+       
+       while (*pathpos) {
+               /* pointer to the next utf8-character */
+               char *utf_ptr = classname->text; 
+
+               /* skip path separator */
+               while ( *pathpos == ':' ) pathpos++;
+               /* extract directory from searchpath */
+               filenamelen=0;
+               while ( (*pathpos) && (*pathpos!=':') ) {
+                   PANICIF (filenamelen >= MAXFILENAME, "Filename too long") ;
+                       
+                       filename[filenamelen++] = *(pathpos++);
+                       }
+
+               filename[filenamelen++] = '/';  
+   
+               /* add classname to filename */
+               while (utf_ptr<utf_end(classname)) {
+                       PANICIF (filenamelen >= MAXFILENAME, "Filename too long");
+                       
+                       c = *utf_ptr++;
+                       if (c=='/') c = '/';     
+                       else {
+                               if ( c<=' ' || c>'z') { 
+                                       /* invalid character */
+                                       c = '?'; 
+                                       }
+                               }
+                       
+                       filename[filenamelen++] = c;    
+                       }
+      
+               /* add suffix */
+               strcpy (filename+filenamelen, ".class");
+
+               classfile = fopen(filename, "r");
+               if (classfile) {
+                       /* file exists */
+                       struct stat buffer;
+                       int err;
+       
+                       /* determine size of classfile */
+                       err = stat (filename, &buffer);
+
+                       if (!err) {
+                               /* read classfile data */                               
+                               classbuffer_size = buffer.st_size;                              
+                               classbuffer      = MNEW(u1,classbuffer_size);
+                               classbuf_pos     = classbuffer-1;
+                               fread(classbuffer, 1, classbuffer_size, classfile);
+                               fclose(classfile);
+                               return true;
+                       }
+               }
+       }
+
+       sprintf (logtext,"Can not open class file '%s'", filename);
+       error();
+
+       return false;
+}
+
+
+/************************** function: suck_stop *******************************
+
+       free memory for buffer with classfile data
+       
+******************************************************************************/
+
+void suck_stop ()
+{
+       /* determine number of bytes of classdata not retrieved by suck-operations */
+       int classdata_left = (classbuffer+classbuffer_size)-classbuf_pos-1;
+
+        if (classdata_left>0) {                
+                       /* surplus */           
+                       sprintf (logtext,"There are %d access bytes at end of classfile",
+                                classdata_left);
+                       dolog();
+       }
 
+       /* free memory */
+       MFREE(classbuffer,u1,classbuffer_size);
+       classbuffer = NULL;
+}
 
 /******************************************************************************/
 /******************* Einige Support-Funkionen *********************************/
@@ -137,7 +365,6 @@ static void skipattributebody ()
        skip_nbytes(suck_u4());
 }
 
-
 /************************* Funktion: skipattributes ****************************
 
        "uberliest im ClassFile eine gew"unschte Anzahl von attribute-Strukturen
@@ -151,169 +378,268 @@ static void skipattributes (u4 num)
                skipattribute();
 }
 
+/******************** function: innerclass_getconstant ************************
 
-
-/************************** Funktion: loadUtf8 *********************************
-
-       liest aus dem ClassFile einen Utf8-String (=komprimierter unicode-text) 
-       und legt daf"ur ein unicode-Symbol an. 
-       Return: Zeiger auf das Symbol 
-
+    like class_getconstant, but if cptags is ZERO null is returned                                      
+       
 *******************************************************************************/
 
-#define MAXUNICODELEN 5000
-static u2 unicodebuffer[MAXUNICODELEN];
-
-static unicode *loadUtf8 ()
+voidptr innerclass_getconstant (classinfo *c, u4 pos, u4 ctype) 
 {
-       u4 unicodelen;
-       u4 letter;
+       /* invalid position in constantpool */
+       if (pos >= c->cpcount) 
+               panic ("Attempt to access constant outside range");
 
-       u4 utflen;
-       u4 b1,b2,b3;
+       /* constantpool entry of type 0 */      
+       if (!c->cptags[pos])
+               return NULL;
 
-       unicodelen = 0;
+       /* check type of constantpool entry */
+       if (c->cptags[pos] != ctype) {
+               sprintf (logtext, "Type mismatch on constant: %d requested, %d here",
+                (int) ctype, (int) c->cptags[pos] );
+               error();
+               }
+               
+       return c->cpinfos[pos];
+}
 
-       utflen = suck_u2 ();
-       while (utflen > 0) {
-               b1 = suck_u1 ();
-               utflen --;
-               if (b1<0x80) letter = b1;
-               else {
-                       b2 = suck_u1 ();
-                       utflen --;
-                       if (b1<0xe0) letter = ((b1 & 0x1f) << 6) | (b2 & 0x3f);
-                       else {
-                               b3 = suck_u1 ();
-                               utflen --;
-                               letter = ((b1 & 0x0f) << 12) | ((b2 & 0x3f) << 6) | (b3 & 0x3f);
-                               }
-                       }       
+/************************ function: attribute_load ****************************
+
+    read attributes from classfile
        
+*******************************************************************************/
+
+static void attribute_load (u4 num, classinfo *c)
+{
+       u4 i,j;
+
+       for (i = 0; i < num; i++) {
+               /* retrieve attribute name */   
+               utf *aname = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
 
-               if (unicodelen >= MAXUNICODELEN) {
-                       panic ("String constant too long");
+               if ( aname == utf_innerclasses)  {                      
+                       /* innerclasses attribute */
+                               
+                       /* skip attribute length */                                             
+                       suck_u4(); 
+                       /* number of records */
+                       c->innerclasscount = suck_u2();
+                       /* allocate memory for innerclass structure */
+                       c->innerclass = MNEW (innerclassinfo, c->innerclasscount);
+
+                       for (j=0;j<c->innerclasscount;j++) {
+                               
+                               /*  The innerclass structure contains a class with an encoded name, 
+                                   its defining scope, its simple name  and a bitmask of the access flags. 
+                                   If an inner class is not a member, its outer_class is NULL, 
+                                   if a class is anonymous, its name is NULL.                              */
+                                                               
+                               innerclassinfo *info = c->innerclass + j;
+
+                               info->inner_class = innerclass_getconstant(c, suck_u2(), CONSTANT_Class); /* CONSTANT_Class_info index */
+                               info->outer_class = innerclass_getconstant(c, suck_u2(), CONSTANT_Class); /* CONSTANT_Class_info index */
+                               info->name  = innerclass_getconstant(c, suck_u2(), CONSTANT_Utf8);        /* CONSTANT_Utf8_info index  */
+                               info->flags = suck_u2 ();                                                 /* access_flags bitmask      */
                        }
-               
-               unicodebuffer[unicodelen++] = letter;                   
+               } else {
+                       /* unknown attribute */
+                       skipattributebody ();
                }
+       }
+}
+
+/******************* function: checkfielddescriptor ****************************
 
+       checks whether a field-descriptor is valid and aborts otherwise
+       all referenced classes are inserted into the list of unloaded classes
        
-       return unicode_new_u2 (unicodebuffer, unicodelen);
-}
+*******************************************************************************/
 
+static void checkfielddescriptor (char *utf_ptr, char *end_pos)
+{
+       char *tstart;  /* pointer to start of classname */
+       char ch;
+       
+       switch (*utf_ptr++) {
+       case 'B':
+       case 'C':
+       case 'I':
+       case 'S':
+       case 'Z':  
+       case 'J':  
+       case 'F':  
+       case 'D':
+               /* primitive type */  
+               break;
 
+       case 'L':
+               /* save start of classname */
+               tstart = utf_ptr;  
+               
+               /* determine length of classname */
+               while ( *utf_ptr++ != ';' )
+                       if (utf_ptr>=end_pos) 
+                               panic ("Missing ';' in objecttype-descriptor");
 
-/******************** interne Funktion: checkfieldtype ************************/
+               /* cause loading of referenced class */                 
+               class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+               break;
 
-static void checkfieldtype (u2 *text, u4 *count, u4 length)
-{
-       u4 l;
+       case '[' : 
+               /* array type */
+               while ((ch = *utf_ptr++)=='[') 
+                       /* skip */ ;
 
-       if (*count >= length) panic ("Type-descriptor exceeds unicode length");
-       
-       l = text[(*count)++];
-       
-       switch (l) {
-               default: panic ("Invalid symbol in type descriptor");
-                        return;
+               /* component type of array */
+               switch (ch) {
                case 'B':
                case 'C':
-               case 'D':
-               case 'F':
                case 'I':
-               case 'J':
                case 'S':
-               case 'Z': return;
-               
-               case '[': checkfieldtype (text, count, length);
-                         return;
-                         
-               case 'L': 
-                       {
-                       u4 tlen,tstart = *count;
+               case 'Z':  
+               case 'J':  
+               case 'F':  
+               case 'D':
+                       /* primitive type */  
+                       break;
                        
-                       if (*count >= length) 
-                          panic ("Objecttype descriptor of length zero");
+               case 'L':
+                       /* save start of classname */
+                       tstart = utf_ptr;
                        
-                       while ( text[*count] != ';' ) {
-                               (*count)++;
-                               if (*count >= length) 
-                                  panic ("Missing ';' in objecttype-descriptor");
-                               }
+                       /* determine length of classname */
+                       while ( *utf_ptr++ != ';' )
+                               if (utf_ptr>=end_pos) 
+                                       panic ("Missing ';' in objecttype-descriptor");
+
+                       /* cause loading of referenced class */                 
+                       class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+                       break;
+
+               default:   
+                       panic ("Ill formed methodtype-descriptor");
+               }
+               break;
                        
-                       tlen = (*count) - tstart;
-                       (*count)++;
+       default:   
+               panic ("Ill formed methodtype-descriptor");
+       }                       
 
-                       if (tlen == 0) panic ("Objecttype descriptor with empty name");
-                                       
-                       class_get ( unicode_new_u2 (text+tstart, tlen) );
-                       }
-               }       
+        /* exceeding characters */             
+       if (utf_ptr!=end_pos) panic ("descriptor has exceeding chars");
 }
 
 
-/******************* Funktion: checkfielddescriptor ****************************
+/******************* function: checkmethoddescriptor ***************************
 
-       "uberpr"uft, ob ein Field-Descriptor ein g"ultiges Format hat.
-       Wenn nicht, dann wird das System angehalten.
-       Au"serdem werden alle Klassen, die hier referenziert werden, 
-       in die Liste zu ladender Klassen eingetragen.
+    checks whether a method-descriptor is valid and aborts otherwise
+    all referenced classes are inserted into the list of unloaded classes      
        
 *******************************************************************************/
 
-void checkfielddescriptor (unicode *d)
+static void checkmethoddescriptor (utf *d)
 {
-       u4 count=0;
-       checkfieldtype (d->text, &count, d->length);
-       if (count != d->length) panic ("Invalid type-descritor encountered");
-}
+       char *utf_ptr = d->text;     /* current position in utf text   */
+       char *end_pos = utf_end(d);  /* points behind utf string       */
+       char *tstart;                /* pointer to start of classname  */
+       char c,ch;
 
+       /* method descriptor must start with parenthesis */
+       if (*utf_ptr++ != '(') panic ("Missing '(' in method descriptor");
 
-/******************* Funktion: checkmethoddescriptor ***************************
+       /* check arguments */
+       while ((c = *utf_ptr++) != ')') {
+               switch (c) {
+               case 'B':
+               case 'C':
+               case 'I':
+               case 'S':
+               case 'Z':  
+               case 'J':  
+               case 'F':  
+               case 'D':
+                       /* primitive type */  
+                       break;
 
-       "uberpr"uft, ob ein Method-Descriptor ein g"ultiges Format hat.
-       Wenn nicht, dann wird das System angehalten.
-       Au"serdem werden alle Klassen, die hier referenziert werden, 
-       in die Liste zu ladender Klassen eingetragen.
-       
-*******************************************************************************/
+               case 'L':
+                       /* save start of classname */ 
+                       tstart = utf_ptr;
+                       
+                       /* determine length of classname */
+                       while ( *utf_ptr++ != ';' )
+                               if (utf_ptr>=end_pos) 
+                                       panic ("Missing ';' in objecttype-descriptor");
+                       
+                       /* cause loading of referenced class */
+                       class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+                       break;
+          
+               case '[' :
+                       /* array type */ 
+                       while ((ch = *utf_ptr++)=='[') 
+                               /* skip */ ;
+
+                       /* component type of array */
+                       switch (ch) {
+                       case 'B':
+                       case 'C':
+                       case 'I':
+                       case 'S':
+                       case 'Z':  
+                       case 'J':  
+                       case 'F':  
+                       case 'D':
+                               /* primitive type */  
+                               break;
 
-void checkmethoddescriptor (unicode *d)
-{
-       u2 *text=d->text;
-       u4 length=d->length;
-       u4 count=0;
-       
-       if (length<2) panic ("Method descriptor too short");
-       if (text[0] != '(') panic ("Missing '(' in method descriptor");
-       count=1;
-       
-       while (text[count] != ')') {
-               checkfieldtype (text,&count,length);
-               if ( count > length-2 ) panic ("Unexpected end of descriptor");
-               }
-               
-       count++;
-       if (text[count] == 'V') count++;
-       else                    checkfieldtype (text, &count,length);
-               
-       if (count != length) panic ("Method-descriptor has exceeding chars");
+                       case 'L':
+                               /* save start of classname */
+                               tstart = utf_ptr;
+                       
+                               /* determine length of classname */     
+                               while ( *utf_ptr++ != ';' )
+                                       if (utf_ptr>=end_pos) 
+                                               panic ("Missing ';' in objecttype-descriptor");
+
+                               /* cause loading of referenced class */
+                               class_new ( utf_new(tstart, utf_ptr-tstart-1) );
+                               break;
+
+                       default:   
+                               panic ("Ill formed methodtype-descriptor");
+                       } 
+                       break;
+                       
+               default:   
+                       panic ("Ill formed methodtype-descriptor");
+               }                       
+       }
+
+       /* check returntype */
+       if (*utf_ptr=='V') {
+               /* returntype void */
+               if ((utf_ptr+1) != end_pos) panic ("Method-descriptor has exceeding chars");
+       }
+       else
+               /* treat as field-descriptor */
+               checkfielddescriptor (utf_ptr,end_pos);
 }
 
 
 /******************** Funktion: buildarraydescriptor ***************************
 
-       erzeugt zu einem namentlich als u2-String vorliegenden Arraytyp eine
+       erzeugt zu einem namentlich als utf-String vorliegenden Arraytyp eine
        entsprechende constant_arraydescriptor - Struktur 
        
 *******************************************************************************/
 
-static constant_arraydescriptor * buildarraydescriptor(u2 *name, u4 namelen)
+constant_arraydescriptor * buildarraydescriptor(char *utf_ptr, u4 namelen)
 {
        constant_arraydescriptor *d;
        
-       if (name[0]!='[') panic ("Attempt to build arraydescriptor for non-array");
+       if (*utf_ptr++ != '[') panic ("Attempt to build arraydescriptor for non-array");
+
        d = NEW (constant_arraydescriptor);
        d -> objectclass = NULL;
        d -> elementdescriptor = NULL;
@@ -322,7 +648,7 @@ static constant_arraydescriptor * buildarraydescriptor(u2 *name, u4 namelen)
        count_const_pool_len += sizeof(constant_arraydescriptor);
 #endif
 
-       switch (name[1]) {
+       switch (*utf_ptr) {
        case 'Z': d -> arraytype = ARRAYTYPE_BOOLEAN; break;
        case 'B': d -> arraytype = ARRAYTYPE_BYTE; break;
        case 'C': d -> arraytype = ARRAYTYPE_CHAR; break;
@@ -334,12 +660,12 @@ static constant_arraydescriptor * buildarraydescriptor(u2 *name, u4 namelen)
 
        case '[':
                d -> arraytype = ARRAYTYPE_ARRAY; 
-               d -> elementdescriptor = buildarraydescriptor (name+1, namelen-1);
+               d -> elementdescriptor = buildarraydescriptor (utf_ptr, namelen-1);
                break;
                
        case 'L':
                d -> arraytype = ARRAYTYPE_OBJECT;
-               d -> objectclass = class_get ( unicode_new_u2 (name+2, namelen-3) );
+               d -> objectclass = class_new ( utf_new(utf_ptr+1, namelen-3) );
                break;
        }
        return d;
@@ -376,7 +702,7 @@ static void displayarraydescriptor (constant_arraydescriptor *d)
        case ARRAYTYPE_LONG: printf ("long[]"); break;
        case ARRAYTYPE_SHORT: printf ("short[]"); break;
        case ARRAYTYPE_ARRAY: displayarraydescriptor(d->elementdescriptor); printf("[]"); break;
-       case ARRAYTYPE_OBJECT: unicode_display(d->objectclass->name); printf("[]"); break;
+       case ARRAYTYPE_OBJECT: utf_display(d->objectclass->name); printf("[]"); break;
        }
 }
 
@@ -401,18 +727,18 @@ static void field_load (fieldinfo *f, classinfo *c)
        u4 attrnum,i;
        u4 jtype;
 
-       f -> flags = suck_u2 ();
-       f -> name = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
-       f -> descriptor = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
-       f -> type = jtype = desc_to_type (f->descriptor);
-       f -> offset = 0;
-
+       f -> flags = suck_u2 ();                                           /* ACC flags                   */
+       f -> name = class_getconstant (c, suck_u2(), CONSTANT_Utf8);       /* name of field               */
+       f -> descriptor = class_getconstant (c, suck_u2(), CONSTANT_Utf8); /* JavaVM descriptor           */
+       f -> type = jtype = desc_to_type (f->descriptor);                  /* data type                   */
+       f -> offset = 0;                                                   /* offset from start of object */
+       
        switch (f->type) {
        case TYPE_INT:        f->value.i = 0; break;
        case TYPE_FLOAT:      f->value.f = 0.0; break;
        case TYPE_DOUBLE:     f->value.d = 0.0; break;
-       case TYPE_ADDRESS:    f->value.a = NULL; 
-                             heap_addreference (&(f->value.a));
+       case TYPE_ADDRESS:    f->value.a = NULL;                              
+                             heap_addreference (&(f->value.a));           /* make global reference (GC)  */    
                              break;
        case TYPE_LONG:
 #if U8_AVAILABLE
@@ -421,21 +747,28 @@ static void field_load (fieldinfo *f, classinfo *c)
                f->value.l.low = 0; f->value.l.high = 0; break;
 #endif 
        }
-       
+
+       /* read attributes */
        attrnum = suck_u2();
        for (i=0; i<attrnum; i++) {
                u4 pindex;
-               unicode *aname;
+               utf *aname;
 
                aname = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
-
-               if ( aname != unicode_new_char ("ConstantValue") ) {
+               
+               if ( aname != utf_constantvalue ) {
+                       /* unknown attribute */
                        skipattributebody ();
                        }
                else {
+                       /* constant value attribute */
+                       
+                       /* skip attribute length */
                        suck_u4();
+                       /* index of value in constantpool */            
                        pindex = suck_u2();
-                               
+               
+                       /* initialize field with value from constantpool */             
                        switch (jtype) {
                                case TYPE_INT: {
                                        constant_integer *ci = 
@@ -468,9 +801,9 @@ static void field_load (fieldinfo *f, classinfo *c)
                                        }
                                        break;
                                                
-                               case TYPE_ADDRESS: {
-                                       unicode *u = 
-                                               class_getconstant(c, pindex, CONSTANT_String);
+                               case TYPE_ADDRESS: { 
+                                       utf *u = class_getconstant(c, pindex, CONSTANT_String);
+                                       /* create javastring from compressed utf8-string */                                     
                                        f->value.a = literalstring_new(u);
                                        }
                                        break;
@@ -482,14 +815,14 @@ static void field_load (fieldinfo *f, classinfo *c)
 
                        }
                }
-               
 }
 
 
-/********************** Funktion: field_free **********************************/
+/********************** function: field_free **********************************/
 
 static void field_free (fieldinfo *f)
 {
+       /* empty */
 }
 
 
@@ -500,15 +833,13 @@ static void field_display (fieldinfo *f)
        printf ("   ");
        printflags (f -> flags);
        printf (" ");
-       unicode_display (f -> name);
+       utf_display (f -> name);
        printf (" ");
-       unicode_display (f -> descriptor);      
+       utf_display (f -> descriptor);  
        printf (" offset: %ld\n", (long int) (f -> offset) );
 }
 
 
-
-
 /******************************************************************************/
 /************************* Funktionen f"ur Methods ****************************/ 
 /******************************************************************************/
@@ -548,6 +879,7 @@ static void method_load (methodinfo *m, classinfo *c)
                m -> stubroutine = createcompilerstub (m);
                }
        else {
+
                functionptr f = native_findfunction 
                       (c->name, m->name, m->descriptor, (m->flags & ACC_STATIC) != 0);
                if (f) {
@@ -565,11 +897,11 @@ static void method_load (methodinfo *m, classinfo *c)
        
        attrnum = suck_u2();
        for (i=0; i<attrnum; i++) {
-               unicode *aname;
+               utf *aname;
 
                aname = class_getconstant (c, suck_u2(), CONSTANT_Utf8);
 
-               if ( aname != unicode_new_char("Code"))  {
+               if ( aname != utf_code)  {
                        skipattributebody ();
                        }
                else {
@@ -609,10 +941,8 @@ static void method_load (methodinfo *m, classinfo *c)
                        
                }
 
-
 }
 
-
 /********************* Funktion: method_free ***********************************
 
        gibt allen Speicher, der extra f"ur eine Methode angefordert wurde,
@@ -640,9 +970,9 @@ void method_display (methodinfo *m)
        printf ("   ");
        printflags (m -> flags);
        printf (" ");
-       unicode_display (m -> name);
+       utf_display (m -> name);
        printf (" "); 
-       unicode_display (m -> descriptor);
+       utf_display (m -> descriptor);
        printf ("\n");
 }
 
@@ -671,65 +1001,20 @@ static bool method_canoverwrite (methodinfo *m, methodinfo *old)
 /******************************************************************************/
 
 
-/******************** Funktion: class_get **************************************
+/******************** function: class_getconstant ******************************
 
-       Sucht im System die Klasse mit dem gew"unschten Namen, oder erzeugt
-       eine neue 'classinfo'-Struktur (und h"angt sie in die Liste der zu
-       ladenen Klassen ein).
-
-*******************************************************************************/
-
-classinfo *class_get (unicode *u)
-{
-       classinfo *c;
-       
-       if (u->class) return u->class;
-       
-#ifdef STATISTICS
-       count_class_infos += sizeof(classinfo);
-#endif
-
-       c = NEW (classinfo);
-       c -> flags = 0;
-       c -> name = u;
-       c -> cpcount = 0;
-       c -> cptags = NULL;
-       c -> cpinfos = NULL;
-       c -> super = NULL;
-       c -> sub = NULL;
-       c -> nextsub = NULL;
-       c -> interfacescount = 0;
-       c -> interfaces = NULL;
-       c -> fieldscount = 0;
-       c -> fields = NULL;
-       c -> methodscount = 0;
-       c -> methods = NULL;
-       c -> linked = false;
-       c -> index = 0;
-       c -> instancesize = 0;
-       c -> header.vftbl = NULL;
-       c -> vftbl = NULL;
-       c -> initialized = false;
-       
-       unicode_setclasslink (u,c);
-       list_addlast (&unloadedclasses, c);
-               
-       return c;
-}
-
-
-
-/******************** Funktion: class_getconstant ******************************
-
-       holt aus dem ConstantPool einer Klasse den Wert an der Stelle 'pos'.
-       Der Wert mu"s vom Typ 'ctype' sein, sonst wird das System angehalten.
+       retrieves the value at position 'pos' of the constantpool of a class
+       if the type of the value is other than 'ctype' the system is stopped
 
 *******************************************************************************/
 
 voidptr class_getconstant (classinfo *c, u4 pos, u4 ctype) 
 {
+       /* invalid position in constantpool */  
        if (pos >= c->cpcount) 
                panic ("Attempt to access constant outside range");
+
+       /* check type of constantpool entry */
        if (c->cptags[pos] != ctype) {
                sprintf (logtext, "Type mismatch on constant: %d requested, %d here",
                 (int) ctype, (int) c->cptags[pos] );
@@ -755,31 +1040,38 @@ u4 class_constanttype (classinfo *c, u4 pos)
 }
 
 
-/******************** Funktion: class_loadcpool ********************************
+/******************** function: class_loadcpool ********************************
 
-       l"adt den gesammten ConstantPool einer Klasse.
-       
-       Dabei werden die einzelnen Eintr"age in ein wesentlich einfachers 
-       Format gebracht (Klassenreferenzen werden aufgel"ost, ...)
-       F"ur eine genaue "Ubersicht "uber das kompakte Format siehe: 'global.h' 
+       loads the constantpool of a class, 
+       the entries are transformed into a simpler format 
+       by resolving references
+       (a detailed overview of the compact structures can be found in global.h)        
 
 *******************************************************************************/
 
 static void class_loadcpool (classinfo *c)
 {
 
-       typedef struct forward_class {      /* Diese Strukturen dienen dazu, */
-               struct forward_class *next;     /* die Infos, die beim ersten */
-               u2 thisindex;                   /* Durchgang durch den ConstantPool */
-               u2 name_index;                  /* gelesen werden, aufzunehmen. */
-       } forward_class;                    /* Erst nachdem der ganze Pool */ 
-                                        /* gelesen wurde, k"onnen alle */
-       typedef struct forward_string {     /* Felder kompletiert werden */
-               struct forward_string *next;    /* (und das auch nur in der richtigen */
-               u2 thisindex;                   /* Reihenfolge) */
+       /* The following structures are used to save information which cannot be 
+          processed during the first pass. After the complete constantpool has 
+          been traversed the references can be resolved. 
+          (only in specific order)                                                */
+       
+       /* CONSTANT_Class_info entries */
+       typedef struct forward_class {      
+               struct forward_class *next; 
+               u2 thisindex;               
+               u2 name_index;              
+       } forward_class;                    
+                                        
+       /* CONSTANT_String */                                      
+       typedef struct forward_string { 
+               struct forward_string *next; 
+               u2 thisindex;                
                u2 string_index;
        } forward_string;
 
+       /* CONSTANT_NameAndType */
        typedef struct forward_nameandtype {
                struct forward_nameandtype *next;
                u2 thisindex;
@@ -787,6 +1079,7 @@ static void class_loadcpool (classinfo *c)
                u2 sig_index;
        } forward_nameandtype;
 
+       /* CONSTANT_Fieldref, CONSTANT_Methodref or CONSTANT_InterfaceMethodref */
        typedef struct forward_fieldmethint {   
                struct forward_fieldmethint *next;
                u2 thisindex;
@@ -796,7 +1089,6 @@ static void class_loadcpool (classinfo *c)
        } forward_fieldmethint;
 
 
-
        u4 idx;
        long int dumpsize = dump_size ();
 
@@ -805,29 +1097,31 @@ static void class_loadcpool (classinfo *c)
        forward_nameandtype *forward_nameandtypes = NULL;
        forward_fieldmethint *forward_fieldmethints = NULL;
 
+       /* number of entries in the constant_pool table  */
        u4 cpcount       = c -> cpcount = suck_u2();
+       /* allocate memory */
        u1 *cptags       = c -> cptags  = MNEW (u1, cpcount);
-       voidptr *cpinfos = c -> cpinfos =  MNEW (voidptr, cpcount);
+       voidptr *cpinfos = c -> cpinfos = MNEW (voidptr, cpcount);
 
 #ifdef STATISTICS
        count_const_pool_len += (sizeof(voidptr) + 1) * cpcount;
 #endif
-
        
+       /* initialize constantpool */
        for (idx=0; idx<cpcount; idx++) {
                cptags[idx] = CONSTANT_UNUSED;
                cpinfos[idx] = NULL;
                }
 
                        
-               /******* Erster Durchgang *******/
-               /* Alle Eintr"age, die nicht unmittelbar aufgel"ost werden k"onnen, 
-                  werden einmal `auf Vorrat' in tempor"are Strukturen eingelesen,
-                  und dann am Ende nocheinmal durchgegangen */
-
+               /******* first pass *******/
+               /* entries which cannot be resolved now are written into 
+                  temporary structures and traversed again later        */
+                  
        idx = 1;
        while (idx < cpcount) {
-               u4 t = suck_u1 ();
+               /* get constant type */
+               u4 t = suck_u1 (); 
                switch ( t ) {
 
                        case CONSTANT_Class: { 
@@ -837,7 +1131,8 @@ static void class_loadcpool (classinfo *c)
                                forward_classes = nfc;
 
                                nfc -> thisindex = idx;
-                               nfc -> name_index = suck_u2 ();
+                               /* reference to CONSTANT_NameAndType */
+                               nfc -> name_index = suck_u2 (); 
 
                                idx++;
                                break;
@@ -845,18 +1140,21 @@ static void class_loadcpool (classinfo *c)
                        
                        case CONSTANT_Fieldref:
                        case CONSTANT_Methodref:
-                       case CONSTANT_InterfaceMethodref: {
+                       case CONSTANT_InterfaceMethodref: { 
                                forward_fieldmethint *nff = DNEW (forward_fieldmethint);
                                
                                nff -> next = forward_fieldmethints;
                                forward_fieldmethints = nff;
 
                                nff -> thisindex = idx;
+                               /* constant type */
                                nff -> tag = t;
-                               nff -> class_index = suck_u2 ();
+                               /* class or interface type that contains the declaration of the field or method */
+                               nff -> class_index = suck_u2 (); 
+                               /* name and descriptor of the field or method */
                                nff -> nameandtype_index = suck_u2 ();
 
-                               idx ++;                                         
+                               idx ++;
                                break;
                                }
                                
@@ -867,6 +1165,7 @@ static void class_loadcpool (classinfo *c)
                                forward_strings = nfs;
                                
                                nfs -> thisindex = idx;
+                               /* reference to CONSTANT_Utf8_info with string characters */
                                nfs -> string_index = suck_u2 ();
                                
                                idx ++;
@@ -880,7 +1179,9 @@ static void class_loadcpool (classinfo *c)
                                forward_nameandtypes = nfn;
                                
                                nfn -> thisindex = idx;
+                               /* reference to CONSTANT_Utf8_info containing simple name */
                                nfn -> name_index = suck_u2 ();
+                               /* reference to CONSTANT_Utf8_info containing field or method descriptor */
                                nfn -> sig_index = suck_u2 ();
                                
                                idx ++;
@@ -944,13 +1245,15 @@ static void class_loadcpool (classinfo *c)
                                break;
                                }
                                
-                       case CONSTANT_Utf8: {
-                               unicode *u;
-
-                               u = loadUtf8 ();
-
-                               cptags [idx] = CONSTANT_Utf8;
-                               cpinfos [idx] = u;
+                       case CONSTANT_Utf8: { 
+
+                               /* number of bytes in the bytes array (not string-length) */
+                               u4 length = suck_u2();
+                               cptags [idx]  = CONSTANT_Utf8;
+                               /* insert utf-string into the utf-symboltable */
+                               cpinfos [idx] = utf_new(classbuf_pos+1, length);
+                               /* skip bytes of the string */
+                               skip_nbytes(length);
                                idx++;
                                break;
                                }
@@ -965,32 +1268,35 @@ static void class_loadcpool (classinfo *c)
                
 
 
-          /* Aufl"osen der noch unfertigen Eintr"age */
+          /* resolve entries in temporary structures */
 
        while (forward_classes) {
-               unicode *name =
+               utf *name =
                  class_getconstant (c, forward_classes -> name_index, CONSTANT_Utf8);
                
-               if ( (name->length>0) && (name->text[0]=='[') ) {
-                       checkfielddescriptor (name); 
+               if ( (name->blength>0) && (name->text[0]=='[') ) {
+                       /* check validity of descriptor */
+                       checkfielddescriptor (name->text, utf_end(name)); 
 
                        cptags  [forward_classes -> thisindex] = CONSTANT_Arraydescriptor;
                        cpinfos [forward_classes -> thisindex] = 
-                          buildarraydescriptor(name->text, name->length);
+                          buildarraydescriptor(name->text, name->blength);
 
                        }
-               else {          
+               else {                                  
                        cptags  [forward_classes -> thisindex] = CONSTANT_Class;
-                       cpinfos [forward_classes -> thisindex] = class_get (name);
+                       /* retrieve class from class-table */
+                       cpinfos [forward_classes -> thisindex] = class_new (name);
                        }
                forward_classes = forward_classes -> next;
                
                }
 
        while (forward_strings) {
-               unicode *text = 
+               utf *text = 
                  class_getconstant (c, forward_strings -> string_index, CONSTANT_Utf8);
-                       
+       
+               /* resolve utf-string */                
                cptags   [forward_strings -> thisindex] = CONSTANT_String;
                cpinfos  [forward_strings -> thisindex] = text;
                
@@ -1004,6 +1310,7 @@ static void class_loadcpool (classinfo *c)
                count_const_pool_len += sizeof(constant_nameandtype);
 #endif
 
+               /* resolve simple name and descriptor */
                cn -> name = class_getconstant 
                   (c, forward_nameandtypes -> name_index, CONSTANT_Utf8);
                cn -> descriptor = class_getconstant
@@ -1023,7 +1330,7 @@ static void class_loadcpool (classinfo *c)
 #ifdef STATISTICS
                count_const_pool_len += sizeof(constant_FMIref);
 #endif
-
+               /* resolve simple name and descriptor */
                nat = class_getconstant
                        (c, forward_fieldmethints -> nameandtype_index, CONSTANT_NameAndType);
 
@@ -1036,10 +1343,12 @@ static void class_loadcpool (classinfo *c)
                cpinfos [forward_fieldmethints -> thisindex] = fmi;
        
                switch (forward_fieldmethints -> tag) {
-               case CONSTANT_Fieldref:  checkfielddescriptor (fmi->descriptor);
+               case CONSTANT_Fieldref:  /* check validity of descriptor */
+                                        checkfielddescriptor (fmi->descriptor->text,utf_end(fmi->descriptor));
                                         break;
                case CONSTANT_InterfaceMethodref: 
-               case CONSTANT_Methodref: checkmethoddescriptor (fmi->descriptor);
+               case CONSTANT_Methodref: /* check validity of descriptor */
+                                        checkmethoddescriptor (fmi->descriptor);
                                         break;
                }               
        
@@ -1066,22 +1375,27 @@ static void class_loadcpool (classinfo *c)
        
 *******************************************************************************/
 
-static void class_load (classinfo *c)
+static int class_load (classinfo *c)
 {
        u4 i;
        u4 mi,ma;
 
-
-       if (loadverbose) {
+       /* output for debugging purposes */
+       if (loadverbose) {              
                sprintf (logtext, "Loading class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name );
+               utf_sprint (logtext+strlen(logtext), c->name );
                dolog();
                }
-
-
-       suck_start (c->name);
-
-       if (suck_u4() != MAGIC) panic("Can not find class-file signature");   
+       
+       /* load classdata, throw exception on error */
+       if (!suck_start (c->name)) {
+               throw_classnotfoundexception();            
+               return false;
+       }
+       
+       /* check signature */           
+       if (suck_u4() != MAGIC) panic("Can not find class-file signature");     
+       /* check version */
        mi = suck_u2(); 
        ma = suck_u2();
        if (ma != MAJOR_VERSION) {
@@ -1097,9 +1411,12 @@ static void class_load (classinfo *c)
 
        class_loadcpool (c);
        
-       c -> flags = suck_u2 ();
-       suck_u2 ();       /* this */
+       /* ACC flags */
+       c -> flags = suck_u2 (); 
+       /* this class */
+       suck_u2 ();       
        
+       /* retrieve superclass */
        if ( (i = suck_u2 () ) ) {
                c -> super = class_getconstant (c, i, CONSTANT_Class);
                }
@@ -1107,6 +1424,7 @@ static void class_load (classinfo *c)
                c -> super = NULL;
                }
                         
+       /* retrieve interfaces */
        c -> interfacescount = suck_u2 ();
        c -> interfaces = MNEW (classinfo*, c -> interfacescount);
        for (i=0; i < c -> interfacescount; i++) {
@@ -1114,12 +1432,14 @@ static void class_load (classinfo *c)
                      class_getconstant (c, suck_u2(), CONSTANT_Class);
                }
 
+       /* load fields */
        c -> fieldscount = suck_u2 ();
        c -> fields = MNEW (fieldinfo, c -> fieldscount);
        for (i=0; i < c -> fieldscount; i++) {
                field_load (&(c->fields[i]), c);
                }
 
+       /* load methods */
        c -> methodscount = suck_u2 ();
        c -> methods = MNEW (methodinfo, c -> methodscount);
        for (i=0; i < c -> methodscount; i++) {
@@ -1132,14 +1452,18 @@ static void class_load (classinfo *c)
        count_class_infos += sizeof(methodinfo) * c -> methodscount;
 #endif
 
+       /* load variable-length attribute structures */ 
+       attribute_load (suck_u2(), c);
 
-       skipattributes ( suck_u2() );
-
-
+       /* free memory */
        suck_stop ();
 
+       /* remove class from list of unloaded classes and 
+          add to list of unlinked classes                */
        list_remove (&unloadedclasses, c);
        list_addlast (&unlinkedclasses, c);
+
+       return true;
 }
 
 
@@ -1158,7 +1482,7 @@ static s4 class_highestinterface (classinfo *c)
        
        if ( ! (c->flags & ACC_INTERFACE) ) {
                sprintf (logtext, "Interface-methods count requested for non-interface:  ");
-       unicode_sprint (logtext+strlen(logtext), c->name);
+       utf_sprint (logtext+strlen(logtext), c->name);
        error();
        }
     
@@ -1302,7 +1626,7 @@ static void class_link (classinfo *c)
 
        if (linkverbose) {
                sprintf (logtext, "Linking Class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name );
+               utf_sprint (logtext+strlen(logtext), c->name );
                dolog ();
                }
 
@@ -1409,13 +1733,13 @@ foundvftblindex: ;
 
        if (super != NULL) {
                methodinfo *fi;
-               static unicode *finame = NULL;
-               static unicode *fidesc = NULL;
+               static utf *finame = NULL;
+               static utf *fidesc = NULL;
 
                if (finame == NULL)
-                       finame = unicode_new_char("finalize");
+                       finame = utf_finalize;
                if (fidesc == NULL)
-                       fidesc = unicode_new_char("()V");
+                       fidesc = utf_fidesc;
 
                fi = class_findmethod (c, finame, fidesc);
                if (fi != NULL) {
@@ -1496,8 +1820,6 @@ static void class_free (classinfo *c)
        s4 i;
        vftbl *v;
                
-       unicode_unlinkclass (c->name);
-       
        class_freecpool (c);
 
        MFREE (c->interfaces, classinfo*, c->interfacescount);
@@ -1523,11 +1845,13 @@ static void class_free (classinfo *c)
                                             (v->interfacetablelength > 1));
                mem_free (v, i);
                }
-               
+
+       if (c->innerclasscount)
+               MFREE (c->innerclass, innerclassinfo, c->innerclasscount);
+
        FREE (c, classinfo);
 }
 
-
 /************************* Funktion: class_findfield ***************************
        
        sucht in einer 'classinfo'-Struktur nach einem Feld mit gew"unschtem
@@ -1535,13 +1859,16 @@ static void class_free (classinfo *c)
 
 *******************************************************************************/
 
-fieldinfo *class_findfield (classinfo *c, unicode *name, unicode *desc)
+
+fieldinfo *class_findfield (classinfo *c, utf *name, utf *desc)
 {
        s4 i;
-       for (i = 0; i < c->fieldscount; i++) {
-               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc))
-                       return &(c->fields[i]);
-               }
+
+       for (i = 0; i < c->fieldscount; i++) { 
+               if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) 
+                       return &(c->fields[i]);                                                         
+    }
+
        panic ("Can not find field given in CONSTANT_Fieldref");
        return NULL;
 }
@@ -1555,7 +1882,7 @@ fieldinfo *class_findfield (classinfo *c, unicode *name, unicode *desc)
 
 *******************************************************************************/
 
-methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc)
+methodinfo *class_findmethod (classinfo *c, utf *name, utf *desc)
 {
        s4 i;
        for (i = 0; i < c->methodscount; i++) {
@@ -1566,6 +1893,71 @@ methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc)
        return NULL;
 }
 
+/************************* Funktion: class_findmethod_approx ******************
+       
+       sucht in einer 'classinfo'-Struktur nach einer Methode mit gew"unschtem
+       Namen und Typ.
+       Wenn als Typ NULL angegeben wird, dann ist der Typ egal.
+       beim Vergleichen des Descriptors wird der R"uckgabewert nicht betrachtet
+
+*******************************************************************************/
+
+methodinfo *class_findmethod_approx (classinfo *c, utf *name, utf *desc)
+{
+       s4 i;
+
+       for (i = 0; i < c->methodscount; i++) 
+               if (c->methods[i].name == name) {
+                       utf *meth_descr = c->methods[i].descriptor;
+                       
+                       if (desc == NULL) 
+                               /* ignore type */
+                               return &(c->methods[i]);
+
+                       if (desc->blength <= meth_descr->blength) {
+                                          /* current position in utf text   */
+                                          char *desc_utf_ptr = desc->text;      
+                                          char *meth_utf_ptr = meth_descr->text;                                         
+                                          /* points behind utf strings */
+                                          char *desc_end = utf_end(desc);         
+                                          char *meth_end = utf_end(meth_descr);   
+                                          char ch;
+
+                                          /* compare argument types */
+                                          while (desc_utf_ptr<desc_end && meth_utf_ptr<meth_end) {
+
+                                                  if ((ch=*desc_utf_ptr++) != (*meth_utf_ptr++))
+                                                          break; /* no match */
+
+                                                  if (ch==')')
+                                                          return &(c->methods[i]);   /* all parameter types equal */
+                                          }
+                       }
+               }
+
+       return NULL;
+}
+
+/***************** Funktion: class_resolvemethod_approx ***********************
+       
+       sucht eine Klasse und alle Superklassen ab, um eine Methode zu finden.
+       (ohne Beachtung des R"uckgabewertes)
+
+*******************************************************************************/
+
+methodinfo *class_resolvemethod_approx (classinfo *c, utf *name, utf *desc)
+{
+       while (c) {
+               /* search for method (ignore returntype) */
+               methodinfo *m = class_findmethod_approx (c, name, desc);
+               /* method found */
+               if (m) return m;
+               /* search superclass */
+               c = c->super;
+               }
+       return NULL;
+}
+
 
 /************************* Funktion: class_resolvemethod ***********************
        
@@ -1574,11 +1966,12 @@ methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc)
 *******************************************************************************/
 
 
-methodinfo *class_resolvemethod (classinfo *c, unicode *name, unicode *desc)
+methodinfo *class_resolvemethod (classinfo *c, utf *name, utf *desc)
 {
        while (c) {
                methodinfo *m = class_findmethod (c, name, desc);
                if (m) return m;
+               /* search superclass */
                c = c->super;
                }
        return NULL;
@@ -1631,13 +2024,13 @@ void class_init (classinfo *c)
        for (i=0; i < c->interfacescount; i++) class_init(c->interfaces[i]);
 
        m = class_findmethod (c, 
-                             unicode_new_char ("<clinit>")
-                             unicode_new_char ("()V"));
+                             utf_clinit
+                             utf_fidesc);
        if (!m) {
                if (initverbose) {
                        sprintf (logtext, "Class ");
-                       unicode_sprint (logtext+strlen(logtext), c->name);
-                       sprintf (logtext+strlen(logtext), " has no initializer");       
+                       utf_sprint (logtext+strlen(logtext), c->name);
+                       sprintf (logtext+strlen(logtext), " has no initializer");       
                        dolog ();
                        }
                return;
@@ -1647,7 +2040,7 @@ void class_init (classinfo *c)
        
        if (initverbose) {
                sprintf (logtext, "Starting initializer for class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name);
+               utf_sprint (logtext+strlen(logtext), c->name);
                dolog ();
        }
 
@@ -1663,19 +2056,57 @@ void class_init (classinfo *c)
        blockInts = b;
 #endif
 
-       if (exceptionptr) {     
-               printf ("#### Initializer has thrown: ");
-               unicode_display (exceptionptr->vftbl->class->name);
+       if (exceptionptr) {     
+               printf ("#### Initializer of ");
+               utf_display (c->name);
+               printf (" has thrown: ");
+               utf_display (exceptionptr->vftbl->class->name);
                printf ("\n");
                fflush (stdout);
                }
 
        if (initverbose) {
                sprintf (logtext, "Finished initializer for class: ");
-               unicode_sprint (logtext+strlen(logtext), c->name);
+               utf_sprint (logtext+strlen(logtext), c->name);
                dolog ();
        }
 
+       if (c->name == utf_systemclass) {
+               /* class java.lang.System requires explicit initialization */
+               
+               if (initverbose)
+                       printf ("#### Initializing class System");
+
+               /* find initializing method */     
+               m = class_findmethod (c, 
+                                       utf_initsystemclass,
+                                       utf_fidesc);
+
+               if (!m) {
+                       /* no method found */
+                       log("initializeSystemClass failed");
+                       return;
+               }
+
+               #ifdef USE_THREADS
+                       b = blockInts;
+                       blockInts = 0;
+               #endif
+
+               exceptionptr = asm_calljavamethod (m, NULL,NULL,NULL,NULL);
+
+               #ifdef USE_THREADS
+                       assert(blockInts == 0);
+                       blockInts = b;
+               #endif
+
+               if (exceptionptr) {                     
+                       printf ("#### initializeSystemClass has thrown: ");
+                       utf_display (exceptionptr->vftbl->class->name);
+                       printf ("\n");
+                       fflush (stdout);                  
+               }
+       }
 }
 
 
@@ -1699,7 +2130,7 @@ void class_showconstantpool (classinfo *c)
                        switch (c -> cptags [i]) {
                                case CONSTANT_Class:
                                        printf ("Classreference -> ");
-                                       unicode_display ( ((classinfo*)e) -> name );
+                                       utf_display ( ((classinfo*)e) -> name );
                                        break;
                                
                                case CONSTANT_Fieldref:
@@ -1711,17 +2142,17 @@ void class_showconstantpool (classinfo *c)
                                  displayFMI:
                                        {
                                        constant_FMIref *fmi = e;
-                                       unicode_display ( fmi->class->name );
+                                       utf_display ( fmi->class->name );
                                        printf (".");
-                                       unicode_display ( fmi->name);
+                                       utf_display ( fmi->name);
                                        printf (" ");
-                                       unicode_display ( fmi->descriptor );
+                                       utf_display ( fmi->descriptor );
                                    }
                                        break;
 
                                case CONSTANT_String:
                                        printf ("String -> ");
-                                       unicode_display (e);
+                                       utf_display (e);
                                        break;
                                case CONSTANT_Integer:
                                        printf ("Integer -> %d", (int) ( ((constant_integer*)e) -> value) );
@@ -1746,14 +2177,14 @@ void class_showconstantpool (classinfo *c)
                                case CONSTANT_NameAndType:
                                        { constant_nameandtype *cnt = e;
                                          printf ("NameAndType: ");
-                                         unicode_display (cnt->name);
+                                         utf_display (cnt->name);
                                          printf (" ");
-                                         unicode_display (cnt->descriptor);
+                                         utf_display (cnt->descriptor);
                                        }
                                        break;
                                case CONSTANT_Utf8:
                                        printf ("Utf8 -> ");
-                                       unicode_display (e);
+                                       utf_display (e);
                                        break;
                                case CONSTANT_Arraydescriptor:  {
                                        printf ("Arraydescriptor: ");
@@ -1782,16 +2213,16 @@ void class_showmethods (classinfo *c)
        printf ("--------- Fields and Methods ----------------\n");
        printf ("Flags: ");     printflags (c->flags);  printf ("\n");
 
-       printf ("This: "); unicode_display (c->name); printf ("\n");
+       printf ("This: "); utf_display (c->name); printf ("\n");
        if (c->super) {
-               printf ("Super: "); unicode_display (c->super->name); printf ("\n");
+               printf ("Super: "); utf_display (c->super->name); printf ("\n");
                }
        printf ("Index: %d\n", c->index);
        
        printf ("interfaces:\n");       
        for (i=0; i < c-> interfacescount; i++) {
                printf ("   ");
-               unicode_display (c -> interfaces[i] -> name);
+               utf_display (c -> interfaces[i] -> name);
                printf (" (%d)\n", c->interfaces[i] -> index);
                }
 
@@ -1832,7 +2263,7 @@ void class_showmethods (classinfo *c)
 
 *******************************************************************************/
 
-classinfo *loader_load (unicode *topname)
+classinfo *loader_load (utf *topname)
 {
        classinfo *top;
        classinfo *c;
@@ -1842,16 +2273,22 @@ classinfo *loader_load (unicode *topname)
 
        if (getloadingtime) starttime = getcputime();
 
-       top = class_get (topname);
+       top = class_new (topname);
 
+       /* load classes */
        while ( (c = list_first(&unloadedclasses)) ) {
-               class_load (c);
-               }
+               if (!class_load (c)) {
+                       list_remove (&unloadedclasses, c);
+                       top=NULL;
+                   }
+        }
 
+       /* link classes */
        while ( (c = list_first(&unlinkedclasses)) ) {
                class_link (c);
                }
 
+       /* measure time */
        if (getloadingtime) {
                stoptime = getcputime();
                loadingtime += (stoptime-starttime);
@@ -1859,31 +2296,60 @@ classinfo *loader_load (unicode *topname)
 
        intsRestore();                          /* schani */
 
-       return top;
+       return top; 
 }
 
 
-/******************* interne Funktion: loader_createarrayclass *****************
+/**************** function: create_primitive_classes ***************************
 
-       Erzeugt (und linkt) eine Klasse f"ur die Arrays.
-       
-*******************************************************************************/
+       create classes representing primitive types 
 
-static classinfo *loader_createarrayclass ()
-{
-       classinfo *c;
-       c = class_get ( unicode_new_char ("The_Array_Class") );
-       
+********************************************************************************/
+
+
+void create_primitive_classes()
+{  
+       int i;
+
+       for (i=0;i<PRIMITIVETYPE_COUNT;i++) {
+               /* create primitive class */
+               classinfo *c = class_new ( utf_new_char(primitivetype_table[i].name) );
+               
+               /* prevent loader from loading primitive class */
+               list_remove (&unloadedclasses, c);
+               /* add to unlinked classes */
+               list_addlast (&unlinkedclasses, c);             
+               c -> super = class_java_lang_Object;
+               class_link (c);
+
+               primitivetype_table[i].class_primitive = c;
+
+               /* create class for wrapping the primitive type */
+               primitivetype_table[i].class_wrap =
+                       class_new( utf_new_char(primitivetype_table[i].wrapname) );
+       }
+}
+
+/***************** function: create_array_class ********************************
+
+       create class representing an array
+
+********************************************************************************/
+
+
+classinfo *create_array_class(utf *u)
+{  
+       classinfo *c = class_new (u);
+       /* prevent loader from loading the array class */
        list_remove (&unloadedclasses, c);
+       /* add to unlinked classes */
        list_addlast (&unlinkedclasses, c);
        c -> super = class_java_lang_Object;
-       
-       class_link (c);
+       class_link(c);
+
        return c;
 }
 
-
-
 /********************** Funktion: loader_init **********************************
 
        Initialisiert alle Listen und l"adt alle Klassen, die vom System
@@ -1893,37 +2359,67 @@ static classinfo *loader_createarrayclass ()
  
 void loader_init ()
 {
+       utf *string_class;
        interfaceindex = 0;
        
        list_init (&unloadedclasses, OFFSET(classinfo, listnode) );
        list_init (&unlinkedclasses, OFFSET(classinfo, listnode) );
        list_init (&linkedclasses, OFFSET(classinfo, listnode) );
 
+       /* create utf-symbols for pointer comparison of frequently used strings */
+       utf_innerclasses    = utf_new_char("InnerClasses");
+       utf_constantvalue   = utf_new_char("ConstantValue");
+       utf_code                = utf_new_char("Code");
+       utf_finalize        = utf_new_char("finalize");
+       utf_fidesc              = utf_new_char("()V");
+       utf_clinit              = utf_new_char("<clinit>");
+       utf_initsystemclass = utf_new_char("initializeSystemClass");
+       utf_systemclass     = utf_new_char("java/lang/System");
+
+       /* create class for arrays */
+       class_array = class_new ( utf_new_char ("The_Array_Class") );
+       list_remove (&unloadedclasses, class_array);
+
+       /* create class for strings, load it after class Object was loaded */
+       string_class = utf_new_char ("java/lang/String");
+       class_java_lang_String = class_new(string_class);
+       list_remove (&unloadedclasses, class_java_lang_String);
 
        class_java_lang_Object = 
-               loader_load ( unicode_new_char ("java/lang/Object") );
+               loader_load ( utf_new_char ("java/lang/Object") );
+
+       list_addlast(&unloadedclasses, class_java_lang_String);
+
        class_java_lang_String = 
-               loader_load ( unicode_new_char ("java/lang/String") );
+               loader_load ( string_class );
        class_java_lang_ClassCastException = 
-               loader_load ( unicode_new_char ("java/lang/ClassCastException") );
+               loader_load ( utf_new_char ("java/lang/ClassCastException") );
        class_java_lang_NullPointerException = 
-               loader_load ( unicode_new_char ("java/lang/NullPointerException") );
+               loader_load ( utf_new_char ("java/lang/NullPointerException") );
        class_java_lang_ArrayIndexOutOfBoundsException = loader_load ( 
-            unicode_new_char ("java/lang/ArrayIndexOutOfBoundsException") );
+            utf_new_char ("java/lang/ArrayIndexOutOfBoundsException") );
        class_java_lang_NegativeArraySizeException = loader_load ( 
-            unicode_new_char ("java/lang/NegativeArraySizeException") );
+            utf_new_char ("java/lang/NegativeArraySizeException") );
        class_java_lang_OutOfMemoryError = loader_load ( 
-            unicode_new_char ("java/lang/OutOfMemoryError") );
+            utf_new_char ("java/lang/OutOfMemoryError") );
        class_java_lang_ArrayStoreException =
-               loader_load ( unicode_new_char ("java/lang/ArrayStoreException") );
+               loader_load ( utf_new_char ("java/lang/ArrayStoreException") );
        class_java_lang_ArithmeticException = 
-               loader_load ( unicode_new_char ("java/lang/ArithmeticException") );
+               loader_load ( utf_new_char ("java/lang/ArithmeticException") );
        class_java_lang_ThreadDeath =                             /* schani */
-               loader_load ( unicode_new_char ("java/lang/ThreadDeath") );
+               loader_load ( utf_new_char ("java/lang/ThreadDeath") );
 
-       class_array = loader_createarrayclass ();
+       /* link class for arrays */
+       list_addlast (&unlinkedclasses, class_array);
+       class_array -> super = class_java_lang_Object;
+       class_link (class_array);
 
+       /* correct vftbl-entries (retarded loading of class java/lang/String) */
+       stringtable_update(); 
 
+       /* create classes representing primitive types */
+       create_primitive_classes();
+               
        proto_java_lang_ClassCastException = 
                builtin_new(class_java_lang_ClassCastException);
        heap_addreference ( (void**) &proto_java_lang_ClassCastException);
@@ -2002,7 +2498,7 @@ static void loader_compute_class_values (classinfo *c)
        for (i = 0; i < c->index; i++)
                printf(" ");
        printf("%3d  %3d  ", (int) c->vftbl->baseval, c->vftbl->diffval);
-       unicode_display(c->name);
+       utf_display(c->name);
        printf("\n");
        }
 */
@@ -2031,6 +2527,19 @@ void loader_compute_subclasses ()
 
 
 
+/******************** function: classloader_buffer ***************************
+    set buffer for reading classdata
+
+******************************************************************************/
+
+void classload_buffer(u1 *buf,int len)
+{
+       classbuffer        =  buf;
+       classbuffer_size   =  len;
+       classbuf_pos       =  buf-1;
+}
+
 /******************** Funktion: loader_close ***********************************
 
        gibt alle Resourcen wieder frei
@@ -2068,3 +2577,4 @@ void loader_close ()
  * tab-width: 4
  * End:
  */
+
index 57686b0845b3cdcfea460c2d755836bdc48c2eae..41bdbcf2daa17f0d1f93e2e7158be31ffa0f5d15 100644 (file)
@@ -13,6 +13,7 @@
 *******************************************************************************/
 
 
+
 /************************* program switches ***********************************/
 
 extern bool loadverbose;         /* Debug-Meldungen beim Laden ausgeben */
@@ -29,26 +30,54 @@ extern list linkedclasses;       /* Liste aller fertig gelinkten Klassen */
 
 /************************ prototypes ******************************************/
 
+/* initialize laoder, load important systemclasses */
 void loader_init ();
+
+/* free resources */
 void loader_close ();
 
-classinfo *loader_load (unicode *topname);
+/* load a class and all referenced classes */
+classinfo *loader_load (utf *topname);
+
+/* initializes all loaded classes */
 void loader_initclasses ();
+
 void loader_compute_subclasses ();
 
-classinfo *class_get (unicode *name);
+/* retrieve constantpool element */
 voidptr class_getconstant (classinfo *class, u4 pos, u4 ctype);
+
+/* determine type of a constantpool element */
 u4 class_constanttype (classinfo *class, u4 pos);
 
-fieldinfo *class_findfield (classinfo *c, unicode *name, unicode *desc);
-methodinfo *class_findmethod (classinfo *c, unicode *name, unicode *desc);
+/* search class for a field */
+fieldinfo *class_findfield (classinfo *c, utf *name, utf *desc);
+
+/* search for a method with a specified name and descriptor */
+methodinfo *class_findmethod (classinfo *c, utf *name, utf *desc);
+methodinfo *class_resolvemethod (classinfo *c, utf *name, utf *dest);
 
-methodinfo *class_resolvemethod (classinfo *c, unicode *name, unicode *dest);
+/* search for a method with specified name and arguments (returntype ignored) */
+methodinfo *class_findmethod_approx (classinfo *c, utf *name, utf *desc);
+methodinfo *class_resolvemethod_approx (classinfo *c, utf *name, utf *dest);
 
 bool class_issubclass (classinfo *sub, classinfo *super);
 
+/* call initializer of class */
 void class_init (classinfo *c);
 
+/* debug purposes */
 void class_showmethods (classinfo *c);
 void class_showconstantpool (classinfo *c);
 
+/* set buffer for reading classdata */
+void classload_buffer(u1 *buf,int len);
+
+/* create class representing specific arraytype */
+classinfo *create_array_class(utf *u);
+
+/* create the arraydescriptor for the arraytype specified by the utf-string */
+constant_arraydescriptor * buildarraydescriptor(char *utf, u4 namelen);
+
+
+
index 48103bee3b6b5db2d5ac74854066bb4730bbe21f..8797971aacf2849963412267cadbc398ffa2d337 100644 (file)
@@ -14,7 +14,7 @@
        Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
        Changes: Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
                 Andreas  Krall      EMAIL: cacao@complang.tuwien.ac.at
-
+                       
        Last Change: 1998/03/24
 
 *******************************************************************************/
 #include "threads/thread.h"                  /* schani */
 #include "threads/locks.h"
 
-
 bool runverbose = false;
 
-int count_unicode_len = 0;
+/* statistics */
+int count_utf_len = 0;         /* size of utf hash                  */
+int count_utf_new = 0;         /* calls of utf_new                  */
+int count_utf_new_found  = 0;  /* calls of utf_new with fast return */
 
+hashtable utf_hash;     /* hashtable for utf8-symbols */
+hashtable string_hash;  /* hashtable for javastrings  */
+hashtable class_hash;   /* hashtable for classes      */
 
 /******************************************************************************
-************************* Der Dateien-Sauger **********************************
-*******************************************************************************
-
-       dient zum Behandeln von Java-ClassFiles ("offnen, schlie"sen, 
-       einlesen von 8-, 16-, 32-, 64-bit Integers und 32-, 64- bit Floats)
-
-******************************************************************************/
-
-static FILE *classfile = NULL;   /* File-handle der gerade gelesenen Datei */
-static char *classpath = "";     /* Suchpfad f"ur die ClassFiles */
+ *********************** hashtable functions **********************************
+ ******************************************************************************/
 
+/* hashsize must be power of 2 */
 
+#define UTF_HASHSTART   16384   /* initial size of utf-hash */    
+#define HASHSTART        2048   /* initial size of javastring and class-hash */
 
-/************************** Funktion: suck_init ******************************
 
-       Wird zu Programmstart einmal aufgerufen und setzt den Suchpfad f"ur
-       Klassenfiles
-
-******************************************************************************/
-
-void suck_init (char *cpath)
-{
-       classfile = NULL;
-       classpath = cpath;
-}
+/******************** function: init_hashtable ******************************
 
-
-/************************** Funktion: suck_start ******************************
-
-       "Offnet die Datei f"ur die Klasse des gegebenen Namens zum Lesen.
-       Dabei werden alle im Suchpfad angegebenen Verzeichnisse durchsucht,
-       bis eine entsprechende Datei  ( <classname>.class) gefunden wird. 
+    Initializes a hashtable structure and allocates memory.
+    The parameter size specifies the initial size of the hashtable.
        
-******************************************************************************/
-
-bool suck_start (unicode *classname)
-{
-#define MAXFILENAME 1000          /* Maximale Langes des Dateinamens plus Pfad */
-
-       char filename[MAXFILENAME+10];   /* Platz fuer '.class' */
-       u2 filenamelen;
-       char *pathpos;
-       u2 i,c;
-
-
-       pathpos = classpath;
-
-       while (*pathpos) {
-               while ( *pathpos == ':' ) pathpos++;
-               filenamelen=0;
-               while ( (*pathpos) && (*pathpos!=':') ) {
-                   PANICIF (filenamelen >= MAXFILENAME, "Filename too long") ;
-                       
-                       filename[filenamelen++] = *(pathpos++);
-                       }
-
-               filename[filenamelen++] = '/';
-   
-               for (i=0; i < classname -> length; i++) {
-                       PANICIF (filenamelen >= MAXFILENAME, "Filename too long");
-                       
-                       c = classname -> text [i];
-                       if (c=='/') c = '/';     /* Slashes im Namen passen zu UNIX */
-                       else {
-                               if ( c<=' ' || c>'z') {
-                                       c = '?';
-                                       }
-                               }
-                       
-                       filename[filenamelen++] = c;    
-                       }
-      
-               strcpy (filename+filenamelen, ".class");
-
-               classfile = fopen(filename, "r");
-               if (classfile) {
-                       return true;
-                       }
-
-               
-               }
-                  
-       sprintf (logtext,"Can not open class file '%s'", filename);
-       error();
-       return false;
-}
-
-
-/************************** Funktion: suck_stop *******************************
-
-       Schlie"st die offene Datei wieder.
-       
-******************************************************************************/
-
-void suck_stop ()
-{
-       u4 rest=0;
-       u1 dummy;
-       
-       while ( fread (&dummy, 1,1, classfile) > 0) rest++;
-       if (rest) {
-               sprintf (logtext,"There are %d access bytes at end of classfile",
-                                (int) rest);
-               dolog();
-               }
-                       
-       fclose (classfile);
-       classfile = NULL;
-}
-      
-
-
-/************************** Lesefunktionen ***********************************
-
-       Lesen von der Datei in verschieden grossen Paketen
-       (8,16,32,64-bit Integer oder Float)
-
 *****************************************************************************/
 
-void suck_nbytes (u1 *buffer, u4 len)
-{
-       if ( fread (buffer, 1, len, classfile) != len) panic ("Unexpected EOF");
-}
-
-
-void skip_nbytes (u4 len)
+void init_hashtable(hashtable *hash, u4 size)
 {
        u4 i;
-       for (i=0; i<len; i++) suck_u1 ();
-}
-
-
-u1 suck_u1 ()
-{
-       u1 b;
-       if ( fread (&b, 1,1, classfile) != 1) panic ("Unexpected EOF");
-       return b;
-}
-
-s1 suck_s1 ()
-{
-       s1 b;
-       if ( fread (&b, 1,1, classfile) != 1) panic ("Unexpected EOF");
-       return b;
-}
 
+       hash->entries = 0;
+       hash->size    = size;
+       hash->ptr     = MNEW (void*, size);
 
-u2 suck_u2 ()
-{
-       u1 b[2];
-       if ( fread (b, 1,2, classfile) != 2) panic ("Unexpected EOF");
-       return (b[0]<<8) + b[1];
-}
-
-s2 suck_s2 ()
-{
-       return suck_u2 ();
-}
-
-
-u4 suck_u4 ()
-{
-       u1 b[4];
-       u4 v;
-       if ( fread (b, 1,4, classfile) != 4) panic ("Unexpected EOF");
-       v = ( ((u4)b[0]) <<24) + ( ((u4)b[1])<<16) + ( ((u4)b[2])<<8) + ((u4)b[3]);
-       return v;
-}
-
-s4 suck_s4 ()
-{
-       s4 v = suck_u4 ();
-       return v;
+       /* clear table */
+       for (i=0; i<size; i++) hash->ptr[i] = NULL;
 }
 
-u8 suck_u8 ()
-{
-#if U8_AVAILABLE
-       u8 lo,hi;
-       hi = suck_u4();
-       lo = suck_u4();
-       return (hi<<32) + lo;
-#else
-       u8 v;
-       v.high = suck_u4();
-       v.low = suck_u4();
-       return v;
-#endif
-}
+/*********************** function: tables_init  *****************************
 
-s8 suck_s8 ()
-{
-       return suck_u8 ();
-}
-       
-
-float suck_float ()
-{
-       float f;
-
-#if !WORDS_BIGENDIAN 
-               u1 buffer[4];
-               u2 i;
-               for (i=0; i<4; i++) buffer[3-i] = suck_u1 ();
-               memcpy ( (u1*) (&f), buffer, 4);
-#else 
-               suck_nbytes ( (u1*) (&f), 4 );
-#endif
-
-       PANICIF (sizeof(float) != 4, "Incompatible float-format");
-       
-       return f;
-}
-
-
-double suck_double ()
-{
-       double d;
-
-#if !WORDS_BIGENDIAN 
-               u1 buffer[8];
-               u2 i;   
-               for (i=0; i<8; i++) buffer[7-i] = suck_u1 ();
-               memcpy ( (u1*) (&d), buffer, 8);
-#else 
-               suck_nbytes ( (u1*) (&d), 8 );
-#endif
-
-       PANICIF (sizeof(double) != 8, "Incompatible double-format" );
-       
-       return d;
-}
-
-
-
-
-/******************************************************************************
-******************** Der Unicode-Symbol-Verwalter *****************************
-*******************************************************************************
-
-       legt eine Hashtabelle f"ur unicode-Symbole an und verwaltet
-       das Eintragen neuer Symbole
-       
-******************************************************************************/
-
-
-
-#define UNICODESTART  2187      /* Startgr"osse: moeglichst gross und prim */
-
-static u4 unicodeentries;       /* Anzahl der Eintr"age in der Tabelle */
-static u4 unicodehashsize;      /* Gr"osse der Tabelle */
-static unicode ** unicodehash;  /* Zeiger auf die Tabelle selbst */
-
-
-/*********************** Funktion: unicode_init ******************************
-
-       Initialisiert die unicode-Symboltabelle (muss zu Systemstart einmal
-       aufgerufen werden)
+    creates hashtables for symboltables 
+       (called once at startup)                         
        
 *****************************************************************************/
 
-void unicode_init ()
+void tables_init ()
 {
-       u4 i;
+       init_hashtable(&utf_hash,    UTF_HASHSTART);  /* hashtable for utf8-symbols */
+       init_hashtable(&string_hash, HASHSTART);      /* hashtable for javastrings */
+       init_hashtable(&class_hash,  HASHSTART);      /* hashtable for classes */ 
        
 #ifdef STATISTICS
-       count_unicode_len += sizeof(unicode*) * unicodehashsize;
+       count_utf_len += sizeof(utf*) * utf_hash.size;
 #endif
 
-       unicodeentries = 0;
-       unicodehashsize = UNICODESTART;
-       unicodehash = MNEW (unicode*, unicodehashsize);
-       for (i=0; i<unicodehashsize; i++) unicodehash[i] = NULL;
 }
 
+/********************** function: tables_close ******************************
 
-/*********************** Funktion: unicode_close *****************************
-
-       Gibt allen Speicher der Symboltabellen frei.
-       Parameter: Ein Zeiger auf eine Funktion, die dazu n"otig ist, 
-                  Stringkonstanten (die mit 'unicode_setstringlink' 
-                  Unicode-Symbole gebunden wurden) wieder freizugeben
+        free memory for hashtables                   
        
 *****************************************************************************/
 
-void unicode_close (stringdeleter del)
+void tables_close (stringdeleter del)
 {
-       unicode *u;
+       utf *u; 
+       literalstring *s;
        u4 i;
        
-       for (i=0; i<unicodehashsize; i++) {
-               u = unicodehash[i];
+       /* dispose utf symbols */
+       for (i=0; i<utf_hash.size; i++) {
+       u = utf_hash.ptr[i];
                while (u) {
-                       unicode *nextu = u->hashlink;
-
-                       if (u->string) del (u->string);
-                       
-                       MFREE (u->text, u2, u->length);
-                       FREE (u, unicode);
+                       /* process elements in external hash chain */
+                       utf *nextu = u->hashlink;
+                       MFREE (u->text, u1, u->blength);
+                       FREE (u, utf);
                        u = nextu;
                        }       
                }
-       MFREE (unicodehash, unicode*, unicodehashsize);
+
+       /* dispose javastrings */
+       for (i=0; i<string_hash.size; i++) {
+               s = string_hash.ptr[i];
+               while (u) {
+                       /* process elements in external hash chain */
+                       literalstring *nexts = s->hashlink;
+                       del(s->string);
+                       FREE(s, literalstring);
+                       s = nexts;
+                       }       
+               }
+
+       /* dispose hashtable structures */
+       MFREE (utf_hash.ptr,    void*, utf_hash.size);
+       MFREE (string_hash.ptr, void*, string_hash.size);
+       MFREE (class_hash.ptr,  void*, class_hash.size);
 }
 
+/********************* function: utf_display *********************************
 
-/********************* Funktion: unicode_display ******************************
-       
-       Gibt ein unicode-Symbol auf stdout aus (zu Debugzwecken)
+       write utf symbol to stdout (debugging purposes)
 
 ******************************************************************************/
 
-void unicode_display (unicode *u)
+void utf_display (utf *u)
 {
-       u2 i,c;
-       for (i=0; i < u->length; i++) {
-               c = u->text[i];
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */
+
+    while (utf_ptr<endpos) {
+
+               /* read next unicode character */                
+               u2 c = utf_nextu2(&utf_ptr);                            
                if (c>=32 && c<=127) printf ("%c",c);
                                else printf ("?");
-               }
+       }
+
        fflush (stdout);
 }
 
-
-/********************* Funktion: unicode_sprint ******************************
+/************************ function: utf_sprint *******************************
        
-       Schreibt ein unicode-Symbol in einen C-String
+    write utf symbol into c-string (debugging purposes)                                                 
 
 ******************************************************************************/ 
 
-void unicode_sprint (char *buffer, unicode *u)
+void utf_sprint (char *buffer, utf *u)
 {
-       u2 i;
-       for (i=0; i < u->length; i++) buffer[i] = u->text[i];
-       buffer[i] = '\0';
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */ 
+    u2 pos = 0;                  /* position in c-string           */
+
+    while (utf_ptr<endpos) 
+               /* copy next unicode character */       
+               buffer[pos++] = utf_nextu2(&utf_ptr);
+
+    /* terminate string */
+    buffer[pos] = '\0';
 }
 
 
-/********************* Funktion: unicode_fprint ******************************
+/********************* Funktion: utf_fprint **********************************
        
-       Schreibt ein unicode-Symbol auf eine Datei aus
+    write utf symbol into file         
 
 ******************************************************************************/ 
 
-void unicode_fprint (FILE *file, unicode *u)
+void utf_fprint (FILE *file, utf *u)
 {
-       u2 i;
-       for (i=0; i < u->length; i++) putc (u->text[i], file);
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */ 
+
+    while (utf_ptr<endpos) 
+               /* write next unicode character */       
+               putc ( utf_nextu2(&utf_ptr), file );
 } 
 
 
-/****************** interne Funktion: u_hashkey ******************************/
+/****************** internal function: utf_hashkey ***************************
 
-static u4 u_hashkey (u2 *text, u2 length)
-{
-       u4 k = 0;
-       u2 i,sh=0;
-       
-       for (i=0; i<length; i++) {
-               k ^=  ( ((u4) (text[i])) << sh );
-               if (sh<16) sh++;
-                    else  sh=0;
-               }
-               
-       return k;
-}
+       The hashkey is computed from the utf-text by using up to 8 characters.
+       For utf-symbols longer than 15 characters 3 characters are taken from
+       the beginning and the end, 2 characters are taken from the middle.
 
-/*************** interne Funktion: u_reorganizehash **************************/
+******************************************************************************/ 
 
-static void u_reorganizehash ()
-{
-       u4 i;
-       unicode *u;
+#define nbs(val) ((u4) *(++text) << val) /* get next byte, left shift by val  */
+#define fbs(val) ((u4) *(  text) << val) /* get first byte, left shift by val */
+
+static u4 utf_hashkey (char *text, u4 length)
+{
+       char *start_pos = text; /* pointer to utf text */
+       u4 a;
+
+       switch (length) {               
+               
+       case 0: /* empty string */
+               return 0;
+
+       case 1: return fbs(0);
+       case 2: return fbs(0) ^ nbs(3);
+       case 3: return fbs(0) ^ nbs(3) ^ nbs(5);
+       case 4: return fbs(0) ^ nbs(2) ^ nbs(4) ^ nbs(6);
+       case 5: return fbs(0) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(6);
+       case 6: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(5) ^ nbs(6);
+       case 7: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6);
+       case 8: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7);
+
+       case 9: a = fbs(0) ^ nbs(1) ^ nbs(2);                
+                text++; 
+                return a ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7) ^ nbs(8);
+
+       case 10: a = fbs(0);
+                 text++;
+                 a^= nbs(2) ^ nbs(3) ^ nbs(4);
+                 text++;
+                 return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9);
+
+       case 11: a = fbs(0);
+                 text++;
+                 a^= nbs(2) ^ nbs(3) ^ nbs(4);
+                 text++;
+                 return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9) ^ nbs(10);
+
+       case 12: a = fbs(0);
+                 text+=2;
+                 a^= nbs(2) ^ nbs(3);
+                 text+=1;
+                 a^= nbs(5) ^ nbs(6) ^ nbs(7);
+                 text+=1;
+                 return a ^ nbs(9) ^ nbs(10);     
+
+       case 13: a = fbs(0) ^ nbs(1);
+                 text+=1;      
+                 a^= nbs(3) ^ nbs(4);
+                 text+=2;      
+                 a^= nbs(7) ^ nbs(8);
+                 text+=2;
+                 return a ^ nbs(9) ^ nbs(10);
+
+       case 14: a = fbs(0);
+                 text+=2;      
+                 a^= nbs(3) ^ nbs(4);
+                 text+=2;      
+                 a^= nbs(7) ^ nbs(8);
+                 text+=2;
+                 return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
+
+       case 15: a = fbs(0);
+                 text+=2;      
+                 a^= nbs(3) ^ nbs(4);
+                 text+=2;      
+                 a^= nbs(7) ^ nbs(8);
+                 text+=2;
+                 return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
+
+       default:  /* 3 characters from beginning */
+                  a = fbs(0);
+                  text+=2;
+                  a^= nbs(3) ^ nbs(4);
+
+                  /* 2 characters from middle */
+                  text = start_pos + (length / 2);
+                  a^= fbs(5);
+                  text+=2;
+                  a^= nbs(6);  
+
+                  /* 3 characters from end */
+                  text = start_pos + length - 4;
+
+                  a^= fbs(7);
+                  text+=1;
+
+                  return a ^ nbs(10) ^ nbs(11);
+    }
+}
 
-       u4 newhashsize = unicodehashsize*2;
-       unicode **newhash = MNEW (unicode*, newhashsize);
 
-#ifdef STATISTICS
-       count_unicode_len += sizeof(unicode*) * unicodehashsize;
-#endif
+/*************************** function: utf_hashkey ***************************
 
-       for (i=0; i<newhashsize; i++) newhash[i] = NULL;
+    compute the hashkey of a unicode string
 
-       for (i=0; i<unicodehashsize; i++) {
-               u = unicodehash[i];
-               while (u) {
-                       unicode *nextu = u -> hashlink;
-                       u4 slot = (u->key) % newhashsize;
-                                               
-                       u->hashlink = newhash[slot];
-                       newhash[slot] = u;
+******************************************************************************/ 
 
-                       u = nextu;
-                       }
-               }
-       
-       MFREE (unicodehash, unicode*, unicodehashsize);
-       unicodehash = newhash;
-       unicodehashsize = newhashsize;
+u4 unicode_hashkey (u2 *text, u2 len)
+{
+       utf_hashkey((char*) text, len);
 }
 
+/************************ function: utf_new **********************************
 
-/****************** Funktion: unicode_new_u2 **********************************
+       Creates a new utf-symbol, the text of the symbol is passed as a 
+       u1-array. The function searches the utf-hashtable for a utf-symbol 
+       with this text. On success the element returned, otherwise a new 
+       hashtable element is created.
 
-       Legt ein neues unicode-Symbol an. Der Text des Symbols wird dieser
-       Funktion als u2-Array "ubergeben
+       If the number of entries in the hashtable exceeds twice the size of the
+       hashtable slots a reorganization of the hashtable is done and the utf 
+       symbols are copied to a new hashtable with doubled size.
 
 ******************************************************************************/
 
-unicode *unicode_new_u2 (u2 *text, u2 length)
+utf *utf_new (char *text, u2 length)
 {
-       u4 key = u_hashkey (text, length);
-       u4 slot = key % unicodehashsize;
-       unicode *u = unicodehash[slot];
+       u4 key;            /* hashkey computed from utf-text */
+       u4 slot;           /* slot in hashtable */
+       utf *u;            /* hashtable element */
        u2 i;
-
-       while (u) {
-               if (u->key == key) {
-                       if (u->length == length) {
-                               for (i=0; i<length; i++) {
-                                       if (text[i] != u->text[i]) goto nomatch;
-                                       }       
-                                       return u;
-                               }
-                       }
-               nomatch:
-               u = u->hashlink;
-               }
-
+       
 #ifdef STATISTICS
-       count_unicode_len += sizeof(unicode) + 2 * length;
+       count_utf_new++;
 #endif
 
-       u = NEW (unicode);
-       u->key = key;
-       u->length = length;
-       u->text = MNEW (u2, length);
-       u->class = NULL;
-       u->string = NULL;
-       u->hashlink = unicodehash[slot];
-       unicodehash[slot] = u;
-       for (i=0; i<length; i++) u->text[i] = text[i];
-
-       unicodeentries++;
-       
-       if ( unicodeentries > (unicodehashsize/2)) u_reorganizehash();
-       
-       return u;
-}
-
-
-/********************* Funktion: unicode_new_char *****************************
+       key  = utf_hashkey (text, length);
+       slot = key & (utf_hash.size-1);
+       u    = utf_hash.ptr[slot];
 
-       Legt ein neues unicode-Symbol an. Der Text des Symbols wird dieser
-       Funktion als C-String ( = char* ) "ubergeben
-
-******************************************************************************/
+       /* search external hash chain for utf-symbol */
+       while (u) {
+               if (u->blength == length) {
 
-unicode *unicode_new_char (char *text)
-{
-#define MAXNEWCHAR 500
-       u2 buffer[MAXNEWCHAR];
-       u2 length = 0;
-       u1 c;
-       
-       while ( (c = *text) != '\0' ) {
-               if (length>=MAXNEWCHAR) panic ("Text too long in unicode_new_char");
-               buffer[length++] = c;
-               text ++;
+                       /* compare text of hashtable elements */
+                       for (i=0; i<length; i++)
+                               if (text[i] != u->text[i]) goto nomatch;
+                       
+#ifdef STATISTICS
+                       count_utf_new_found++;
+#endif
+                       /* symbol found in hashtable */                                 
+                       return u;
                }
-       return unicode_new_u2 (buffer, length);
-}
-
-
-/********************** Funktion: unicode_setclasslink ************************
-
-       H"angt einen Verweis auf eine Klasse an ein unicode-Symbol an.
+               nomatch:
+               u = u->hashlink; /* next element in external chain */
+       }
 
-******************************************************************************/
+#ifdef STATISTICS
+       count_utf_len += sizeof(utf) + length;
+#endif
 
-void unicode_setclasslink (unicode *u, classinfo *class)
-{
-       PANICIF (u->class, "Attempt to attach class to already attached symbol");
-       u->class = class;
-}
+       /* location in hashtable found, create new utf element */
+       u = NEW (utf);
+       u->blength  = length;             /* length in bytes of utfstring */
+       u->hashlink = utf_hash.ptr[slot]; /* link in external hashchain   */            
+       u->text     = mem_alloc(length);  /* allocate memory for utf-text */
+       memcpy(u->text,text,length);      /* copy utf-text                */
+       utf_hash.ptr[slot] = u;           /* insert symbol into table     */ 
 
-/********************** Funktion: unicode_getclasslink ************************
+       utf_hash.entries++;               /* update number of entries     */
 
-       Sucht den Verweis von einem unicode-Symbol auf eine Klasse.
-       Wenn keine solche Klasse existiert, dann wird ein Fehler
-       ausgegeben.
+       if ( utf_hash.entries > (utf_hash.size*2)) { 
 
-******************************************************************************/
+        /* reorganization of hashtable, average length of 
+           the external chains is approx. 2                */  
 
-classinfo *unicode_getclasslink (unicode *u)
-{
-       PANICIF (!u->class, "Attempt to get unknown class-reference");
-       return u->class;
-}
+         u4 i;
+         utf *u;
+         hashtable newhash; /* the new hashtable */
 
+         /* create new hashtable, double the size */
+         init_hashtable(&newhash, utf_hash.size*2);
+         newhash.entries=utf_hash.entries;
 
+#ifdef STATISTICS
+         count_utf_len += sizeof(utf*) * utf_hash.size;
+#endif
 
-/********************* Funktion: unicode_unlinkclass *************************
+         /* transfer elements to new hashtable */
+         for (i=0; i<utf_hash.size; i++) {
+               u = (utf*) utf_hash.ptr[i];
+               while (u) {
+                       utf *nextu = u -> hashlink;
+                       u4 slot = (utf_hashkey(u->text,u->blength)) & (newhash.size-1);
+                                               
+                       u->hashlink = (utf*) newhash.ptr[slot];
+                       newhash.ptr[slot] = u;
 
-       Entfernt den Verweis auf eine Klasse wieder von einem Symbol
+                       /* follow link in external hash chain */
+                       u = nextu;
+                       }
+               }
        
-******************************************************************************/
-
-void unicode_unlinkclass (unicode *u)
-{
-       PANICIF (!u->class, "Attempt to unlink not yet linked symbol");
-       u -> class = NULL;
-}
-
-
-
-/******************* Funktion> unicode_setstringlink *********************
-
-       H"angt einen Verweis auf einen konstanten String an ein 
-       Unicode-Symbol
+         /* dispose old table */
+         MFREE (utf_hash.ptr, void*, utf_hash.size);
+         utf_hash = newhash;
+       }
        
-*************************************************************************/
-
-void unicode_setstringlink (unicode *u, java_objectheader *str)
-{
-       PANICIF (u->string, "Attempt to attach string to already attached symbol");
-       u->string = str;
+       return u;
 }
 
 
-/********************* Funktion: unicode_unlinkstring *************************
+/********************* function: utf_new_char ********************************
+
+    creates a new utf symbol, the text for this symbol is passed
+    as a c-string ( = char* )
 
-       Entfernt den Verweis auf einen String wieder von einem Symbol
-       
 ******************************************************************************/
 
-void unicode_unlinkstring (unicode *u)
+utf *utf_new_char (char *text)
 {
-       PANICIF (!u->class, "Attempt to unlink not yet linked symbol");
-       u -> string = NULL;
+       return utf_new(text, strlen(text));
 }
 
+/************************** Funktion: utf_show ******************************
 
+    writes the utf symbols in the utfhash to stdout and
+    displays the number of external hash chains grouped 
+    according to the chainlength
+    (debugging purposes)
 
-/*********************** Funktion: unicode_show ******************************
-
-       gibt eine Aufstellung aller Symbol im unicode-hash auf stdout aus.
-       (nur f"ur Debug-Zwecke)
-       
 *****************************************************************************/
 
-void unicode_show ()
+void utf_show ()
 {
-       unicode *u;
+
+#define CHAIN_LIMIT 20               /* limit for seperated enumeration */
+
+       u4 chain_count[CHAIN_LIMIT]; /* numbers of chains */
+       u4 max_chainlength = 0;      /* maximum length of the chains */
+       u4 sum_chainlength = 0;      /* sum of the chainlengths */
+       u4 beyond_limit = 0;         /* number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
        u4 i;
 
-       printf ("UNICODE-HASH: %d slots for %d entries\n", 
-                (int) unicodehashsize, (int) unicodeentries );
-                 
-       for (i=0; i<unicodehashsize; i++) {
-               u = unicodehash[i];
+       printf ("UTF-HASH:\n");
+
+       /* show element of utf-hashtable */
+       for (i=0; i<utf_hash.size; i++) {
+               utf *u = utf_hash.ptr[i];
                if (u) {
                        printf ("SLOT %d: ", (int) i);
                        while (u) {
                                printf ("'");
-                               unicode_display (u);
+                               utf_display (u);
                                printf ("' ");
-                               if (u->string) printf ("(string)  ");
                                u = u->hashlink;
                                }       
                        printf ("\n");
                        }
                
                }
-}
+
+       printf ("UTF-HASH: %d slots for %d entries\n", 
+                (int) utf_hash.size, (int) utf_hash.entries );
+
+
+       if (utf_hash.entries == 0)
+               return;
+
+       printf("chains:\n  chainlength    number of chains    %% of utfstrings\n");
+
+       for (i=0;i<CHAIN_LIMIT;i++)
+               chain_count[i]=0;
+
+       /* count numbers of hashchains according to their length */
+       for (i=0; i<utf_hash.size; i++) {
+                 
+               utf *u = (utf*) utf_hash.ptr[i];
+               u4 chain_length = 0;
+
+               /* determine chainlength */
+               while (u) {
+                       u = u->hashlink;
+                       chain_length++;
+                       }
+
+               /* update sum of all chainlengths */
+               sum_chainlength+=chain_length;
+
+               /* determine the maximum length of the chains */
+               if (chain_length>max_chainlength)
+                       max_chainlength = chain_length;
+
+               /* update number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
+               if (chain_length>=CHAIN_LIMIT) {
+                       beyond_limit+=chain_length;
+                       chain_length=CHAIN_LIMIT-1;
+               }
+
+               /* update number of hashchains of current length */
+               chain_count[chain_length]++;
+               }
+
+       /* display results */  
+       for (i=1;i<CHAIN_LIMIT-1;i++) 
+               printf("       %2d %17d %18.2f%%\n",i,chain_count[i],(((float) chain_count[i]*i*100)/utf_hash.entries));
+         
+       printf("     >=%2d %17d %18.2f%%\n",CHAIN_LIMIT-1,chain_count[CHAIN_LIMIT-1],((float) beyond_limit*100)/utf_hash.entries);
 
 
+       printf("max. chainlength:%5d\n",max_chainlength);
+
+       /* avg. chainlength = sum of chainlengths / number of chains */
+       printf("avg. chainlength:%5.2f\n",(float) sum_chainlength / (utf_hash.size-chain_count[0]));
+}
 
 /******************************************************************************
 *********************** Diverse Support-Funktionen ****************************
@@ -622,17 +513,19 @@ void unicode_show ()
 
 
 /******************** Funktion: desc_to_type **********************************
-
-       Findet zu einem gegebenen Typdescriptor den entsprechenden 
-       Java-Grunddatentyp.
+   
+    Findet zu einem gegebenen Typdescriptor den entsprechenden 
+    Java-Grunddatentyp.
        
 ******************************************************************************/
 
-u2 desc_to_type (unicode *descriptor)
+u2 desc_to_type (utf *descriptor)
 {
-       if (descriptor->length < 1) panic ("Type-Descriptor is empty string");
+       char *utf_ptr = descriptor->text;  /* current position in utf text */
+
+       if (descriptor->blength < 1) panic ("Type-Descriptor is empty string");
        
-       switch (descriptor->text[0]) {
+       switch (*utf_ptr++) {
        case 'B': 
        case 'C':
        case 'I':
@@ -646,7 +539,7 @@ u2 desc_to_type (unicode *descriptor)
        }
                        
        sprintf (logtext, "Invalid Type-Descriptor: "); 
-       unicode_sprint (logtext+strlen(logtext), descriptor);
+       utf_sprint (logtext+strlen(logtext), descriptor);
        error (); 
        return 0;
 }
@@ -659,7 +552,7 @@ u2 desc_to_type (unicode *descriptor)
        
 ******************************************************************************/
 
-u2 desc_typesize (unicode *descriptor)
+u2 desc_typesize (utf *descriptor)
 {
        switch (desc_to_type(descriptor)) {
        case TYPE_INT:     return 4;
@@ -670,6 +563,252 @@ u2 desc_typesize (unicode *descriptor)
        default:           return 0;
        }
 }
+
+
+/********************** function: utf_nextu2 *********************************
+
+    read the next unicode character from the utf string and
+    increment the utf-string pointer accordingly
+
+******************************************************************************/
+
+u2 utf_nextu2(char **utf_ptr) 
+{
+    /* uncompressed unicode character */
+    u2 unicode_char;   
+    /* current position in utf text */ 
+    unsigned char *utf = (unsigned char *) (*utf_ptr);  
+    /* bytes representing the unicode character */
+    unsigned char ch1, ch2, ch3;
+    /* number of bytes used to represent the unicode character */
+    int len;           
+       
+    switch ((ch1 = utf[0]) >> 4) {
+      default: /* 1 byte */
+               (*utf_ptr)++;
+               return ch1;
+       case 0xC: 
+       case 0xD: /* 2 bytes */
+                 if (((ch2 = utf[1]) & 0xC0) == 0x80) {
+                   unsigned char high = ch1 & 0x1F;
+                   unsigned char low  = ch2 & 0x3F;
+                   unicode_char = (high << 6) + low;
+                   len = 2;
+                 } 
+                 break;
+
+       case 0xE: /* 2 or 3 bytes */
+                 if (((ch2 = utf[1]) & 0xC0) == 0x80) {
+                    if (((ch3 = utf[2]) & 0xC0) == 0x80) {
+                       unsigned char low  = ch3 & 0x3f;
+                       unsigned char mid  = ch2 & 0x3f;
+                       unsigned char high = ch1 & 0x0f;
+                       unicode_char = (((high << 6) + mid) << 6) + low;
+                       len = 3;
+                    } else
+                       len = 2;                                           
+                }
+                 break;
+    }
+
+    /* update position in utf-text */
+    *utf_ptr = (char *) (utf + len);
+    return unicode_char;
+}
+/******************** Funktion: class_new **************************************
+
+    searches for the class with the specified name in the classes hashtable,
+    if there is no such class a new classinfo structure is created and inserted
+    into the list of classes to be loaded
+
+*******************************************************************************/
+
+classinfo *class_new (utf *u)
+{
+       classinfo *c;     /* hashtable element */ 
+       u4 key;           /* hashkey computed from classname */   
+       u4 slot;          /* slot in hashtable */
+       u2 i;
+
+       key  = utf_hashkey (u->text, u->blength);
+       slot = key & (class_hash.size-1);
+       c    = class_hash.ptr[slot];
+
+       /* search external hash chain for the class */
+       while (c) {
+               if (c->name->blength == u->blength) {
+                       for (i=0; i<u->blength; i++) 
+                               if (u->text[i] != c->name->text[i]) goto nomatch;
+                                               
+                               /* class found in hashtable */                                                                  
+                               return c;
+                       }
+                       
+               nomatch:
+               c = c->hashlink; /* next element in external chain */
+               }
+
+       /* location in hashtable found, create new classinfo structure */
+
+#ifdef STATISTICS
+       count_class_infos += sizeof(classinfo);
+#endif
+
+       c = NEW (classinfo);
+       c -> flags = 0;
+       c -> name = u;
+       c -> cpcount = 0;
+       c -> cptags = NULL;
+       c -> cpinfos = NULL;
+       c -> super = NULL;
+       c -> sub = NULL;
+       c -> nextsub = NULL;
+       c -> interfacescount = 0;
+       c -> interfaces = NULL;
+       c -> fieldscount = 0;
+       c -> fields = NULL;
+       c -> methodscount = 0;
+       c -> methods = NULL;
+       c -> linked = false;
+       c -> index = 0;
+       c -> instancesize = 0;
+       c -> header.vftbl = NULL;
+       c -> innerclasscount = 0;
+       c -> innerclass = NULL;
+       c -> vftbl = NULL;
+       c -> initialized = false;
+       
+       /* prepare loading of the class */
+       list_addlast (&unloadedclasses, c);
+
+       /* insert class into the hashtable */
+       c->hashlink = class_hash.ptr[slot];
+       class_hash.ptr[slot] = c;
+
+       /* update number of hashtable-entries */
+       class_hash.entries++;
+
+       if ( class_hash.entries > (class_hash.size*2)) {  
+
+          /* reorganization of hashtable, average length of 
+             the external chains is approx. 2                */  
+
+         u4 i;
+         classinfo *c;
+         hashtable newhash;  /* the new hashtable */
+
+         /* create new hashtable, double the size */
+         init_hashtable(&newhash, class_hash.size*2);
+         newhash.entries = class_hash.entries;
+
+         /* transfer elements to new hashtable */
+         for (i=0; i<class_hash.size; i++) {
+               c = (classinfo*) class_hash.ptr[i];
+               while (c) {
+                       classinfo *nextc = c -> hashlink;
+                       u4 slot = (utf_hashkey(c->name->text,c->name->blength)) & (newhash.size-1);
+                                               
+                       c->hashlink = newhash.ptr[slot];
+                       newhash.ptr[slot] = c;
+
+                       c = nextc;
+                       }
+               }
+       
+         /* dispose old table */       
+         MFREE (class_hash.ptr, void*, class_hash.size);
+         class_hash = newhash;
+       }
+                       
+       return c;
+}
+
+/******************** Funktion: class_get **************************************
+
+    searches for the class with the specified name in the classes hashtable
+    if there is no such class NULL is returned
+
+*******************************************************************************/
+
+classinfo *class_get (utf *u)
+{
+       classinfo *c;  /* hashtable element */ 
+       u4 key;        /* hashkey computed from classname */   
+       u4 slot;       /* slot in hashtable */
+       u2 i;  
+
+       key  = utf_hashkey (u->text, u->blength);
+       slot = key & (class_hash.size-1);
+       c    = class_hash.ptr[slot];
+
+       /* search external hash-chain */
+       while (c) {
+               if (c->name->blength == u->blength) {
+                       
+                       /* compare classnames */
+                       for (i=0; i<u->blength; i++) 
+                               if (u->text[i] != c->name->text[i]) goto nomatch;
+
+                       /* class found in hashtable */                          
+                       return c;
+                       }
+                       
+               nomatch:
+               c = c->hashlink;
+               }
+
+       /* class not found */
+       return NULL;
+}
+
+
+/************************** function: utf_strlen ******************************
+
+    determine number of unicode characters in the utf string
+
+*******************************************************************************/
+
+u4 utf_strlen(utf *u) 
+{
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */
+    u4 len = 0;                         /* number of unicode characters   */
+
+    while (utf_ptr<endpos) {
+      len++;
+      /* next unicode character */
+      utf_nextu2(&utf_ptr);
+    }
+
+    if (utf_ptr!=endpos)
+       /* string ended abruptly */
+       panic("illegal utf string"); 
+
+    return len;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 
index 4726a3a295ae20f155053a6b8c430556cee27c35..8ae42bcf457bc775e5348352972e4cc1e66cd89d 100644 (file)
 
 #include "global.h" /* for unicode. -- phil */
 
-extern bool collectverbose;
+#define CLASS(name)     (unicode_getclasslink(unicode_new_char(name)))
 
+/* to determine the end of utf strings */
+#define utf_end(utf) ((char *) utf->text+utf->blength)
 
-#define CLASS(name)     (unicode_getclasslink(unicode_new_char(name)))
+/* switches for debug messages */
+extern bool collectverbose;
+extern list unloadedclasses;
 
+/* function for disposing javastrings */
 typedef void (*stringdeleter) ( java_objectheader *string );
+    
+/* creates hashtables for symboltables */
+void tables_init ();
+
+/* free memory for hashtables */ 
+void tables_close (stringdeleter del);
+
+/* write utf symbol to file/buffer */
+void utf_sprint (char *buffer, utf *u);
+void utf_fprint (FILE *file, utf *u);
+void utf_display (utf *u);
+
+/* create new utf-symbol */
+utf *utf_new (char *text, u2 length);
+utf *utf_new_char (char *text);
+
+/* show utf-table */
+void utf_show ();
+
+/* get next unicode character of a utf-string */
+u2 utf_nextu2(char **utf);
+
+/* get number of unicode characters of a utf string */
+u4 utf_strlen(utf *u);
 
+/* search for class and create it if not found */
+classinfo *class_new (utf *u);
 
-void suck_init (char *classpath);
-bool suck_start (unicode *name);
-void suck_stop ();
-void suck_nbytes (u1 *buffer, u4 len);
-void skip_nbytes (u4 len);
-u1 suck_u1 ();
-s1 suck_s1 ();
-u2 suck_u2 ();
-s2 suck_s2 ();
-u4 suck_u4 ();
-s4 suck_s4 ();
-u8 suck_u8 ();
-s8 suck_s8 ();
-float suck_float ();
-double suck_double ();
-
-
-void unicode_init ();
-void unicode_close (stringdeleter del);
-void unicode_display (unicode *u);
-void unicode_sprint (char *buffer, unicode *u);
-void unicode_fprint (FILE *file, unicode *u);
-unicode *unicode_new_u2 (u2 *text, u2 length);
-unicode *unicode_new_char (char *text);
-void unicode_setclasslink (unicode *u, classinfo *class);
-classinfo *unicode_getclasslink (unicode *u);
-void unicode_unlinkclass (unicode *u);
-void unicode_setstringlink (unicode *u, java_objectheader *str);
-void unicode_unlinkstring (unicode *u);
-void unicode_show ();
-
-u2 desc_to_type (unicode *descriptor);
-u2 desc_typesize (unicode *descriptor);
+/* get javatype according to a typedescriptor */
+u2 desc_to_type (utf *descriptor);
+
+/* get length of a datatype */
+u2 desc_typesize (utf *descriptor);
+
+/* determine hashkey of a unicode-symbol */
+u4 unicode_hashkey (u2 *text, u2 length);
+
+/* create hashtable */
+void init_hashtable(hashtable *hash, u4 size);
+
+/* search for class in classtable */
+classinfo *class_get (utf *u);
 
 
 void heap_init (u4 size, u4 startsize, void **stackbottom);
@@ -63,3 +75,8 @@ void heap_addreference (void **reflocation);
 void gc_init (void);
 void gc_thread (void);
 void gc_call (void);
+
+
+
+
+
index 48103bee3b6b5db2d5ac74854066bb4730bbe21f..8797971aacf2849963412267cadbc398ffa2d337 100644 (file)
--- a/tables.c
+++ b/tables.c
@@ -14,7 +14,7 @@
        Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
        Changes: Mark Probst         EMAIL: cacao@complang.tuwien.ac.at
                 Andreas  Krall      EMAIL: cacao@complang.tuwien.ac.at
-
+                       
        Last Change: 1998/03/24
 
 *******************************************************************************/
 #include "threads/thread.h"                  /* schani */
 #include "threads/locks.h"
 
-
 bool runverbose = false;
 
-int count_unicode_len = 0;
+/* statistics */
+int count_utf_len = 0;         /* size of utf hash                  */
+int count_utf_new = 0;         /* calls of utf_new                  */
+int count_utf_new_found  = 0;  /* calls of utf_new with fast return */
 
+hashtable utf_hash;     /* hashtable for utf8-symbols */
+hashtable string_hash;  /* hashtable for javastrings  */
+hashtable class_hash;   /* hashtable for classes      */
 
 /******************************************************************************
-************************* Der Dateien-Sauger **********************************
-*******************************************************************************
-
-       dient zum Behandeln von Java-ClassFiles ("offnen, schlie"sen, 
-       einlesen von 8-, 16-, 32-, 64-bit Integers und 32-, 64- bit Floats)
-
-******************************************************************************/
-
-static FILE *classfile = NULL;   /* File-handle der gerade gelesenen Datei */
-static char *classpath = "";     /* Suchpfad f"ur die ClassFiles */
+ *********************** hashtable functions **********************************
+ ******************************************************************************/
 
+/* hashsize must be power of 2 */
 
+#define UTF_HASHSTART   16384   /* initial size of utf-hash */    
+#define HASHSTART        2048   /* initial size of javastring and class-hash */
 
-/************************** Funktion: suck_init ******************************
 
-       Wird zu Programmstart einmal aufgerufen und setzt den Suchpfad f"ur
-       Klassenfiles
-
-******************************************************************************/
-
-void suck_init (char *cpath)
-{
-       classfile = NULL;
-       classpath = cpath;
-}
+/******************** function: init_hashtable ******************************
 
-
-/************************** Funktion: suck_start ******************************
-
-       "Offnet die Datei f"ur die Klasse des gegebenen Namens zum Lesen.
-       Dabei werden alle im Suchpfad angegebenen Verzeichnisse durchsucht,
-       bis eine entsprechende Datei  ( <classname>.class) gefunden wird. 
+    Initializes a hashtable structure and allocates memory.
+    The parameter size specifies the initial size of the hashtable.
        
-******************************************************************************/
-
-bool suck_start (unicode *classname)
-{
-#define MAXFILENAME 1000          /* Maximale Langes des Dateinamens plus Pfad */
-
-       char filename[MAXFILENAME+10];   /* Platz fuer '.class' */
-       u2 filenamelen;
-       char *pathpos;
-       u2 i,c;
-
-
-       pathpos = classpath;
-
-       while (*pathpos) {
-               while ( *pathpos == ':' ) pathpos++;
-               filenamelen=0;
-               while ( (*pathpos) && (*pathpos!=':') ) {
-                   PANICIF (filenamelen >= MAXFILENAME, "Filename too long") ;
-                       
-                       filename[filenamelen++] = *(pathpos++);
-                       }
-
-               filename[filenamelen++] = '/';
-   
-               for (i=0; i < classname -> length; i++) {
-                       PANICIF (filenamelen >= MAXFILENAME, "Filename too long");
-                       
-                       c = classname -> text [i];
-                       if (c=='/') c = '/';     /* Slashes im Namen passen zu UNIX */
-                       else {
-                               if ( c<=' ' || c>'z') {
-                                       c = '?';
-                                       }
-                               }
-                       
-                       filename[filenamelen++] = c;    
-                       }
-      
-               strcpy (filename+filenamelen, ".class");
-
-               classfile = fopen(filename, "r");
-               if (classfile) {
-                       return true;
-                       }
-
-               
-               }
-                  
-       sprintf (logtext,"Can not open class file '%s'", filename);
-       error();
-       return false;
-}
-
-
-/************************** Funktion: suck_stop *******************************
-
-       Schlie"st die offene Datei wieder.
-       
-******************************************************************************/
-
-void suck_stop ()
-{
-       u4 rest=0;
-       u1 dummy;
-       
-       while ( fread (&dummy, 1,1, classfile) > 0) rest++;
-       if (rest) {
-               sprintf (logtext,"There are %d access bytes at end of classfile",
-                                (int) rest);
-               dolog();
-               }
-                       
-       fclose (classfile);
-       classfile = NULL;
-}
-      
-
-
-/************************** Lesefunktionen ***********************************
-
-       Lesen von der Datei in verschieden grossen Paketen
-       (8,16,32,64-bit Integer oder Float)
-
 *****************************************************************************/
 
-void suck_nbytes (u1 *buffer, u4 len)
-{
-       if ( fread (buffer, 1, len, classfile) != len) panic ("Unexpected EOF");
-}
-
-
-void skip_nbytes (u4 len)
+void init_hashtable(hashtable *hash, u4 size)
 {
        u4 i;
-       for (i=0; i<len; i++) suck_u1 ();
-}
-
-
-u1 suck_u1 ()
-{
-       u1 b;
-       if ( fread (&b, 1,1, classfile) != 1) panic ("Unexpected EOF");
-       return b;
-}
-
-s1 suck_s1 ()
-{
-       s1 b;
-       if ( fread (&b, 1,1, classfile) != 1) panic ("Unexpected EOF");
-       return b;
-}
 
+       hash->entries = 0;
+       hash->size    = size;
+       hash->ptr     = MNEW (void*, size);
 
-u2 suck_u2 ()
-{
-       u1 b[2];
-       if ( fread (b, 1,2, classfile) != 2) panic ("Unexpected EOF");
-       return (b[0]<<8) + b[1];
-}
-
-s2 suck_s2 ()
-{
-       return suck_u2 ();
-}
-
-
-u4 suck_u4 ()
-{
-       u1 b[4];
-       u4 v;
-       if ( fread (b, 1,4, classfile) != 4) panic ("Unexpected EOF");
-       v = ( ((u4)b[0]) <<24) + ( ((u4)b[1])<<16) + ( ((u4)b[2])<<8) + ((u4)b[3]);
-       return v;
-}
-
-s4 suck_s4 ()
-{
-       s4 v = suck_u4 ();
-       return v;
+       /* clear table */
+       for (i=0; i<size; i++) hash->ptr[i] = NULL;
 }
 
-u8 suck_u8 ()
-{
-#if U8_AVAILABLE
-       u8 lo,hi;
-       hi = suck_u4();
-       lo = suck_u4();
-       return (hi<<32) + lo;
-#else
-       u8 v;
-       v.high = suck_u4();
-       v.low = suck_u4();
-       return v;
-#endif
-}
+/*********************** function: tables_init  *****************************
 
-s8 suck_s8 ()
-{
-       return suck_u8 ();
-}
-       
-
-float suck_float ()
-{
-       float f;
-
-#if !WORDS_BIGENDIAN 
-               u1 buffer[4];
-               u2 i;
-               for (i=0; i<4; i++) buffer[3-i] = suck_u1 ();
-               memcpy ( (u1*) (&f), buffer, 4);
-#else 
-               suck_nbytes ( (u1*) (&f), 4 );
-#endif
-
-       PANICIF (sizeof(float) != 4, "Incompatible float-format");
-       
-       return f;
-}
-
-
-double suck_double ()
-{
-       double d;
-
-#if !WORDS_BIGENDIAN 
-               u1 buffer[8];
-               u2 i;   
-               for (i=0; i<8; i++) buffer[7-i] = suck_u1 ();
-               memcpy ( (u1*) (&d), buffer, 8);
-#else 
-               suck_nbytes ( (u1*) (&d), 8 );
-#endif
-
-       PANICIF (sizeof(double) != 8, "Incompatible double-format" );
-       
-       return d;
-}
-
-
-
-
-/******************************************************************************
-******************** Der Unicode-Symbol-Verwalter *****************************
-*******************************************************************************
-
-       legt eine Hashtabelle f"ur unicode-Symbole an und verwaltet
-       das Eintragen neuer Symbole
-       
-******************************************************************************/
-
-
-
-#define UNICODESTART  2187      /* Startgr"osse: moeglichst gross und prim */
-
-static u4 unicodeentries;       /* Anzahl der Eintr"age in der Tabelle */
-static u4 unicodehashsize;      /* Gr"osse der Tabelle */
-static unicode ** unicodehash;  /* Zeiger auf die Tabelle selbst */
-
-
-/*********************** Funktion: unicode_init ******************************
-
-       Initialisiert die unicode-Symboltabelle (muss zu Systemstart einmal
-       aufgerufen werden)
+    creates hashtables for symboltables 
+       (called once at startup)                         
        
 *****************************************************************************/
 
-void unicode_init ()
+void tables_init ()
 {
-       u4 i;
+       init_hashtable(&utf_hash,    UTF_HASHSTART);  /* hashtable for utf8-symbols */
+       init_hashtable(&string_hash, HASHSTART);      /* hashtable for javastrings */
+       init_hashtable(&class_hash,  HASHSTART);      /* hashtable for classes */ 
        
 #ifdef STATISTICS
-       count_unicode_len += sizeof(unicode*) * unicodehashsize;
+       count_utf_len += sizeof(utf*) * utf_hash.size;
 #endif
 
-       unicodeentries = 0;
-       unicodehashsize = UNICODESTART;
-       unicodehash = MNEW (unicode*, unicodehashsize);
-       for (i=0; i<unicodehashsize; i++) unicodehash[i] = NULL;
 }
 
+/********************** function: tables_close ******************************
 
-/*********************** Funktion: unicode_close *****************************
-
-       Gibt allen Speicher der Symboltabellen frei.
-       Parameter: Ein Zeiger auf eine Funktion, die dazu n"otig ist, 
-                  Stringkonstanten (die mit 'unicode_setstringlink' 
-                  Unicode-Symbole gebunden wurden) wieder freizugeben
+        free memory for hashtables                   
        
 *****************************************************************************/
 
-void unicode_close (stringdeleter del)
+void tables_close (stringdeleter del)
 {
-       unicode *u;
+       utf *u; 
+       literalstring *s;
        u4 i;
        
-       for (i=0; i<unicodehashsize; i++) {
-               u = unicodehash[i];
+       /* dispose utf symbols */
+       for (i=0; i<utf_hash.size; i++) {
+       u = utf_hash.ptr[i];
                while (u) {
-                       unicode *nextu = u->hashlink;
-
-                       if (u->string) del (u->string);
-                       
-                       MFREE (u->text, u2, u->length);
-                       FREE (u, unicode);
+                       /* process elements in external hash chain */
+                       utf *nextu = u->hashlink;
+                       MFREE (u->text, u1, u->blength);
+                       FREE (u, utf);
                        u = nextu;
                        }       
                }
-       MFREE (unicodehash, unicode*, unicodehashsize);
+
+       /* dispose javastrings */
+       for (i=0; i<string_hash.size; i++) {
+               s = string_hash.ptr[i];
+               while (u) {
+                       /* process elements in external hash chain */
+                       literalstring *nexts = s->hashlink;
+                       del(s->string);
+                       FREE(s, literalstring);
+                       s = nexts;
+                       }       
+               }
+
+       /* dispose hashtable structures */
+       MFREE (utf_hash.ptr,    void*, utf_hash.size);
+       MFREE (string_hash.ptr, void*, string_hash.size);
+       MFREE (class_hash.ptr,  void*, class_hash.size);
 }
 
+/********************* function: utf_display *********************************
 
-/********************* Funktion: unicode_display ******************************
-       
-       Gibt ein unicode-Symbol auf stdout aus (zu Debugzwecken)
+       write utf symbol to stdout (debugging purposes)
 
 ******************************************************************************/
 
-void unicode_display (unicode *u)
+void utf_display (utf *u)
 {
-       u2 i,c;
-       for (i=0; i < u->length; i++) {
-               c = u->text[i];
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */
+
+    while (utf_ptr<endpos) {
+
+               /* read next unicode character */                
+               u2 c = utf_nextu2(&utf_ptr);                            
                if (c>=32 && c<=127) printf ("%c",c);
                                else printf ("?");
-               }
+       }
+
        fflush (stdout);
 }
 
-
-/********************* Funktion: unicode_sprint ******************************
+/************************ function: utf_sprint *******************************
        
-       Schreibt ein unicode-Symbol in einen C-String
+    write utf symbol into c-string (debugging purposes)                                                 
 
 ******************************************************************************/ 
 
-void unicode_sprint (char *buffer, unicode *u)
+void utf_sprint (char *buffer, utf *u)
 {
-       u2 i;
-       for (i=0; i < u->length; i++) buffer[i] = u->text[i];
-       buffer[i] = '\0';
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */ 
+    u2 pos = 0;                  /* position in c-string           */
+
+    while (utf_ptr<endpos) 
+               /* copy next unicode character */       
+               buffer[pos++] = utf_nextu2(&utf_ptr);
+
+    /* terminate string */
+    buffer[pos] = '\0';
 }
 
 
-/********************* Funktion: unicode_fprint ******************************
+/********************* Funktion: utf_fprint **********************************
        
-       Schreibt ein unicode-Symbol auf eine Datei aus
+    write utf symbol into file         
 
 ******************************************************************************/ 
 
-void unicode_fprint (FILE *file, unicode *u)
+void utf_fprint (FILE *file, utf *u)
 {
-       u2 i;
-       for (i=0; i < u->length; i++) putc (u->text[i], file);
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */ 
+
+    while (utf_ptr<endpos) 
+               /* write next unicode character */       
+               putc ( utf_nextu2(&utf_ptr), file );
 } 
 
 
-/****************** interne Funktion: u_hashkey ******************************/
+/****************** internal function: utf_hashkey ***************************
 
-static u4 u_hashkey (u2 *text, u2 length)
-{
-       u4 k = 0;
-       u2 i,sh=0;
-       
-       for (i=0; i<length; i++) {
-               k ^=  ( ((u4) (text[i])) << sh );
-               if (sh<16) sh++;
-                    else  sh=0;
-               }
-               
-       return k;
-}
+       The hashkey is computed from the utf-text by using up to 8 characters.
+       For utf-symbols longer than 15 characters 3 characters are taken from
+       the beginning and the end, 2 characters are taken from the middle.
 
-/*************** interne Funktion: u_reorganizehash **************************/
+******************************************************************************/ 
 
-static void u_reorganizehash ()
-{
-       u4 i;
-       unicode *u;
+#define nbs(val) ((u4) *(++text) << val) /* get next byte, left shift by val  */
+#define fbs(val) ((u4) *(  text) << val) /* get first byte, left shift by val */
+
+static u4 utf_hashkey (char *text, u4 length)
+{
+       char *start_pos = text; /* pointer to utf text */
+       u4 a;
+
+       switch (length) {               
+               
+       case 0: /* empty string */
+               return 0;
+
+       case 1: return fbs(0);
+       case 2: return fbs(0) ^ nbs(3);
+       case 3: return fbs(0) ^ nbs(3) ^ nbs(5);
+       case 4: return fbs(0) ^ nbs(2) ^ nbs(4) ^ nbs(6);
+       case 5: return fbs(0) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(6);
+       case 6: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(5) ^ nbs(6);
+       case 7: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6);
+       case 8: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7);
+
+       case 9: a = fbs(0) ^ nbs(1) ^ nbs(2);                
+                text++; 
+                return a ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7) ^ nbs(8);
+
+       case 10: a = fbs(0);
+                 text++;
+                 a^= nbs(2) ^ nbs(3) ^ nbs(4);
+                 text++;
+                 return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9);
+
+       case 11: a = fbs(0);
+                 text++;
+                 a^= nbs(2) ^ nbs(3) ^ nbs(4);
+                 text++;
+                 return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9) ^ nbs(10);
+
+       case 12: a = fbs(0);
+                 text+=2;
+                 a^= nbs(2) ^ nbs(3);
+                 text+=1;
+                 a^= nbs(5) ^ nbs(6) ^ nbs(7);
+                 text+=1;
+                 return a ^ nbs(9) ^ nbs(10);     
+
+       case 13: a = fbs(0) ^ nbs(1);
+                 text+=1;      
+                 a^= nbs(3) ^ nbs(4);
+                 text+=2;      
+                 a^= nbs(7) ^ nbs(8);
+                 text+=2;
+                 return a ^ nbs(9) ^ nbs(10);
+
+       case 14: a = fbs(0);
+                 text+=2;      
+                 a^= nbs(3) ^ nbs(4);
+                 text+=2;      
+                 a^= nbs(7) ^ nbs(8);
+                 text+=2;
+                 return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
+
+       case 15: a = fbs(0);
+                 text+=2;      
+                 a^= nbs(3) ^ nbs(4);
+                 text+=2;      
+                 a^= nbs(7) ^ nbs(8);
+                 text+=2;
+                 return a ^ nbs(9) ^ nbs(10) ^ nbs(11);
+
+       default:  /* 3 characters from beginning */
+                  a = fbs(0);
+                  text+=2;
+                  a^= nbs(3) ^ nbs(4);
+
+                  /* 2 characters from middle */
+                  text = start_pos + (length / 2);
+                  a^= fbs(5);
+                  text+=2;
+                  a^= nbs(6);  
+
+                  /* 3 characters from end */
+                  text = start_pos + length - 4;
+
+                  a^= fbs(7);
+                  text+=1;
+
+                  return a ^ nbs(10) ^ nbs(11);
+    }
+}
 
-       u4 newhashsize = unicodehashsize*2;
-       unicode **newhash = MNEW (unicode*, newhashsize);
 
-#ifdef STATISTICS
-       count_unicode_len += sizeof(unicode*) * unicodehashsize;
-#endif
+/*************************** function: utf_hashkey ***************************
 
-       for (i=0; i<newhashsize; i++) newhash[i] = NULL;
+    compute the hashkey of a unicode string
 
-       for (i=0; i<unicodehashsize; i++) {
-               u = unicodehash[i];
-               while (u) {
-                       unicode *nextu = u -> hashlink;
-                       u4 slot = (u->key) % newhashsize;
-                                               
-                       u->hashlink = newhash[slot];
-                       newhash[slot] = u;
+******************************************************************************/ 
 
-                       u = nextu;
-                       }
-               }
-       
-       MFREE (unicodehash, unicode*, unicodehashsize);
-       unicodehash = newhash;
-       unicodehashsize = newhashsize;
+u4 unicode_hashkey (u2 *text, u2 len)
+{
+       utf_hashkey((char*) text, len);
 }
 
+/************************ function: utf_new **********************************
 
-/****************** Funktion: unicode_new_u2 **********************************
+       Creates a new utf-symbol, the text of the symbol is passed as a 
+       u1-array. The function searches the utf-hashtable for a utf-symbol 
+       with this text. On success the element returned, otherwise a new 
+       hashtable element is created.
 
-       Legt ein neues unicode-Symbol an. Der Text des Symbols wird dieser
-       Funktion als u2-Array "ubergeben
+       If the number of entries in the hashtable exceeds twice the size of the
+       hashtable slots a reorganization of the hashtable is done and the utf 
+       symbols are copied to a new hashtable with doubled size.
 
 ******************************************************************************/
 
-unicode *unicode_new_u2 (u2 *text, u2 length)
+utf *utf_new (char *text, u2 length)
 {
-       u4 key = u_hashkey (text, length);
-       u4 slot = key % unicodehashsize;
-       unicode *u = unicodehash[slot];
+       u4 key;            /* hashkey computed from utf-text */
+       u4 slot;           /* slot in hashtable */
+       utf *u;            /* hashtable element */
        u2 i;
-
-       while (u) {
-               if (u->key == key) {
-                       if (u->length == length) {
-                               for (i=0; i<length; i++) {
-                                       if (text[i] != u->text[i]) goto nomatch;
-                                       }       
-                                       return u;
-                               }
-                       }
-               nomatch:
-               u = u->hashlink;
-               }
-
+       
 #ifdef STATISTICS
-       count_unicode_len += sizeof(unicode) + 2 * length;
+       count_utf_new++;
 #endif
 
-       u = NEW (unicode);
-       u->key = key;
-       u->length = length;
-       u->text = MNEW (u2, length);
-       u->class = NULL;
-       u->string = NULL;
-       u->hashlink = unicodehash[slot];
-       unicodehash[slot] = u;
-       for (i=0; i<length; i++) u->text[i] = text[i];
-
-       unicodeentries++;
-       
-       if ( unicodeentries > (unicodehashsize/2)) u_reorganizehash();
-       
-       return u;
-}
-
-
-/********************* Funktion: unicode_new_char *****************************
+       key  = utf_hashkey (text, length);
+       slot = key & (utf_hash.size-1);
+       u    = utf_hash.ptr[slot];
 
-       Legt ein neues unicode-Symbol an. Der Text des Symbols wird dieser
-       Funktion als C-String ( = char* ) "ubergeben
-
-******************************************************************************/
+       /* search external hash chain for utf-symbol */
+       while (u) {
+               if (u->blength == length) {
 
-unicode *unicode_new_char (char *text)
-{
-#define MAXNEWCHAR 500
-       u2 buffer[MAXNEWCHAR];
-       u2 length = 0;
-       u1 c;
-       
-       while ( (c = *text) != '\0' ) {
-               if (length>=MAXNEWCHAR) panic ("Text too long in unicode_new_char");
-               buffer[length++] = c;
-               text ++;
+                       /* compare text of hashtable elements */
+                       for (i=0; i<length; i++)
+                               if (text[i] != u->text[i]) goto nomatch;
+                       
+#ifdef STATISTICS
+                       count_utf_new_found++;
+#endif
+                       /* symbol found in hashtable */                                 
+                       return u;
                }
-       return unicode_new_u2 (buffer, length);
-}
-
-
-/********************** Funktion: unicode_setclasslink ************************
-
-       H"angt einen Verweis auf eine Klasse an ein unicode-Symbol an.
+               nomatch:
+               u = u->hashlink; /* next element in external chain */
+       }
 
-******************************************************************************/
+#ifdef STATISTICS
+       count_utf_len += sizeof(utf) + length;
+#endif
 
-void unicode_setclasslink (unicode *u, classinfo *class)
-{
-       PANICIF (u->class, "Attempt to attach class to already attached symbol");
-       u->class = class;
-}
+       /* location in hashtable found, create new utf element */
+       u = NEW (utf);
+       u->blength  = length;             /* length in bytes of utfstring */
+       u->hashlink = utf_hash.ptr[slot]; /* link in external hashchain   */            
+       u->text     = mem_alloc(length);  /* allocate memory for utf-text */
+       memcpy(u->text,text,length);      /* copy utf-text                */
+       utf_hash.ptr[slot] = u;           /* insert symbol into table     */ 
 
-/********************** Funktion: unicode_getclasslink ************************
+       utf_hash.entries++;               /* update number of entries     */
 
-       Sucht den Verweis von einem unicode-Symbol auf eine Klasse.
-       Wenn keine solche Klasse existiert, dann wird ein Fehler
-       ausgegeben.
+       if ( utf_hash.entries > (utf_hash.size*2)) { 
 
-******************************************************************************/
+        /* reorganization of hashtable, average length of 
+           the external chains is approx. 2                */  
 
-classinfo *unicode_getclasslink (unicode *u)
-{
-       PANICIF (!u->class, "Attempt to get unknown class-reference");
-       return u->class;
-}
+         u4 i;
+         utf *u;
+         hashtable newhash; /* the new hashtable */
 
+         /* create new hashtable, double the size */
+         init_hashtable(&newhash, utf_hash.size*2);
+         newhash.entries=utf_hash.entries;
 
+#ifdef STATISTICS
+         count_utf_len += sizeof(utf*) * utf_hash.size;
+#endif
 
-/********************* Funktion: unicode_unlinkclass *************************
+         /* transfer elements to new hashtable */
+         for (i=0; i<utf_hash.size; i++) {
+               u = (utf*) utf_hash.ptr[i];
+               while (u) {
+                       utf *nextu = u -> hashlink;
+                       u4 slot = (utf_hashkey(u->text,u->blength)) & (newhash.size-1);
+                                               
+                       u->hashlink = (utf*) newhash.ptr[slot];
+                       newhash.ptr[slot] = u;
 
-       Entfernt den Verweis auf eine Klasse wieder von einem Symbol
+                       /* follow link in external hash chain */
+                       u = nextu;
+                       }
+               }
        
-******************************************************************************/
-
-void unicode_unlinkclass (unicode *u)
-{
-       PANICIF (!u->class, "Attempt to unlink not yet linked symbol");
-       u -> class = NULL;
-}
-
-
-
-/******************* Funktion> unicode_setstringlink *********************
-
-       H"angt einen Verweis auf einen konstanten String an ein 
-       Unicode-Symbol
+         /* dispose old table */
+         MFREE (utf_hash.ptr, void*, utf_hash.size);
+         utf_hash = newhash;
+       }
        
-*************************************************************************/
-
-void unicode_setstringlink (unicode *u, java_objectheader *str)
-{
-       PANICIF (u->string, "Attempt to attach string to already attached symbol");
-       u->string = str;
+       return u;
 }
 
 
-/********************* Funktion: unicode_unlinkstring *************************
+/********************* function: utf_new_char ********************************
+
+    creates a new utf symbol, the text for this symbol is passed
+    as a c-string ( = char* )
 
-       Entfernt den Verweis auf einen String wieder von einem Symbol
-       
 ******************************************************************************/
 
-void unicode_unlinkstring (unicode *u)
+utf *utf_new_char (char *text)
 {
-       PANICIF (!u->class, "Attempt to unlink not yet linked symbol");
-       u -> string = NULL;
+       return utf_new(text, strlen(text));
 }
 
+/************************** Funktion: utf_show ******************************
 
+    writes the utf symbols in the utfhash to stdout and
+    displays the number of external hash chains grouped 
+    according to the chainlength
+    (debugging purposes)
 
-/*********************** Funktion: unicode_show ******************************
-
-       gibt eine Aufstellung aller Symbol im unicode-hash auf stdout aus.
-       (nur f"ur Debug-Zwecke)
-       
 *****************************************************************************/
 
-void unicode_show ()
+void utf_show ()
 {
-       unicode *u;
+
+#define CHAIN_LIMIT 20               /* limit for seperated enumeration */
+
+       u4 chain_count[CHAIN_LIMIT]; /* numbers of chains */
+       u4 max_chainlength = 0;      /* maximum length of the chains */
+       u4 sum_chainlength = 0;      /* sum of the chainlengths */
+       u4 beyond_limit = 0;         /* number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
        u4 i;
 
-       printf ("UNICODE-HASH: %d slots for %d entries\n", 
-                (int) unicodehashsize, (int) unicodeentries );
-                 
-       for (i=0; i<unicodehashsize; i++) {
-               u = unicodehash[i];
+       printf ("UTF-HASH:\n");
+
+       /* show element of utf-hashtable */
+       for (i=0; i<utf_hash.size; i++) {
+               utf *u = utf_hash.ptr[i];
                if (u) {
                        printf ("SLOT %d: ", (int) i);
                        while (u) {
                                printf ("'");
-                               unicode_display (u);
+                               utf_display (u);
                                printf ("' ");
-                               if (u->string) printf ("(string)  ");
                                u = u->hashlink;
                                }       
                        printf ("\n");
                        }
                
                }
-}
+
+       printf ("UTF-HASH: %d slots for %d entries\n", 
+                (int) utf_hash.size, (int) utf_hash.entries );
+
+
+       if (utf_hash.entries == 0)
+               return;
+
+       printf("chains:\n  chainlength    number of chains    %% of utfstrings\n");
+
+       for (i=0;i<CHAIN_LIMIT;i++)
+               chain_count[i]=0;
+
+       /* count numbers of hashchains according to their length */
+       for (i=0; i<utf_hash.size; i++) {
+                 
+               utf *u = (utf*) utf_hash.ptr[i];
+               u4 chain_length = 0;
+
+               /* determine chainlength */
+               while (u) {
+                       u = u->hashlink;
+                       chain_length++;
+                       }
+
+               /* update sum of all chainlengths */
+               sum_chainlength+=chain_length;
+
+               /* determine the maximum length of the chains */
+               if (chain_length>max_chainlength)
+                       max_chainlength = chain_length;
+
+               /* update number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */
+               if (chain_length>=CHAIN_LIMIT) {
+                       beyond_limit+=chain_length;
+                       chain_length=CHAIN_LIMIT-1;
+               }
+
+               /* update number of hashchains of current length */
+               chain_count[chain_length]++;
+               }
+
+       /* display results */  
+       for (i=1;i<CHAIN_LIMIT-1;i++) 
+               printf("       %2d %17d %18.2f%%\n",i,chain_count[i],(((float) chain_count[i]*i*100)/utf_hash.entries));
+         
+       printf("     >=%2d %17d %18.2f%%\n",CHAIN_LIMIT-1,chain_count[CHAIN_LIMIT-1],((float) beyond_limit*100)/utf_hash.entries);
 
 
+       printf("max. chainlength:%5d\n",max_chainlength);
+
+       /* avg. chainlength = sum of chainlengths / number of chains */
+       printf("avg. chainlength:%5.2f\n",(float) sum_chainlength / (utf_hash.size-chain_count[0]));
+}
 
 /******************************************************************************
 *********************** Diverse Support-Funktionen ****************************
@@ -622,17 +513,19 @@ void unicode_show ()
 
 
 /******************** Funktion: desc_to_type **********************************
-
-       Findet zu einem gegebenen Typdescriptor den entsprechenden 
-       Java-Grunddatentyp.
+   
+    Findet zu einem gegebenen Typdescriptor den entsprechenden 
+    Java-Grunddatentyp.
        
 ******************************************************************************/
 
-u2 desc_to_type (unicode *descriptor)
+u2 desc_to_type (utf *descriptor)
 {
-       if (descriptor->length < 1) panic ("Type-Descriptor is empty string");
+       char *utf_ptr = descriptor->text;  /* current position in utf text */
+
+       if (descriptor->blength < 1) panic ("Type-Descriptor is empty string");
        
-       switch (descriptor->text[0]) {
+       switch (*utf_ptr++) {
        case 'B': 
        case 'C':
        case 'I':
@@ -646,7 +539,7 @@ u2 desc_to_type (unicode *descriptor)
        }
                        
        sprintf (logtext, "Invalid Type-Descriptor: "); 
-       unicode_sprint (logtext+strlen(logtext), descriptor);
+       utf_sprint (logtext+strlen(logtext), descriptor);
        error (); 
        return 0;
 }
@@ -659,7 +552,7 @@ u2 desc_to_type (unicode *descriptor)
        
 ******************************************************************************/
 
-u2 desc_typesize (unicode *descriptor)
+u2 desc_typesize (utf *descriptor)
 {
        switch (desc_to_type(descriptor)) {
        case TYPE_INT:     return 4;
@@ -670,6 +563,252 @@ u2 desc_typesize (unicode *descriptor)
        default:           return 0;
        }
 }
+
+
+/********************** function: utf_nextu2 *********************************
+
+    read the next unicode character from the utf string and
+    increment the utf-string pointer accordingly
+
+******************************************************************************/
+
+u2 utf_nextu2(char **utf_ptr) 
+{
+    /* uncompressed unicode character */
+    u2 unicode_char;   
+    /* current position in utf text */ 
+    unsigned char *utf = (unsigned char *) (*utf_ptr);  
+    /* bytes representing the unicode character */
+    unsigned char ch1, ch2, ch3;
+    /* number of bytes used to represent the unicode character */
+    int len;           
+       
+    switch ((ch1 = utf[0]) >> 4) {
+      default: /* 1 byte */
+               (*utf_ptr)++;
+               return ch1;
+       case 0xC: 
+       case 0xD: /* 2 bytes */
+                 if (((ch2 = utf[1]) & 0xC0) == 0x80) {
+                   unsigned char high = ch1 & 0x1F;
+                   unsigned char low  = ch2 & 0x3F;
+                   unicode_char = (high << 6) + low;
+                   len = 2;
+                 } 
+                 break;
+
+       case 0xE: /* 2 or 3 bytes */
+                 if (((ch2 = utf[1]) & 0xC0) == 0x80) {
+                    if (((ch3 = utf[2]) & 0xC0) == 0x80) {
+                       unsigned char low  = ch3 & 0x3f;
+                       unsigned char mid  = ch2 & 0x3f;
+                       unsigned char high = ch1 & 0x0f;
+                       unicode_char = (((high << 6) + mid) << 6) + low;
+                       len = 3;
+                    } else
+                       len = 2;                                           
+                }
+                 break;
+    }
+
+    /* update position in utf-text */
+    *utf_ptr = (char *) (utf + len);
+    return unicode_char;
+}
+/******************** Funktion: class_new **************************************
+
+    searches for the class with the specified name in the classes hashtable,
+    if there is no such class a new classinfo structure is created and inserted
+    into the list of classes to be loaded
+
+*******************************************************************************/
+
+classinfo *class_new (utf *u)
+{
+       classinfo *c;     /* hashtable element */ 
+       u4 key;           /* hashkey computed from classname */   
+       u4 slot;          /* slot in hashtable */
+       u2 i;
+
+       key  = utf_hashkey (u->text, u->blength);
+       slot = key & (class_hash.size-1);
+       c    = class_hash.ptr[slot];
+
+       /* search external hash chain for the class */
+       while (c) {
+               if (c->name->blength == u->blength) {
+                       for (i=0; i<u->blength; i++) 
+                               if (u->text[i] != c->name->text[i]) goto nomatch;
+                                               
+                               /* class found in hashtable */                                                                  
+                               return c;
+                       }
+                       
+               nomatch:
+               c = c->hashlink; /* next element in external chain */
+               }
+
+       /* location in hashtable found, create new classinfo structure */
+
+#ifdef STATISTICS
+       count_class_infos += sizeof(classinfo);
+#endif
+
+       c = NEW (classinfo);
+       c -> flags = 0;
+       c -> name = u;
+       c -> cpcount = 0;
+       c -> cptags = NULL;
+       c -> cpinfos = NULL;
+       c -> super = NULL;
+       c -> sub = NULL;
+       c -> nextsub = NULL;
+       c -> interfacescount = 0;
+       c -> interfaces = NULL;
+       c -> fieldscount = 0;
+       c -> fields = NULL;
+       c -> methodscount = 0;
+       c -> methods = NULL;
+       c -> linked = false;
+       c -> index = 0;
+       c -> instancesize = 0;
+       c -> header.vftbl = NULL;
+       c -> innerclasscount = 0;
+       c -> innerclass = NULL;
+       c -> vftbl = NULL;
+       c -> initialized = false;
+       
+       /* prepare loading of the class */
+       list_addlast (&unloadedclasses, c);
+
+       /* insert class into the hashtable */
+       c->hashlink = class_hash.ptr[slot];
+       class_hash.ptr[slot] = c;
+
+       /* update number of hashtable-entries */
+       class_hash.entries++;
+
+       if ( class_hash.entries > (class_hash.size*2)) {  
+
+          /* reorganization of hashtable, average length of 
+             the external chains is approx. 2                */  
+
+         u4 i;
+         classinfo *c;
+         hashtable newhash;  /* the new hashtable */
+
+         /* create new hashtable, double the size */
+         init_hashtable(&newhash, class_hash.size*2);
+         newhash.entries = class_hash.entries;
+
+         /* transfer elements to new hashtable */
+         for (i=0; i<class_hash.size; i++) {
+               c = (classinfo*) class_hash.ptr[i];
+               while (c) {
+                       classinfo *nextc = c -> hashlink;
+                       u4 slot = (utf_hashkey(c->name->text,c->name->blength)) & (newhash.size-1);
+                                               
+                       c->hashlink = newhash.ptr[slot];
+                       newhash.ptr[slot] = c;
+
+                       c = nextc;
+                       }
+               }
+       
+         /* dispose old table */       
+         MFREE (class_hash.ptr, void*, class_hash.size);
+         class_hash = newhash;
+       }
+                       
+       return c;
+}
+
+/******************** Funktion: class_get **************************************
+
+    searches for the class with the specified name in the classes hashtable
+    if there is no such class NULL is returned
+
+*******************************************************************************/
+
+classinfo *class_get (utf *u)
+{
+       classinfo *c;  /* hashtable element */ 
+       u4 key;        /* hashkey computed from classname */   
+       u4 slot;       /* slot in hashtable */
+       u2 i;  
+
+       key  = utf_hashkey (u->text, u->blength);
+       slot = key & (class_hash.size-1);
+       c    = class_hash.ptr[slot];
+
+       /* search external hash-chain */
+       while (c) {
+               if (c->name->blength == u->blength) {
+                       
+                       /* compare classnames */
+                       for (i=0; i<u->blength; i++) 
+                               if (u->text[i] != c->name->text[i]) goto nomatch;
+
+                       /* class found in hashtable */                          
+                       return c;
+                       }
+                       
+               nomatch:
+               c = c->hashlink;
+               }
+
+       /* class not found */
+       return NULL;
+}
+
+
+/************************** function: utf_strlen ******************************
+
+    determine number of unicode characters in the utf string
+
+*******************************************************************************/
+
+u4 utf_strlen(utf *u) 
+{
+    char *endpos  = utf_end(u);  /* points behind utf string       */
+    char *utf_ptr = u->text;     /* current position in utf text   */
+    u4 len = 0;                         /* number of unicode characters   */
+
+    while (utf_ptr<endpos) {
+      len++;
+      /* next unicode character */
+      utf_nextu2(&utf_ptr);
+    }
+
+    if (utf_ptr!=endpos)
+       /* string ended abruptly */
+       panic("illegal utf string"); 
+
+    return len;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 
index 4726a3a295ae20f155053a6b8c430556cee27c35..8ae42bcf457bc775e5348352972e4cc1e66cd89d 100644 (file)
--- a/tables.h
+++ b/tables.h
 
 #include "global.h" /* for unicode. -- phil */
 
-extern bool collectverbose;
+#define CLASS(name)     (unicode_getclasslink(unicode_new_char(name)))
 
+/* to determine the end of utf strings */
+#define utf_end(utf) ((char *) utf->text+utf->blength)
 
-#define CLASS(name)     (unicode_getclasslink(unicode_new_char(name)))
+/* switches for debug messages */
+extern bool collectverbose;
+extern list unloadedclasses;
 
+/* function for disposing javastrings */
 typedef void (*stringdeleter) ( java_objectheader *string );
+    
+/* creates hashtables for symboltables */
+void tables_init ();
+
+/* free memory for hashtables */ 
+void tables_close (stringdeleter del);
+
+/* write utf symbol to file/buffer */
+void utf_sprint (char *buffer, utf *u);
+void utf_fprint (FILE *file, utf *u);
+void utf_display (utf *u);
+
+/* create new utf-symbol */
+utf *utf_new (char *text, u2 length);
+utf *utf_new_char (char *text);
+
+/* show utf-table */
+void utf_show ();
+
+/* get next unicode character of a utf-string */
+u2 utf_nextu2(char **utf);
+
+/* get number of unicode characters of a utf string */
+u4 utf_strlen(utf *u);
 
+/* search for class and create it if not found */
+classinfo *class_new (utf *u);
 
-void suck_init (char *classpath);
-bool suck_start (unicode *name);
-void suck_stop ();
-void suck_nbytes (u1 *buffer, u4 len);
-void skip_nbytes (u4 len);
-u1 suck_u1 ();
-s1 suck_s1 ();
-u2 suck_u2 ();
-s2 suck_s2 ();
-u4 suck_u4 ();
-s4 suck_s4 ();
-u8 suck_u8 ();
-s8 suck_s8 ();
-float suck_float ();
-double suck_double ();
-
-
-void unicode_init ();
-void unicode_close (stringdeleter del);
-void unicode_display (unicode *u);
-void unicode_sprint (char *buffer, unicode *u);
-void unicode_fprint (FILE *file, unicode *u);
-unicode *unicode_new_u2 (u2 *text, u2 length);
-unicode *unicode_new_char (char *text);
-void unicode_setclasslink (unicode *u, classinfo *class);
-classinfo *unicode_getclasslink (unicode *u);
-void unicode_unlinkclass (unicode *u);
-void unicode_setstringlink (unicode *u, java_objectheader *str);
-void unicode_unlinkstring (unicode *u);
-void unicode_show ();
-
-u2 desc_to_type (unicode *descriptor);
-u2 desc_typesize (unicode *descriptor);
+/* get javatype according to a typedescriptor */
+u2 desc_to_type (utf *descriptor);
+
+/* get length of a datatype */
+u2 desc_typesize (utf *descriptor);
+
+/* determine hashkey of a unicode-symbol */
+u4 unicode_hashkey (u2 *text, u2 length);
+
+/* create hashtable */
+void init_hashtable(hashtable *hash, u4 size);
+
+/* search for class in classtable */
+classinfo *class_get (utf *u);
 
 
 void heap_init (u4 size, u4 startsize, void **stackbottom);
@@ -63,3 +75,8 @@ void heap_addreference (void **reflocation);
 void gc_init (void);
 void gc_thread (void);
 void gc_call (void);
+
+
+
+
+
index e9a766e250d1b28f1458562454e111007053ac0d..805690b48cdf9032f833d3c1a614036e95130c38 100644 (file)
@@ -101,7 +101,7 @@ initLocks (void)
 
        /* Load exception classes */
        class_java_lang_IllegalMonitorStateException =
-               loader_load(unicode_new_char("java/lang/IllegalMonitorStateException"));
+               loader_load(utf_new_char("java/lang/IllegalMonitorStateException"));
 }
 
 /*
index a473fb9653a6d13ebeb2ddfeaa399f85ef684282..a9f45512e3feb2398f51c5995d6a1594df64b48e 100644 (file)
@@ -137,14 +137,14 @@ initThreads(u1 *stackbottom)
        }
 
     /* Allocate a thread to be the main thread */
-    liveThreads = the_main_thread = (thread*)builtin_new(loader_load(unicode_new_char("java/lang/Thread")));
+    liveThreads = the_main_thread = (thread*)builtin_new(loader_load(utf_new_char("java/lang/Thread")));
     assert(the_main_thread != 0);
        /* heap_addreference((void **) &liveThreads); */
     
     the_main_thread->PrivateInfo = 1;
     CONTEXT(the_main_thread).free = false;
 
-    the_main_thread->name = javastring_new(unicode_new_char("main"));
+    the_main_thread->name = javastring_new(utf_new_char("main"));
     the_main_thread->priority = NORM_THREAD_PRIO;
     CONTEXT(the_main_thread).priority = (u1)the_main_thread->priority;
     CONTEXT(the_main_thread).exceptionptr = 0;
@@ -167,14 +167,14 @@ initThreads(u1 *stackbottom)
        the_main_thread->target = 0;
        the_main_thread->interruptRequested = 0;
        the_main_thread->group =
-               (threadGroup*)builtin_new(loader_load(unicode_new_char("java/lang/ThreadGroup")));
+               (threadGroup*)builtin_new(loader_load(utf_new_char("java/lang/ThreadGroup")));
        /* we should call the constructor */
        assert(the_main_thread->group != 0);
 
        talive++;
 
        /* Load exception classes */
-       class_java_lang_ThreadDeath = loader_load(unicode_new_char("java/lang/ThreadDeath"));
+       class_java_lang_ThreadDeath = loader_load(utf_new_char("java/lang/ThreadDeath"));
 
        DBG( fprintf(stderr, "finishing initThreads\n"); );
 
@@ -242,7 +242,7 @@ startDaemon(void* func, char* nm, int stackSize)
 
     DBG( printf("startDaemon %s\n", nm); );
 
-       tid = (thread*)builtin_new(loader_load(unicode_new_char("java/lang/Thread")));
+       tid = (thread*)builtin_new(loader_load(utf_new_char("java/lang/Thread")));
        assert(tid != 0);
 
        for (i = 0; i < MAXTHREADS; ++i)
@@ -292,7 +292,7 @@ firstStartThread(void)
 
        /* Find the run()V method and call it */
        method = class_findmethod(currentThread->header.vftbl->class,
-                                                         unicode_new_char("run"), unicode_new_char("()V"));
+                                                         utf_new_char("run"), utf_new_char("()V"));
        if (method == 0)
                panic("Cannot find method \'void run ()\'");
        asm_calljavamethod(method, currentThread, NULL, NULL, NULL);
@@ -515,6 +515,7 @@ killThread(thread* tid)
                /* If we only have daemons left, then everyone is dead. */
                if (talive == tdaemon) {
                        /* atexit functions get called to clean things up */
+                       intsRestore();
                        exit(0);
                }
 
index fed33a70bfc0e140a8f5ea4e9b73d5ec0005a8de..16b647d50d6561faf857633b05f4b54ccf3a693c 100644 (file)
@@ -209,7 +209,7 @@ threadedAccept(int fd, struct sockaddr* addr, int* len)
 #if defined(BLOCKING_CALLS)
        blockOnFile(fd, TH_ACCEPT);
 #endif
-       r = accept(fd, addr, (size_t*)len);
+       r = accept(fd, addr, (int*)len);
        if (r >= 0
            || !(errno == EINPROGRESS || errno == EALREADY
                 || errno == EWOULDBLOCK))