1 /* src/native/jni.hpp - JNI types and data structures
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 /* jni.hpp *********************************************************************
28 ATTENTION: We include this file before we actually define our own
29 jni.h. We do this because otherwise we can get into unresolvable
30 circular header dependencies.
32 GNU Classpath's headers define:
34 #define __CLASSPATH_JNI_MD_H__
35 #define _CLASSPATH_JNI_H
39 _CLASSPATH_VM_JNI_TYPES_DEFINED
41 OpenJDK's headers define:
43 #define _JAVASOFT_JNI_MD_H_
44 #define _JAVASOFT_JNI_H_
48 JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H
50 CLASSPATH_JNI_MD_H and CLASSPATH_JNI_H are defined in config.h.
52 We include both headers (jni.h and jni_md.h) with the absolute path
53 so we can be sure that the preprocessor does not pick up another
54 header from the search path. Furthermore we include jni_md.h
55 before jni.h as the latter includes the former.
57 *******************************************************************************/
69 // Define these to override the typedefs in jni.h
70 #define _CLASSPATH_VM_JNI_TYPES_DEFINED 1 // GNU Classpath
71 #define JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H 1 // OpenJDK
73 // First include jni_md.h so we have the Java primitive types.
74 #include INCLUDE_JNI_MD_H
77 // Include the C++ wrapper classes.
78 //#include "vm/javaobjects.hpp"
79 #include "vm/global.h"
82 // Some additional JNI version numbers, we currently support JNI 1.6.
83 #define JNI_VERSION_SUPPORTED JNI_VERSION_1_6
84 #define JNI_VERSION_CACAO 0xcaca0000
87 // Typedef the JNI types.
88 typedef java_handle_t* jobject;
89 typedef java_handle_t* jclass;
90 typedef java_handle_t* jstring;
91 typedef java_handle_t* jthrowable;
92 typedef java_handle_t* jweak; // FIXME
93 typedef java_handle_array_t* jarray;
94 typedef java_handle_objectarray_t* jobjectArray;
95 typedef java_handle_booleanarray_t* jbooleanArray;
96 typedef java_handle_bytearray_t* jbyteArray;
97 typedef java_handle_chararray_t* jcharArray;
98 typedef java_handle_shortarray_t* jshortArray;
99 typedef java_handle_intarray_t* jintArray;
100 typedef java_handle_longarray_t* jlongArray;
101 typedef java_handle_floatarray_t* jfloatArray;
102 typedef java_handle_doublearray_t* jdoubleArray;
105 // We need some additional stuff for the various JNI headers.
106 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
108 // These typedefs and defines are copied from GNU Classpath's jni.h
109 #define JNI_TRUE true
110 #define JNI_FALSE false
112 typedef struct _Jv_JNIEnv JNIEnv;
113 typedef struct _Jv_JavaVM JavaVM;
115 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
117 // These typedefs are copied from OpenJDK's jni.h
118 typedef unsigned char jboolean;
119 typedef unsigned short jchar;
120 typedef short jshort;
121 typedef float jfloat;
122 typedef double jdouble;
126 typedef union jvalue {
139 typedef struct _jfieldID *jfieldID;
142 typedef struct _jmethodID *jmethodID;
144 /* Return values from jobjectRefType */
145 typedef enum _jobjectType {
146 JNIInvalidRefType = 0,
148 JNIGlobalRefType = 2,
149 JNIWeakGlobalRefType = 3
155 // Now include jni.h to complete the JNI header.
156 #include INCLUDE_JNI_H
160 #include "vm/global.h"
167 /* CACAO related stuff ********************************************************/
169 extern const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface;
170 extern struct JNINativeInterface_ _Jv_JNINativeInterface;
173 /* hashtable_global_ref_entry *************************************************/
175 typedef struct hashtable_global_ref_entry hashtable_global_ref_entry;
177 struct hashtable_global_ref_entry {
178 java_object_t *o; /* object pointer of global ref */
179 int32_t refs; /* references of the current pointer */
180 hashtable_global_ref_entry *hashlink; /* link for external chaining */
184 /* function prototypes ********************************************************/
187 bool jni_version_check(int version);
197 * These are local overrides for various environment variables in Emacs.
198 * Please do not remove this and leave it at the end of the file, where
199 * Emacs will automagically detect them.
200 * ---------------------------------------------------------------------
203 * indent-tabs-mode: t
207 * vim:noexpandtab:sw=4:ts=4: