x86_64 include added
[cacao.git] / jni.c
diff --git a/jni.c b/jni.c
index 40826da3f694c5c089f7e73ffeb2996e1f8e484d..265a28a8c9c01c4ec6ba15b9347703c461285667 100644 (file)
--- a/jni.c
+++ b/jni.c
@@ -3,7 +3,7 @@
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
    R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
    M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
-   P. Tomsich, J. Wenninger
+   P. Tomsich, J. Wenninger, M. Platter
 
    This file is part of CACAO.
 
 
    Authors: ?
 
-   Changes: Joseph Wenninger
+   Changes: Joseph Wenninger, Martin Platter
 
-   $Id: jni.c 1030 2004-04-26 16:03:01Z twisti $
+   $Id: jni.c 1384 2004-08-02 11:41:26Z motse $
 
 */
 
 
 #include <string.h>
+#include "exceptions.h"
 #include "main.h"
 #include "jni.h"
 #include "global.h"
 #include "tables.h"
 #include "native.h"
 #include "builtin.h"
+#include "options.h"
+#include "statistics.h"
 #include "threads/thread.h"
-#include "toolbox/loging.h"
+#include "toolbox/logging.h"
 #include "toolbox/memory.h"
 #include "nat/java_lang_Byte.h"
 #include "nat/java_lang_Character.h"
@@ -506,6 +509,7 @@ jmethodID get_virtual(jobject obj,jmethodID methodID) {
 
 jmethodID get_nonvirtual(jclass clazz,jmethodID methodID) {
        if (clazz==methodID->class) return methodID;
+/*class_resolvemethod -> classfindmethod? (JOWENN)*/
        return class_resolvemethod (clazz, methodID->name, methodID->descriptor);
 }
 
@@ -635,14 +639,14 @@ jlong callLongMethod(jobject obj, jmethodID methodID, va_list args)
        jni_callblock *blk;
        jlong ret;
 
-       /*
+/*     
         log_text("JNI-Call: CallObjectMethodV");
         utf_display(methodID->name);
         utf_display(methodID->descriptor);
         printf("\nParmaeter count: %d\n",argcount);
         utf_display(obj->vftbl->class->name);
         printf("\n");
-        */
+*/      
        if (methodID == 0) {
                *exceptionptr = new_exception(string_java_lang_NoSuchMethodError); 
                return 0;
@@ -670,7 +674,7 @@ jlong callLongMethod(jobject obj, jmethodID methodID, va_list args)
 
        blk = MNEW(jni_callblock, 4 /*argcount+2*/);
 
-       fill_callblock(obj, methodID->descriptor, blk, args, 'L');
+       fill_callblock(obj, methodID->descriptor, blk, args, 'J');
 
        /*      printf("parameter: obj: %p",blk[0].item); */
        ret = asm_calljavafunction2long(methodID,
@@ -1167,7 +1171,10 @@ jmethodID GetMethodID(JNIEnv* env, jclass clazz, const char *name, const char *s
        );
 
        if (!m) *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
-
+       else if (m->flags & ACC_STATIC)   {
+               m=0;
+               *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       }
        return m;
 }
 
@@ -1351,17 +1358,20 @@ jint CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
 
 jlong CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
 {
-       log_text("JNI-Call: CallLongMethod");
+       jlong ret;
+       va_list vaargs;
+       
+       va_start(vaargs,methodID);
+       ret = callLongMethod(obj,get_virtual(obj, methodID),vaargs);
+       va_end(vaargs);
 
-       return 0;
+       return ret;
 }
 
 
 jlong CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
 {
-       log_text("JNI-Call: CallLongMethodV");
-
-       return 0;
+       return  callLongMethod(obj,get_virtual(obj, methodID),args);
 }
 
 
@@ -1912,6 +1922,10 @@ jmethodID GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, const c
                                                        utf_new_char((char *) sig));
 
        if (!m) *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       else if (!(m->flags & ACC_STATIC))   {
+               m=0;
+               *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       }
 
        return m;
 }
@@ -1919,17 +1933,24 @@ jmethodID GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, const c
 
 jobject CallStaticObjectMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
 {
-       log_text("JNI-Call: CallStaticObjectMethod");
+       jobject ret;
+       va_list vaargs;
 
-       return NULL;
+       /* log_text("JNI-Call: CallStaticObjectMethod");*/
+
+       va_start(vaargs, methodID);
+       ret = callObjectMethod(0, methodID, vaargs);
+       va_end(vaargs);
+
+       return ret;
 }
 
 
 jobject CallStaticObjectMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
 {
-       log_text("JNI-Call: CallStaticObjectMethodV");
-
-       return NULL;
+       /* log_text("JNI-Call: CallStaticObjectMethodV"); */
+       
+       return callObjectMethod(0,methodID,args);
 }