CACAO
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
source
cacao
src
native
jni.hpp
Go to the documentation of this file.
1
/* src/native/jni.hpp - JNI types and data structures
2
3
Copyright (C) 1996-2013
4
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6
This file is part of CACAO.
7
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.
12
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.
17
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
21
02110-1301, USA.
22
23
*/
24
25
26
/* jni.hpp *********************************************************************
27
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.
31
32
GNU Classpath's headers define:
33
34
#define __CLASSPATH_JNI_MD_H__
35
#define _CLASSPATH_JNI_H
36
37
and jni.h uses:
38
39
_CLASSPATH_VM_JNI_TYPES_DEFINED
40
41
OpenJDK's headers define:
42
43
#define _JAVASOFT_JNI_MD_H_
44
#define _JAVASOFT_JNI_H_
45
46
and jni.h uses:
47
48
JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H
49
50
CLASSPATH_JNI_MD_H and CLASSPATH_JNI_H are defined in config.h.
51
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.
56
57
*******************************************************************************/
58
59
60
#ifndef _JNI_HPP
61
#define _JNI_HPP
62
63
#include <stdint.h>
// for int32_t
64
#include "config.h"
// for INCLUDE_JNI_H, etc
65
#include "
native/jni.hpp
"
// for JNI_VERSION_1_6, etc
66
#include "
vm/global.hpp
"
// for java_handle_t, etc
67
68
struct
hashtable_global_ref_entry
;
69
70
// Define these to override the typedefs in jni.h
71
#define _CLASSPATH_VM_JNI_TYPES_DEFINED 1 // GNU Classpath
72
#define JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H 1 // OpenJDK
73
74
// First include jni_md.h so we have the Java primitive types.
75
#include INCLUDE_JNI_MD_H
76
77
78
// Include the C++ wrapper classes.
79
//#include "vm/javaobjects.hpp"
80
81
// Some additional JNI version numbers, we currently support JNI 1.6.
82
#define JNI_VERSION_SUPPORTED JNI_VERSION_1_6
83
#define JNI_VERSION_CACAO 0xcaca0000
84
85
86
// Typedef the JNI types.
87
typedef
java_handle_t
*
jobject
;
88
typedef
java_handle_t
*
jclass
;
89
typedef
java_handle_t
*
jstring
;
90
typedef
java_handle_t
*
jthrowable
;
91
typedef
java_handle_t
*
jweak
;
// FIXME
92
typedef
java_handle_array_t
*
jarray
;
93
typedef
java_handle_objectarray_t
*
jobjectArray
;
94
typedef
java_handle_booleanarray_t
*
jbooleanArray
;
95
typedef
java_handle_bytearray_t
*
jbyteArray
;
96
typedef
java_handle_chararray_t
*
jcharArray
;
97
typedef
java_handle_shortarray_t
*
jshortArray
;
98
typedef
java_handle_intarray_t
*
jintArray
;
99
typedef
java_handle_longarray_t
*
jlongArray
;
100
typedef
java_handle_floatarray_t
*
jfloatArray
;
101
typedef
java_handle_doublearray_t
*
jdoubleArray
;
102
103
104
// We need some additional stuff for the various JNI headers.
105
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
106
107
// These typedefs and defines are copied from GNU Classpath's jni.h
108
#define JNI_TRUE true
109
#define JNI_FALSE false
110
111
class
_Jv_JNIEnv;
112
class
_Jv_JavaVM;
113
typedef
_Jv_JNIEnv
JNIEnv
;
114
typedef
_Jv_JavaVM
JavaVM
;
115
116
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
117
118
// These typedefs are copied from OpenJDK's jni.h
119
typedef
unsigned
char
jboolean;
120
typedef
unsigned
short
jchar;
121
typedef
short
jshort;
122
typedef
float
jfloat;
123
typedef
double
jdouble;
124
125
typedef
jint jsize;
126
127
typedef
union
jvalue {
128
jboolean z;
129
jbyte b;
130
jchar c;
131
jshort s;
132
jint
i
;
133
jlong j;
134
jfloat f;
135
jdouble d;
136
jobject
l;
137
} jvalue;
138
139
struct
_jfieldID;
140
typedef
struct
_jfieldID *jfieldID;
141
142
struct
_jmethodID;
143
typedef
struct
_jmethodID *jmethodID;
144
145
/* Return values from jobjectRefType */
146
typedef
enum
_jobjectType {
147
JNIInvalidRefType = 0,
148
JNILocalRefType = 1,
149
JNIGlobalRefType = 2,
150
JNIWeakGlobalRefType = 3
151
} jobjectRefType;
152
153
#endif
154
155
156
// Now include jni.h to complete the JNI header.
157
#include INCLUDE_JNI_H
158
159
/* CACAO related stuff ********************************************************/
160
161
extern
"C"
const
JNIInvokeInterface_
_Jv_JNIInvokeInterface
;
162
extern
"C"
JNINativeInterface_
_Jv_JNINativeInterface
;
163
164
165
/* hashtable_global_ref_entry *************************************************/
166
167
typedef
struct
hashtable_global_ref_entry
hashtable_global_ref_entry
;
168
169
struct
hashtable_global_ref_entry
{
170
java_object_t
*
o
;
/* object pointer of global ref */
171
int32_t
refs
;
/* references of the current pointer */
172
hashtable_global_ref_entry
*
hashlink
;
/* link for external chaining */
173
};
174
175
176
/* function prototypes ********************************************************/
177
178
bool
jni_init
(
void
);
179
bool
jni_version_check
(
int
version
);
180
181
182
#endif // _JNI_HPP
183
184
185
/*
186
* These are local overrides for various environment variables in Emacs.
187
* Please do not remove this and leave it at the end of the file, where
188
* Emacs will automagically detect them.
189
* ---------------------------------------------------------------------
190
* Local variables:
191
* mode: c++
192
* indent-tabs-mode: t
193
* c-basic-offset: 4
194
* tab-width: 4
195
* End:
196
* vim:noexpandtab:sw=4:ts=4:
197
*/
_Jv_JNIInvokeInterface
const JNIInvokeInterface_ _Jv_JNIInvokeInterface
Definition:
jni.cpp:3841
java_object_t
Definition:
global.hpp:263
JNIEnv
_Jv_JNIEnv JNIEnv
Definition:
jni.hpp:112
JavaVM
_Jv_JavaVM JavaVM
Definition:
jni.hpp:114
hashtable_global_ref_entry::refs
int32_t refs
Definition:
jni.hpp:171
jni_init
bool jni_init(void)
Definition:
jni.cpp:190
jfloatArray
java_handle_floatarray_t * jfloatArray
Definition:
jni.hpp:100
jclass
java_handle_t * jclass
Definition:
jni.hpp:88
_Jv_JNINativeInterface
JNINativeInterface_ _Jv_JNINativeInterface
Definition:
jni.cpp:3856
version
static void version(bool opt_exit)
Definition:
vm.cpp:529
jstring
java_handle_t * jstring
Definition:
jni.hpp:89
i
MIIterator i
Definition:
LivetimeAnalysisPass.cpp:149
hashtable_global_ref_entry
Definition:
jni.hpp:169
jobject
java_handle_t * jobject
Definition:
jni.hpp:87
jweak
java_handle_t * jweak
Definition:
jni.hpp:91
jarray
java_handle_array_t * jarray
Definition:
jni.hpp:92
jbyteArray
java_handle_bytearray_t * jbyteArray
Definition:
jni.hpp:95
hashtable_global_ref_entry::hashlink
hashtable_global_ref_entry * hashlink
Definition:
jni.hpp:172
global.hpp
jni.hpp
jdoubleArray
java_handle_doublearray_t * jdoubleArray
Definition:
jni.hpp:101
jobjectArray
java_handle_objectarray_t * jobjectArray
Definition:
jni.hpp:93
jshortArray
java_handle_shortarray_t * jshortArray
Definition:
jni.hpp:97
jthrowable
java_handle_t * jthrowable
Definition:
jni.hpp:90
jni_version_check
bool jni_version_check(int version)
Definition:
jni.cpp:282
jbooleanArray
java_handle_booleanarray_t * jbooleanArray
Definition:
jni.hpp:94
jcharArray
java_handle_chararray_t * jcharArray
Definition:
jni.hpp:96
jlongArray
java_handle_longarray_t * jlongArray
Definition:
jni.hpp:99
hashtable_global_ref_entry::o
java_object_t * o
Definition:
jni.hpp:170
jintArray
java_handle_intarray_t * jintArray
Definition:
jni.hpp:98
Generated on Fri Aug 4 2017 03:01:45 for CACAO by
1.8.5