blob: ceaeb966c2c680f2871b429bd88947914f9b75f7 [file] [log] [blame]
Ian Rogersdf20fe02011-07-20 20:34:16 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_JNI_INTERNAL_H_
4#define ART_SRC_JNI_INTERNAL_H_
5
6#include "jni.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07007
8#include "assembler.h"
9#include "macros.h"
Ian Rogersdf20fe02011-07-20 20:34:16 -070010
11namespace art {
12
13// TODO: This is a place holder for a true JNIEnv used to provide limited
14// functionality for the JNI compiler
15class JniEnvironment {
16 public:
17 explicit JniEnvironment();
18
19 static Offset MonitorEnterOffset() {
20 return Offset(OFFSETOF_MEMBER(JniEnvironment, monitor_enter_));
21 }
22
23 static Offset MonitorExitOffset() {
24 return Offset(OFFSETOF_MEMBER(JniEnvironment, monitor_exit_));
25 }
26
27 private:
Carl Shapiroea4dca82011-08-01 13:45:38 -070028 struct JNINativeInterface_* functions_;
29
Ian Rogersdf20fe02011-07-20 20:34:16 -070030 void (*monitor_enter_)(JniEnvironment*, jobject);
31 void (*monitor_exit_)(JniEnvironment*, jobject);
Carl Shapiro2ed144c2011-07-26 16:52:08 -070032
33 DISALLOW_COPY_AND_ASSIGN(JniEnvironment);
34};
35
Carl Shapiroea4dca82011-08-01 13:45:38 -070036class JniNativeInterface {
Carl Shapiro2ed144c2011-07-26 16:52:08 -070037 public:
Carl Shapiroea4dca82011-08-01 13:45:38 -070038 static struct JNINativeInterface* GetInterface() {
39 return &native_interface_;
40 }
Carl Shapiro2ed144c2011-07-26 16:52:08 -070041 private:
Carl Shapiroea4dca82011-08-01 13:45:38 -070042 static jint GetVersion(JNIEnv* env);
43
44 static jclass DefineClass(JNIEnv* env,
45 const char* name,
46 jobject loader,
47 const jbyte* buf,
48 jsize len);
49 static jclass FindClass(JNIEnv* env, const char* name);
50
51 static jmethodID FromReflectedMethod(JNIEnv* env, jobject method);
52 static jfieldID FromReflectedField(JNIEnv* env, jobject field);
53 static jobject ToReflectedMethod(JNIEnv* env,
54 jclass cls,
55 jmethodID methodID,
56 jboolean isStatic);
57
58 static jclass GetSuperclass(JNIEnv* env, jclass sub);
59 static jboolean IsAssignableFrom(JNIEnv* env, jclass sub, jclass sup);
60 static jobject ToReflectedField(JNIEnv* env,
61 jclass cls,
62 jfieldID fieldID,
63 jboolean isStatic);
64
65 static jint Throw(JNIEnv* env, jthrowable obj);
66 static jint ThrowNew(JNIEnv* env, jclass clazz, const char* msg);
67 static jthrowable ExceptionOccurred(JNIEnv* env);
68 static void ExceptionDescribe(JNIEnv* env);
69 static void ExceptionClear(JNIEnv* env);
70 static void FatalError(JNIEnv* env, const char* msg);
71
72 static jint PushLocalFrame(JNIEnv* env, jint cap);
73 static jobject PopLocalFrame(JNIEnv* env, jobject res);
74
75 static jobject NewGlobalRef(JNIEnv* env, jobject lobj);
76 static void DeleteGlobalRef(JNIEnv* env, jobject gref);
77 static void DeleteLocalRef(JNIEnv* env, jobject obj);
78 static jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2);
79
80 static jobject NewLocalRef(JNIEnv* env, jobject ref);
81 static jint EnsureLocalCapacity(JNIEnv* env, jint);
82
83 static jobject AllocObject(JNIEnv* env, jclass clazz);
84 static jobject NewObject(JNIEnv* env, jclass clazz, jmethodID methodID, ...);
85 static jobject NewObjectV(JNIEnv* env,
86 jclass clazz,
87 jmethodID methodID,
88 va_list args);
89 static jobject NewObjectA(JNIEnv* env,
90 jclass clazz,
91 jmethodID methodID,
92 jvalue* args);
93
94 static jclass GetObjectClass(JNIEnv* env, jobject obj);
95 static jboolean IsInstanceOf(JNIEnv* env, jobject obj, jclass clazz);
96
97 static jmethodID GetMethodID(JNIEnv* env,
98 jclass clazz,
99 const char* name,
100 const char* sig);
101
102 static jobject CallObjectMethod(JNIEnv* env,
103 jobject obj,
104 jmethodID methodID,
105 ...);
106 static jobject CallObjectMethodV(JNIEnv* env,
107 jobject obj,
108 jmethodID methodID,
109 va_list args);
110 static jobject CallObjectMethodA(JNIEnv* env,
111 jobject obj,
112 jmethodID methodID,
113 jvalue* args);
114
115 static jboolean CallBooleanMethod(JNIEnv* env,
116 jobject obj,
117 jmethodID methodID,
118 ...);
119 static jboolean CallBooleanMethodV(JNIEnv* env,
120 jobject obj,
121 jmethodID methodID,
122 va_list args);
123 static jboolean CallBooleanMethodA(JNIEnv* env,
124 jobject obj,
125 jmethodID methodID,
126 jvalue* args);
127
128 static jbyte CallByteMethod(JNIEnv* env,
129 jobject obj,
130 jmethodID methodID,
131 ...);
132 static jbyte CallByteMethodV(JNIEnv* env,
133 jobject obj,
134 jmethodID methodID,
135 va_list args);
136 static jbyte CallByteMethodA(JNIEnv* env,
137 jobject obj,
138 jmethodID methodID,
139 jvalue* args);
140
141 static jchar CallCharMethod(JNIEnv* env,
142 jobject obj,
143 jmethodID methodID,
144 ...);
145 static jchar CallCharMethodV(JNIEnv* env,
146 jobject obj,
147 jmethodID methodID,
148 va_list args);
149 static jchar CallCharMethodA(JNIEnv* env,
150 jobject obj,
151 jmethodID methodID,
152 jvalue* args);
153
154 static jshort CallShortMethod(JNIEnv* env,
155 jobject obj,
156 jmethodID methodID,
157 ...);
158 static jshort CallShortMethodV(JNIEnv* env,
159 jobject obj,
160 jmethodID methodID,
161 va_list args);
162 static jshort CallShortMethodA(JNIEnv* env,
163 jobject obj,
164 jmethodID methodID,
165 jvalue* args);
166
167 static jint CallIntMethod(JNIEnv* env,
168 jobject obj,
169 jmethodID methodID,
170 ...);
171 static jint CallIntMethodV(JNIEnv* env,
172 jobject obj,
173 jmethodID methodID,
174 va_list args);
175 static jint CallIntMethodA(JNIEnv* env,
176 jobject obj,
177 jmethodID methodID,
178 jvalue* args);
179
180 static jlong CallLongMethod(JNIEnv* env,
181 jobject obj,
182 jmethodID methodID,
183 ...);
184 static jlong CallLongMethodV(JNIEnv* env,
185 jobject obj,
186 jmethodID methodID,
187 va_list args);
188 static jlong CallLongMethodA(JNIEnv* env,
189 jobject obj,
190 jmethodID methodID,
191 jvalue* args);
192
193 static jfloat CallFloatMethod(JNIEnv* env,
194 jobject obj,
195 jmethodID methodID,
196 ...);
197 static jfloat CallFloatMethodV(JNIEnv* env,
198 jobject obj,
199 jmethodID methodID,
200 va_list args);
201 static jfloat CallFloatMethodA(JNIEnv* env,
202 jobject obj,
203 jmethodID methodID,
204 jvalue* args);
205
206 static jdouble CallDoubleMethod(JNIEnv* env,
207 jobject obj,
208 jmethodID methodID,
209 ...);
210 static jdouble CallDoubleMethodV(JNIEnv* env,
211 jobject obj,
212 jmethodID methodID,
213 va_list args);
214 static jdouble CallDoubleMethodA(JNIEnv* env,
215 jobject obj,
216 jmethodID methodID,
217 jvalue* args);
218
219 static void CallVoidMethod(JNIEnv* env,
220 jobject obj,
221 jmethodID methodID,
222 ...);
223 static void CallVoidMethodV(JNIEnv* env,
224 jobject obj,
225 jmethodID methodID,
226 va_list args);
227 static void CallVoidMethodA(JNIEnv* env,
228 jobject obj,
229 jmethodID methodID,
230 jvalue* args);
231
232 static jobject CallNonvirtualObjectMethod(JNIEnv* env,
233 jobject obj,
234 jclass clazz,
235 jmethodID methodID,
236 ...);
237 static jobject CallNonvirtualObjectMethodV(JNIEnv* env,
238 jobject obj,
239 jclass clazz,
240 jmethodID methodID,
241 va_list args);
242 static jobject CallNonvirtualObjectMethodA(JNIEnv* env,
243 jobject obj,
244 jclass clazz,
245 jmethodID methodID,
246 jvalue* args);
247
248 static jboolean CallNonvirtualBooleanMethod(JNIEnv* env,
249 jobject obj,
250 jclass clazz,
251 jmethodID methodID,
252 ...);
253 static jboolean CallNonvirtualBooleanMethodV(JNIEnv* env,
254 jobject obj,
255 jclass clazz,
256 jmethodID methodID,
257 va_list args);
258 static jboolean CallNonvirtualBooleanMethodA(JNIEnv* env,
259 jobject obj,
260 jclass clazz,
261 jmethodID methodID,
262 jvalue* args);
263
264 static jbyte CallNonvirtualByteMethod(JNIEnv* env,
265 jobject obj,
266 jclass clazz,
267 jmethodID methodID,
268 ...);
269 static jbyte CallNonvirtualByteMethodV(JNIEnv* env,
270 jobject obj,
271 jclass clazz,
272 jmethodID methodID,
273 va_list args);
274 static jbyte CallNonvirtualByteMethodA(JNIEnv* env,
275 jobject obj,
276 jclass clazz,
277 jmethodID methodID,
278 jvalue* args);
279
280 static jchar CallNonvirtualCharMethod(JNIEnv* env,
281 jobject obj,
282 jclass clazz,
283 jmethodID methodID,
284 ...);
285 static jchar CallNonvirtualCharMethodV(JNIEnv* env,
286 jobject obj,
287 jclass clazz,
288 jmethodID methodID,
289 va_list args);
290 static jchar CallNonvirtualCharMethodA(JNIEnv* env,
291 jobject obj,
292 jclass clazz,
293 jmethodID methodID,
294 jvalue* args);
295
296 static jshort CallNonvirtualShortMethod(JNIEnv* env,
297 jobject obj,
298 jclass clazz,
299 jmethodID methodID,
300 ...);
301 static jshort CallNonvirtualShortMethodV(JNIEnv* env,
302 jobject obj,
303 jclass clazz,
304 jmethodID methodID,
305 va_list args);
306 static jshort CallNonvirtualShortMethodA(JNIEnv* env,
307 jobject obj,
308 jclass clazz,
309 jmethodID methodID,
310 jvalue* args);
311
312 static jint CallNonvirtualIntMethod(JNIEnv* env,
313 jobject obj,
314 jclass clazz,
315 jmethodID methodID,
316 ...);
317 static jint CallNonvirtualIntMethodV(JNIEnv* env,
318 jobject obj,
319 jclass clazz,
320 jmethodID methodID,
321 va_list args);
322 static jint CallNonvirtualIntMethodA(JNIEnv* env,
323 jobject obj,
324 jclass clazz,
325 jmethodID methodID,
326 jvalue* args);
327
328 static jlong CallNonvirtualLongMethod(JNIEnv* env,
329 jobject obj,
330 jclass clazz,
331 jmethodID methodID,
332 ...);
333 static jlong CallNonvirtualLongMethodV(JNIEnv* env,
334 jobject obj,
335 jclass clazz,
336 jmethodID methodID,
337 va_list args);
338 static jlong CallNonvirtualLongMethodA(JNIEnv* env,
339 jobject obj,
340 jclass clazz,
341 jmethodID methodID,
342 jvalue* args);
343
344 static jfloat CallNonvirtualFloatMethod(JNIEnv* env,
345 jobject obj,
346 jclass clazz,
347 jmethodID methodID,
348 ...);
349 static jfloat CallNonvirtualFloatMethodV(JNIEnv* env,
350 jobject obj,
351 jclass clazz,
352 jmethodID methodID,
353 va_list args);
354 static jfloat CallNonvirtualFloatMethodA(JNIEnv* env,
355 jobject obj,
356 jclass clazz,
357 jmethodID methodID,
358 jvalue* args);
359
360 static jdouble CallNonvirtualDoubleMethod(JNIEnv* env,
361 jobject obj,
362 jclass clazz,
363 jmethodID methodID,
364 ...);
365 static jdouble CallNonvirtualDoubleMethodV(JNIEnv* env,
366 jobject obj,
367 jclass clazz,
368 jmethodID methodID,
369 va_list args);
370 static jdouble CallNonvirtualDoubleMethodA(JNIEnv* env,
371 jobject obj,
372 jclass clazz,
373 jmethodID methodID,
374 jvalue* args);
375
376 static void CallNonvirtualVoidMethod(JNIEnv* env,
377 jobject obj,
378 jclass clazz,
379 jmethodID methodID,
380 ...);
381 static void CallNonvirtualVoidMethodV(JNIEnv* env,
382 jobject obj,
383 jclass clazz,
384 jmethodID methodID,
385 va_list args);
386 static void CallNonvirtualVoidMethodA(JNIEnv* env,
387 jobject obj,
388 jclass clazz,
389 jmethodID methodID,
390 jvalue* args);
391
392 static jfieldID GetFieldID(JNIEnv* env,
393 jclass clazz,
394 const char* name,
395 const char* sig);
396
397 static jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID);
398 static jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID);
399 static jbyte GetByteField(JNIEnv* env, jobject obj, jfieldID fieldID);
400 static jchar GetCharField(JNIEnv* env, jobject obj, jfieldID fieldID);
401 static jshort GetShortField(JNIEnv* env, jobject obj, jfieldID fieldID);
402 static jint GetIntField(JNIEnv* env, jobject obj, jfieldID fieldID);
403 static jlong GetLongField(JNIEnv* env, jobject obj, jfieldID fieldID);
404 static jfloat GetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID);
405 static jdouble GetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID);
406
407 static void SetObjectField(JNIEnv* env,
408 jobject obj,
409 jfieldID fieldID,
410 jobject val);
411 static void SetBooleanField(JNIEnv* env,
412 jobject obj,
413 jfieldID fieldID,
414 jboolean val);
415 static void SetByteField(JNIEnv* env,
416 jobject obj,
417 jfieldID fieldID,
418 jbyte val);
419 static void SetCharField(JNIEnv* env,
420 jobject obj,
421 jfieldID fieldID,
422 jchar val);
423 static void SetShortField(JNIEnv* env,
424 jobject obj,
425 jfieldID fieldID,
426 jshort val);
427 static void SetIntField(JNIEnv* env, jobject obj, jfieldID fieldID, jint val);
428 static void SetLongField(JNIEnv* env,
429 jobject obj,
430 jfieldID fieldID,
431 jlong val);
432 static void SetFloatField(JNIEnv* env,
433 jobject obj,
434 jfieldID fieldID,
435 jfloat val);
436 static void SetDoubleField(JNIEnv* env,
437 jobject obj,
438 jfieldID fieldID,
439 jdouble val);
440
441 static jmethodID GetStaticMethodID(JNIEnv* env,
442 jclass clazz,
443 const char* name,
444 const char* sig);
445
446 static jobject CallStaticObjectMethod(JNIEnv* env,
447 jclass clazz,
448 jmethodID methodID,
449 ...);
450 static jobject CallStaticObjectMethodV(JNIEnv* env,
451 jclass clazz,
452 jmethodID methodID,
453 va_list args);
454 static jobject CallStaticObjectMethodA(JNIEnv* env,
455 jclass clazz,
456 jmethodID methodID,
457 jvalue* args);
458
459 static jboolean CallStaticBooleanMethod(JNIEnv* env,
460 jclass clazz,
461 jmethodID methodID,
462 ...);
463 static jboolean CallStaticBooleanMethodV(JNIEnv* env,
464 jclass clazz,
465 jmethodID methodID,
466 va_list args);
467 static jboolean CallStaticBooleanMethodA(JNIEnv* env,
468 jclass clazz,
469 jmethodID methodID,
470 jvalue* args);
471
472 static jbyte CallStaticByteMethod(JNIEnv* env,
473 jclass clazz,
474 jmethodID methodID,
475 ...);
476 static jbyte CallStaticByteMethodV(JNIEnv* env,
477 jclass clazz,
478 jmethodID methodID,
479 va_list args);
480 static jbyte CallStaticByteMethodA(JNIEnv* env,
481 jclass clazz,
482 jmethodID methodID,
483 jvalue* args);
484
485 static jchar CallStaticCharMethod(JNIEnv* env,
486 jclass clazz,
487 jmethodID methodID,
488 ...);
489 static jchar CallStaticCharMethodV(JNIEnv* env,
490 jclass clazz,
491 jmethodID methodID,
492 va_list args);
493 static jchar CallStaticCharMethodA(JNIEnv* env,
494 jclass clazz,
495 jmethodID methodID,
496 jvalue* args);
497
498 static jshort CallStaticShortMethod(JNIEnv* env,
499 jclass clazz,
500 jmethodID methodID,
501 ...);
502 static jshort CallStaticShortMethodV(JNIEnv* env,
503 jclass clazz,
504 jmethodID methodID,
505 va_list args);
506 static jshort CallStaticShortMethodA(JNIEnv* env,
507 jclass clazz,
508 jmethodID methodID,
509 jvalue* args);
510
511 static jint CallStaticIntMethod(JNIEnv* env,
512 jclass clazz,
513 jmethodID methodID,
514 ...);
515 static jint CallStaticIntMethodV(JNIEnv* env,
516 jclass clazz,
517 jmethodID methodID,
518 va_list args);
519 static jint CallStaticIntMethodA(JNIEnv* env,
520 jclass clazz,
521 jmethodID methodID,
522 jvalue* args);
523
524 static jlong CallStaticLongMethod(JNIEnv* env,
525 jclass clazz,
526 jmethodID methodID,
527 ...);
528 static jlong CallStaticLongMethodV(JNIEnv* env,
529 jclass clazz,
530 jmethodID methodID,
531 va_list args);
532 static jlong CallStaticLongMethodA(JNIEnv* env,
533 jclass clazz,
534 jmethodID methodID,
535 jvalue* args);
536
537 static jfloat CallStaticFloatMethod(JNIEnv* env,
538 jclass clazz,
539 jmethodID methodID,
540 ...);
541 static jfloat CallStaticFloatMethodV(JNIEnv* env,
542 jclass clazz,
543 jmethodID methodID,
544 va_list args);
545 static jfloat CallStaticFloatMethodA(JNIEnv* env,
546 jclass clazz,
547 jmethodID methodID,
548 jvalue* args);
549
550 static jdouble CallStaticDoubleMethod(JNIEnv* env,
551 jclass clazz,
552 jmethodID methodID,
553 ...);
554 static jdouble CallStaticDoubleMethodV(JNIEnv* env,
555 jclass clazz,
556 jmethodID methodID,
557 va_list args);
558 static jdouble CallStaticDoubleMethodA(JNIEnv* env,
559 jclass clazz,
560 jmethodID methodID,
561 jvalue* args);
562
563 static void CallStaticVoidMethod(JNIEnv* env,
564 jclass cls,
565 jmethodID methodID,
566 ...);
567 static void CallStaticVoidMethodV(JNIEnv* env,
568 jclass cls,
569 jmethodID methodID,
570 va_list args);
571 static void CallStaticVoidMethodA(JNIEnv* env,
572 jclass cls,
573 jmethodID methodID,
574 jvalue* args);
575
576 static jfieldID GetStaticFieldID(JNIEnv* env,
577 jclass clazz,
578 const char* name,
579 const char* sig);
580 static jobject GetStaticObjectField(JNIEnv* env,
581 jclass clazz,
582 jfieldID fieldID);
583 static jboolean GetStaticBooleanField(JNIEnv* env,
584 jclass clazz,
585 jfieldID fieldID);
586 static jbyte GetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID);
587 static jchar GetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID);
588 static jshort GetStaticShortField(JNIEnv* env,
589 jclass clazz,
590 jfieldID fieldID);
591 static jint GetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID);
592 static jlong GetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID);
593 static jfloat GetStaticFloatField(JNIEnv* env,
594 jclass clazz,
595 jfieldID fieldID);
596 static jdouble GetStaticDoubleField(JNIEnv* env,
597 jclass clazz,
598 jfieldID fieldID);
599
600 static void SetStaticObjectField(JNIEnv* env,
601 jclass clazz,
602 jfieldID fieldID,
603 jobject value);
604 static void SetStaticBooleanField(JNIEnv* env,
605 jclass clazz,
606 jfieldID fieldID,
607 jboolean value);
608 static void SetStaticByteField(JNIEnv* env,
609 jclass clazz,
610 jfieldID fieldID,
611 jbyte value);
612 static void SetStaticCharField(JNIEnv* env,
613 jclass clazz,
614 jfieldID fieldID,
615 jchar value);
616 static void SetStaticShortField(JNIEnv* env,
617 jclass clazz,
618 jfieldID fieldID,
619 jshort value);
620 static void SetStaticIntField(JNIEnv* env,
621 jclass clazz,
622 jfieldID fieldID,
623 jint value);
624 static void SetStaticLongField(JNIEnv* env,
625 jclass clazz,
626 jfieldID fieldID,
627 jlong value);
628 static void SetStaticFloatField(JNIEnv* env,
629 jclass clazz,
630 jfieldID fieldID,
631 jfloat value);
632 static void SetStaticDoubleField(JNIEnv* env,
633 jclass clazz,
634 jfieldID fieldID,
635 jdouble value);
636
637 static jstring NewString(JNIEnv* env, const jchar* unicode, jsize len);
638 static jsize GetStringLength(JNIEnv* env, jstring str);
639 static const jchar* GetStringChars(JNIEnv* env,
640 jstring str,
641 jboolean* isCopy);
642 static void ReleaseStringChars(JNIEnv* env, jstring str, const jchar* chars);
643 static jstring NewStringUTF(JNIEnv* env, const char* utf);
644 static jsize GetStringUTFLength(JNIEnv* env, jstring str);
645 static const char* GetStringUTFChars(JNIEnv* env,
646 jstring str,
647 jboolean* isCopy);
648 static void ReleaseStringUTFChars(JNIEnv* env,
649 jstring str,
650 const char* chars);
651
652 static jsize GetArrayLength(JNIEnv* env, jarray array);
653
654 static jobjectArray NewObjectArray(JNIEnv* env,
655 jsize len,
656 jclass clazz,
657 jobject init);
658 static jobject GetObjectArrayElement(JNIEnv* env,
659 jobjectArray array,
660 jsize index);
661 static void SetObjectArrayElement(JNIEnv* env,
662 jobjectArray array,
663 jsize index,
664 jobject val);
665
666 static jbooleanArray NewBooleanArray(JNIEnv* env, jsize len);
667 static jbyteArray NewByteArray(JNIEnv* env, jsize len);
668 static jcharArray NewCharArray(JNIEnv* env, jsize len);
669 static jshortArray NewShortArray(JNIEnv* env, jsize len);
670 static jintArray NewIntArray(JNIEnv* env, jsize len);
671 static jlongArray NewLongArray(JNIEnv* env, jsize len);
672 static jfloatArray NewFloatArray(JNIEnv* env, jsize len);
673 static jdoubleArray NewDoubleArray(JNIEnv* env, jsize len);
674
675 static jboolean* GetBooleanArrayElements(JNIEnv* env,
676 jbooleanArray array,
677 jboolean* isCopy);
678 static jbyte* GetByteArrayElements(JNIEnv* env,
679 jbyteArray array,
680 jboolean* isCopy);
681 static jchar* GetCharArrayElements(JNIEnv* env,
682 jcharArray array,
683 jboolean* isCopy);
684 static jshort* GetShortArrayElements(JNIEnv* env,
685 jshortArray array,
686 jboolean* isCopy);
687 static jint* GetIntArrayElements(JNIEnv* env,
688 jintArray array,
689 jboolean* isCopy);
690 static jlong* GetLongArrayElements(JNIEnv* env,
691 jlongArray array,
692 jboolean* isCopy);
693 static jfloat* GetFloatArrayElements(JNIEnv* env,
694 jfloatArray array,
695 jboolean* isCopy);
696 static jdouble* GetDoubleArrayElements(JNIEnv* env,
697 jdoubleArray array,
698 jboolean* isCopy);
699
700 static void ReleaseBooleanArrayElements(JNIEnv* env,
701 jbooleanArray array,
702 jboolean* elems,
703 jint mode);
704 static void ReleaseByteArrayElements(JNIEnv* env,
705 jbyteArray array,
706 jbyte* elems,
707 jint mode);
708 static void ReleaseCharArrayElements(JNIEnv* env,
709 jcharArray array,
710 jchar* elems,
711 jint mode);
712 static void ReleaseShortArrayElements(JNIEnv* env,
713 jshortArray array,
714 jshort* elems,
715 jint mode);
716 static void ReleaseIntArrayElements(JNIEnv* env,
717 jintArray array,
718 jint* elems,
719 jint mode);
720 static void ReleaseLongArrayElements(JNIEnv* env,
721 jlongArray array,
722 jlong* elems,
723 jint mode);
724 static void ReleaseFloatArrayElements(JNIEnv* env,
725 jfloatArray array,
726 jfloat* elems,
727 jint mode);
728 static void ReleaseDoubleArrayElements(JNIEnv* env,
729 jdoubleArray array,
730 jdouble* elems,
731 jint mode);
732
733 static void GetBooleanArrayRegion(JNIEnv* env,
734 jbooleanArray array,
735 jsize start,
736 jsize l,
737 jboolean* buf);
738 static void GetByteArrayRegion(JNIEnv* env,
739 jbyteArray array,
740 jsize start,
741 jsize len,
742 jbyte* buf);
743 static void GetCharArrayRegion(JNIEnv* env,
744 jcharArray array,
745 jsize start,
746 jsize len,
747 jchar* buf);
748 static void GetShortArrayRegion(JNIEnv* env,
749 jshortArray array,
750 jsize start,
751 jsize len,
752 jshort* buf);
753 static void GetIntArrayRegion(JNIEnv* env,
754 jintArray array,
755 jsize start,
756 jsize len,
757 jint* buf);
758 static void GetLongArrayRegion(JNIEnv* env,
759 jlongArray array,
760 jsize start,
761 jsize len,
762 jlong* buf);
763 static void GetFloatArrayRegion(JNIEnv* env,
764 jfloatArray array,
765 jsize start,
766 jsize len,
767 jfloat* buf);
768 static void GetDoubleArrayRegion(JNIEnv* env,
769 jdoubleArray array,
770 jsize start,
771 jsize len,
772 jdouble* buf);
773
774 static void SetBooleanArrayRegion(JNIEnv* env,
775 jbooleanArray array,
776 jsize start,
777 jsize l,
778 const jboolean* buf);
779 static void SetByteArrayRegion(JNIEnv* env,
780 jbyteArray array,
781 jsize start,
782 jsize len,
783 const jbyte* buf);
784 static void SetCharArrayRegion(JNIEnv* env,
785 jcharArray array,
786 jsize start,
787 jsize len,
788 const jchar* buf);
789 static void SetShortArrayRegion(JNIEnv* env,
790 jshortArray array,
791 jsize start,
792 jsize len,
793 const jshort* buf);
794 static void SetIntArrayRegion(JNIEnv* env,
795 jintArray array,
796 jsize start,
797 jsize len,
798 const jint* buf);
799 static void SetLongArrayRegion(JNIEnv* env,
800 jlongArray array,
801 jsize start,
802 jsize len,
803 const jlong* buf);
804 static void SetFloatArrayRegion(JNIEnv* env,
805 jfloatArray array,
806 jsize start,
807 jsize len,
808 const jfloat* buf);
809 static void SetDoubleArrayRegion(JNIEnv* env,
810 jdoubleArray array,
811 jsize start,
812 jsize len,
813 const jdouble* buf);
814
815 static jint RegisterNatives(JNIEnv* env,
816 jclass clazz,
817 const JNINativeMethod* methods,
818 jint nMethods);
819 static jint UnregisterNatives(JNIEnv* env, jclass clazz);
820
821 static jint MonitorEnter(JNIEnv* env, jobject obj);
822 static jint MonitorExit(JNIEnv* env, jobject obj);
823
824 static jint GetJavaVM(JNIEnv* env, JavaVM* *vm);
825
826 static void GetStringRegion(JNIEnv* env,
827 jstring str,
828 jsize start,
829 jsize len,
830 jchar* buf);
831 static void GetStringUTFRegion(JNIEnv* env,
832 jstring str,
833 jsize start,
834 jsize len,
835 char* buf);
836
837 static void* GetPrimitiveArrayCritical(JNIEnv* env,
838 jarray array,
839 jboolean* isCopy);
840 static void ReleasePrimitiveArrayCritical(JNIEnv* env,
841 jarray array,
842 void* carray,
843 jint mode);
844
845 static const jchar* GetStringCritical(JNIEnv* env,
846 jstring s,
847 jboolean* isCopy);
848 static void ReleaseStringCritical(JNIEnv* env, jstring s, const jchar* cstr);
849
850 static jweak NewWeakGlobalRef(JNIEnv* env, jobject obj);
851 static void DeleteWeakGlobalRef(JNIEnv* env, jweak obj);
852
853 static jboolean ExceptionCheck(JNIEnv* env);
854
855 static jobject NewDirectByteBuffer(JNIEnv* env,
856 void* address,
857 jlong capacity);
858 static void* GetDirectBufferAddress(JNIEnv* env, jobject buf);
859 static jlong GetDirectBufferCapacity(JNIEnv* env, jobject buf);
860
861 static jobjectRefType GetObjectRefType(JNIEnv* env, jobject obj);
862
863 static struct JNINativeInterface native_interface_;
864 DISALLOW_IMPLICIT_CONSTRUCTORS(JniNativeInterface);
865};
866
867class JniInvokeInterface {
868 public:
869 static struct JNIInvokeInterface* GetInterface() {
870 return &invoke_interface_;
871 }
872 private:
873 static jint DestroyJavaVM(JavaVM* vm);
874 static jint AttachCurrentThread(JavaVM* vm, JNIEnv** penv, void* thr_args);
875 static jint DetachCurrentThread(JavaVM* vm);
876 static jint GetEnv(JavaVM* vm, void** penv, int version);
877 static jint AttachCurrentThreadAsDaemon(JavaVM* vm,
878 JNIEnv** penv,
879 void* thr_args);
880 static struct JNIInvokeInterface invoke_interface_;
881 DISALLOW_IMPLICIT_CONSTRUCTORS(JniInvokeInterface);
Ian Rogersdf20fe02011-07-20 20:34:16 -0700882};
883
884} // namespace art
Carl Shapiroea4dca82011-08-01 13:45:38 -0700885
Ian Rogersdf20fe02011-07-20 20:34:16 -0700886#endif // ART_SRC_JNI_INTERNAL_H_