removed the class hash and all functions identifying classes by name only
[cacao.git] / src / native / jni.h
index 29a6f207e6a8b7748f50595501b73fd9667a5b55..ad78fc5172f43c09bd048783032db0d9a3cdd754 100644 (file)
@@ -1,9 +1,9 @@
 /* native/jni.h - JNI types and data structures
 
-   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
+   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+   Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    Contact: cacao@complang.tuwien.ac.at
 
-   Authors: ?
+   Authors: Reinhard Grafl
+            Roman Obermaisser
 
-   $Id: jni.h 1621 2004-11-30 13:06:55Z twisti $
+   Changes: Christian Thalinger
+
+   $Id: jni.h 2129 2005-03-29 22:27:08Z twisti $
 
 */
 
 #ifndef _JNI_H
 #define _JNI_H
 
+#include <stdio.h>
 #include <stdarg.h>
 
 #include "types.h"
+#include "vm/field.h"
 #include "vm/global.h"
+#include "vm/method.h"
+
 
+/* JNI versions */
 
-#define JNI_VERSION       0x00010002
+#define JNI_VERSION_1_1    0x00010001
+#define JNI_VERSION_1_2    0x00010002
+#define JNI_VERSION_1_4    0x00010004
 
 #define JNIEXPORT
 #define JNICALL
 
 
+/* JNI-Boolean */
+
+#define JNI_FALSE        0
+#define JNI_TRUE         1
+
+
+/* Error codes */
+
+#define JNI_OK           0
+#define JNI_ERR          (-1)
+#define JNI_EDETACHED    (-2)              /* thread detached from the VM */
+#define JNI_EVERSION     (-3)              /* JNI version error */
+
+
 /* JNI datatypes */
 
+#define jboolean        u1
+#define jbyte           s1
+#define jchar           u2
+#define jshort          s2
+#define jint            s4
+#define jlong           s8
+#define jfloat          float
+#define jdouble         double
+
 #define jobject         java_objectheader*
 #define jclass          struct classinfo*
 #define jthrowable      jobject
 #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*    
 
 
