blob: 8346ca4e5f141deae70daf62314a8b34c4e5dc82 [file] [log] [blame]
The Android Open Source Project7f844dd2009-03-03 19:28:47 -08001/*
Dan Bornsteinbf785f42010-08-03 18:09:42 -07002 * Copyright (C) 2006 The Android Open Source Project
The Android Open Source Project7f844dd2009-03-03 19:28:47 -08003 *
Dan Bornsteinbf785f42010-08-03 18:09:42 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
The Android Open Source Project7f844dd2009-03-03 19:28:47 -080018 * JNI specification, as defined by Sun:
19 * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html
20 *
21 * Everything here is expected to be VM-neutral.
22 */
Dan Bornsteinbf785f42010-08-03 18:09:42 -070023
Orion Hodsonce487362020-04-22 19:41:46 +010024#pragma once
The Android Open Source Project7f844dd2009-03-03 19:28:47 -080025
26#include <stdarg.h>
Elliott Hughes97b65562013-02-27 16:37:26 -080027#include <stdint.h>
The Android Open Source Project7f844dd2009-03-03 19:28:47 -080028
Elliott Hughes97b65562013-02-27 16:37:26 -080029/* Primitive types that match up with Java equivalents. */
30typedef uint8_t jboolean; /* unsigned 8 bits */
31typedef int8_t jbyte; /* signed 8 bits */
32typedef uint16_t jchar; /* unsigned 16 bits */
33typedef int16_t jshort; /* signed 16 bits */
34typedef int32_t jint; /* signed 32 bits */
35typedef int64_t jlong; /* signed 64 bits */
36typedef float jfloat; /* 32-bit IEEE 754 */
37typedef double jdouble; /* 64-bit IEEE 754 */
The Android Open Source Project7f844dd2009-03-03 19:28:47 -080038
39/* "cardinal indices and sizes" */
Elliott Hughes97b65562013-02-27 16:37:26 -080040typedef jint jsize;
The Android Open Source Project7f844dd2009-03-03 19:28:47 -080041
42#ifdef __cplusplus
43/*
44 * Reference types, in C++
45 */
46class _jobject {};
47class _jclass : public _jobject {};
48class _jstring : public _jobject {};
49class _jarray : public _jobject {};
50class _jobjectArray : public _jarray {};
51class _jbooleanArray : public _jarray {};
52class _jbyteArray : public _jarray {};
53class _jcharArray : public _jarray {};
54class _jshortArray : public _jarray {};
55class _jintArray : public _jarray {};
56class _jlongArray : public _jarray {};
57class _jfloatArray : public _jarray {};
58class _jdoubleArray : public _jarray {};
59class _jthrowable : public _jobject {};
60
61typedef _jobject* jobject;
62typedef _jclass* jclass;
63typedef _jstring* jstring;
64typedef _jarray* jarray;
65typedef _jobjectArray* jobjectArray;
66typedef _jbooleanArray* jbooleanArray;
67typedef _jbyteArray* jbyteArray;
68typedef _jcharArray* jcharArray;
69typedef _jshortArray* jshortArray;
70typedef _jintArray* jintArray;
71typedef _jlongArray* jlongArray;
72typedef _jfloatArray* jfloatArray;
73typedef _jdoubleArray* jdoubleArray;
74typedef _jthrowable* jthrowable;
75typedef _jobject* jweak;
76
77
78#else /* not __cplusplus */
79
80/*
81 * Reference types, in C.
82 */
83typedef void* jobject;
84typedef jobject jclass;
85typedef jobject jstring;
86typedef jobject jarray;
87typedef jarray jobjectArray;
88typedef jarray jbooleanArray;
89typedef jarray jbyteArray;
90typedef jarray jcharArray;
91typedef jarray jshortArray;
92typedef jarray jintArray;
93typedef jarray jlongArray;
94typedef jarray jfloatArray;
95typedef jarray jdoubleArray;
96typedef jobject jthrowable;
97typedef jobject jweak;
98
99#endif /* not __cplusplus */
100
101struct _jfieldID; /* opaque structure */
102typedef struct _jfieldID* jfieldID; /* field IDs */
103
104struct _jmethodID; /* opaque structure */
105typedef struct _jmethodID* jmethodID; /* method IDs */
106
107struct JNIInvokeInterface;
108
109typedef union jvalue {
110 jboolean z;
111 jbyte b;
112 jchar c;
113 jshort s;
114 jint i;
115 jlong j;
116 jfloat f;
117 jdouble d;
118 jobject l;
119} jvalue;
120
121typedef enum jobjectRefType {
122 JNIInvalidRefType = 0,
123 JNILocalRefType = 1,
124 JNIGlobalRefType = 2,
125 JNIWeakGlobalRefType = 3
126} jobjectRefType;
127
Carl Shapiroabb4eff2010-06-08 16:37:12 -0700128typedef struct {
129 const char* name;
130 const char* signature;
131 void* fnPtr;
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800132} JNINativeMethod;
133
134struct _JNIEnv;
135struct _JavaVM;
136typedef const struct JNINativeInterface* C_JNIEnv;
137
138#if defined(__cplusplus)
139typedef _JNIEnv JNIEnv;
140typedef _JavaVM JavaVM;
141#else
142typedef const struct JNINativeInterface* JNIEnv;
143typedef const struct JNIInvokeInterface* JavaVM;
144#endif
145
146/*
147 * Table of interface function pointers.
148 */
149struct JNINativeInterface {
150 void* reserved0;
151 void* reserved1;
152 void* reserved2;
153 void* reserved3;
154
155 jint (*GetVersion)(JNIEnv *);
156
157 jclass (*DefineClass)(JNIEnv*, const char*, jobject, const jbyte*,
158 jsize);
159 jclass (*FindClass)(JNIEnv*, const char*);
160
161 jmethodID (*FromReflectedMethod)(JNIEnv*, jobject);
162 jfieldID (*FromReflectedField)(JNIEnv*, jobject);
163 /* spec doesn't show jboolean parameter */
164 jobject (*ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean);
165
166 jclass (*GetSuperclass)(JNIEnv*, jclass);
167 jboolean (*IsAssignableFrom)(JNIEnv*, jclass, jclass);
168
169 /* spec doesn't show jboolean parameter */
170 jobject (*ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean);
171
172 jint (*Throw)(JNIEnv*, jthrowable);
173 jint (*ThrowNew)(JNIEnv *, jclass, const char *);
174 jthrowable (*ExceptionOccurred)(JNIEnv*);
175 void (*ExceptionDescribe)(JNIEnv*);
176 void (*ExceptionClear)(JNIEnv*);
177 void (*FatalError)(JNIEnv*, const char*);
178
179 jint (*PushLocalFrame)(JNIEnv*, jint);
180 jobject (*PopLocalFrame)(JNIEnv*, jobject);
181
182 jobject (*NewGlobalRef)(JNIEnv*, jobject);
183 void (*DeleteGlobalRef)(JNIEnv*, jobject);
184 void (*DeleteLocalRef)(JNIEnv*, jobject);
185 jboolean (*IsSameObject)(JNIEnv*, jobject, jobject);
186
187 jobject (*NewLocalRef)(JNIEnv*, jobject);
188 jint (*EnsureLocalCapacity)(JNIEnv*, jint);
189
190 jobject (*AllocObject)(JNIEnv*, jclass);
191 jobject (*NewObject)(JNIEnv*, jclass, jmethodID, ...);
192 jobject (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700193 jobject (*NewObjectA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800194
195 jclass (*GetObjectClass)(JNIEnv*, jobject);
196 jboolean (*IsInstanceOf)(JNIEnv*, jobject, jclass);
197 jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*);
198
199 jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...);
200 jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700201 jobject (*CallObjectMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800202 jboolean (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...);
203 jboolean (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700204 jboolean (*CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800205 jbyte (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...);
206 jbyte (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700207 jbyte (*CallByteMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800208 jchar (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...);
209 jchar (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700210 jchar (*CallCharMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800211 jshort (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...);
212 jshort (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700213 jshort (*CallShortMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800214 jint (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...);
215 jint (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700216 jint (*CallIntMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800217 jlong (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...);
218 jlong (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700219 jlong (*CallLongMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800220 jfloat (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...);
221 jfloat (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700222 jfloat (*CallFloatMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800223 jdouble (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...);
224 jdouble (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700225 jdouble (*CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800226 void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...);
227 void (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700228 void (*CallVoidMethodA)(JNIEnv*, jobject, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800229
230 jobject (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass,
231 jmethodID, ...);
232 jobject (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass,
233 jmethodID, va_list);
234 jobject (*CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700235 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800236 jboolean (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass,
237 jmethodID, ...);
238 jboolean (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass,
239 jmethodID, va_list);
240 jboolean (*CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700241 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800242 jbyte (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass,
243 jmethodID, ...);
244 jbyte (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass,
245 jmethodID, va_list);
246 jbyte (*CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700247 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800248 jchar (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass,
249 jmethodID, ...);
250 jchar (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass,
251 jmethodID, va_list);
252 jchar (*CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700253 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800254 jshort (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass,
255 jmethodID, ...);
256 jshort (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass,
257 jmethodID, va_list);
258 jshort (*CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700259 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800260 jint (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass,
261 jmethodID, ...);
262 jint (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass,
263 jmethodID, va_list);
264 jint (*CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700265 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800266 jlong (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass,
267 jmethodID, ...);
268 jlong (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass,
269 jmethodID, va_list);
270 jlong (*CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700271 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800272 jfloat (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass,
273 jmethodID, ...);
274 jfloat (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass,
275 jmethodID, va_list);
276 jfloat (*CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700277 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800278 jdouble (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass,
279 jmethodID, ...);
280 jdouble (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass,
281 jmethodID, va_list);
282 jdouble (*CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700283 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800284 void (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass,
285 jmethodID, ...);
286 void (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass,
287 jmethodID, va_list);
288 void (*CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700289 jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800290
291 jfieldID (*GetFieldID)(JNIEnv*, jclass, const char*, const char*);
292
293 jobject (*GetObjectField)(JNIEnv*, jobject, jfieldID);
294 jboolean (*GetBooleanField)(JNIEnv*, jobject, jfieldID);
295 jbyte (*GetByteField)(JNIEnv*, jobject, jfieldID);
296 jchar (*GetCharField)(JNIEnv*, jobject, jfieldID);
297 jshort (*GetShortField)(JNIEnv*, jobject, jfieldID);
298 jint (*GetIntField)(JNIEnv*, jobject, jfieldID);
299 jlong (*GetLongField)(JNIEnv*, jobject, jfieldID);
300 jfloat (*GetFloatField)(JNIEnv*, jobject, jfieldID);
301 jdouble (*GetDoubleField)(JNIEnv*, jobject, jfieldID);
302
303 void (*SetObjectField)(JNIEnv*, jobject, jfieldID, jobject);
304 void (*SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean);
305 void (*SetByteField)(JNIEnv*, jobject, jfieldID, jbyte);
306 void (*SetCharField)(JNIEnv*, jobject, jfieldID, jchar);
307 void (*SetShortField)(JNIEnv*, jobject, jfieldID, jshort);
308 void (*SetIntField)(JNIEnv*, jobject, jfieldID, jint);
309 void (*SetLongField)(JNIEnv*, jobject, jfieldID, jlong);
310 void (*SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat);
311 void (*SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble);
312
313 jmethodID (*GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*);
314
315 jobject (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...);
316 jobject (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700317 jobject (*CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800318 jboolean (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...);
319 jboolean (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID,
320 va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700321 jboolean (*CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800322 jbyte (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...);
323 jbyte (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700324 jbyte (*CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800325 jchar (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...);
326 jchar (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700327 jchar (*CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800328 jshort (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...);
329 jshort (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700330 jshort (*CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800331 jint (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...);
332 jint (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700333 jint (*CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800334 jlong (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...);
335 jlong (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700336 jlong (*CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800337 jfloat (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...);
338 jfloat (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700339 jfloat (*CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800340 jdouble (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...);
341 jdouble (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700342 jdouble (*CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800343 void (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...);
344 void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list);
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700345 void (*CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, const jvalue*);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800346
347 jfieldID (*GetStaticFieldID)(JNIEnv*, jclass, const char*,
348 const char*);
349
350 jobject (*GetStaticObjectField)(JNIEnv*, jclass, jfieldID);
351 jboolean (*GetStaticBooleanField)(JNIEnv*, jclass, jfieldID);
352 jbyte (*GetStaticByteField)(JNIEnv*, jclass, jfieldID);
353 jchar (*GetStaticCharField)(JNIEnv*, jclass, jfieldID);
354 jshort (*GetStaticShortField)(JNIEnv*, jclass, jfieldID);
355 jint (*GetStaticIntField)(JNIEnv*, jclass, jfieldID);
356 jlong (*GetStaticLongField)(JNIEnv*, jclass, jfieldID);
357 jfloat (*GetStaticFloatField)(JNIEnv*, jclass, jfieldID);
358 jdouble (*GetStaticDoubleField)(JNIEnv*, jclass, jfieldID);
359
360 void (*SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject);
361 void (*SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean);
362 void (*SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte);
363 void (*SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar);
364 void (*SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort);
365 void (*SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint);
366 void (*SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong);
367 void (*SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat);
368 void (*SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble);
369
370 jstring (*NewString)(JNIEnv*, const jchar*, jsize);
371 jsize (*GetStringLength)(JNIEnv*, jstring);
372 const jchar* (*GetStringChars)(JNIEnv*, jstring, jboolean*);
373 void (*ReleaseStringChars)(JNIEnv*, jstring, const jchar*);
374 jstring (*NewStringUTF)(JNIEnv*, const char*);
375 jsize (*GetStringUTFLength)(JNIEnv*, jstring);
376 /* JNI spec says this returns const jbyte*, but that's inconsistent */
377 const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*);
378 void (*ReleaseStringUTFChars)(JNIEnv*, jstring, const char*);
379 jsize (*GetArrayLength)(JNIEnv*, jarray);
380 jobjectArray (*NewObjectArray)(JNIEnv*, jsize, jclass, jobject);
381 jobject (*GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize);
382 void (*SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject);
383
384 jbooleanArray (*NewBooleanArray)(JNIEnv*, jsize);
385 jbyteArray (*NewByteArray)(JNIEnv*, jsize);
386 jcharArray (*NewCharArray)(JNIEnv*, jsize);
387 jshortArray (*NewShortArray)(JNIEnv*, jsize);
388 jintArray (*NewIntArray)(JNIEnv*, jsize);
389 jlongArray (*NewLongArray)(JNIEnv*, jsize);
390 jfloatArray (*NewFloatArray)(JNIEnv*, jsize);
391 jdoubleArray (*NewDoubleArray)(JNIEnv*, jsize);
392
393 jboolean* (*GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*);
394 jbyte* (*GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*);
395 jchar* (*GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*);
396 jshort* (*GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*);
397 jint* (*GetIntArrayElements)(JNIEnv*, jintArray, jboolean*);
398 jlong* (*GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*);
399 jfloat* (*GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*);
400 jdouble* (*GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*);
401
402 void (*ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray,
403 jboolean*, jint);
404 void (*ReleaseByteArrayElements)(JNIEnv*, jbyteArray,
405 jbyte*, jint);
406 void (*ReleaseCharArrayElements)(JNIEnv*, jcharArray,
407 jchar*, jint);
408 void (*ReleaseShortArrayElements)(JNIEnv*, jshortArray,
409 jshort*, jint);
410 void (*ReleaseIntArrayElements)(JNIEnv*, jintArray,
411 jint*, jint);
412 void (*ReleaseLongArrayElements)(JNIEnv*, jlongArray,
413 jlong*, jint);
414 void (*ReleaseFloatArrayElements)(JNIEnv*, jfloatArray,
415 jfloat*, jint);
416 void (*ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray,
417 jdouble*, jint);
418
419 void (*GetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
420 jsize, jsize, jboolean*);
421 void (*GetByteArrayRegion)(JNIEnv*, jbyteArray,
422 jsize, jsize, jbyte*);
423 void (*GetCharArrayRegion)(JNIEnv*, jcharArray,
424 jsize, jsize, jchar*);
425 void (*GetShortArrayRegion)(JNIEnv*, jshortArray,
426 jsize, jsize, jshort*);
427 void (*GetIntArrayRegion)(JNIEnv*, jintArray,
428 jsize, jsize, jint*);
429 void (*GetLongArrayRegion)(JNIEnv*, jlongArray,
430 jsize, jsize, jlong*);
431 void (*GetFloatArrayRegion)(JNIEnv*, jfloatArray,
432 jsize, jsize, jfloat*);
433 void (*GetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
434 jsize, jsize, jdouble*);
435
436 /* spec shows these without const; some jni.h do, some don't */
437 void (*SetBooleanArrayRegion)(JNIEnv*, jbooleanArray,
438 jsize, jsize, const jboolean*);
439 void (*SetByteArrayRegion)(JNIEnv*, jbyteArray,
440 jsize, jsize, const jbyte*);
441 void (*SetCharArrayRegion)(JNIEnv*, jcharArray,
442 jsize, jsize, const jchar*);
443 void (*SetShortArrayRegion)(JNIEnv*, jshortArray,
444 jsize, jsize, const jshort*);
445 void (*SetIntArrayRegion)(JNIEnv*, jintArray,
446 jsize, jsize, const jint*);
447 void (*SetLongArrayRegion)(JNIEnv*, jlongArray,
448 jsize, jsize, const jlong*);
449 void (*SetFloatArrayRegion)(JNIEnv*, jfloatArray,
450 jsize, jsize, const jfloat*);
451 void (*SetDoubleArrayRegion)(JNIEnv*, jdoubleArray,
452 jsize, jsize, const jdouble*);
453
454 jint (*RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*,
455 jint);
456 jint (*UnregisterNatives)(JNIEnv*, jclass);
457 jint (*MonitorEnter)(JNIEnv*, jobject);
458 jint (*MonitorExit)(JNIEnv*, jobject);
459 jint (*GetJavaVM)(JNIEnv*, JavaVM**);
460
461 void (*GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*);
462 void (*GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*);
463
464 void* (*GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*);
465 void (*ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint);
466
467 const jchar* (*GetStringCritical)(JNIEnv*, jstring, jboolean*);
468 void (*ReleaseStringCritical)(JNIEnv*, jstring, const jchar*);
469
470 jweak (*NewWeakGlobalRef)(JNIEnv*, jobject);
471 void (*DeleteWeakGlobalRef)(JNIEnv*, jweak);
472
473 jboolean (*ExceptionCheck)(JNIEnv*);
474
475 jobject (*NewDirectByteBuffer)(JNIEnv*, void*, jlong);
476 void* (*GetDirectBufferAddress)(JNIEnv*, jobject);
477 jlong (*GetDirectBufferCapacity)(JNIEnv*, jobject);
478
479 /* added in JNI 1.6 */
480 jobjectRefType (*GetObjectRefType)(JNIEnv*, jobject);
481};
482
483/*
484 * C++ object wrapper.
485 *
486 * This is usually overlaid on a C struct whose first element is a
487 * JNINativeInterface*. We rely somewhat on compiler behavior.
488 */
489struct _JNIEnv {
490 /* do not rename this; it does not seem to be entirely opaque */
491 const struct JNINativeInterface* functions;
492
493#if defined(__cplusplus)
494
495 jint GetVersion()
496 { return functions->GetVersion(this); }
497
498 jclass DefineClass(const char *name, jobject loader, const jbyte* buf,
499 jsize bufLen)
500 { return functions->DefineClass(this, name, loader, buf, bufLen); }
501
502 jclass FindClass(const char* name)
503 { return functions->FindClass(this, name); }
504
505 jmethodID FromReflectedMethod(jobject method)
506 { return functions->FromReflectedMethod(this, method); }
507
508 jfieldID FromReflectedField(jobject field)
509 { return functions->FromReflectedField(this, field); }
510
511 jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic)
512 { return functions->ToReflectedMethod(this, cls, methodID, isStatic); }
513
514 jclass GetSuperclass(jclass clazz)
515 { return functions->GetSuperclass(this, clazz); }
516
517 jboolean IsAssignableFrom(jclass clazz1, jclass clazz2)
518 { return functions->IsAssignableFrom(this, clazz1, clazz2); }
519
520 jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic)
521 { return functions->ToReflectedField(this, cls, fieldID, isStatic); }
522
523 jint Throw(jthrowable obj)
524 { return functions->Throw(this, obj); }
525
526 jint ThrowNew(jclass clazz, const char* message)
527 { return functions->ThrowNew(this, clazz, message); }
528
529 jthrowable ExceptionOccurred()
530 { return functions->ExceptionOccurred(this); }
531
532 void ExceptionDescribe()
533 { functions->ExceptionDescribe(this); }
534
535 void ExceptionClear()
536 { functions->ExceptionClear(this); }
537
538 void FatalError(const char* msg)
539 { functions->FatalError(this, msg); }
540
541 jint PushLocalFrame(jint capacity)
542 { return functions->PushLocalFrame(this, capacity); }
543
544 jobject PopLocalFrame(jobject result)
545 { return functions->PopLocalFrame(this, result); }
546
547 jobject NewGlobalRef(jobject obj)
548 { return functions->NewGlobalRef(this, obj); }
549
550 void DeleteGlobalRef(jobject globalRef)
551 { functions->DeleteGlobalRef(this, globalRef); }
552
553 void DeleteLocalRef(jobject localRef)
554 { functions->DeleteLocalRef(this, localRef); }
555
556 jboolean IsSameObject(jobject ref1, jobject ref2)
557 { return functions->IsSameObject(this, ref1, ref2); }
558
559 jobject NewLocalRef(jobject ref)
560 { return functions->NewLocalRef(this, ref); }
561
562 jint EnsureLocalCapacity(jint capacity)
563 { return functions->EnsureLocalCapacity(this, capacity); }
564
565 jobject AllocObject(jclass clazz)
566 { return functions->AllocObject(this, clazz); }
567
568 jobject NewObject(jclass clazz, jmethodID methodID, ...)
569 {
570 va_list args;
571 va_start(args, methodID);
572 jobject result = functions->NewObjectV(this, clazz, methodID, args);
573 va_end(args);
574 return result;
575 }
576
577 jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args)
578 { return functions->NewObjectV(this, clazz, methodID, args); }
579
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700580 jobject NewObjectA(jclass clazz, jmethodID methodID, const jvalue* args)
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800581 { return functions->NewObjectA(this, clazz, methodID, args); }
582
583 jclass GetObjectClass(jobject obj)
584 { return functions->GetObjectClass(this, obj); }
585
586 jboolean IsInstanceOf(jobject obj, jclass clazz)
587 { return functions->IsInstanceOf(this, obj, clazz); }
588
589 jmethodID GetMethodID(jclass clazz, const char* name, const char* sig)
590 { return functions->GetMethodID(this, clazz, name, sig); }
591
592#define CALL_TYPE_METHOD(_jtype, _jname) \
593 _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...) \
594 { \
595 _jtype result; \
596 va_list args; \
597 va_start(args, methodID); \
598 result = functions->Call##_jname##MethodV(this, obj, methodID, \
599 args); \
600 va_end(args); \
601 return result; \
602 }
603#define CALL_TYPE_METHODV(_jtype, _jname) \
604 _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID, \
605 va_list args) \
606 { return functions->Call##_jname##MethodV(this, obj, methodID, args); }
607#define CALL_TYPE_METHODA(_jtype, _jname) \
608 _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID, \
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700609 const jvalue* args) \
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800610 { return functions->Call##_jname##MethodA(this, obj, methodID, args); }
611
612#define CALL_TYPE(_jtype, _jname) \
613 CALL_TYPE_METHOD(_jtype, _jname) \
614 CALL_TYPE_METHODV(_jtype, _jname) \
615 CALL_TYPE_METHODA(_jtype, _jname)
616
617 CALL_TYPE(jobject, Object)
618 CALL_TYPE(jboolean, Boolean)
619 CALL_TYPE(jbyte, Byte)
620 CALL_TYPE(jchar, Char)
621 CALL_TYPE(jshort, Short)
622 CALL_TYPE(jint, Int)
623 CALL_TYPE(jlong, Long)
624 CALL_TYPE(jfloat, Float)
625 CALL_TYPE(jdouble, Double)
626
627 void CallVoidMethod(jobject obj, jmethodID methodID, ...)
628 {
629 va_list args;
630 va_start(args, methodID);
631 functions->CallVoidMethodV(this, obj, methodID, args);
632 va_end(args);
633 }
634 void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args)
635 { functions->CallVoidMethodV(this, obj, methodID, args); }
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700636 void CallVoidMethodA(jobject obj, jmethodID methodID, const jvalue* args)
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800637 { functions->CallVoidMethodA(this, obj, methodID, args); }
638
639#define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \
640 _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz, \
641 jmethodID methodID, ...) \
642 { \
643 _jtype result; \
644 va_list args; \
645 va_start(args, methodID); \
646 result = functions->CallNonvirtual##_jname##MethodV(this, obj, \
647 clazz, methodID, args); \
648 va_end(args); \
649 return result; \
650 }
651#define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \
652 _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz, \
653 jmethodID methodID, va_list args) \
654 { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz, \
655 methodID, args); }
656#define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) \
657 _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz, \
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700658 jmethodID methodID, const jvalue* args) \
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800659 { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz, \
660 methodID, args); }
661
662#define CALL_NONVIRT_TYPE(_jtype, _jname) \
663 CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \
664 CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \
665 CALL_NONVIRT_TYPE_METHODA(_jtype, _jname)
666
667 CALL_NONVIRT_TYPE(jobject, Object)
668 CALL_NONVIRT_TYPE(jboolean, Boolean)
669 CALL_NONVIRT_TYPE(jbyte, Byte)
670 CALL_NONVIRT_TYPE(jchar, Char)
671 CALL_NONVIRT_TYPE(jshort, Short)
672 CALL_NONVIRT_TYPE(jint, Int)
673 CALL_NONVIRT_TYPE(jlong, Long)
674 CALL_NONVIRT_TYPE(jfloat, Float)
675 CALL_NONVIRT_TYPE(jdouble, Double)
676
677 void CallNonvirtualVoidMethod(jobject obj, jclass clazz,
678 jmethodID methodID, ...)
679 {
680 va_list args;
681 va_start(args, methodID);
682 functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args);
683 va_end(args);
684 }
685 void CallNonvirtualVoidMethodV(jobject obj, jclass clazz,
686 jmethodID methodID, va_list args)
687 { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); }
688 void CallNonvirtualVoidMethodA(jobject obj, jclass clazz,
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700689 jmethodID methodID, const jvalue* args)
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800690 { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); }
691
692 jfieldID GetFieldID(jclass clazz, const char* name, const char* sig)
693 { return functions->GetFieldID(this, clazz, name, sig); }
694
695 jobject GetObjectField(jobject obj, jfieldID fieldID)
696 { return functions->GetObjectField(this, obj, fieldID); }
697 jboolean GetBooleanField(jobject obj, jfieldID fieldID)
698 { return functions->GetBooleanField(this, obj, fieldID); }
699 jbyte GetByteField(jobject obj, jfieldID fieldID)
700 { return functions->GetByteField(this, obj, fieldID); }
701 jchar GetCharField(jobject obj, jfieldID fieldID)
702 { return functions->GetCharField(this, obj, fieldID); }
703 jshort GetShortField(jobject obj, jfieldID fieldID)
704 { return functions->GetShortField(this, obj, fieldID); }
705 jint GetIntField(jobject obj, jfieldID fieldID)
706 { return functions->GetIntField(this, obj, fieldID); }
707 jlong GetLongField(jobject obj, jfieldID fieldID)
708 { return functions->GetLongField(this, obj, fieldID); }
709 jfloat GetFloatField(jobject obj, jfieldID fieldID)
710 { return functions->GetFloatField(this, obj, fieldID); }
711 jdouble GetDoubleField(jobject obj, jfieldID fieldID)
712 { return functions->GetDoubleField(this, obj, fieldID); }
713
714 void SetObjectField(jobject obj, jfieldID fieldID, jobject value)
715 { functions->SetObjectField(this, obj, fieldID, value); }
716 void SetBooleanField(jobject obj, jfieldID fieldID, jboolean value)
717 { functions->SetBooleanField(this, obj, fieldID, value); }
718 void SetByteField(jobject obj, jfieldID fieldID, jbyte value)
719 { functions->SetByteField(this, obj, fieldID, value); }
720 void SetCharField(jobject obj, jfieldID fieldID, jchar value)
721 { functions->SetCharField(this, obj, fieldID, value); }
722 void SetShortField(jobject obj, jfieldID fieldID, jshort value)
723 { functions->SetShortField(this, obj, fieldID, value); }
724 void SetIntField(jobject obj, jfieldID fieldID, jint value)
725 { functions->SetIntField(this, obj, fieldID, value); }
726 void SetLongField(jobject obj, jfieldID fieldID, jlong value)
727 { functions->SetLongField(this, obj, fieldID, value); }
728 void SetFloatField(jobject obj, jfieldID fieldID, jfloat value)
729 { functions->SetFloatField(this, obj, fieldID, value); }
730 void SetDoubleField(jobject obj, jfieldID fieldID, jdouble value)
731 { functions->SetDoubleField(this, obj, fieldID, value); }
732
733 jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig)
734 { return functions->GetStaticMethodID(this, clazz, name, sig); }
735
736#define CALL_STATIC_TYPE_METHOD(_jtype, _jname) \
737 _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID, \
738 ...) \
739 { \
740 _jtype result; \
741 va_list args; \
742 va_start(args, methodID); \
743 result = functions->CallStatic##_jname##MethodV(this, clazz, \
744 methodID, args); \
745 va_end(args); \
746 return result; \
747 }
748#define CALL_STATIC_TYPE_METHODV(_jtype, _jname) \
749 _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID, \
750 va_list args) \
751 { return functions->CallStatic##_jname##MethodV(this, clazz, methodID, \
752 args); }
753#define CALL_STATIC_TYPE_METHODA(_jtype, _jname) \
754 _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID, \
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700755 const jvalue* args) \
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800756 { return functions->CallStatic##_jname##MethodA(this, clazz, methodID, \
757 args); }
758
759#define CALL_STATIC_TYPE(_jtype, _jname) \
760 CALL_STATIC_TYPE_METHOD(_jtype, _jname) \
761 CALL_STATIC_TYPE_METHODV(_jtype, _jname) \
762 CALL_STATIC_TYPE_METHODA(_jtype, _jname)
763
764 CALL_STATIC_TYPE(jobject, Object)
765 CALL_STATIC_TYPE(jboolean, Boolean)
766 CALL_STATIC_TYPE(jbyte, Byte)
767 CALL_STATIC_TYPE(jchar, Char)
768 CALL_STATIC_TYPE(jshort, Short)
769 CALL_STATIC_TYPE(jint, Int)
770 CALL_STATIC_TYPE(jlong, Long)
771 CALL_STATIC_TYPE(jfloat, Float)
772 CALL_STATIC_TYPE(jdouble, Double)
773
Chris Wailes0bfb3dd2022-06-17 13:27:47 -0700774 __attribute__((no_stack_protector))
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800775 void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...)
776 {
777 va_list args;
778 va_start(args, methodID);
779 functions->CallStaticVoidMethodV(this, clazz, methodID, args);
780 va_end(args);
781 }
782 void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args)
783 { functions->CallStaticVoidMethodV(this, clazz, methodID, args); }
Elliott Hughesd1f27d72018-06-15 17:35:18 -0700784 void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, const jvalue* args)
The Android Open Source Project7f844dd2009-03-03 19:28:47 -0800785 { functions->CallStaticVoidMethodA(this, clazz, methodID, args); }
786
787 jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig)
788 { return functions->GetStaticFieldID(this, clazz, name, sig); }
789
790 jobject GetStaticObjectField(jclass clazz, jfieldID fieldID)
791 { return functions->GetStaticObjectField(this, clazz, fieldID); }
792 jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID)
793 { return functions->GetStaticBooleanField(this, clazz, fieldID); }
794 jbyte GetStaticByteField(jclass clazz, jfieldID fieldID)
795 { return functions->GetStaticByteField(this, clazz, fieldID); }
796 jchar GetStaticCharField(jclass clazz, jfieldID fieldID)
797 { return functions->GetStaticCharField(this, clazz, fieldID); }
798 jshort GetStaticShortField(jclass clazz, jfieldID fieldID)
799 { return functions->GetStaticShortField(this, clazz, fieldID); }
800 jint GetStaticIntField(jclass clazz, jfieldID fieldID)
801 { return functions->GetStaticIntField(this, clazz, fieldID); }
802 jlong GetStaticLongField(jclass clazz, jfieldID fieldID)
803 { return functions->GetStaticLongField(this, clazz, fieldID); }
804 jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID)
805 { return functions->GetStaticFloatField(this, clazz, fieldID); }
806 jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID)
807 { return functions->GetStaticDoubleField(this, clazz, fieldID); }
808
809 void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject value)
810 { functions->SetStaticObjectField(this, clazz, fieldID, value); }
811 void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean value)
812 { functions->SetStaticBooleanField(this, clazz, fieldID, value); }
813 void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte value)
814 { functions->SetStaticByteField(this, clazz, fieldID, value); }
815 void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar value)
816 { functions->SetStaticCharField(this, clazz, fieldID, value); }
817 void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort value)
818 { functions->SetStaticShortField(this, clazz, fieldID, value); }
819 void SetStaticIntField(jclass clazz, jfieldID fieldID, jint value)
820 { functions->SetStaticIntField(this, clazz, fieldID, value); }
821 void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong value)
822 { functions->SetStaticLongField(this, clazz, fieldID, value); }
823 void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat value)
824 { functions->SetStaticFloatField(this, clazz, fieldID, value); }
825 void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble value)
826 { functions->SetStaticDoubleField(this, clazz, fieldID, value); }
827
828 jstring NewString(const jchar* unicodeChars, jsize len)
829 { return functions->NewString(this, unicodeChars, len); }
830
831 jsize GetStringLength(jstring string)
832 { return functions->GetStringLength(this, string); }
833
834 const jchar* GetStringChars(jstring string, jboolean* isCopy)
835 { return functions->GetStringChars(this, string, isCopy); }
836
837 void ReleaseStringChars(jstring string, const jchar* chars)
838 { functions->ReleaseStringChars(this, string, chars); }
839
840 jstring NewStringUTF(const char* bytes)
841 { return functions->NewStringUTF(this, bytes); }
842
843 jsize GetStringUTFLength(jstring string)
844 { return functions->GetStringUTFLength(this, string); }
845
846 const char* GetStringUTFChars(jstring string, jboolean* isCopy)
847 { return functions->GetStringUTFChars(this, string, isCopy); }
848
849 void ReleaseStringUTFChars(jstring string, const char* utf)
850 { functions->ReleaseStringUTFChars(this, string, utf); }
851
852 jsize GetArrayLength(jarray array)
853 { return functions->GetArrayLength(this, array); }
854
855 jobjectArray NewObjectArray(jsize length, jclass elementClass,
856 jobject initialElement)
857 { return functions->NewObjectArray(this, length, elementClass,
858 initialElement); }
859
860 jobject GetObjectArrayElement(jobjectArray array, jsize index)
861 { return functions->GetObjectArrayElement(this, array, index); }
862
863 void SetObjectArrayElement(jobjectArray array, jsize index, jobject value)
864 { functions->SetObjectArrayElement(this, array, index, value); }
865
866 jbooleanArray NewBooleanArray(jsize length)
867 { return functions->NewBooleanArray(this, length); }
868 jbyteArray NewByteArray(jsize length)
869 { return functions->NewByteArray(this, length); }
870 jcharArray NewCharArray(jsize length)
871 { return functions->NewCharArray(this, length); }
872 jshortArray NewShortArray(jsize length)
873 { return functions->NewShortArray(this, length); }
874 jintArray NewIntArray(jsize length)
875 { return functions->NewIntArray(this, length); }
876 jlongArray NewLongArray(jsize length)
877 { return functions->NewLongArray(this, length); }
878 jfloatArray NewFloatArray(jsize length)
879 { return functions->NewFloatArray(this, length); }
880 jdoubleArray NewDoubleArray(jsize length)
881 { return functions->NewDoubleArray(this, length); }
882
883 jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy)
884 { return functions->GetBooleanArrayElements(this, array, isCopy); }
885 jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy)
886 { return functions->GetByteArrayElements(this, array, isCopy); }
887 jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy)
888 { return functions->GetCharArrayElements(this, array, isCopy); }
889 jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy)
890 { return functions->GetShortArrayElements(this, array, isCopy); }
891 jint* GetIntArrayElements(jintArray array, jboolean* isCopy)
892 { return functions->GetIntArrayElements(this, array, isCopy); }
893 jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy)
894 { return functions->GetLongArrayElements(this, array, isCopy); }
895 jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy)
896 { return functions->GetFloatArrayElements(this, array, isCopy); }
897 jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy)
898 { return functions->GetDoubleArrayElements(this, array, isCopy); }
899
900 void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems,
901 jint mode)
902 { functions->ReleaseBooleanArrayElements(this, array, elems, mode); }
903 void ReleaseByteArrayElements(jbyteArray array, jbyte* elems,
904 jint mode)
905 { functions->ReleaseByteArrayElements(this, array, elems, mode); }
906 void ReleaseCharArrayElements(jcharArray array, jchar* elems,
907 jint mode)
908 { functions->ReleaseCharArrayElements(this, array, elems, mode); }
909 void ReleaseShortArrayElements(jshortArray array, jshort* elems,
910 jint mode)
911 { functions->ReleaseShortArrayElements(this, array, elems, mode); }
912 void ReleaseIntArrayElements(jintArray array, jint* elems,
913 jint mode)
914 { functions->ReleaseIntArrayElements(this, array, elems, mode); }
915 void ReleaseLongArrayElements(jlongArray array, jlong* elems,
916 jint mode)
917 { functions->ReleaseLongArrayElements(this, array, elems, mode); }
918 void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems,
919 jint mode)
920 { functions->ReleaseFloatArrayElements(this, array, elems, mode); }
921 void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems,
922 jint mode)
923 { functions->ReleaseDoubleArrayElements(this, array, elems, mode); }
924
925 void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
926 jboolean* buf)
927 { functions->GetBooleanArrayRegion(this, array, start, len, buf); }
928 void GetByteArrayRegion(jbyteArray array, jsize start, jsize len,
929 jbyte* buf)
930 { functions->GetByteArrayRegion(this, array, start, len, buf); }
931 void GetCharArrayRegion(jcharArray array, jsize start, jsize len,
932 jchar* buf)
933 { functions->GetCharArrayRegion(this, array, start, len, buf); }
934 void GetShortArrayRegion(jshortArray array, jsize start, jsize len,
935 jshort* buf)
936 { functions->GetShortArrayRegion(this, array, start, len, buf); }
937 void GetIntArrayRegion(jintArray array, jsize start, jsize len,
938 jint* buf)
939 { functions->GetIntArrayRegion(this, array, start, len, buf); }
940 void GetLongArrayRegion(jlongArray array, jsize start, jsize len,
941 jlong* buf)
942 { functions->GetLongArrayRegion(this, array, start, len, buf); }
943 void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
944 jfloat* buf)
945 { functions->GetFloatArrayRegion(this, array, start, len, buf); }
946 void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
947 jdouble* buf)
948 { functions->GetDoubleArrayRegion(this, array, start, len, buf); }
949
950 void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len,
951 const jboolean* buf)
952 { functions->SetBooleanArrayRegion(this, array, start, len, buf); }
953 void SetByteArrayRegion(jbyteArray array, jsize start, jsize len,
954 const jbyte* buf)
955 { functions->SetByteArrayRegion(this, array, start, len, buf); }
956 void SetCharArrayRegion(jcharArray array, jsize start, jsize len,
957 const jchar* buf)
958 { functions->SetCharArrayRegion(this, array, start, len, buf); }
959 void SetShortArrayRegion(jshortArray array, jsize start, jsize len,
960 const jshort* buf)
961 { functions->SetShortArrayRegion(this, array, start, len, buf); }
962 void SetIntArrayRegion(jintArray array, jsize start, jsize len,
963 const jint* buf)
964 { functions->SetIntArrayRegion(this, array, start, len, buf); }
965 void SetLongArrayRegion(jlongArray array, jsize start, jsize len,
966 const jlong* buf)
967 { functions->SetLongArrayRegion(this, array, start, len, buf); }
968 void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len,
969 const jfloat* buf)
970 { functions->SetFloatArrayRegion(this, array, start, len, buf); }
971 void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len,
972 const jdouble* buf)
973 { functions->SetDoubleArrayRegion(this, array, start, len, buf); }
974
975 jint RegisterNatives(jclass clazz, const JNINativeMethod* methods,
976 jint nMethods)
977 { return functions->RegisterNatives(this, clazz, methods, nMethods); }
978
979 jint UnregisterNatives(jclass clazz)
980 { return functions->UnregisterNatives(this, clazz); }
981
982 jint MonitorEnter(jobject obj)
983 { return functions->MonitorEnter(this, obj); }
984
985 jint MonitorExit(jobject obj)
986 { return functions->MonitorExit(this, obj); }
987
988 jint GetJavaVM(JavaVM** vm)
989 { return functions->GetJavaVM(this, vm); }
990
991 void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf)
992 { functions->GetStringRegion(this, str, start, len, buf); }
993
994 void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf)
995 { return functions->GetStringUTFRegion(this, str, start, len, buf); }
996
997 void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy)
998 { return functions->GetPrimitiveArrayCritical(this, array, isCopy); }
999
1000 void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode)
1001 { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); }
1002
1003 const jchar* GetStringCritical(jstring string, jboolean* isCopy)
1004 { return functions->GetStringCritical(this, string, isCopy); }
1005
1006 void ReleaseStringCritical(jstring string, const jchar* carray)
1007 { functions->ReleaseStringCritical(this, string, carray); }
1008
1009 jweak NewWeakGlobalRef(jobject obj)
1010 { return functions->NewWeakGlobalRef(this, obj); }
1011
1012 void DeleteWeakGlobalRef(jweak obj)
1013 { functions->DeleteWeakGlobalRef(this, obj); }
1014
1015 jboolean ExceptionCheck()
1016 { return functions->ExceptionCheck(this); }
1017
1018 jobject NewDirectByteBuffer(void* address, jlong capacity)
1019 { return functions->NewDirectByteBuffer(this, address, capacity); }
1020
1021 void* GetDirectBufferAddress(jobject buf)
1022 { return functions->GetDirectBufferAddress(this, buf); }
1023
1024 jlong GetDirectBufferCapacity(jobject buf)
1025 { return functions->GetDirectBufferCapacity(this, buf); }
1026
1027 /* added in JNI 1.6 */
1028 jobjectRefType GetObjectRefType(jobject obj)
1029 { return functions->GetObjectRefType(this, obj); }
1030#endif /*__cplusplus*/
1031};
1032
1033
1034/*
1035 * JNI invocation interface.
1036 */
1037struct JNIInvokeInterface {
1038 void* reserved0;
1039 void* reserved1;
1040 void* reserved2;
Carl Shapiroabb4eff2010-06-08 16:37:12 -07001041
The Android Open Source Project7f844dd2009-03-03 19:28:47 -08001042 jint (*DestroyJavaVM)(JavaVM*);
1043 jint (*AttachCurrentThread)(JavaVM*, JNIEnv**, void*);
1044 jint (*DetachCurrentThread)(JavaVM*);
1045 jint (*GetEnv)(JavaVM*, void**, jint);
1046 jint (*AttachCurrentThreadAsDaemon)(JavaVM*, JNIEnv**, void*);
1047};
1048
1049/*
1050 * C++ version.
1051 */
1052struct _JavaVM {
1053 const struct JNIInvokeInterface* functions;
1054
1055#if defined(__cplusplus)
1056 jint DestroyJavaVM()
1057 { return functions->DestroyJavaVM(this); }
1058 jint AttachCurrentThread(JNIEnv** p_env, void* thr_args)
1059 { return functions->AttachCurrentThread(this, p_env, thr_args); }
1060 jint DetachCurrentThread()
1061 { return functions->DetachCurrentThread(this); }
1062 jint GetEnv(void** env, jint version)
1063 { return functions->GetEnv(this, env, version); }
1064 jint AttachCurrentThreadAsDaemon(JNIEnv** p_env, void* thr_args)
1065 { return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); }
1066#endif /*__cplusplus*/
1067};
1068
1069struct JavaVMAttachArgs {
1070 jint version; /* must be >= JNI_VERSION_1_2 */
1071 const char* name; /* NULL or name of thread as modified UTF-8 str */
1072 jobject group; /* global ref of a ThreadGroup object, or NULL */
1073};
1074typedef struct JavaVMAttachArgs JavaVMAttachArgs;
1075
1076/*
1077 * JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no
1078 * longer supported.)
1079 */
1080typedef struct JavaVMOption {
1081 const char* optionString;
1082 void* extraInfo;
1083} JavaVMOption;
1084
1085typedef struct JavaVMInitArgs {
1086 jint version; /* use JNI_VERSION_1_2 or later */
1087
1088 jint nOptions;
1089 JavaVMOption* options;
1090 jboolean ignoreUnrecognized;
1091} JavaVMInitArgs;
1092
1093#ifdef __cplusplus
1094extern "C" {
1095#endif
1096/*
1097 * VM initialization functions.
1098 *
1099 * Note these are the only symbols exported for JNI by the VM.
1100 */
1101jint JNI_GetDefaultJavaVMInitArgs(void*);
1102jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*);
1103jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*);
1104
Elliott Hughes154661e2011-08-19 11:32:49 -07001105#define JNIIMPORT
1106#define JNIEXPORT __attribute__ ((visibility ("default")))
1107#define JNICALL
1108
The Android Open Source Project7f844dd2009-03-03 19:28:47 -08001109/*
1110 * Prototypes for functions exported by loadable shared libs. These are
1111 * called by JNI, not provided by JNI.
1112 */
Elliott Hughes154661e2011-08-19 11:32:49 -07001113JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved);
1114JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved);
The Android Open Source Project7f844dd2009-03-03 19:28:47 -08001115
1116#ifdef __cplusplus
1117}
1118#endif
1119
1120
1121/*
1122 * Manifest constants.
1123 */
1124#define JNI_FALSE 0
1125#define JNI_TRUE 1
1126
1127#define JNI_VERSION_1_1 0x00010001
1128#define JNI_VERSION_1_2 0x00010002
1129#define JNI_VERSION_1_4 0x00010004
1130#define JNI_VERSION_1_6 0x00010006
1131
1132#define JNI_OK (0) /* no error */
1133#define JNI_ERR (-1) /* generic error */
1134#define JNI_EDETACHED (-2) /* thread detached from the VM */
1135#define JNI_EVERSION (-3) /* JNI version error */
Elliott Hugheseaea4522018-06-15 17:07:40 -07001136#define JNI_ENOMEM (-4) /* Out of memory */
1137#define JNI_EEXIST (-5) /* VM already created */
1138#define JNI_EINVAL (-6) /* Invalid argument */
The Android Open Source Project7f844dd2009-03-03 19:28:47 -08001139
1140#define JNI_COMMIT 1 /* copy content, do not free buffer */
1141#define JNI_ABORT 2 /* free buffer w/o copying back */
1142