-typedef struct _JavaVM* JavaVM;
-
-struct _JavaVM{
-   void *(*reserved0) ();
-   void *(*reserved1) ();
-   void *(*reserved2) ();
-   jint (*DestroyJavaVM) (JavaVM *);
-   jint (*AttachCurrentThread) (JavaVM *, void **, void *);
-   jint (*DetachCurrentThread) (JavaVM *);
-   jint (*GetEnv) (JavaVM *, void **, jint);
-   jint (*AttachCurrentThreadAsDaemon) (JavaVM *, void **, void *);
-
-};
-
-
 typedef union jvalue {
     jboolean z;
     jbyte    b;
@@ -103,10 +114,92 @@ typedef union jvalue {
     jobject  l;
 } jvalue;
 
-/* JNI-Boolean */
 
-#define JNI_FALSE 0
-#define JNI_TRUE  1
+typedef struct JDK1_1InitArgs JDK1_1InitArgs;
+
+struct JDK1_1InitArgs {
+       /* The first two fields were reserved in JDK 1.1, and
+          formally introduced in JDK 1.1.2. */
+       /* Java VM version */
+       jint version;
+
+       /* System properties. */
+       char **properties;
+
+       /* whether to check the Java source files are newer than
+        * compiled class files. */
+       jint checkSource;
+
+       /* maximum native stack size of Java-created threads. */
+       jint nativeStackSize;
+
+       /* maximum Java stack size. */
+       jint javaStackSize;
+
+       /* initial heap size. */
+       jint minHeapSize;
+
+       /* maximum heap size. */
+       jint maxHeapSize;
+
+       /* controls whether Java byte code should be verified:
+        * 0 -- none, 1 -- remotely loaded code, 2 -- all code. */ 
+       jint verifyMode;
+
+       /* the local directory path for class loading. */
+       const char *classpath;
+
+       /* a hook for a function that redirects all VM messages. */
+       jint (*vfprintf)(FILE *fp, const char *format,
+                                        va_list args);
+
+       /* a VM exit hook. */
+       void (*exit)(jint code);
+
+       /* a VM abort hook. */
+       void (*abort)();
+
+       /* whether to enable class GC. */
+       jint enableClassGC;
+
+       /* whether GC messages will appear. */
+       jint enableVerboseGC;
+
+       /* whether asynchronous GC is allowed. */
+       jint disableAsyncGC;
+
+       /* Three reserved fields. */
+       jint reserved0;
+       jint reserved1;
+       jint reserved2;
+};
+
+
+typedef struct JDK1_1AttachArgs {
+       /*
+        * JDK 1.1 does not need any arguments to attach a
+        * native thread. The padding is here to satisfy the C
+        * compiler which does not permit empty structures.
+        */
+       void *__padding;
+} JDK1_1AttachArgs;
+
+
+typedef struct JNIInvokeInterface *JavaVM;
+/*  typedef struct _JavaVM *JavaVM; */
+
+/*  struct _JavaVM { */
+struct JNIInvokeInterface {
+   void *(*reserved0) ();
+   void *(*reserved1) ();
+   void *(*reserved2) ();
+   jint (*DestroyJavaVM) (JavaVM *);
+   jint (*AttachCurrentThread) (JavaVM *, void **, void *);
+   jint (*DetachCurrentThread) (JavaVM *);
+   jint (*GetEnv) (JavaVM *, void **, jint);
+   jint (*AttachCurrentThreadAsDaemon) (JavaVM *, void **, void *);
+};
+
 
 /* native method name, signature and function pointer for use in RegisterNatives */
 
@@ -136,10 +229,11 @@ typedef struct {
        Java VM Interface 
 */
 
-typedef struct JNI_Table *JNIEnv;
+typedef struct JNINativeInterface *JNIEnv;
+/*  typedef struct JNI_Table *JNIEnv; */
 
-struct JNI_Table {
-    
+/*  struct JNI_Table { */
+struct JNINativeInterface {
     /* reserverd for future JNI-functions */
     void *unused0;
     void *unused1;
@@ -161,7 +255,7 @@ struct JNI_Table {
     jobject (*ToReflectedMethod) (JNIEnv*, jclass cls, jmethodID methodID, jboolean isStatic);
 
     jclass (*GetSuperclass) (JNIEnv*, jclass sub);
-    jboolean (*IsAssignableForm) (JNIEnv*, jclass sub, jclass sup);
+    jboolean (*IsAssignableFrom) (JNIEnv*, jclass sub, jclass sup);
 
     jobject (*ToReflectedField) (JNIEnv*, jclass cls, jfieldID fieldID, jboolean isStatic);
 
@@ -378,7 +472,7 @@ struct JNI_Table {
     const jchar *(*GetStringChars) (JNIEnv*, jstring str, jboolean *isCopy);
     void (*ReleaseStringChars) (JNIEnv*, jstring str, const jchar *chars);
 
-    jstring (*NewStringUTF) (JNIEnv*, const char *utf);
+    jstring (*NewStringUTF) (JNIEnv*, const char *bytes);
     jsize (*GetStringUTFLength) (JNIEnv*, jstring str);
     const char* (*GetStringUTFChars) (JNIEnv*, jstring str, jboolean *isCopy);
     void (*ReleaseStringUTFChars) (JNIEnv*, jstring str, const char* chars);
@@ -447,8 +541,11 @@ struct JNI_Table {
     jint (*MonitorExit) (JNIEnv*, jobject obj);
 
     /* JavaVM interface */
+
     jint (*GetJavaVM) (JNIEnv*, JavaVM **vm);
 
+       /* new JNI 1.2 functions */
+
     void (*GetStringRegion) (JNIEnv*, jstring str, jsize start, jsize len, jchar *buf);
     void (*GetStringUTFRegion) (JNIEnv*, jstring str, jsize start, jsize len, char *buf);
 
@@ -462,17 +559,20 @@ struct JNI_Table {
     void (*DeleteWeakGlobalRef) (JNIEnv*, jweak ref);
 
     jboolean (*ExceptionCheck) (JNIEnv*);
-};
 
+       /* new JNI 1.4 functions */
 
-/* the active JNI function table */
+       jobject (*NewDirectByteBuffer) (JNIEnv *env, void* address, jlong capacity);
+       void* (*GetDirectBufferAddress) (JNIEnv *env, jobject buf);
+       jlong (*GetDirectBufferCapacity) (JNIEnv *env, jobject buf);
+};
 
-extern JNIEnv env;
-extern JavaVM javaVM;
-extern struct JNI_Table envTable;
 
+/* function prototypes ********************************************************/
 
-/* function prototypes */
+jint JNI_GetDefaultJavaVMInitArgs(void *vm_args);
+jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs);
+jint JNI_CreateJavaVM(JavaVM **p_vm, JNIEnv **p_env, void *vm_args);
 
 jfieldID getFieldID_critical(JNIEnv *env, jclass clazz, char *name, char *sig);