1 /* src/native/jni.c - implementation of the Java Native Interface functions
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: jni.c 8179 2007-07-05 11:21:08Z michi $
38 #include "mm/gc-common.h"
39 #include "mm/memory.h"
40 #include "native/jni.h"
41 #include "native/native.h"
43 #if defined(ENABLE_JAVASE)
44 # if defined(WITH_CLASSPATH_GNU)
45 # include "native/include/gnu_classpath_Pointer.h"
47 # if SIZEOF_VOID_P == 8
48 # include "native/include/gnu_classpath_Pointer64.h"
50 # include "native/include/gnu_classpath_Pointer32.h"
55 #include "native/include/java_lang_Object.h"
56 #include "native/include/java_lang_Byte.h"
57 #include "native/include/java_lang_Character.h"
58 #include "native/include/java_lang_Short.h"
59 #include "native/include/java_lang_Integer.h"
60 #include "native/include/java_lang_Boolean.h"
61 #include "native/include/java_lang_Long.h"
62 #include "native/include/java_lang_Float.h"
63 #include "native/include/java_lang_Double.h"
64 #include "native/include/java_lang_String.h"
65 #include "native/include/java_lang_Throwable.h"
67 #if defined(ENABLE_JAVASE)
68 # if defined(WITH_CLASSPATH_SUN)
69 # include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
72 # include "native/include/java_lang_ClassLoader.h"
74 # include "native/include/java_lang_reflect_Constructor.h"
75 # include "native/include/java_lang_reflect_Field.h"
76 # include "native/include/java_lang_reflect_Method.h"
78 # include "native/include/java_nio_Buffer.h"
80 # if defined(WITH_CLASSPATH_GNU)
81 # include "native/include/java_nio_DirectByteBufferImpl.h"
85 #if defined(ENABLE_JVMTI)
86 # include "native/jvmti/cacaodbg.h"
89 #include "native/vm/java_lang_Class.h"
91 #if defined(ENABLE_JAVASE)
92 # include "native/vm/java_lang_ClassLoader.h"
93 # include "native/vm/reflect.h"
96 #include "threads/lock-common.h"
97 #include "threads/threads-common.h"
99 #include "toolbox/logging.h"
101 #include "vm/builtin.h"
102 #include "vm/exceptions.h"
103 #include "vm/global.h"
104 #include "vm/initialize.h"
105 #include "vm/resolve.h"
106 #include "vm/stringlocal.h"
109 #include "vm/jit/asmpart.h"
110 #include "vm/jit/jit.h"
111 #include "vm/jit/stacktrace.h"
113 #include "vmcore/loader.h"
114 #include "vmcore/options.h"
115 #include "vmcore/primitive.h"
116 #include "vmcore/statistics.h"
119 /* global variables ***********************************************************/
121 /* global reference table *****************************************************/
123 /* hashsize must be power of 2 */
125 #define HASHTABLE_GLOBAL_REF_SIZE 64 /* initial size of globalref-hash */
127 static hashtable *hashtable_global_ref; /* hashtable for globalrefs */
130 /* direct buffer stuff ********************************************************/
132 #if defined(ENABLE_JAVASE)
133 static classinfo *class_java_nio_Buffer;
134 static classinfo *class_java_nio_DirectByteBufferImpl;
135 static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
137 # if defined(WITH_CLASSPATH_GNU)
138 # if SIZEOF_VOID_P == 8
139 static classinfo *class_gnu_classpath_Pointer64;
141 static classinfo *class_gnu_classpath_Pointer32;
145 static methodinfo *dbbirw_init;
149 /* local reference table ******************************************************/
151 #if !defined(ENABLE_THREADS)
152 localref_table *_no_threads_localref_table;
156 /* accessing instance fields macros *******************************************/
158 #define SET_FIELD(o,type,f,value) \
159 *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset)) = (type) (value)
161 #define GET_FIELD(o,type,f) \
162 *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset))
165 /* some forward declarations **************************************************/
167 jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref);
168 jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity);
171 /* jni_init ********************************************************************
173 Initialize the JNI subsystem.
175 *******************************************************************************/
179 /* create global ref hashtable */
181 hashtable_global_ref = NEW(hashtable);
183 hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
186 #if defined(ENABLE_JAVASE)
187 /* direct buffer stuff */
189 if (!(class_java_nio_Buffer =
190 load_class_bootstrap(utf_new_char("java/nio/Buffer"))) ||
191 !link_class(class_java_nio_Buffer))
194 # if defined(WITH_CLASSPATH_GNU)
195 if (!(class_java_nio_DirectByteBufferImpl =
196 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
197 !link_class(class_java_nio_DirectByteBufferImpl))
200 if (!(class_java_nio_DirectByteBufferImpl_ReadWrite =
201 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) ||
202 !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite))
206 class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite,
208 utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
211 # if SIZEOF_VOID_P == 8
212 if (!(class_gnu_classpath_Pointer64 =
213 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) ||
214 !link_class(class_gnu_classpath_Pointer64))
217 if (!(class_gnu_classpath_Pointer32 =
218 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) ||
219 !link_class(class_gnu_classpath_Pointer32))
223 #endif /* defined(ENABLE_JAVASE) */
229 /* jni_init_localref_table *****************************************************
231 Initializes the local references table of the current thread.
233 *******************************************************************************/
235 bool jni_init_localref_table(void)
239 #if defined(ENABLE_GC_CACAO)
240 /* XXX this one will never get freed for the main thread;
241 call jni_free_localref_table() if you want to do it! */
242 lrt = NEW(localref_table);
244 lrt = GCNEW(localref_table);
250 lrt->capacity = LOCALREFTABLE_CAPACITY;
252 lrt->localframes = 1;
253 lrt->prev = LOCALREFTABLE;
255 /* clear the references array (memset is faster then a for-loop) */
257 MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY);
265 /* jni_init_localref_table *****************************************************
267 Frees the local references table of the current thread.
269 *******************************************************************************/
271 bool jni_free_localref_table(void)
275 #if defined(ENABLE_GC_CACAO)
279 assert(lrt->prev == NULL);
281 FREE(lrt, localref_table);
283 LOCALREFTABLE = NULL;
290 /* _Jv_jni_CallObjectMethod ****************************************************
292 Internal function to call Java Object methods.
294 *******************************************************************************/
296 static java_objectheader *_Jv_jni_CallObjectMethod(java_objectheader *o,
298 methodinfo *m, va_list ap)
301 java_objectheader *ro;
303 STATISTICS(jniinvokation());
306 exceptions_throw_nullpointerexception();
310 /* Class initialization is done by the JIT compiler. This is ok
311 since a static method always belongs to the declaring class. */
313 if (m->flags & ACC_STATIC) {
314 /* For static methods we reset the object. */
319 /* for convenience */
324 /* For instance methods we make a virtual function table lookup. */
326 resm = method_vftbl_lookup(vftbl, m);
329 STATISTICS(jnicallXmethodnvokation());
331 ro = vm_call_method_valist(resm, o, ap);
337 /* _Jv_jni_CallObjectMethodA ***************************************************
339 Internal function to call Java Object methods.
341 *******************************************************************************/
343 static java_objectheader *_Jv_jni_CallObjectMethodA(java_objectheader *o,
349 java_objectheader *ro;
351 STATISTICS(jniinvokation());
354 exceptions_throw_nullpointerexception();
358 /* Class initialization is done by the JIT compiler. This is ok
359 since a static method always belongs to the declaring class. */
361 if (m->flags & ACC_STATIC) {
362 /* For static methods we reset the object. */
367 /* for convenience */
372 /* For instance methods we make a virtual function table lookup. */
374 resm = method_vftbl_lookup(vftbl, m);
377 STATISTICS(jnicallXmethodnvokation());
379 ro = vm_call_method_jvalue(resm, o, args);
385 /* _Jv_jni_CallIntMethod *******************************************************
387 Internal function to call Java integer class methods (boolean,
388 byte, char, short, int).
390 *******************************************************************************/
392 static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl,
393 methodinfo *m, va_list ap)
398 STATISTICS(jniinvokation());
401 exceptions_throw_nullpointerexception();
405 /* Class initialization is done by the JIT compiler. This is ok
406 since a static method always belongs to the declaring class. */
408 if (m->flags & ACC_STATIC) {
409 /* For static methods we reset the object. */
414 /* for convenience */
419 /* For instance methods we make a virtual function table lookup. */
421 resm = method_vftbl_lookup(vftbl, m);
424 STATISTICS(jnicallXmethodnvokation());
426 i = vm_call_method_int_valist(resm, o, ap);
432 /* _Jv_jni_CallIntMethodA ******************************************************
434 Internal function to call Java integer class methods (boolean,
435 byte, char, short, int).
437 *******************************************************************************/
439 static jint _Jv_jni_CallIntMethodA(java_objectheader *o, vftbl_t *vftbl,
440 methodinfo *m, const jvalue *args)
445 STATISTICS(jniinvokation());
448 exceptions_throw_nullpointerexception();
452 /* Class initialization is done by the JIT compiler. This is ok
453 since a static method always belongs to the declaring class. */
455 if (m->flags & ACC_STATIC) {
456 /* For static methods we reset the object. */
461 /* for convenience */
466 /* For instance methods we make a virtual function table lookup. */
468 resm = method_vftbl_lookup(vftbl, m);
471 STATISTICS(jnicallXmethodnvokation());
473 i = vm_call_method_int_jvalue(resm, o, args);
479 /* _Jv_jni_CallLongMethod ******************************************************
481 Internal function to call Java long methods.
483 *******************************************************************************/
485 static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl,
486 methodinfo *m, va_list ap)
491 STATISTICS(jniinvokation());
494 exceptions_throw_nullpointerexception();
498 /* Class initialization is done by the JIT compiler. This is ok
499 since a static method always belongs to the declaring class. */
501 if (m->flags & ACC_STATIC) {
502 /* For static methods we reset the object. */
507 /* for convenience */
512 /* For instance methods we make a virtual function table lookup. */
514 resm = method_vftbl_lookup(vftbl, m);
517 STATISTICS(jnicallXmethodnvokation());
519 l = vm_call_method_long_valist(resm, o, ap);
525 /* _Jv_jni_CallLongMethodA *****************************************************
527 Internal function to call Java long methods.
529 *******************************************************************************/
531 static jlong _Jv_jni_CallLongMethodA(java_objectheader *o, vftbl_t *vftbl,
532 methodinfo *m, const jvalue *args)
537 STATISTICS(jniinvokation());
540 exceptions_throw_nullpointerexception();
544 /* Class initialization is done by the JIT compiler. This is ok
545 since a static method always belongs to the declaring class. */
547 if (m->flags & ACC_STATIC) {
548 /* For static methods we reset the object. */
553 /* for convenience */
558 /* For instance methods we make a virtual function table lookup. */
560 resm = method_vftbl_lookup(vftbl, m);
563 STATISTICS(jnicallXmethodnvokation());
565 l = vm_call_method_long_jvalue(resm, o, args);
571 /* _Jv_jni_CallFloatMethod *****************************************************
573 Internal function to call Java float methods.
575 *******************************************************************************/
577 static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl,
578 methodinfo *m, va_list ap)
583 /* Class initialization is done by the JIT compiler. This is ok
584 since a static method always belongs to the declaring class. */
586 if (m->flags & ACC_STATIC) {
587 /* For static methods we reset the object. */
592 /* for convenience */
597 /* For instance methods we make a virtual function table lookup. */
599 resm = method_vftbl_lookup(vftbl, m);
602 STATISTICS(jnicallXmethodnvokation());
604 f = vm_call_method_float_valist(resm, o, ap);
610 /* _Jv_jni_CallFloatMethodA ****************************************************
612 Internal function to call Java float methods.
614 *******************************************************************************/
616 static jfloat _Jv_jni_CallFloatMethodA(java_objectheader *o, vftbl_t *vftbl,
617 methodinfo *m, const jvalue *args)
622 /* Class initialization is done by the JIT compiler. This is ok
623 since a static method always belongs to the declaring class. */
625 if (m->flags & ACC_STATIC) {
626 /* For static methods we reset the object. */
631 /* for convenience */
636 /* For instance methods we make a virtual function table lookup. */
638 resm = method_vftbl_lookup(vftbl, m);
641 STATISTICS(jnicallXmethodnvokation());
643 f = vm_call_method_float_jvalue(resm, o, args);
649 /* _Jv_jni_CallDoubleMethod ****************************************************
651 Internal function to call Java double methods.
653 *******************************************************************************/
655 static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl,
656 methodinfo *m, va_list ap)
661 /* Class initialization is done by the JIT compiler. This is ok
662 since a static method always belongs to the declaring class. */
664 if (m->flags & ACC_STATIC) {
665 /* For static methods we reset the object. */
670 /* for convenience */
675 /* For instance methods we make a virtual function table lookup. */
677 resm = method_vftbl_lookup(vftbl, m);
680 d = vm_call_method_double_valist(resm, o, ap);
686 /* _Jv_jni_CallDoubleMethodA ***************************************************
688 Internal function to call Java double methods.
690 *******************************************************************************/
692 static jdouble _Jv_jni_CallDoubleMethodA(java_objectheader *o, vftbl_t *vftbl,
693 methodinfo *m, const jvalue *args)
698 /* Class initialization is done by the JIT compiler. This is ok
699 since a static method always belongs to the declaring class. */
701 if (m->flags & ACC_STATIC) {
702 /* For static methods we reset the object. */
707 /* for convenience */
712 /* For instance methods we make a virtual function table lookup. */
714 resm = method_vftbl_lookup(vftbl, m);
717 d = vm_call_method_double_jvalue(resm, o, args);
723 /* _Jv_jni_CallVoidMethod ******************************************************
725 Internal function to call Java void methods.
727 *******************************************************************************/
729 static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl,
730 methodinfo *m, va_list ap)
735 exceptions_throw_nullpointerexception();
739 /* Class initialization is done by the JIT compiler. This is ok
740 since a static method always belongs to the declaring class. */
742 if (m->flags & ACC_STATIC) {
743 /* For static methods we reset the object. */
748 /* for convenience */
753 /* For instance methods we make a virtual function table lookup. */
755 resm = method_vftbl_lookup(vftbl, m);
758 STATISTICS(jnicallXmethodnvokation());
760 (void) vm_call_method_valist(resm, o, ap);
764 /* _Jv_jni_CallVoidMethodA *****************************************************
766 Internal function to call Java void methods.
768 *******************************************************************************/
770 static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
771 methodinfo *m, const jvalue *args)
776 exceptions_throw_nullpointerexception();
780 /* Class initialization is done by the JIT compiler. This is ok
781 since a static method always belongs to the declaring class. */
783 if (m->flags & ACC_STATIC) {
784 /* For static methods we reset the object. */
789 /* for convenience */
794 /* For instance methods we make a virtual function table lookup. */
796 resm = method_vftbl_lookup(vftbl, m);
799 STATISTICS(jnicallXmethodnvokation());
801 (void) vm_call_method_jvalue(resm, o, args);
805 /* _Jv_jni_invokeNative ********************************************************
807 Invoke a method on the given object with the given arguments.
809 For instance methods OBJ must be != NULL and the method is looked up
810 in the vftbl of the object.
812 For static methods, OBJ is ignored.
814 *******************************************************************************/
816 #if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) \
817 && !defined(__M68K__) && !defined(__ARM__) && !defined(__SPARC_64__)
818 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
819 java_objectarray *params)
823 java_objectheader *ro;
826 java_objectheader *xptr;
829 exceptions_throw_nullpointerexception();
833 argcount = m->parseddesc->paramcount;
834 paramcount = argcount;
836 /* if method is non-static, remove the `this' pointer */
838 if (!(m->flags & ACC_STATIC))
841 /* For instance methods the object has to be an instance of the
842 class the method belongs to. For static methods the obj
843 parameter is ignored. */
845 if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
846 exceptions_throw_illegalargumentexception();
850 /* check if we got the right number of arguments */
852 if (((params == NULL) && (paramcount != 0)) ||
853 (params && (params->header.size != paramcount)))
855 exceptions_throw_illegalargumentexception();
859 /* for instance methods we need an object */
861 if (!(m->flags & ACC_STATIC) && (o == NULL)) {
862 /* XXX not sure if that is the correct exception */
863 exceptions_throw_nullpointerexception();
867 /* for static methods, zero object to make subsequent code simpler */
868 if (m->flags & ACC_STATIC)
872 /* for instance methods we must do a vftbl lookup */
873 resm = method_vftbl_lookup(o->vftbl, m);
876 /* for static methods, just for convenience */
880 vmargs = MNEW(vm_arg, argcount);
882 if (!vm_vmargs_from_objectarray(resm, o, vmargs, params)) {
883 MFREE(vmargs, vm_arg, argcount);
887 switch (resm->parseddesc->returntype.decltype) {
889 (void) vm_call_method_vmarg(resm, argcount, vmargs);
894 case PRIMITIVETYPE_BOOLEAN: {
896 java_lang_Boolean *bo;
898 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
900 ro = builtin_new(class_java_lang_Boolean);
902 /* setting the value of the object direct */
904 bo = (java_lang_Boolean *) ro;
909 case PRIMITIVETYPE_BYTE: {
913 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
915 ro = builtin_new(class_java_lang_Byte);
917 /* setting the value of the object direct */
919 bo = (java_lang_Byte *) ro;
924 case PRIMITIVETYPE_CHAR: {
926 java_lang_Character *co;
928 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
930 ro = builtin_new(class_java_lang_Character);
932 /* setting the value of the object direct */
934 co = (java_lang_Character *) ro;
939 case PRIMITIVETYPE_SHORT: {
943 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
945 ro = builtin_new(class_java_lang_Short);
947 /* setting the value of the object direct */
949 so = (java_lang_Short *) ro;
954 case PRIMITIVETYPE_INT: {
956 java_lang_Integer *io;
958 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
960 ro = builtin_new(class_java_lang_Integer);
962 /* setting the value of the object direct */
964 io = (java_lang_Integer *) ro;
969 case PRIMITIVETYPE_LONG: {
973 l = vm_call_method_long_vmarg(resm, argcount, vmargs);
975 ro = builtin_new(class_java_lang_Long);
977 /* setting the value of the object direct */
979 lo = (java_lang_Long *) ro;
984 case PRIMITIVETYPE_FLOAT: {
988 f = vm_call_method_float_vmarg(resm, argcount, vmargs);
990 ro = builtin_new(class_java_lang_Float);
992 /* setting the value of the object direct */
994 fo = (java_lang_Float *) ro;
999 case PRIMITIVETYPE_DOUBLE: {
1001 java_lang_Double *_do;
1003 d = vm_call_method_double_vmarg(resm, argcount, vmargs);
1005 ro = builtin_new(class_java_lang_Double);
1007 /* setting the value of the object direct */
1009 _do = (java_lang_Double *) ro;
1015 ro = vm_call_method_vmarg(resm, argcount, vmargs);
1019 /* if this happens the exception has already been set by
1020 fill_callblock_from_objectarray */
1022 MFREE(vmargs, vm_arg, argcount);
1027 MFREE(vmargs, vm_arg, argcount);
1029 xptr = exceptions_get_exception();
1032 /* clear exception pointer, we are calling JIT code again */
1034 exceptions_clear_exception();
1036 exceptions_throw_invocationtargetexception(xptr);
1042 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
1043 java_objectarray *params)
1046 java_objectheader *ro;
1049 java_objectheader *xptr;
1054 exceptions_throw_nullpointerexception();
1058 argcount = m->parseddesc->paramcount;
1059 paramcount = argcount;
1061 /* if method is non-static, remove the `this' pointer */
1063 if (!(m->flags & ACC_STATIC))
1066 /* For instance methods the object has to be an instance of the
1067 class the method belongs to. For static methods the obj
1068 parameter is ignored. */
1070 if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
1071 exceptions_throw_illegalargumentexception();
1075 /* check if we got the right number of arguments */
1077 if (((params == NULL) && (paramcount != 0)) ||
1078 (params && (params->header.size != paramcount)))
1080 exceptions_throw_illegalargumentexception();
1084 /* for instance methods we need an object */
1086 if (!(m->flags & ACC_STATIC) && (o == NULL)) {
1087 /* XXX not sure if that is the correct exception */
1088 exceptions_throw_nullpointerexception();
1092 /* for static methods, zero object to make subsequent code simpler */
1093 if (m->flags & ACC_STATIC)
1097 /* for instance methods we must do a vftbl lookup */
1098 resm = method_vftbl_lookup(o->vftbl, m);
1101 /* for static methods, just for convenience */
1105 /* mark start of dump memory area */
1107 dumpsize = dump_size();
1109 /* fill the argument array from a object-array */
1111 array = vm_array_from_objectarray(resm, o, params);
1113 if (array == NULL) {
1114 /* release dump area */
1116 dump_release(dumpsize);
1121 switch (resm->parseddesc->returntype.decltype) {
1123 (void) vm_call_array(resm, array);
1128 case PRIMITIVETYPE_BOOLEAN: {
1130 java_lang_Boolean *bo;
1132 i = vm_call_int_array(resm, array);
1134 ro = builtin_new(class_java_lang_Boolean);
1136 /* setting the value of the object direct */
1138 bo = (java_lang_Boolean *) ro;
1143 case PRIMITIVETYPE_BYTE: {
1147 i = vm_call_int_array(resm, array);
1149 ro = builtin_new(class_java_lang_Byte);
1151 /* setting the value of the object direct */
1153 bo = (java_lang_Byte *) ro;
1158 case PRIMITIVETYPE_CHAR: {
1160 java_lang_Character *co;
1162 i = vm_call_int_array(resm, array);
1164 ro = builtin_new(class_java_lang_Character);
1166 /* setting the value of the object direct */
1168 co = (java_lang_Character *) ro;
1173 case PRIMITIVETYPE_SHORT: {
1175 java_lang_Short *so;
1177 i = vm_call_int_array(resm, array);
1179 ro = builtin_new(class_java_lang_Short);
1181 /* setting the value of the object direct */
1183 so = (java_lang_Short *) ro;
1188 case PRIMITIVETYPE_INT: {
1190 java_lang_Integer *io;
1192 i = vm_call_int_array(resm, array);
1194 ro = builtin_new(class_java_lang_Integer);
1196 /* setting the value of the object direct */
1198 io = (java_lang_Integer *) ro;
1203 case PRIMITIVETYPE_LONG: {
1207 l = vm_call_long_array(resm, array);
1209 ro = builtin_new(class_java_lang_Long);
1211 /* setting the value of the object direct */
1213 lo = (java_lang_Long *) ro;
1218 case PRIMITIVETYPE_FLOAT: {
1220 java_lang_Float *fo;
1222 f = vm_call_float_array(resm, array);
1224 ro = builtin_new(class_java_lang_Float);
1226 /* setting the value of the object direct */
1228 fo = (java_lang_Float *) ro;
1233 case PRIMITIVETYPE_DOUBLE: {
1235 java_lang_Double *_do;
1237 d = vm_call_double_array(resm, array);
1239 ro = builtin_new(class_java_lang_Double);
1241 /* setting the value of the object direct */
1243 _do = (java_lang_Double *) ro;
1249 ro = vm_call_array(resm, array);
1253 /* if this happens the exception has already been set by
1254 fill_callblock_from_objectarray */
1256 /* release dump area */
1258 dump_release(dumpsize);
1263 xptr = exceptions_get_exception();
1266 /* clear exception pointer, we are calling JIT code again */
1268 exceptions_clear_exception();
1270 exceptions_throw_invocationtargetexception(xptr);
1273 /* release dump area */
1275 dump_release(dumpsize);
1282 /* GetVersion ******************************************************************
1284 Returns the major version number in the higher 16 bits and the
1285 minor version number in the lower 16 bits.
1287 *******************************************************************************/
1289 jint _Jv_JNI_GetVersion(JNIEnv *env)
1291 STATISTICS(jniinvokation());
1293 /* we support JNI 1.4 */
1295 return JNI_VERSION_1_4;
1299 /* Class Operations ***********************************************************/
1301 /* DefineClass *****************************************************************
1303 Loads a class from a buffer of raw class data. The buffer
1304 containing the raw class data is not referenced by the VM after the
1305 DefineClass call returns, and it may be discarded if desired.
1307 *******************************************************************************/
1309 jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
1310 const jbyte *buf, jsize bufLen)
1312 #if defined(ENABLE_JAVASE)
1313 java_lang_ClassLoader *cl;
1314 java_lang_String *s;
1318 STATISTICS(jniinvokation());
1320 cl = (java_lang_ClassLoader *) loader;
1321 s = (java_lang_String *) javastring_new_from_utf_string(name);
1322 ba = (java_bytearray *) buf;
1324 c = (jclass) _Jv_java_lang_ClassLoader_defineClass(cl, s, ba, 0, bufLen,
1327 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1329 vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration");
1331 /* keep compiler happy */
1338 /* FindClass *******************************************************************
1340 This function loads a locally-defined class. It searches the
1341 directories and zip files specified by the CLASSPATH environment
1342 variable for the class with the specified name.
1344 *******************************************************************************/
1346 jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
1348 #if defined(ENABLE_JAVASE)
1353 STATISTICS(jniinvokation());
1355 u = utf_new_char_classname((char *) name);
1357 /* Check stacktrace for classloader, if one found use it,
1358 otherwise use the system classloader. */
1360 /* Quote from the JNI documentation:
1362 In the Java 2 Platform, FindClass locates the class loader
1363 associated with the current native method. If the native code
1364 belongs to a system class, no class loader will be
1365 involved. Otherwise, the proper class loader will be invoked to
1366 load and link the named class. When FindClass is called through
1367 the Invocation Interface, there is no current native method or
1368 its associated class loader. In that case, the result of
1369 ClassLoader.getBaseClassLoader is used." */
1371 cc = stacktrace_getCurrentClass();
1374 c = load_class_from_sysloader(u);
1376 c = load_class_from_classloader(u, cc->classloader);
1384 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1386 vm_abort("_Jv_JNI_FindClass: not implemented in this configuration");
1388 /* keep compiler happy */
1395 /* GetSuperclass ***************************************************************
1397 If clazz represents any class other than the class Object, then
1398 this function returns the object that represents the superclass of
1399 the class specified by clazz.
1401 *******************************************************************************/
1403 jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
1407 STATISTICS(jniinvokation());
1409 c = ((classinfo *) sub)->super.cls;
1414 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1418 /* IsAssignableFrom ************************************************************
1420 Determines whether an object of sub can be safely cast to sup.
1422 *******************************************************************************/
1424 jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
1426 java_lang_Class *csup;
1427 java_lang_Class *csub;
1429 csup = (java_lang_Class *) sup;
1430 csub = (java_lang_Class *) sub;
1432 STATISTICS(jniinvokation());
1434 return _Jv_java_lang_Class_isAssignableFrom(csup, csub);
1438 /* Throw ***********************************************************************
1440 Causes a java.lang.Throwable object to be thrown.
1442 *******************************************************************************/
1444 jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj)
1446 java_objectheader *o;
1448 STATISTICS(jniinvokation());
1450 o = (java_objectheader *) obj;
1452 exceptions_set_exception(o);
1458 /* ThrowNew ********************************************************************
1460 Constructs an exception object from the specified class with the
1461 message specified by message and causes that exception to be
1464 *******************************************************************************/
1466 jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg)
1469 java_objectheader *o;
1470 java_objectheader *s;
1472 STATISTICS(jniinvokation());
1474 c = (classinfo *) clazz;
1477 s = javastring_new_from_utf_string(msg);
1479 /* instantiate exception object */
1481 o = native_new_and_init_string(c, s);
1486 exceptions_set_exception(o);
1492 /* ExceptionOccurred ***********************************************************
1494 Determines if an exception is being thrown. The exception stays
1495 being thrown until either the native code calls ExceptionClear(),
1496 or the Java code handles the exception.
1498 *******************************************************************************/
1500 jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env)
1502 java_objectheader *o;
1504 STATISTICS(jniinvokation());
1506 o = exceptions_get_exception();
1508 return _Jv_JNI_NewLocalRef(env, (jthrowable) o);
1512 /* ExceptionDescribe ***********************************************************
1514 Prints an exception and a backtrace of the stack to a system
1515 error-reporting channel, such as stderr. This is a convenience
1516 routine provided for debugging.
1518 *******************************************************************************/
1520 void _Jv_JNI_ExceptionDescribe(JNIEnv *env)
1522 java_objectheader *o;
1525 STATISTICS(jniinvokation());
1527 o = exceptions_get_exception();
1530 /* clear exception, because we are calling jit code again */
1532 exceptions_clear_exception();
1534 /* get printStackTrace method from exception class */
1536 m = class_resolveclassmethod(o->vftbl->class,
1537 utf_printStackTrace,
1543 /* XXX what should we do? */
1546 /* print the stacktrace */
1548 (void) vm_call_method(m, o);
1553 /* ExceptionClear **************************************************************
1555 Clears any exception that is currently being thrown. If no
1556 exception is currently being thrown, this routine has no effect.
1558 *******************************************************************************/
1560 void _Jv_JNI_ExceptionClear(JNIEnv *env)
1562 STATISTICS(jniinvokation());
1564 exceptions_clear_exception();
1568 /* FatalError ******************************************************************
1570 Raises a fatal error and does not expect the VM to recover. This
1571 function does not return.
1573 *******************************************************************************/
1575 void _Jv_JNI_FatalError(JNIEnv *env, const char *msg)
1577 STATISTICS(jniinvokation());
1579 /* this seems to be the best way */
1581 vm_abort("JNI Fatal error: %s", msg);
1585 /* PushLocalFrame **************************************************************
1587 Creates a new local reference frame, in which at least a given
1588 number of local references can be created.
1590 *******************************************************************************/
1592 jint _Jv_JNI_PushLocalFrame(JNIEnv* env, jint capacity)
1595 localref_table *lrt;
1596 localref_table *nlrt;
1598 STATISTICS(jniinvokation());
1603 /* Allocate new local reference table on Java heap. Calculate the
1604 additional memory we have to allocate. */
1606 if (capacity > LOCALREFTABLE_CAPACITY)
1607 additionalrefs = capacity - LOCALREFTABLE_CAPACITY;
1611 #if defined(ENABLE_GC_CACAO)
1612 nlrt = MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
1614 nlrt = GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
1620 /* get current local reference table from thread */
1622 lrt = LOCALREFTABLE;
1624 /* Set up the new local reference table and add it to the local
1627 nlrt->capacity = capacity;
1629 nlrt->localframes = lrt->localframes + 1;
1632 /* store new local reference table in thread */
1634 LOCALREFTABLE = nlrt;
1640 /* PopLocalFrame ***************************************************************
1642 Pops off the current local reference frame, frees all the local
1643 references, and returns a local reference in the previous local
1644 reference frame for the given result object.
1646 *******************************************************************************/
1648 jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result)
1650 localref_table *lrt;
1651 localref_table *plrt;
1655 STATISTICS(jniinvokation());
1657 /* get current local reference table from thread */
1659 lrt = LOCALREFTABLE;
1661 localframes = lrt->localframes;
1663 /* Don't delete the top local frame, as this one is allocated in
1664 the native stub on the stack and is freed automagically on
1667 if (localframes == 1)
1668 return _Jv_JNI_NewLocalRef(env, result);
1670 /* release all current local frames */
1672 for (; localframes >= 1; localframes--) {
1673 /* get previous frame */
1677 /* clear all reference entries */
1679 MSET(&lrt->refs[0], 0, java_objectheader*, lrt->capacity);
1683 #if defined(ENABLE_GC_CACAO)
1684 /* for the exact GC local reference tables are not on the heap,
1685 so we need to free them explicitly here. */
1687 if (lrt->capacity > LOCALREFTABLE_CAPACITY)
1688 additionalrefs = lrt->capacity - LOCALREFTABLE_CAPACITY;
1692 MFREE(lrt, u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
1695 /* set new local references table */
1700 /* store new local reference table in thread */
1702 LOCALREFTABLE = lrt;
1704 /* add local reference and return the value */
1706 return _Jv_JNI_NewLocalRef(env, result);
1710 /* DeleteLocalRef **************************************************************
1712 Deletes the local reference pointed to by localRef.
1714 *******************************************************************************/
1716 void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef)
1718 java_objectheader *o;
1719 localref_table *lrt;
1722 STATISTICS(jniinvokation());
1724 o = (java_objectheader *) localRef;
1726 /* get local reference table (thread specific) */
1728 lrt = LOCALREFTABLE;
1730 /* go through all local frames */
1732 for (; lrt != NULL; lrt = lrt->prev) {
1734 /* and try to remove the reference */
1736 for (i = 0; i < lrt->capacity; i++) {
1737 if (lrt->refs[i] == o) {
1738 lrt->refs[i] = NULL;
1746 /* this should not happen */
1748 /* if (opt_checkjni) */
1749 /* FatalError(env, "Bad global or local ref passed to JNI"); */
1750 log_text("JNI-DeleteLocalRef: Local ref passed to JNI not found");
1754 /* IsSameObject ****************************************************************
1756 Tests whether two references refer to the same Java object.
1758 *******************************************************************************/
1760 jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2)
1762 STATISTICS(jniinvokation());
1771 /* NewLocalRef *****************************************************************
1773 Creates a new local reference that refers to the same object as ref.
1775 *******************************************************************************/
1777 jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref)
1779 localref_table *lrt;
1782 STATISTICS(jniinvokation());
1787 /* get local reference table (thread specific) */
1789 lrt = LOCALREFTABLE;
1791 /* Check if we have space for the requested reference? No,
1792 allocate a new frame. This is actually not what the spec says,
1793 but for compatibility reasons... */
1795 if (lrt->used == lrt->capacity) {
1796 if (_Jv_JNI_EnsureLocalCapacity(env, 16) != 0)
1799 /* get the new local reference table */
1801 lrt = LOCALREFTABLE;
1804 /* insert the reference */
1806 for (i = 0; i < lrt->capacity; i++) {
1807 if (lrt->refs[i] == NULL) {
1808 lrt->refs[i] = (java_objectheader *) ref;
1815 /* should not happen, just to be sure */
1819 /* keep compiler happy */
1825 /* EnsureLocalCapacity *********************************************************
1827 Ensures that at least a given number of local references can be
1828 created in the current thread
1830 *******************************************************************************/
1832 jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity)
1834 localref_table *lrt;
1836 STATISTICS(jniinvokation());
1838 /* get local reference table (thread specific) */
1840 lrt = LOCALREFTABLE;
1842 /* check if capacity elements are available in the local references table */
1844 if ((lrt->used + capacity) > lrt->capacity)
1845 return _Jv_JNI_PushLocalFrame(env, capacity);
1851 /* AllocObject *****************************************************************
1853 Allocates a new Java object without invoking any of the
1854 constructors for the object. Returns a reference to the object.
1856 *******************************************************************************/
1858 jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
1861 java_objectheader *o;
1863 STATISTICS(jniinvokation());
1865 c = (classinfo *) clazz;
1867 if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
1868 exceptions_throw_instantiationexception(c);
1874 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1878 /* NewObject *******************************************************************
1880 Programmers place all arguments that are to be passed to the
1881 constructor immediately following the methodID
1882 argument. NewObject() accepts these arguments and passes them to
1883 the Java method that the programmer wishes to invoke.
1885 *******************************************************************************/
1887 jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
1889 java_objectheader *o;
1894 STATISTICS(jniinvokation());
1896 c = (classinfo *) clazz;
1897 m = (methodinfo *) methodID;
1906 /* call constructor */
1908 va_start(ap, methodID);
1909 _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
1912 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1916 /* NewObjectV ******************************************************************
1918 Programmers place all arguments that are to be passed to the
1919 constructor in an args argument of type va_list that immediately
1920 follows the methodID argument. NewObjectV() accepts these
1921 arguments, and, in turn, passes them to the Java method that the
1922 programmer wishes to invoke.
1924 *******************************************************************************/
1926 jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
1929 java_objectheader *o;
1933 STATISTICS(jniinvokation());
1935 c = (classinfo *) clazz;
1936 m = (methodinfo *) methodID;
1945 /* call constructor */
1947 _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
1949 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1953 /* NewObjectA *****************************************************************
1955 Programmers place all arguments that are to be passed to the
1956 constructor in an args array of jvalues that immediately follows
1957 the methodID argument. NewObjectA() accepts the arguments in this
1958 array, and, in turn, passes them to the Java method that the
1959 programmer wishes to invoke.
1961 *******************************************************************************/
1963 jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
1966 java_objectheader *o;
1970 STATISTICS(jniinvokation());
1972 c = (classinfo *) clazz;
1973 m = (methodinfo *) methodID;
1982 /* call constructor */
1984 _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
1986 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1990 /* GetObjectClass **************************************************************
1992 Returns the class of an object.
1994 *******************************************************************************/
1996 jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj)
1998 java_objectheader *o;
2001 STATISTICS(jniinvokation());
2003 o = (java_objectheader *) obj;
2005 if ((o == NULL) || (o->vftbl == NULL))
2008 c = o->vftbl->class;
2010 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
2014 /* IsInstanceOf ****************************************************************
2016 Tests whether an object is an instance of a class.
2018 *******************************************************************************/
2020 jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
2023 java_lang_Object *o;
2025 STATISTICS(jniinvokation());
2027 c = (java_lang_Class *) clazz;
2028 o = (java_lang_Object *) obj;
2030 return _Jv_java_lang_Class_isInstance(c, o);
2034 /* Reflection Support *********************************************************/
2036 /* FromReflectedMethod *********************************************************
2038 Converts java.lang.reflect.Method or java.lang.reflect.Constructor
2039 object to a method ID.
2041 *******************************************************************************/
2043 jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
2045 #if defined(ENABLE_JAVASE)
2046 java_objectheader *o;
2051 STATISTICS(jniinvokation());
2053 o = (java_objectheader *) method;
2058 if (builtin_instanceof(o, class_java_lang_reflect_Method)) {
2059 java_lang_reflect_Method *rm;
2061 rm = (java_lang_reflect_Method *) method;
2062 c = (classinfo *) (rm->clazz);
2065 else if (builtin_instanceof(o, class_java_lang_reflect_Constructor)) {
2066 java_lang_reflect_Constructor *rc;
2068 rc = (java_lang_reflect_Constructor *) method;
2069 c = (classinfo *) (rc->clazz);
2075 m = &(c->methods[slot]);
2077 return (jmethodID) m;
2079 vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
2081 /* keep compiler happy */
2088 /* FromReflectedField **********************************************************
2090 Converts a java.lang.reflect.Field to a field ID.
2092 *******************************************************************************/
2094 jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
2096 #if defined(ENABLE_JAVASE)
2097 java_lang_reflect_Field *rf;
2101 STATISTICS(jniinvokation());
2103 rf = (java_lang_reflect_Field *) field;
2108 c = (classinfo *) rf->clazz;
2109 f = &(c->fields[rf->slot]);
2111 return (jfieldID) f;
2113 vm_abort("_Jv_JNI_FromReflectedField: not implemented in this configuration");
2115 /* keep compiler happy */
2122 /* ToReflectedMethod ***********************************************************
2124 Converts a method ID derived from cls to an instance of the
2125 java.lang.reflect.Method class or to an instance of the
2126 java.lang.reflect.Constructor class.
2128 *******************************************************************************/
2130 jobject _Jv_JNI_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID,
2133 #if defined(ENABLE_JAVASE)
2135 java_lang_reflect_Constructor *rc;
2136 java_lang_reflect_Method *rm;
2138 STATISTICS(jniinvokation());
2140 m = (methodinfo *) methodID;
2142 /* HotSpot does the same assert. */
2144 assert(((m->flags & ACC_STATIC) != 0) == (isStatic != 0));
2146 if (m->name == utf_init) {
2147 rc = reflect_constructor_new(m);
2149 return (jobject) rc;
2152 rm = reflect_method_new(m);
2154 return (jobject) rm;
2157 vm_abort("_Jv_JNI_ToReflectedMethod: not implemented in this configuration");
2159 /* keep compiler happy */
2166 /* ToReflectedField ************************************************************
2168 Converts a field ID derived from cls to an instance of the
2169 java.lang.reflect.Field class.
2171 *******************************************************************************/
2173 jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID,
2176 STATISTICS(jniinvokation());
2178 log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!");
2184 /* Calling Instance Methods ***************************************************/
2186 /* GetMethodID *****************************************************************
2188 Returns the method ID for an instance (nonstatic) method of a class
2189 or interface. The method may be defined in one of the clazz's
2190 superclasses and inherited by clazz. The method is determined by
2191 its name and signature.
2193 GetMethodID() causes an uninitialized class to be initialized.
2195 *******************************************************************************/
2197 jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
2205 STATISTICS(jniinvokation());
2207 c = (classinfo *) clazz;
2212 if (!(c->state & CLASS_INITIALIZED))
2213 if (!initialize_class(c))
2216 /* try to get the method of the class or one of it's superclasses */
2218 uname = utf_new_char((char *) name);
2219 udesc = utf_new_char((char *) sig);
2221 m = class_resolvemethod(c, uname, udesc);
2223 if ((m == NULL) || (m->flags & ACC_STATIC)) {
2224 exceptions_throw_nosuchmethoderror(c, uname, udesc);
2229 return (jmethodID) m;
2233 /* JNI-functions for calling instance methods *********************************/
2235 jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2238 java_objectheader *o;
2240 java_objectheader *ret;
2243 o = (java_objectheader *) obj;
2244 m = (methodinfo *) methodID;
2246 va_start(ap, methodID);
2247 ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, ap);
2250 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2254 jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2257 java_objectheader *o;
2259 java_objectheader *ret;
2261 o = (java_objectheader *) obj;
2262 m = (methodinfo *) methodID;
2264 ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, args);
2266 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2270 jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2273 java_objectheader *o;
2275 java_objectheader *ret;
2277 o = (java_objectheader *) obj;
2278 m = (methodinfo *) methodID;
2280 ret = _Jv_jni_CallObjectMethodA(o, o->vftbl, m, args);
2282 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2286 jboolean _Jv_JNI_CallBooleanMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2289 java_objectheader *o;
2294 o = (java_objectheader *) obj;
2295 m = (methodinfo *) methodID;
2297 va_start(ap, methodID);
2298 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2305 jboolean _Jv_JNI_CallBooleanMethodV(JNIEnv *env, jobject obj,
2306 jmethodID methodID, va_list args)
2308 java_objectheader *o;
2312 o = (java_objectheader *) obj;
2313 m = (methodinfo *) methodID;
2315 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2321 jboolean _Jv_JNI_CallBooleanMethodA(JNIEnv *env, jobject obj,
2322 jmethodID methodID, const jvalue *args)
2324 java_objectheader *o;
2328 o = (java_objectheader *) obj;
2329 m = (methodinfo *) methodID;
2331 b = _Jv_jni_CallIntMethodA(o, o->vftbl, m, args);
2337 jbyte _Jv_JNI_CallByteMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2339 java_objectheader *o;
2344 o = (java_objectheader *) obj;
2345 m = (methodinfo *) methodID;
2347 va_start(ap, methodID);
2348 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2356 jbyte _Jv_JNI_CallByteMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2359 java_objectheader *o;
2363 o = (java_objectheader *) obj;
2364 m = (methodinfo *) methodID;
2366 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2372 jbyte _Jv_JNI_CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2375 log_text("JNI-Call: CallByteMethodA: IMPLEMENT ME!");
2381 jchar _Jv_JNI_CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2383 java_objectheader *o;
2388 o = (java_objectheader *) obj;
2389 m = (methodinfo *) methodID;
2391 va_start(ap, methodID);
2392 c = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2399 jchar _Jv_JNI_CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2402 java_objectheader *o;
2406 o = (java_objectheader *) obj;
2407 m = (methodinfo *) methodID;
2409 c = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2415 jchar _Jv_JNI_CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2418 log_text("JNI-Call: CallCharMethodA: IMPLEMENT ME!");
2424 jshort _Jv_JNI_CallShortMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2427 java_objectheader *o;
2432 o = (java_objectheader *) obj;
2433 m = (methodinfo *) methodID;
2435 va_start(ap, methodID);
2436 s = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2443 jshort _Jv_JNI_CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2446 java_objectheader *o;
2450 o = (java_objectheader *) obj;
2451 m = (methodinfo *) methodID;
2453 s = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2459 jshort _Jv_JNI_CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2462 log_text("JNI-Call: CallShortMethodA: IMPLEMENT ME!");
2469 jint _Jv_JNI_CallIntMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2471 java_objectheader *o;
2476 o = (java_objectheader *) obj;
2477 m = (methodinfo *) methodID;
2479 va_start(ap, methodID);
2480 i = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2487 jint _Jv_JNI_CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2490 java_objectheader *o;
2494 o = (java_objectheader *) obj;
2495 m = (methodinfo *) methodID;
2497 i = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2503 jint _Jv_JNI_CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2506 log_text("JNI-Call: CallIntMethodA: IMPLEMENT ME!");
2513 jlong _Jv_JNI_CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2515 java_objectheader *o;
2520 o = (java_objectheader *) obj;
2521 m = (methodinfo *) methodID;
2523 va_start(ap, methodID);
2524 l = _Jv_jni_CallLongMethod(o, o->vftbl, m, ap);
2531 jlong _Jv_JNI_CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2534 java_objectheader *o;
2538 o = (java_objectheader *) obj;
2539 m = (methodinfo *) methodID;
2541 l = _Jv_jni_CallLongMethod(o, o->vftbl, m, args);
2547 jlong _Jv_JNI_CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2550 log_text("JNI-Call: CallLongMethodA: IMPLEMENT ME!");
2557 jfloat _Jv_JNI_CallFloatMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2560 java_objectheader *o;
2565 o = (java_objectheader *) obj;
2566 m = (methodinfo *) methodID;
2568 va_start(ap, methodID);
2569 f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, ap);
2576 jfloat _Jv_JNI_CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2579 java_objectheader *o;
2583 o = (java_objectheader *) obj;
2584 m = (methodinfo *) methodID;
2586 f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, args);
2592 jfloat _Jv_JNI_CallFloatMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2595 log_text("JNI-Call: CallFloatMethodA: IMPLEMENT ME!");
2602 jdouble _Jv_JNI_CallDoubleMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2605 java_objectheader *o;
2610 o = (java_objectheader *) obj;
2611 m = (methodinfo *) methodID;
2613 va_start(ap, methodID);
2614 d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, ap);
2621 jdouble _Jv_JNI_CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2624 java_objectheader *o;
2628 o = (java_objectheader *) obj;
2629 m = (methodinfo *) methodID;
2631 d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, args);
2637 jdouble _Jv_JNI_CallDoubleMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2640 log_text("JNI-Call: CallDoubleMethodA: IMPLEMENT ME!");
2647 void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2649 java_objectheader *o;
2653 o = (java_objectheader *) obj;
2654 m = (methodinfo *) methodID;
2656 va_start(ap, methodID);
2657 _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
2662 void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2665 java_objectheader *o;
2668 o = (java_objectheader *) obj;
2669 m = (methodinfo *) methodID;
2671 _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
2675 void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2678 java_objectheader *o;
2681 o = (java_objectheader *) obj;
2682 m = (methodinfo *) methodID;
2684 _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
2689 jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
2690 jclass clazz, jmethodID methodID,
2693 java_objectheader *o;
2696 java_objectheader *r;
2699 o = (java_objectheader *) obj;
2700 c = (classinfo *) clazz;
2701 m = (methodinfo *) methodID;
2703 va_start(ap, methodID);
2704 r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
2707 return _Jv_JNI_NewLocalRef(env, (jobject) r);
2711 jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
2712 jclass clazz, jmethodID methodID,
2715 java_objectheader *o;
2718 java_objectheader *r;
2720 o = (java_objectheader *) obj;
2721 c = (classinfo *) clazz;
2722 m = (methodinfo *) methodID;
2724 r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
2726 return _Jv_JNI_NewLocalRef(env, (jobject) r);
2730 jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj,
2731 jclass clazz, jmethodID methodID,
2734 log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
2736 return _Jv_JNI_NewLocalRef(env, NULL);
2741 jboolean _Jv_JNI_CallNonvirtualBooleanMethod(JNIEnv *env, jobject obj,
2742 jclass clazz, jmethodID methodID,
2745 java_objectheader *o;
2751 o = (java_objectheader *) obj;
2752 c = (classinfo *) clazz;
2753 m = (methodinfo *) methodID;
2755 va_start(ap, methodID);
2756 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2763 jboolean _Jv_JNI_CallNonvirtualBooleanMethodV(JNIEnv *env, jobject obj,
2764 jclass clazz, jmethodID methodID,
2767 java_objectheader *o;
2772 o = (java_objectheader *) obj;
2773 c = (classinfo *) clazz;
2774 m = (methodinfo *) methodID;
2776 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2782 jboolean _Jv_JNI_CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj,
2783 jclass clazz, jmethodID methodID,
2786 log_text("JNI-Call: CallNonvirtualBooleanMethodA: IMPLEMENT ME!");
2792 jbyte _Jv_JNI_CallNonvirtualByteMethod(JNIEnv *env, jobject obj, jclass clazz,
2793 jmethodID methodID, ...)
2795 java_objectheader *o;
2801 o = (java_objectheader *) obj;
2802 c = (classinfo *) clazz;
2803 m = (methodinfo *) methodID;
2805 va_start(ap, methodID);
2806 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2813 jbyte _Jv_JNI_CallNonvirtualByteMethodV(JNIEnv *env, jobject obj, jclass clazz,
2814 jmethodID methodID, va_list args)
2816 java_objectheader *o;
2821 o = (java_objectheader *) obj;
2822 c = (classinfo *) clazz;
2823 m = (methodinfo *) methodID;
2825 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2831 jbyte _Jv_JNI_CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz,
2832 jmethodID methodID, const jvalue *args)
2834 log_text("JNI-Call: CallNonvirtualByteMethodA: IMPLEMENT ME!");
2841 jchar _Jv_JNI_CallNonvirtualCharMethod(JNIEnv *env, jobject obj, jclass clazz,
2842 jmethodID methodID, ...)
2844 java_objectheader *o;
2850 o = (java_objectheader *) obj;
2851 c = (classinfo *) clazz;
2852 m = (methodinfo *) methodID;
2854 va_start(ap, methodID);
2855 ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2862 jchar _Jv_JNI_CallNonvirtualCharMethodV(JNIEnv *env, jobject obj, jclass clazz,
2863 jmethodID methodID, va_list args)
2865 java_objectheader *o;
2870 o = (java_objectheader *) obj;
2871 c = (classinfo *) clazz;
2872 m = (methodinfo *) methodID;
2874 ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2880 jchar _Jv_JNI_CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz,
2881 jmethodID methodID, const jvalue *args)
2883 log_text("JNI-Call: CallNonvirtualCharMethodA: IMPLEMENT ME!");
2890 jshort _Jv_JNI_CallNonvirtualShortMethod(JNIEnv *env, jobject obj,
2891 jclass clazz, jmethodID methodID, ...)
2893 java_objectheader *o;
2899 o = (java_objectheader *) obj;
2900 c = (classinfo *) clazz;
2901 m = (methodinfo *) methodID;
2903 va_start(ap, methodID);
2904 s = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2911 jshort _Jv_JNI_CallNonvirtualShortMethodV(JNIEnv *env, jobject obj,
2912 jclass clazz, jmethodID methodID,
2915 java_objectheader *o;
2920 o = (java_objectheader *) obj;
2921 c = (classinfo *) clazz;
2922 m = (methodinfo *) methodID;
2924 s = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2930 jshort _Jv_JNI_CallNonvirtualShortMethodA(JNIEnv *env, jobject obj,
2931 jclass clazz, jmethodID methodID,
2934 log_text("JNI-Call: CallNonvirtualShortMethodA: IMPLEMENT ME!");
2941 jint _Jv_JNI_CallNonvirtualIntMethod(JNIEnv *env, jobject obj, jclass clazz,
2942 jmethodID methodID, ...)
2944 java_objectheader *o;
2950 o = (java_objectheader *) obj;
2951 c = (classinfo *) clazz;
2952 m = (methodinfo *) methodID;
2954 va_start(ap, methodID);
2955 i = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2962 jint _Jv_JNI_CallNonvirtualIntMethodV(JNIEnv *env, jobject obj, jclass clazz,
2963 jmethodID methodID, va_list args)
2965 java_objectheader *o;
2970 o = (java_objectheader *) obj;
2971 c = (classinfo *) clazz;
2972 m = (methodinfo *) methodID;
2974 i = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2980 jint _Jv_JNI_CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz,
2981 jmethodID methodID, const jvalue *args)
2983 log_text("JNI-Call: CallNonvirtualIntMethodA: IMPLEMENT ME!");
2990 jlong _Jv_JNI_CallNonvirtualLongMethod(JNIEnv *env, jobject obj, jclass clazz,
2991 jmethodID methodID, ...)
2993 java_objectheader *o;
2999 o = (java_objectheader *) obj;
3000 c = (classinfo *) clazz;
3001 m = (methodinfo *) methodID;
3003 va_start(ap, methodID);
3004 l = _Jv_jni_CallLongMethod(o, c->vftbl, m, ap);
3011 jlong _Jv_JNI_CallNonvirtualLongMethodV(JNIEnv *env, jobject obj, jclass clazz,
3012 jmethodID methodID, va_list args)
3014 java_objectheader *o;
3019 o = (java_objectheader *) obj;
3020 c = (classinfo *) clazz;
3021 m = (methodinfo *) methodID;
3023 l = _Jv_jni_CallLongMethod(o, c->vftbl, m, args);
3029 jlong _Jv_JNI_CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz,
3030 jmethodID methodID, const jvalue *args)
3032 log_text("JNI-Call: CallNonvirtualLongMethodA: IMPLEMENT ME!");
3039 jfloat _Jv_JNI_CallNonvirtualFloatMethod(JNIEnv *env, jobject obj,
3040 jclass clazz, jmethodID methodID, ...)
3042 java_objectheader *o;
3048 o = (java_objectheader *) obj;
3049 c = (classinfo *) clazz;
3050 m = (methodinfo *) methodID;
3052 va_start(ap, methodID);
3053 f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, ap);
3060 jfloat _Jv_JNI_CallNonvirtualFloatMethodV(JNIEnv *env, jobject obj,
3061 jclass clazz, jmethodID methodID,
3064 java_objectheader *o;
3069 o = (java_objectheader *) obj;
3070 c = (classinfo *) clazz;
3071 m = (methodinfo *) methodID;
3073 f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, args);
3079 jfloat _Jv_JNI_CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj,
3080 jclass clazz, jmethodID methodID,
3083 log_text("JNI-Call: CallNonvirtualFloatMethodA: IMPLEMENT ME!");
3090 jdouble _Jv_JNI_CallNonvirtualDoubleMethod(JNIEnv *env, jobject obj,
3091 jclass clazz, jmethodID methodID,
3094 java_objectheader *o;
3100 o = (java_objectheader *) obj;
3101 c = (classinfo *) clazz;
3102 m = (methodinfo *) methodID;
3104 va_start(ap, methodID);
3105 d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, ap);
3112 jdouble _Jv_JNI_CallNonvirtualDoubleMethodV(JNIEnv *env, jobject obj,
3113 jclass clazz, jmethodID methodID,
3116 java_objectheader *o;
3121 o = (java_objectheader *) obj;
3122 c = (classinfo *) clazz;
3123 m = (methodinfo *) methodID;
3125 d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, args);
3131 jdouble _Jv_JNI_CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj,
3132 jclass clazz, jmethodID methodID,
3135 log_text("JNI-Call: CallNonvirtualDoubleMethodA: IMPLEMENT ME!");
3142 void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz,
3143 jmethodID methodID, ...)
3145 java_objectheader *o;
3150 o = (java_objectheader *) obj;
3151 c = (classinfo *) clazz;
3152 m = (methodinfo *) methodID;
3154 va_start(ap, methodID);
3155 _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap);
3160 void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
3161 jmethodID methodID, va_list args)
3163 java_objectheader *o;
3167 o = (java_objectheader *) obj;
3168 c = (classinfo *) clazz;
3169 m = (methodinfo *) methodID;
3171 _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
3175 void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
3176 jmethodID methodID, const jvalue * args)
3178 java_objectheader *o;
3182 o = (java_objectheader *) obj;
3183 c = (classinfo *) clazz;
3184 m = (methodinfo *) methodID;
3186 _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
3190 /* Accessing Fields of Objects ************************************************/
3192 /* GetFieldID ******************************************************************
3194 Returns the field ID for an instance (nonstatic) field of a
3195 class. The field is specified by its name and signature. The
3196 Get<type>Field and Set<type>Field families of accessor functions
3197 use field IDs to retrieve object fields.
3199 *******************************************************************************/
3201 jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
3209 STATISTICS(jniinvokation());
3211 c = (classinfo *) clazz;
3213 /* XXX NPE check? */
3215 uname = utf_new_char((char *) name);
3216 udesc = utf_new_char((char *) sig);
3218 f = class_findfield(c, uname, udesc);
3221 exceptions_throw_nosuchfielderror(c, uname);
3223 return (jfieldID) f;
3227 /* Get<type>Field Routines *****************************************************
3229 This family of accessor routines returns the value of an instance
3230 (nonstatic) field of an object. The field to access is specified by
3231 a field ID obtained by calling GetFieldID().
3233 *******************************************************************************/
3235 jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)
3237 java_objectheader *o;
3239 STATISTICS(jniinvokation());
3241 o = GET_FIELD(obj, java_objectheader*, fieldID);
3243 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3247 jboolean _Jv_JNI_GetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID)
3251 STATISTICS(jniinvokation());
3253 i = GET_FIELD(obj, s4, fieldID);
3255 return (jboolean) i;
3259 jbyte _Jv_JNI_GetByteField(JNIEnv *env, jobject obj, jfieldID fieldID)
3263 STATISTICS(jniinvokation());
3265 i = GET_FIELD(obj, s4, fieldID);
3271 jchar _Jv_JNI_GetCharField(JNIEnv *env, jobject obj, jfieldID fieldID)
3275 STATISTICS(jniinvokation());
3277 i = GET_FIELD(obj, s4, fieldID);
3283 jshort _Jv_JNI_GetShortField(JNIEnv *env, jobject obj, jfieldID fieldID)
3287 STATISTICS(jniinvokation());
3289 i = GET_FIELD(obj, s4, fieldID);
3295 jint _Jv_JNI_GetIntField(JNIEnv *env, jobject obj, jfieldID fieldID)
3297 java_objectheader *o;
3301 STATISTICS(jniinvokation());
3303 o = (java_objectheader *) obj;
3304 f = (fieldinfo *) fieldID;
3306 i = GET_FIELD(o, s4, f);
3312 jlong _Jv_JNI_GetLongField(JNIEnv *env, jobject obj, jfieldID fieldID)
3316 STATISTICS(jniinvokation());
3318 l = GET_FIELD(obj, s8, fieldID);
3324 jfloat _Jv_JNI_GetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID)
3328 STATISTICS(jniinvokation());
3330 f = GET_FIELD(obj, float, fieldID);
3336 jdouble _Jv_JNI_GetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID)
3340 STATISTICS(jniinvokation());
3342 d = GET_FIELD(obj, double, fieldID);
3348 /* Set<type>Field Routines *****************************************************
3350 This family of accessor routines sets the value of an instance
3351 (nonstatic) field of an object. The field to access is specified by
3352 a field ID obtained by calling GetFieldID().
3354 *******************************************************************************/
3356 void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID,
3359 STATISTICS(jniinvokation());
3361 SET_FIELD(obj, java_objectheader*, fieldID, value);
3365 void _Jv_JNI_SetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID,
3368 STATISTICS(jniinvokation());
3370 SET_FIELD(obj, s4, fieldID, value);
3374 void _Jv_JNI_SetByteField(JNIEnv *env, jobject obj, jfieldID fieldID,
3377 STATISTICS(jniinvokation());
3379 SET_FIELD(obj, s4, fieldID, value);
3383 void _Jv_JNI_SetCharField(JNIEnv *env, jobject obj, jfieldID fieldID,
3386 STATISTICS(jniinvokation());
3388 SET_FIELD(obj, s4, fieldID, value);
3392 void _Jv_JNI_SetShortField(JNIEnv *env, jobject obj, jfieldID fieldID,
3395 STATISTICS(jniinvokation());
3397 SET_FIELD(obj, s4, fieldID, value);
3401 void _Jv_JNI_SetIntField(JNIEnv *env, jobject obj, jfieldID fieldID, jint value)
3403 STATISTICS(jniinvokation());
3405 SET_FIELD(obj, s4, fieldID, value);
3409 void _Jv_JNI_SetLongField(JNIEnv *env, jobject obj, jfieldID fieldID,
3412 STATISTICS(jniinvokation());
3414 SET_FIELD(obj, s8, fieldID, value);
3418 void _Jv_JNI_SetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID,
3421 STATISTICS(jniinvokation());
3423 SET_FIELD(obj, float, fieldID, value);
3427 void _Jv_JNI_SetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID,
3430 STATISTICS(jniinvokation());
3432 SET_FIELD(obj, double, fieldID, value);
3436 /* Calling Static Methods *****************************************************/
3438 /* GetStaticMethodID ***********************************************************
3440 Returns the method ID for a static method of a class. The method is
3441 specified by its name and signature.
3443 GetStaticMethodID() causes an uninitialized class to be
3446 *******************************************************************************/
3448 jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name,
3456 STATISTICS(jniinvokation());
3458 c = (classinfo *) clazz;
3463 if (!(c->state & CLASS_INITIALIZED))
3464 if (!initialize_class(c))
3467 /* try to get the static method of the class */
3469 uname = utf_new_char((char *) name);
3470 udesc = utf_new_char((char *) sig);
3472 m = class_resolvemethod(c, uname, udesc);
3474 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
3475 exceptions_throw_nosuchmethoderror(c, uname, udesc);
3480 return (jmethodID) m;
3484 jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz,
3485 jmethodID methodID, ...)
3488 java_objectheader *o;
3491 m = (methodinfo *) methodID;
3493 va_start(ap, methodID);
3494 o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
3497 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3501 jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz,
3502 jmethodID methodID, va_list args)
3505 java_objectheader *o;
3507 m = (methodinfo *) methodID;
3509 o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
3511 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3515 jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
3516 jmethodID methodID, const jvalue *args)
3519 java_objectheader *o;
3521 m = (methodinfo *) methodID;
3523 o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
3525 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3529 jboolean _Jv_JNI_CallStaticBooleanMethod(JNIEnv *env, jclass clazz,
3530 jmethodID methodID, ...)
3536 m = (methodinfo *) methodID;
3538 va_start(ap, methodID);
3539 b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3546 jboolean _Jv_JNI_CallStaticBooleanMethodV(JNIEnv *env, jclass clazz,
3547 jmethodID methodID, va_list args)
3552 m = (methodinfo *) methodID;
3554 b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3560 jboolean _Jv_JNI_CallStaticBooleanMethodA(JNIEnv *env, jclass clazz,
3561 jmethodID methodID, const jvalue *args)
3566 m = (methodinfo *) methodID;
3568 b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3574 jbyte _Jv_JNI_CallStaticByteMethod(JNIEnv *env, jclass clazz,
3575 jmethodID methodID, ...)
3581 m = (methodinfo *) methodID;
3583 va_start(ap, methodID);
3584 b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3591 jbyte _Jv_JNI_CallStaticByteMethodV(JNIEnv *env, jclass clazz,
3592 jmethodID methodID, va_list args)
3597 m = (methodinfo *) methodID;
3599 b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3605 jbyte _Jv_JNI_CallStaticByteMethodA(JNIEnv *env, jclass clazz,
3606 jmethodID methodID, const jvalue *args)
3611 m = (methodinfo *) methodID;
3613 b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3619 jchar _Jv_JNI_CallStaticCharMethod(JNIEnv *env, jclass clazz,
3620 jmethodID methodID, ...)
3626 m = (methodinfo *) methodID;
3628 va_start(ap, methodID);
3629 c = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3636 jchar _Jv_JNI_CallStaticCharMethodV(JNIEnv *env, jclass clazz,
3637 jmethodID methodID, va_list args)
3642 m = (methodinfo *) methodID;
3644 c = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3650 jchar _Jv_JNI_CallStaticCharMethodA(JNIEnv *env, jclass clazz,
3651 jmethodID methodID, const jvalue *args)
3656 m = (methodinfo *) methodID;
3658 c = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3664 jshort _Jv_JNI_CallStaticShortMethod(JNIEnv *env, jclass clazz,
3665 jmethodID methodID, ...)
3671 m = (methodinfo *) methodID;
3673 va_start(ap, methodID);
3674 s = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3681 jshort _Jv_JNI_CallStaticShortMethodV(JNIEnv *env, jclass clazz,
3682 jmethodID methodID, va_list args)
3687 m = (methodinfo *) methodID;
3689 s = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3695 jshort _Jv_JNI_CallStaticShortMethodA(JNIEnv *env, jclass clazz,
3696 jmethodID methodID, const jvalue *args)
3701 m = (methodinfo *) methodID;
3703 s = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3709 jint _Jv_JNI_CallStaticIntMethod(JNIEnv *env, jclass clazz, jmethodID methodID,
3716 m = (methodinfo *) methodID;
3718 va_start(ap, methodID);
3719 i = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3726 jint _Jv_JNI_CallStaticIntMethodV(JNIEnv *env, jclass clazz,
3727 jmethodID methodID, va_list args)
3732 m = (methodinfo *) methodID;
3734 i = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3740 jint _Jv_JNI_CallStaticIntMethodA(JNIEnv *env, jclass clazz,
3741 jmethodID methodID, const jvalue *args)
3746 m = (methodinfo *) methodID;
3748 i = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3754 jlong _Jv_JNI_CallStaticLongMethod(JNIEnv *env, jclass clazz,
3755 jmethodID methodID, ...)
3761 m = (methodinfo *) methodID;
3763 va_start(ap, methodID);
3764 l = _Jv_jni_CallLongMethod(NULL, NULL, m, ap);
3771 jlong _Jv_JNI_CallStaticLongMethodV(JNIEnv *env, jclass clazz,
3772 jmethodID methodID, va_list args)
3777 m = (methodinfo *) methodID;
3779 l = _Jv_jni_CallLongMethod(NULL, NULL, m, args);
3785 jlong _Jv_JNI_CallStaticLongMethodA(JNIEnv *env, jclass clazz,
3786 jmethodID methodID, const jvalue *args)
3791 m = (methodinfo *) methodID;
3793 l = _Jv_jni_CallLongMethodA(NULL, NULL, m, args);
3800 jfloat _Jv_JNI_CallStaticFloatMethod(JNIEnv *env, jclass clazz,
3801 jmethodID methodID, ...)
3807 m = (methodinfo *) methodID;
3809 va_start(ap, methodID);
3810 f = _Jv_jni_CallFloatMethod(NULL, NULL, m, ap);
3817 jfloat _Jv_JNI_CallStaticFloatMethodV(JNIEnv *env, jclass clazz,
3818 jmethodID methodID, va_list args)
3823 m = (methodinfo *) methodID;
3825 f = _Jv_jni_CallFloatMethod(NULL, NULL, m, args);
3831 jfloat _Jv_JNI_CallStaticFloatMethodA(JNIEnv *env, jclass clazz,
3832 jmethodID methodID, const jvalue *args)
3837 m = (methodinfo *) methodID;
3839 f = _Jv_jni_CallFloatMethodA(NULL, NULL, m, args);
3845 jdouble _Jv_JNI_CallStaticDoubleMethod(JNIEnv *env, jclass clazz,
3846 jmethodID methodID, ...)
3852 m = (methodinfo *) methodID;
3854 va_start(ap, methodID);
3855 d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, ap);
3862 jdouble _Jv_JNI_CallStaticDoubleMethodV(JNIEnv *env, jclass clazz,
3863 jmethodID methodID, va_list args)
3868 m = (methodinfo *) methodID;
3870 d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, args);
3876 jdouble _Jv_JNI_CallStaticDoubleMethodA(JNIEnv *env, jclass clazz,
3877 jmethodID methodID, const jvalue *args)
3882 m = (methodinfo *) methodID;
3884 d = _Jv_jni_CallDoubleMethodA(NULL, NULL, m, args);
3890 void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz,
3891 jmethodID methodID, ...)
3896 m = (methodinfo *) methodID;
3898 va_start(ap, methodID);
3899 _Jv_jni_CallVoidMethod(NULL, NULL, m, ap);
3904 void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz,
3905 jmethodID methodID, va_list args)
3909 m = (methodinfo *) methodID;
3911 _Jv_jni_CallVoidMethod(NULL, NULL, m, args);
3915 void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz,
3916 jmethodID methodID, const jvalue * args)
3920 m = (methodinfo *) methodID;
3922 _Jv_jni_CallVoidMethodA(NULL, NULL, m, args);
3926 /* Accessing Static Fields ****************************************************/
3928 /* GetStaticFieldID ************************************************************
3930 Returns the field ID for a static field of a class. The field is
3931 specified by its name and signature. The GetStatic<type>Field and
3932 SetStatic<type>Field families of accessor functions use field IDs
3933 to retrieve static fields.
3935 *******************************************************************************/
3937 jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
3945 STATISTICS(jniinvokation());
3947 c = (classinfo *) clazz;
3949 uname = utf_new_char((char *) name);
3950 usig = utf_new_char((char *) sig);
3952 f = class_findfield(c, uname, usig);
3955 exceptions_throw_nosuchfielderror(c, uname);
3957 return (jfieldID) f;
3961 /* GetStatic<type>Field ********************************************************
3963 This family of accessor routines returns the value of a static
3966 *******************************************************************************/
3968 jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz,
3974 STATISTICS(jniinvokation());
3976 c = (classinfo *) clazz;
3977 f = (fieldinfo *) fieldID;
3979 if (!(c->state & CLASS_INITIALIZED))
3980 if (!initialize_class(c))
3983 return _Jv_JNI_NewLocalRef(env, f->value.a);
3987 jboolean _Jv_JNI_GetStaticBooleanField(JNIEnv *env, jclass clazz,
3993 STATISTICS(jniinvokation());
3995 c = (classinfo *) clazz;
3996 f = (fieldinfo *) fieldID;
3998 if (!(c->state & CLASS_INITIALIZED))
3999 if (!initialize_class(c))
4006 jbyte _Jv_JNI_GetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4011 STATISTICS(jniinvokation());
4013 c = (classinfo *) clazz;
4014 f = (fieldinfo *) fieldID;
4016 if (!(c->state & CLASS_INITIALIZED))
4017 if (!initialize_class(c))
4024 jchar _Jv_JNI_GetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4029 STATISTICS(jniinvokation());
4031 c = (classinfo *) clazz;
4032 f = (fieldinfo *) fieldID;
4034 if (!(c->state & CLASS_INITIALIZED))
4035 if (!initialize_class(c))
4042 jshort _Jv_JNI_GetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4047 STATISTICS(jniinvokation());
4049 c = (classinfo *) clazz;
4050 f = (fieldinfo *) fieldID;
4052 if (!(c->state & CLASS_INITIALIZED))
4053 if (!initialize_class(c))
4060 jint _Jv_JNI_GetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4065 STATISTICS(jniinvokation());
4067 c = (classinfo *) clazz;
4068 f = (fieldinfo *) fieldID;
4070 if (!(c->state & CLASS_INITIALIZED))
4071 if (!initialize_class(c))
4078 jlong _Jv_JNI_GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4083 STATISTICS(jniinvokation());
4085 c = (classinfo *) clazz;
4086 f = (fieldinfo *) fieldID;
4088 if (!(c->state & CLASS_INITIALIZED))
4089 if (!initialize_class(c))
4096 jfloat _Jv_JNI_GetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4101 STATISTICS(jniinvokation());
4103 c = (classinfo *) clazz;
4104 f = (fieldinfo *) fieldID;
4106 if (!(c->state & CLASS_INITIALIZED))
4107 if (!initialize_class(c))
4114 jdouble _Jv_JNI_GetStaticDoubleField(JNIEnv *env, jclass clazz,
4120 STATISTICS(jniinvokation());
4122 c = (classinfo *) clazz;
4123 f = (fieldinfo *) fieldID;
4125 if (!(c->state & CLASS_INITIALIZED))
4126 if (!initialize_class(c))
4133 /* SetStatic<type>Field *******************************************************
4135 This family of accessor routines sets the value of a static field
4138 *******************************************************************************/
4140 void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4146 STATISTICS(jniinvokation());
4148 c = (classinfo *) clazz;
4149 f = (fieldinfo *) fieldID;
4151 if (!(c->state & CLASS_INITIALIZED))
4152 if (!initialize_class(c))
4159 void _Jv_JNI_SetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4165 STATISTICS(jniinvokation());
4167 c = (classinfo *) clazz;
4168 f = (fieldinfo *) fieldID;
4170 if (!(c->state & CLASS_INITIALIZED))
4171 if (!initialize_class(c))
4178 void _Jv_JNI_SetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4184 STATISTICS(jniinvokation());
4186 c = (classinfo *) clazz;
4187 f = (fieldinfo *) fieldID;
4189 if (!(c->state & CLASS_INITIALIZED))
4190 if (!initialize_class(c))
4197 void _Jv_JNI_SetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4203 STATISTICS(jniinvokation());
4205 c = (classinfo *) clazz;
4206 f = (fieldinfo *) fieldID;
4208 if (!(c->state & CLASS_INITIALIZED))
4209 if (!initialize_class(c))
4216 void _Jv_JNI_SetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4222 STATISTICS(jniinvokation());
4224 c = (classinfo *) clazz;
4225 f = (fieldinfo *) fieldID;
4227 if (!(c->state & CLASS_INITIALIZED))
4228 if (!initialize_class(c))
4235 void _Jv_JNI_SetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4241 STATISTICS(jniinvokation());
4243 c = (classinfo *) clazz;
4244 f = (fieldinfo *) fieldID;
4246 if (!(c->state & CLASS_INITIALIZED))
4247 if (!initialize_class(c))
4254 void _Jv_JNI_SetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4260 STATISTICS(jniinvokation());
4262 c = (classinfo *) clazz;
4263 f = (fieldinfo *) fieldID;
4265 if (!(c->state & CLASS_INITIALIZED))
4266 if (!initialize_class(c))
4273 void _Jv_JNI_SetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4279 STATISTICS(jniinvokation());
4281 c = (classinfo *) clazz;
4282 f = (fieldinfo *) fieldID;
4284 if (!(c->state & CLASS_INITIALIZED))
4285 if (!initialize_class(c))
4292 void _Jv_JNI_SetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4298 STATISTICS(jniinvokation());
4300 c = (classinfo *) clazz;
4301 f = (fieldinfo *) fieldID;
4303 if (!(c->state & CLASS_INITIALIZED))
4304 if (!initialize_class(c))
4311 /* String Operations **********************************************************/
4313 /* NewString *******************************************************************
4315 Create new java.lang.String object from an array of Unicode
4318 *******************************************************************************/
4320 jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len)
4322 java_lang_String *s;
4326 STATISTICS(jniinvokation());
4328 s = (java_lang_String *) builtin_new(class_java_lang_String);
4329 a = builtin_newarray_char(len);
4331 /* javastring or characterarray could not be created */
4332 if ((a == NULL) || (s == NULL))
4336 for (i = 0; i < len; i++)
4337 a->data[i] = buf[i];
4343 return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
4347 static jchar emptyStringJ[]={0,0};
4349 /* GetStringLength *************************************************************
4351 Returns the length (the count of Unicode characters) of a Java
4354 *******************************************************************************/
4356 jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str)
4358 java_lang_String *s;
4360 s = (java_lang_String *) str;
4366 /******************** convertes javastring to u2-array ****************************/
4368 u2 *javastring_tou2(jstring so)
4370 java_lang_String *s;
4375 STATISTICS(jniinvokation());
4377 s = (java_lang_String *) so;
4387 /* allocate memory */
4389 stringbuffer = MNEW(u2, s->count + 1);
4393 for (i = 0; i < s->count; i++)
4394 stringbuffer[i] = a->data[s->offset + i];
4396 /* terminate string */
4398 stringbuffer[i] = '\0';
4400 return stringbuffer;
4404 /* GetStringChars **************************************************************
4406 Returns a pointer to the array of Unicode characters of the
4407 string. This pointer is valid until ReleaseStringChars() is called.
4409 *******************************************************************************/
4411 const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy)
4415 STATISTICS(jniinvokation());
4417 jc = javastring_tou2(str);
4429 return emptyStringJ;
4433 /* ReleaseStringChars **********************************************************
4435 Informs the VM that the native code no longer needs access to
4436 chars. The chars argument is a pointer obtained from string using
4439 *******************************************************************************/
4441 void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
4443 STATISTICS(jniinvokation());
4445 if (chars == emptyStringJ)
4448 MFREE(((jchar *) chars), jchar, ((java_lang_String *) str)->count + 1);
4452 /* NewStringUTF ****************************************************************
4454 Constructs a new java.lang.String object from an array of UTF-8
4457 *******************************************************************************/
4459 jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
4461 java_lang_String *s;
4463 STATISTICS(jniinvokation());
4465 s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
4467 return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
4471 /****************** returns the utf8 length in bytes of a string *******************/
4473 jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string)
4475 java_lang_String *s;
4478 STATISTICS(jniinvokation());
4480 s = (java_lang_String *) string;
4482 length = u2_utflength(s->value->data, s->count);
4488 /* GetStringUTFChars ***********************************************************
4490 Returns a pointer to an array of UTF-8 characters of the
4491 string. This array is valid until it is released by
4492 ReleaseStringUTFChars().
4494 *******************************************************************************/
4496 const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string,
4501 STATISTICS(jniinvokation());
4509 u = javastring_toutf((java_objectheader *) string, false);
4518 /* ReleaseStringUTFChars *******************************************************
4520 Informs the VM that the native code no longer needs access to
4521 utf. The utf argument is a pointer derived from string using
4522 GetStringUTFChars().
4524 *******************************************************************************/
4526 void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf)
4528 STATISTICS(jniinvokation());
4530 /* XXX we don't release utf chars right now, perhaps that should be done
4531 later. Since there is always one reference the garbage collector will
4536 /* Array Operations ***********************************************************/
4538 /* GetArrayLength **************************************************************
4540 Returns the number of elements in the array.
4542 *******************************************************************************/
4544 jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array)
4546 java_arrayheader *a;
4548 STATISTICS(jniinvokation());
4550 a = (java_arrayheader *) array;
4556 /* NewObjectArray **************************************************************
4558 Constructs a new array holding objects in class elementClass. All
4559 elements are initially set to initialElement.
4561 *******************************************************************************/
4563 jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
4564 jclass elementClass, jobject initialElement)
4567 java_objectheader *o;
4568 java_objectarray *oa;
4571 STATISTICS(jniinvokation());
4573 c = (classinfo *) elementClass;
4574 o = (java_objectheader *) initialElement;
4577 exceptions_throw_negativearraysizeexception();
4581 oa = builtin_anewarray(length, c);
4586 /* set all elements to initialElement */
4588 for (i = 0; i < length; i++)
4591 return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa);
4595 jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
4598 java_objectarray *oa;
4599 java_objectheader *o;
4601 STATISTICS(jniinvokation());
4603 oa = (java_objectarray *) array;
4605 if (index >= oa->header.size) {
4606 exceptions_throw_arrayindexoutofboundsexception();
4610 o = oa->data[index];
4612 return _Jv_JNI_NewLocalRef(env, (jobject) o);
4616 void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
4617 jsize index, jobject val)
4619 java_objectarray *oa;
4620 java_objectheader *o;
4622 STATISTICS(jniinvokation());
4624 oa = (java_objectarray *) array;
4625 o = (java_objectheader *) val;
4627 if (index >= oa->header.size) {
4628 exceptions_throw_arrayindexoutofboundsexception();
4632 /* check if the class of value is a subclass of the element class
4635 if (!builtin_canstore(oa, o))
4638 oa->data[index] = o;
4642 jbooleanArray _Jv_JNI_NewBooleanArray(JNIEnv *env, jsize len)
4644 java_booleanarray *ba;
4646 STATISTICS(jniinvokation());
4649 exceptions_throw_negativearraysizeexception();
4653 ba = builtin_newarray_boolean(len);
4655 return (jbooleanArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
4659 jbyteArray _Jv_JNI_NewByteArray(JNIEnv *env, jsize len)
4663 STATISTICS(jniinvokation());
4666 exceptions_throw_negativearraysizeexception();
4670 ba = builtin_newarray_byte(len);
4672 return (jbyteArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
4676 jcharArray _Jv_JNI_NewCharArray(JNIEnv *env, jsize len)
4680 STATISTICS(jniinvokation());
4683 exceptions_throw_negativearraysizeexception();
4687 ca = builtin_newarray_char(len);
4689 return (jcharArray) _Jv_JNI_NewLocalRef(env, (jobject) ca);
4693 jshortArray _Jv_JNI_NewShortArray(JNIEnv *env, jsize len)
4695 java_shortarray *sa;
4697 STATISTICS(jniinvokation());
4700 exceptions_throw_negativearraysizeexception();
4704 sa = builtin_newarray_short(len);
4706 return (jshortArray) _Jv_JNI_NewLocalRef(env, (jobject) sa);
4710 jintArray _Jv_JNI_NewIntArray(JNIEnv *env, jsize len)
4714 STATISTICS(jniinvokation());
4717 exceptions_throw_negativearraysizeexception();
4721 ia = builtin_newarray_int(len);
4723 return (jintArray) _Jv_JNI_NewLocalRef(env, (jobject) ia);
4727 jlongArray _Jv_JNI_NewLongArray(JNIEnv *env, jsize len)
4731 STATISTICS(jniinvokation());
4734 exceptions_throw_negativearraysizeexception();
4738 la = builtin_newarray_long(len);
4740 return (jlongArray) _Jv_JNI_NewLocalRef(env, (jobject) la);
4744 jfloatArray _Jv_JNI_NewFloatArray(JNIEnv *env, jsize len)
4746 java_floatarray *fa;
4748 STATISTICS(jniinvokation());
4751 exceptions_throw_negativearraysizeexception();
4755 fa = builtin_newarray_float(len);
4757 return (jfloatArray) _Jv_JNI_NewLocalRef(env, (jobject) fa);
4761 jdoubleArray _Jv_JNI_NewDoubleArray(JNIEnv *env, jsize len)
4763 java_doublearray *da;
4765 STATISTICS(jniinvokation());
4768 exceptions_throw_negativearraysizeexception();
4772 da = builtin_newarray_double(len);
4774 return (jdoubleArray) _Jv_JNI_NewLocalRef(env, (jobject) da);
4778 /* Get<PrimitiveType>ArrayElements *********************************************
4780 A family of functions that returns the body of the primitive array.
4782 *******************************************************************************/
4784 jboolean *_Jv_JNI_GetBooleanArrayElements(JNIEnv *env, jbooleanArray array,
4787 java_booleanarray *ba;
4789 STATISTICS(jniinvokation());
4791 ba = (java_booleanarray *) array;
4794 *isCopy = JNI_FALSE;
4800 jbyte *_Jv_JNI_GetByteArrayElements(JNIEnv *env, jbyteArray array,
4805 STATISTICS(jniinvokation());
4807 ba = (java_bytearray *) array;
4810 *isCopy = JNI_FALSE;
4816 jchar *_Jv_JNI_GetCharArrayElements(JNIEnv *env, jcharArray array,
4821 STATISTICS(jniinvokation());
4823 ca = (java_chararray *) array;
4826 *isCopy = JNI_FALSE;
4832 jshort *_Jv_JNI_GetShortArrayElements(JNIEnv *env, jshortArray array,
4835 java_shortarray *sa;
4837 STATISTICS(jniinvokation());
4839 sa = (java_shortarray *) array;
4842 *isCopy = JNI_FALSE;
4848 jint *_Jv_JNI_GetIntArrayElements(JNIEnv *env, jintArray array,
4853 STATISTICS(jniinvokation());
4855 ia = (java_intarray *) array;
4858 *isCopy = JNI_FALSE;
4864 jlong *_Jv_JNI_GetLongArrayElements(JNIEnv *env, jlongArray array,
4869 STATISTICS(jniinvokation());
4871 la = (java_longarray *) array;
4874 *isCopy = JNI_FALSE;
4876 /* We cast this one to prevent a compiler warning on 64-bit
4877 systems since GNU Classpath typedef jlong to long long. */
4879 return (jlong *) la->data;
4883 jfloat *_Jv_JNI_GetFloatArrayElements(JNIEnv *env, jfloatArray array,
4886 java_floatarray *fa;
4888 STATISTICS(jniinvokation());
4890 fa = (java_floatarray *) array;
4893 *isCopy = JNI_FALSE;
4899 jdouble *_Jv_JNI_GetDoubleArrayElements(JNIEnv *env, jdoubleArray array,
4902 java_doublearray *da;
4904 STATISTICS(jniinvokation());
4906 da = (java_doublearray *) array;
4909 *isCopy = JNI_FALSE;
4915 /* Release<PrimitiveType>ArrayElements *****************************************
4917 A family of functions that informs the VM that the native code no
4918 longer needs access to elems. The elems argument is a pointer
4919 derived from array using the corresponding
4920 Get<PrimitiveType>ArrayElements() function. If necessary, this
4921 function copies back all changes made to elems to the original
4924 *******************************************************************************/
4926 void _Jv_JNI_ReleaseBooleanArrayElements(JNIEnv *env, jbooleanArray array,
4927 jboolean *elems, jint mode)
4929 java_booleanarray *ba;
4931 STATISTICS(jniinvokation());
4933 ba = (java_booleanarray *) array;
4935 if (elems != ba->data) {
4938 MCOPY(ba->data, elems, u1, ba->header.size);
4941 MCOPY(ba->data, elems, u1, ba->header.size);
4942 /* XXX TWISTI how should it be freed? */
4945 /* XXX TWISTI how should it be freed? */
4952 void _Jv_JNI_ReleaseByteArrayElements(JNIEnv *env, jbyteArray array,
4953 jbyte *elems, jint mode)
4957 STATISTICS(jniinvokation());
4959 ba = (java_bytearray *) array;
4961 if (elems != ba->data) {
4964 MCOPY(ba->data, elems, s1, ba->header.size);
4967 MCOPY(ba->data, elems, s1, ba->header.size);
4968 /* XXX TWISTI how should it be freed? */
4971 /* XXX TWISTI how should it be freed? */
4978 void _Jv_JNI_ReleaseCharArrayElements(JNIEnv *env, jcharArray array,
4979 jchar *elems, jint mode)
4983 STATISTICS(jniinvokation());
4985 ca = (java_chararray *) array;
4987 if (elems != ca->data) {
4990 MCOPY(ca->data, elems, u2, ca->header.size);
4993 MCOPY(ca->data, elems, u2, ca->header.size);
4994 /* XXX TWISTI how should it be freed? */
4997 /* XXX TWISTI how should it be freed? */
5004 void _Jv_JNI_ReleaseShortArrayElements(JNIEnv *env, jshortArray array,
5005 jshort *elems, jint mode)
5007 java_shortarray *sa;
5009 STATISTICS(jniinvokation());
5011 sa = (java_shortarray *) array;
5013 if (elems != sa->data) {
5016 MCOPY(sa->data, elems, s2, sa->header.size);
5019 MCOPY(sa->data, elems, s2, sa->header.size);
5020 /* XXX TWISTI how should it be freed? */
5023 /* XXX TWISTI how should it be freed? */
5030 void _Jv_JNI_ReleaseIntArrayElements(JNIEnv *env, jintArray array, jint *elems,
5035 STATISTICS(jniinvokation());
5037 ia = (java_intarray *) array;
5039 if (elems != ia->data) {
5042 MCOPY(ia->data, elems, s4, ia->header.size);
5045 MCOPY(ia->data, elems, s4, ia->header.size);
5046 /* XXX TWISTI how should it be freed? */
5049 /* XXX TWISTI how should it be freed? */
5056 void _Jv_JNI_ReleaseLongArrayElements(JNIEnv *env, jlongArray array,
5057 jlong *elems, jint mode)
5061 STATISTICS(jniinvokation());
5063 la = (java_longarray *) array;
5065 /* We cast this one to prevent a compiler warning on 64-bit
5066 systems since GNU Classpath typedef jlong to long long. */
5068 if ((s8 *) elems != la->data) {
5071 MCOPY(la->data, elems, s8, la->header.size);
5074 MCOPY(la->data, elems, s8, la->header.size);
5075 /* XXX TWISTI how should it be freed? */
5078 /* XXX TWISTI how should it be freed? */
5085 void _Jv_JNI_ReleaseFloatArrayElements(JNIEnv *env, jfloatArray array,
5086 jfloat *elems, jint mode)
5088 java_floatarray *fa;
5090 STATISTICS(jniinvokation());
5092 fa = (java_floatarray *) array;
5094 if (elems != fa->data) {
5097 MCOPY(fa->data, elems, float, fa->header.size);
5100 MCOPY(fa->data, elems, float, fa->header.size);
5101 /* XXX TWISTI how should it be freed? */
5104 /* XXX TWISTI how should it be freed? */
5111 void _Jv_JNI_ReleaseDoubleArrayElements(JNIEnv *env, jdoubleArray array,
5112 jdouble *elems, jint mode)
5114 java_doublearray *da;
5116 STATISTICS(jniinvokation());
5118 da = (java_doublearray *) array;
5120 if (elems != da->data) {
5123 MCOPY(da->data, elems, double, da->header.size);
5126 MCOPY(da->data, elems, double, da->header.size);
5127 /* XXX TWISTI how should it be freed? */
5130 /* XXX TWISTI how should it be freed? */
5137 /* Get<PrimitiveType>ArrayRegion **********************************************
5139 A family of functions that copies a region of a primitive array
5142 *******************************************************************************/
5144 void _Jv_JNI_GetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
5145 jsize start, jsize len, jboolean *buf)
5147 java_booleanarray *ba;
5149 STATISTICS(jniinvokation());
5151 ba = (java_booleanarray *) array;
5153 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5154 exceptions_throw_arrayindexoutofboundsexception();
5156 MCOPY(buf, &ba->data[start], u1, len);
5160 void _Jv_JNI_GetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
5161 jsize len, jbyte *buf)
5165 STATISTICS(jniinvokation());
5167 ba = (java_bytearray *) array;
5169 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5170 exceptions_throw_arrayindexoutofboundsexception();
5172 MCOPY(buf, &ba->data[start], s1, len);
5176 void _Jv_JNI_GetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
5177 jsize len, jchar *buf)
5181 STATISTICS(jniinvokation());
5183 ca = (java_chararray *) array;
5185 if ((start < 0) || (len < 0) || (start + len > ca->header.size))
5186 exceptions_throw_arrayindexoutofboundsexception();
5188 MCOPY(buf, &ca->data[start], u2, len);
5192 void _Jv_JNI_GetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
5193 jsize len, jshort *buf)
5195 java_shortarray *sa;
5197 STATISTICS(jniinvokation());
5199 sa = (java_shortarray *) array;
5201 if ((start < 0) || (len < 0) || (start + len > sa->header.size))
5202 exceptions_throw_arrayindexoutofboundsexception();
5204 MCOPY(buf, &sa->data[start], s2, len);
5208 void _Jv_JNI_GetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
5209 jsize len, jint *buf)
5213 STATISTICS(jniinvokation());
5215 ia = (java_intarray *) array;
5217 if ((start < 0) || (len < 0) || (start + len > ia->header.size))
5218 exceptions_throw_arrayindexoutofboundsexception();
5220 MCOPY(buf, &ia->data[start], s4, len);
5224 void _Jv_JNI_GetLongArrayRegion(JNIEnv *env, jlongArray array, jsize start,
5225 jsize len, jlong *buf)
5229 STATISTICS(jniinvokation());
5231 la = (java_longarray *) array;
5233 if ((start < 0) || (len < 0) || (start + len > la->header.size))
5234 exceptions_throw_arrayindexoutofboundsexception();
5236 MCOPY(buf, &la->data[start], s8, len);
5240 void _Jv_JNI_GetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
5241 jsize len, jfloat *buf)
5243 java_floatarray *fa;
5245 STATISTICS(jniinvokation());
5247 fa = (java_floatarray *) array;
5249 if ((start < 0) || (len < 0) || (start + len > fa->header.size))
5250 exceptions_throw_arrayindexoutofboundsexception();
5252 MCOPY(buf, &fa->data[start], float, len);
5256 void _Jv_JNI_GetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
5257 jsize len, jdouble *buf)
5259 java_doublearray *da;
5261 STATISTICS(jniinvokation());
5263 da = (java_doublearray *) array;
5265 if ((start < 0) || (len < 0) || (start + len > da->header.size))
5266 exceptions_throw_arrayindexoutofboundsexception();
5268 MCOPY(buf, &da->data[start], double, len);
5272 /* Set<PrimitiveType>ArrayRegion **********************************************
5274 A family of functions that copies back a region of a primitive
5275 array from a buffer.
5277 *******************************************************************************/
5279 void _Jv_JNI_SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
5280 jsize start, jsize len, const jboolean *buf)
5282 java_booleanarray *ba;
5284 STATISTICS(jniinvokation());
5286 ba = (java_booleanarray *) array;
5288 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5289 exceptions_throw_arrayindexoutofboundsexception();
5291 MCOPY(&ba->data[start], buf, u1, len);
5295 void _Jv_JNI_SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
5296 jsize len, const jbyte *buf)
5300 STATISTICS(jniinvokation());
5302 ba = (java_bytearray *) array;
5304 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5305 exceptions_throw_arrayindexoutofboundsexception();
5307 MCOPY(&ba->data[start], buf, s1, len);
5311 void _Jv_JNI_SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
5312 jsize len, const jchar *buf)
5316 STATISTICS(jniinvokation());
5318 ca = (java_chararray *) array;
5320 if ((start < 0) || (len < 0) || (start + len > ca->header.size))
5321 exceptions_throw_arrayindexoutofboundsexception();
5323 MCOPY(&ca->data[start], buf, u2, len);
5327 void _Jv_JNI_SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
5328 jsize len, const jshort *buf)
5330 java_shortarray *sa;
5332 STATISTICS(jniinvokation());
5334 sa = (java_shortarray *) array;
5336 if ((start < 0) || (len < 0) || (start + len > sa->header.size))
5337 exceptions_throw_arrayindexoutofboundsexception();
5339 MCOPY(&sa->data[start], buf, s2, len);
5343 void _Jv_JNI_SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
5344 jsize len, const jint *buf)
5348 STATISTICS(jniinvokation());
5350 ia = (java_intarray *) array;
5352 if ((start < 0) || (len < 0) || (start + len > ia->header.size))
5353 exceptions_throw_arrayindexoutofboundsexception();
5355 MCOPY(&ia->data[start], buf, s4, len);
5359 void _Jv_JNI_SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start,
5360 jsize len, const jlong *buf)
5364 STATISTICS(jniinvokation());
5366 la = (java_longarray *) array;
5368 if ((start < 0) || (len < 0) || (start + len > la->header.size))
5369 exceptions_throw_arrayindexoutofboundsexception();
5371 MCOPY(&la->data[start], buf, s8, len);
5375 void _Jv_JNI_SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
5376 jsize len, const jfloat *buf)
5378 java_floatarray *fa;
5380 STATISTICS(jniinvokation());
5382 fa = (java_floatarray *) array;
5384 if ((start < 0) || (len < 0) || (start + len > fa->header.size))
5385 exceptions_throw_arrayindexoutofboundsexception();
5387 MCOPY(&fa->data[start], buf, float, len);
5391 void _Jv_JNI_SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
5392 jsize len, const jdouble *buf)
5394 java_doublearray *da;
5396 STATISTICS(jniinvokation());
5398 da = (java_doublearray *) array;
5400 if ((start < 0) || (len < 0) || (start + len > da->header.size))
5401 exceptions_throw_arrayindexoutofboundsexception();
5403 MCOPY(&da->data[start], buf, double, len);
5407 /* Registering Native Methods *************************************************/
5409 /* RegisterNatives *************************************************************
5411 Registers native methods with the class specified by the clazz
5412 argument. The methods parameter specifies an array of
5413 JNINativeMethod structures that contain the names, signatures, and
5414 function pointers of the native methods. The nMethods parameter
5415 specifies the number of native methods in the array.
5417 *******************************************************************************/
5419 jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz,
5420 const JNINativeMethod *methods, jint nMethods)
5424 STATISTICS(jniinvokation());
5426 c = (classinfo *) clazz;
5428 /* XXX: if implemented this needs a call to jvmti_NativeMethodBind
5429 if (jvmti) jvmti_NativeMethodBind(method, address, new_address_ptr);
5432 native_method_register(c->name, methods, nMethods);
5438 /* UnregisterNatives ***********************************************************
5440 Unregisters native methods of a class. The class goes back to the
5441 state before it was linked or registered with its native method
5444 This function should not be used in normal native code. Instead, it
5445 provides special programs a way to reload and relink native
5448 *******************************************************************************/
5450 jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz)
5452 STATISTICS(jniinvokation());
5454 /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */
5456 log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!");
5462 /* Monitor Operations *********************************************************/
5464 /* MonitorEnter ****************************************************************
5466 Enters the monitor associated with the underlying Java object
5469 *******************************************************************************/
5471 jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj)
5473 STATISTICS(jniinvokation());
5476 exceptions_throw_nullpointerexception();
5480 LOCK_MONITOR_ENTER(obj);
5486 /* MonitorExit *****************************************************************
5488 The current thread must be the owner of the monitor associated with
5489 the underlying Java object referred to by obj. The thread
5490 decrements the counter indicating the number of times it has
5491 entered this monitor. If the value of the counter becomes zero, the
5492 current thread releases the monitor.
5494 *******************************************************************************/
5496 jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj)
5498 STATISTICS(jniinvokation());
5501 exceptions_throw_nullpointerexception();
5505 LOCK_MONITOR_EXIT(obj);
5511 /* JavaVM Interface ***********************************************************/
5513 /* GetJavaVM *******************************************************************
5515 Returns the Java VM interface (used in the Invocation API)
5516 associated with the current thread. The result is placed at the
5517 location pointed to by the second argument, vm.
5519 *******************************************************************************/
5521 jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **vm)
5523 STATISTICS(jniinvokation());
5525 *vm = (JavaVM *) _Jv_jvm;
5531 /* GetStringRegion *************************************************************
5533 Copies len number of Unicode characters beginning at offset start
5534 to the given buffer buf.
5536 Throws StringIndexOutOfBoundsException on index overflow.
5538 *******************************************************************************/
5540 void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len,
5543 java_lang_String *s;
5546 STATISTICS(jniinvokation());
5548 s = (java_lang_String *) str;
5551 if ((start < 0) || (len < 0) || (start > s->count) ||
5552 (start + len > s->count)) {
5553 exceptions_throw_stringindexoutofboundsexception();
5557 MCOPY(buf, &ca->data[start], u2, len);
5561 /* GetStringUTFRegion **********************************************************
5563 Translates len number of Unicode characters beginning at offset
5564 start into UTF-8 format and place the result in the given buffer
5567 Throws StringIndexOutOfBoundsException on index overflow.
5569 *******************************************************************************/
5571 void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start,
5572 jsize len, char *buf)
5574 java_lang_String *s;
5578 STATISTICS(jniinvokation());
5580 s = (java_lang_String *) str;
5583 if ((start < 0) || (len < 0) || (start > s->count) ||
5584 (start + len > s->count)) {
5585 exceptions_throw_stringindexoutofboundsexception();
5589 /* XXX not sure if this is correct */
5591 for (i = 0; i < len; i++)
5592 buf[i] = ca->data[start + i];
5598 /* GetPrimitiveArrayCritical ***************************************************
5600 Obtain a direct pointer to array elements.
5602 *******************************************************************************/
5604 void *_Jv_JNI_GetPrimitiveArrayCritical(JNIEnv *env, jarray array,
5610 ba = (java_bytearray *) array;
5612 /* do the same as Kaffe does */
5614 bp = _Jv_JNI_GetByteArrayElements(env, (jbyteArray) ba, isCopy);
5620 /* ReleasePrimitiveArrayCritical ***********************************************
5622 No specific documentation.
5624 *******************************************************************************/
5626 void _Jv_JNI_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array,
5627 void *carray, jint mode)
5629 STATISTICS(jniinvokation());
5631 /* do the same as Kaffe does */
5633 _Jv_JNI_ReleaseByteArrayElements(env, (jbyteArray) array, (jbyte *) carray,
5638 /* GetStringCritical ***********************************************************
5640 The semantics of these two functions are similar to the existing
5641 Get/ReleaseStringChars functions.
5643 *******************************************************************************/
5645 const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string,
5648 STATISTICS(jniinvokation());
5650 return _Jv_JNI_GetStringChars(env, string, isCopy);
5654 void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string,
5655 const jchar *cstring)
5657 STATISTICS(jniinvokation());
5659 _Jv_JNI_ReleaseStringChars(env, string, cstring);
5663 jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj)
5665 STATISTICS(jniinvokation());
5667 log_text("JNI-Call: NewWeakGlobalRef: IMPLEMENT ME!");
5673 void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref)
5675 STATISTICS(jniinvokation());
5677 log_text("JNI-Call: DeleteWeakGlobalRef: IMPLEMENT ME");
5681 /* NewGlobalRef ****************************************************************
5683 Creates a new global reference to the object referred to by the obj
5686 *******************************************************************************/
5688 jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
5690 hashtable_global_ref_entry *gre;
5691 u4 key; /* hashkey */
5692 u4 slot; /* slot in hashtable */
5693 java_objectheader *o;
5695 STATISTICS(jniinvokation());
5697 o = (java_objectheader *) obj;
5699 LOCK_MONITOR_ENTER(hashtable_global_ref->header);
5701 /* normally addresses are aligned to 4, 8 or 16 bytes */
5703 key = ((u4) (ptrint) obj) >> 4; /* align to 16-byte boundaries */
5704 slot = key & (hashtable_global_ref->size - 1);
5705 gre = hashtable_global_ref->ptr[slot];
5707 /* search external hash chain for the entry */
5711 /* global object found, increment the reference */
5715 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5720 gre = gre->hashlink; /* next element in external chain */
5723 /* global ref not found, create a new one */
5725 gre = NEW(hashtable_global_ref_entry);
5727 #if defined(ENABLE_GC_CACAO)
5728 /* register global ref with the GC */
5730 gc_reference_register(&(gre->o));
5736 /* insert entry into hashtable */
5738 gre->hashlink = hashtable_global_ref->ptr[slot];
5740 hashtable_global_ref->ptr[slot] = gre;
5742 /* update number of hashtable-entries */
5744 hashtable_global_ref->entries++;
5746 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5752 /* DeleteGlobalRef *************************************************************
5754 Deletes the global reference pointed to by globalRef.
5756 *******************************************************************************/
5758 void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
5760 hashtable_global_ref_entry *gre;
5761 hashtable_global_ref_entry *prevgre;
5762 u4 key; /* hashkey */
5763 u4 slot; /* slot in hashtable */
5764 java_objectheader *o;
5766 STATISTICS(jniinvokation());
5768 o = (java_objectheader *) globalRef;
5770 LOCK_MONITOR_ENTER(hashtable_global_ref->header);
5772 /* normally addresses are aligned to 4, 8 or 16 bytes */
5774 key = ((u4) (ptrint) globalRef) >> 4; /* align to 16-byte boundaries */
5775 slot = key & (hashtable_global_ref->size - 1);
5776 gre = hashtable_global_ref->ptr[slot];
5778 /* initialize prevgre */
5782 /* search external hash chain for the entry */
5786 /* global object found, decrement the reference count */
5790 /* if reference count is 0, remove the entry */
5792 if (gre->refs == 0) {
5793 /* special handling if it's the first in the chain */
5795 if (prevgre == NULL)
5796 hashtable_global_ref->ptr[slot] = gre->hashlink;
5798 prevgre->hashlink = gre->hashlink;
5800 #if defined(ENABLE_GC_CACAO)
5801 /* unregister global ref with the GC */
5803 gc_reference_unregister(&(gre->o));
5806 FREE(gre, hashtable_global_ref_entry);
5809 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5814 prevgre = gre; /* save current pointer for removal */
5815 gre = gre->hashlink; /* next element in external chain */
5818 log_println("JNI-DeleteGlobalRef: global reference not found");
5820 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5824 /* ExceptionCheck **************************************************************
5826 Returns JNI_TRUE when there is a pending exception; otherwise,
5829 *******************************************************************************/
5831 jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
5833 java_objectheader *o;
5835 STATISTICS(jniinvokation());
5837 o = exceptions_get_exception();
5839 return (o != NULL) ? JNI_TRUE : JNI_FALSE;
5843 /* New JNI 1.4 functions ******************************************************/
5845 /* NewDirectByteBuffer *********************************************************
5847 Allocates and returns a direct java.nio.ByteBuffer referring to the
5848 block of memory starting at the memory address address and
5849 extending capacity bytes.
5851 *******************************************************************************/
5853 jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
5855 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5856 java_objectheader *nbuf;
5858 # if SIZEOF_VOID_P == 8
5859 gnu_classpath_Pointer64 *paddress;
5861 gnu_classpath_Pointer32 *paddress;
5864 STATISTICS(jniinvokation());
5866 /* alocate a gnu.classpath.Pointer{32,64} object */
5868 # if SIZEOF_VOID_P == 8
5869 if (!(paddress = (gnu_classpath_Pointer64 *)
5870 builtin_new(class_gnu_classpath_Pointer64)))
5872 if (!(paddress = (gnu_classpath_Pointer32 *)
5873 builtin_new(class_gnu_classpath_Pointer32)))
5877 /* fill gnu.classpath.Pointer{32,64} with address */
5879 paddress->data = (ptrint) address;
5881 /* create a java.nio.DirectByteBufferImpl$ReadWrite object */
5883 nbuf = (*env)->NewObject(env, class_java_nio_DirectByteBufferImpl_ReadWrite,
5884 (jmethodID) dbbirw_init, NULL, paddress,
5885 (jint) capacity, (jint) capacity, (jint) 0);
5887 /* add local reference and return the value */
5889 return _Jv_JNI_NewLocalRef(env, nbuf);
5891 vm_abort("_Jv_JNI_NewDirectByteBuffer: not implemented in this configuration");
5893 /* keep compiler happy */
5900 /* GetDirectBufferAddress ******************************************************
5902 Fetches and returns the starting address of the memory region
5903 referenced by the given direct java.nio.Buffer.
5905 *******************************************************************************/
5907 void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
5909 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5910 java_nio_DirectByteBufferImpl *nbuf;
5911 # if SIZEOF_VOID_P == 8
5912 gnu_classpath_Pointer64 *address;
5914 gnu_classpath_Pointer32 *address;
5917 STATISTICS(jniinvokation());
5919 if (!builtin_instanceof(buf, class_java_nio_Buffer))
5922 nbuf = (java_nio_DirectByteBufferImpl *) buf;
5924 # if SIZEOF_VOID_P == 8
5925 address = (gnu_classpath_Pointer64 *) nbuf->address;
5927 address = (gnu_classpath_Pointer32 *) nbuf->address;
5930 if (address == NULL)
5933 return (void *) address->data;
5935 vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration");
5937 /* keep compiler happy */
5944 /* GetDirectBufferCapacity *****************************************************
5946 Fetches and returns the capacity in bytes of the memory region
5947 referenced by the given direct java.nio.Buffer.
5949 *******************************************************************************/
5951 jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
5953 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5954 java_objectheader *o;
5955 java_nio_Buffer *nbuf;
5957 STATISTICS(jniinvokation());
5959 o = (java_objectheader *) buf;
5961 if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl))
5964 nbuf = (java_nio_Buffer *) o;
5966 return (jlong) nbuf->cap;
5968 vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration");
5970 /* keep compiler happy */
5977 /* DestroyJavaVM ***************************************************************
5979 Unloads a Java VM and reclaims its resources. Only the main thread
5980 can unload the VM. The system waits until the main thread is only
5981 remaining user thread before it destroys the VM.
5983 *******************************************************************************/
5985 jint _Jv_JNI_DestroyJavaVM(JavaVM *vm)
5989 STATISTICS(jniinvokation());
5991 status = vm_destroy(vm);
5997 /* AttachCurrentThread *********************************************************
5999 Attaches the current thread to a Java VM. Returns a JNI interface
6000 pointer in the JNIEnv argument.
6002 Trying to attach a thread that is already attached is a no-op.
6004 A native thread cannot be attached simultaneously to two Java VMs.
6006 When a thread is attached to the VM, the context class loader is
6007 the bootstrap loader.
6009 *******************************************************************************/
6011 static s4 jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon)
6013 JavaVMAttachArgs *vm_aargs;
6015 #if defined(ENABLE_THREADS)
6016 if (threads_get_current_threadobject() == NULL) {
6017 vm_aargs = (JavaVMAttachArgs *) thr_args;
6019 if (vm_aargs != NULL) {
6020 if ((vm_aargs->version != JNI_VERSION_1_2) &&
6021 (vm_aargs->version != JNI_VERSION_1_4))
6022 return JNI_EVERSION;
6025 if (!threads_attach_current_thread(vm_aargs, false))
6028 if (!jni_init_localref_table())
6039 jint _Jv_JNI_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args)
6041 STATISTICS(jniinvokation());
6043 return jni_attach_current_thread(p_env, thr_args, false);
6047 /* DetachCurrentThread *********************************************************
6049 Detaches the current thread from a Java VM. All Java monitors held
6050 by this thread are released. All Java threads waiting for this
6051 thread to die are notified.
6053 In JDK 1.1, the main thread cannot be detached from the VM. It must
6054 call DestroyJavaVM to unload the entire VM.
6056 In the JDK, the main thread can be detached from the VM.
6058 The main thread, which is the thread that created the Java VM,
6059 cannot be detached from the VM. Instead, the main thread must call
6060 JNI_DestroyJavaVM() to unload the entire VM.
6062 *******************************************************************************/
6064 jint _Jv_JNI_DetachCurrentThread(JavaVM *vm)
6066 #if defined(ENABLE_THREADS)
6067 threadobject *thread;
6069 STATISTICS(jniinvokation());
6071 thread = threads_get_current_threadobject();
6076 if (!jni_free_localref_table())
6079 if (!threads_detach_thread(thread))
6087 /* GetEnv **********************************************************************
6089 If the current thread is not attached to the VM, sets *env to NULL,
6090 and returns JNI_EDETACHED. If the specified version is not
6091 supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise,
6092 sets *env to the appropriate interface, and returns JNI_OK.
6094 *******************************************************************************/
6096 jint _Jv_JNI_GetEnv(JavaVM *vm, void **env, jint version)
6098 STATISTICS(jniinvokation());
6100 #if defined(ENABLE_THREADS)
6101 if (threads_get_current_threadobject() == NULL) {
6104 return JNI_EDETACHED;
6108 /* check the JNI version */
6111 case JNI_VERSION_1_1:
6112 case JNI_VERSION_1_2:
6113 case JNI_VERSION_1_4:
6121 #if defined(ENABLE_JVMTI)
6122 if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE)
6123 == JVMTI_VERSION_INTERFACE_JVMTI) {
6125 *env = (void *) jvmti_new_environment();
6134 return JNI_EVERSION;
6138 /* AttachCurrentThreadAsDaemon *************************************************
6140 Same semantics as AttachCurrentThread, but the newly-created
6141 java.lang.Thread instance is a daemon.
6143 If the thread has already been attached via either
6144 AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine
6145 simply sets the value pointed to by penv to the JNIEnv of the
6146 current thread. In this case neither AttachCurrentThread nor this
6147 routine have any effect on the daemon status of the thread.
6149 *******************************************************************************/
6151 jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
6153 STATISTICS(jniinvokation());
6155 return jni_attach_current_thread(penv, args, true);
6159 /* JNI invocation table *******************************************************/
6161 const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = {
6166 _Jv_JNI_DestroyJavaVM,
6167 _Jv_JNI_AttachCurrentThread,
6168 _Jv_JNI_DetachCurrentThread,
6170 _Jv_JNI_AttachCurrentThreadAsDaemon
6174 /* JNI function table *********************************************************/
6176 struct JNINativeInterface_ _Jv_JNINativeInterface = {
6183 _Jv_JNI_DefineClass,
6185 _Jv_JNI_FromReflectedMethod,
6186 _Jv_JNI_FromReflectedField,
6187 _Jv_JNI_ToReflectedMethod,
6188 _Jv_JNI_GetSuperclass,
6189 _Jv_JNI_IsAssignableFrom,
6190 _Jv_JNI_ToReflectedField,
6194 _Jv_JNI_ExceptionOccurred,
6195 _Jv_JNI_ExceptionDescribe,
6196 _Jv_JNI_ExceptionClear,
6198 _Jv_JNI_PushLocalFrame,
6199 _Jv_JNI_PopLocalFrame,
6201 _Jv_JNI_NewGlobalRef,
6202 _Jv_JNI_DeleteGlobalRef,
6203 _Jv_JNI_DeleteLocalRef,
6204 _Jv_JNI_IsSameObject,
6205 _Jv_JNI_NewLocalRef,
6206 _Jv_JNI_EnsureLocalCapacity,
6208 _Jv_JNI_AllocObject,
6213 _Jv_JNI_GetObjectClass,
6214 _Jv_JNI_IsInstanceOf,
6216 _Jv_JNI_GetMethodID,
6218 _Jv_JNI_CallObjectMethod,
6219 _Jv_JNI_CallObjectMethodV,
6220 _Jv_JNI_CallObjectMethodA,
6221 _Jv_JNI_CallBooleanMethod,
6222 _Jv_JNI_CallBooleanMethodV,
6223 _Jv_JNI_CallBooleanMethodA,
6224 _Jv_JNI_CallByteMethod,
6225 _Jv_JNI_CallByteMethodV,
6226 _Jv_JNI_CallByteMethodA,
6227 _Jv_JNI_CallCharMethod,
6228 _Jv_JNI_CallCharMethodV,
6229 _Jv_JNI_CallCharMethodA,
6230 _Jv_JNI_CallShortMethod,
6231 _Jv_JNI_CallShortMethodV,
6232 _Jv_JNI_CallShortMethodA,
6233 _Jv_JNI_CallIntMethod,
6234 _Jv_JNI_CallIntMethodV,
6235 _Jv_JNI_CallIntMethodA,
6236 _Jv_JNI_CallLongMethod,
6237 _Jv_JNI_CallLongMethodV,
6238 _Jv_JNI_CallLongMethodA,
6239 _Jv_JNI_CallFloatMethod,
6240 _Jv_JNI_CallFloatMethodV,
6241 _Jv_JNI_CallFloatMethodA,
6242 _Jv_JNI_CallDoubleMethod,
6243 _Jv_JNI_CallDoubleMethodV,
6244 _Jv_JNI_CallDoubleMethodA,
6245 _Jv_JNI_CallVoidMethod,
6246 _Jv_JNI_CallVoidMethodV,
6247 _Jv_JNI_CallVoidMethodA,
6249 _Jv_JNI_CallNonvirtualObjectMethod,
6250 _Jv_JNI_CallNonvirtualObjectMethodV,
6251 _Jv_JNI_CallNonvirtualObjectMethodA,
6252 _Jv_JNI_CallNonvirtualBooleanMethod,
6253 _Jv_JNI_CallNonvirtualBooleanMethodV,
6254 _Jv_JNI_CallNonvirtualBooleanMethodA,
6255 _Jv_JNI_CallNonvirtualByteMethod,
6256 _Jv_JNI_CallNonvirtualByteMethodV,
6257 _Jv_JNI_CallNonvirtualByteMethodA,
6258 _Jv_JNI_CallNonvirtualCharMethod,
6259 _Jv_JNI_CallNonvirtualCharMethodV,
6260 _Jv_JNI_CallNonvirtualCharMethodA,
6261 _Jv_JNI_CallNonvirtualShortMethod,
6262 _Jv_JNI_CallNonvirtualShortMethodV,
6263 _Jv_JNI_CallNonvirtualShortMethodA,
6264 _Jv_JNI_CallNonvirtualIntMethod,
6265 _Jv_JNI_CallNonvirtualIntMethodV,
6266 _Jv_JNI_CallNonvirtualIntMethodA,
6267 _Jv_JNI_CallNonvirtualLongMethod,
6268 _Jv_JNI_CallNonvirtualLongMethodV,
6269 _Jv_JNI_CallNonvirtualLongMethodA,
6270 _Jv_JNI_CallNonvirtualFloatMethod,
6271 _Jv_JNI_CallNonvirtualFloatMethodV,
6272 _Jv_JNI_CallNonvirtualFloatMethodA,
6273 _Jv_JNI_CallNonvirtualDoubleMethod,
6274 _Jv_JNI_CallNonvirtualDoubleMethodV,
6275 _Jv_JNI_CallNonvirtualDoubleMethodA,
6276 _Jv_JNI_CallNonvirtualVoidMethod,
6277 _Jv_JNI_CallNonvirtualVoidMethodV,
6278 _Jv_JNI_CallNonvirtualVoidMethodA,
6282 _Jv_JNI_GetObjectField,
6283 _Jv_JNI_GetBooleanField,
6284 _Jv_JNI_GetByteField,
6285 _Jv_JNI_GetCharField,
6286 _Jv_JNI_GetShortField,
6287 _Jv_JNI_GetIntField,
6288 _Jv_JNI_GetLongField,
6289 _Jv_JNI_GetFloatField,
6290 _Jv_JNI_GetDoubleField,
6291 _Jv_JNI_SetObjectField,
6292 _Jv_JNI_SetBooleanField,
6293 _Jv_JNI_SetByteField,
6294 _Jv_JNI_SetCharField,
6295 _Jv_JNI_SetShortField,
6296 _Jv_JNI_SetIntField,
6297 _Jv_JNI_SetLongField,
6298 _Jv_JNI_SetFloatField,
6299 _Jv_JNI_SetDoubleField,
6301 _Jv_JNI_GetStaticMethodID,
6303 _Jv_JNI_CallStaticObjectMethod,
6304 _Jv_JNI_CallStaticObjectMethodV,
6305 _Jv_JNI_CallStaticObjectMethodA,
6306 _Jv_JNI_CallStaticBooleanMethod,
6307 _Jv_JNI_CallStaticBooleanMethodV,
6308 _Jv_JNI_CallStaticBooleanMethodA,
6309 _Jv_JNI_CallStaticByteMethod,
6310 _Jv_JNI_CallStaticByteMethodV,
6311 _Jv_JNI_CallStaticByteMethodA,
6312 _Jv_JNI_CallStaticCharMethod,
6313 _Jv_JNI_CallStaticCharMethodV,
6314 _Jv_JNI_CallStaticCharMethodA,
6315 _Jv_JNI_CallStaticShortMethod,
6316 _Jv_JNI_CallStaticShortMethodV,
6317 _Jv_JNI_CallStaticShortMethodA,
6318 _Jv_JNI_CallStaticIntMethod,
6319 _Jv_JNI_CallStaticIntMethodV,
6320 _Jv_JNI_CallStaticIntMethodA,
6321 _Jv_JNI_CallStaticLongMethod,
6322 _Jv_JNI_CallStaticLongMethodV,
6323 _Jv_JNI_CallStaticLongMethodA,
6324 _Jv_JNI_CallStaticFloatMethod,
6325 _Jv_JNI_CallStaticFloatMethodV,
6326 _Jv_JNI_CallStaticFloatMethodA,
6327 _Jv_JNI_CallStaticDoubleMethod,
6328 _Jv_JNI_CallStaticDoubleMethodV,
6329 _Jv_JNI_CallStaticDoubleMethodA,
6330 _Jv_JNI_CallStaticVoidMethod,
6331 _Jv_JNI_CallStaticVoidMethodV,
6332 _Jv_JNI_CallStaticVoidMethodA,
6334 _Jv_JNI_GetStaticFieldID,
6336 _Jv_JNI_GetStaticObjectField,
6337 _Jv_JNI_GetStaticBooleanField,
6338 _Jv_JNI_GetStaticByteField,
6339 _Jv_JNI_GetStaticCharField,
6340 _Jv_JNI_GetStaticShortField,
6341 _Jv_JNI_GetStaticIntField,
6342 _Jv_JNI_GetStaticLongField,
6343 _Jv_JNI_GetStaticFloatField,
6344 _Jv_JNI_GetStaticDoubleField,
6345 _Jv_JNI_SetStaticObjectField,
6346 _Jv_JNI_SetStaticBooleanField,
6347 _Jv_JNI_SetStaticByteField,
6348 _Jv_JNI_SetStaticCharField,
6349 _Jv_JNI_SetStaticShortField,
6350 _Jv_JNI_SetStaticIntField,
6351 _Jv_JNI_SetStaticLongField,
6352 _Jv_JNI_SetStaticFloatField,
6353 _Jv_JNI_SetStaticDoubleField,
6356 _Jv_JNI_GetStringLength,
6357 _Jv_JNI_GetStringChars,
6358 _Jv_JNI_ReleaseStringChars,
6360 _Jv_JNI_NewStringUTF,
6361 _Jv_JNI_GetStringUTFLength,
6362 _Jv_JNI_GetStringUTFChars,
6363 _Jv_JNI_ReleaseStringUTFChars,
6365 _Jv_JNI_GetArrayLength,
6367 _Jv_JNI_NewObjectArray,
6368 _Jv_JNI_GetObjectArrayElement,
6369 _Jv_JNI_SetObjectArrayElement,
6371 _Jv_JNI_NewBooleanArray,
6372 _Jv_JNI_NewByteArray,
6373 _Jv_JNI_NewCharArray,
6374 _Jv_JNI_NewShortArray,
6375 _Jv_JNI_NewIntArray,
6376 _Jv_JNI_NewLongArray,
6377 _Jv_JNI_NewFloatArray,
6378 _Jv_JNI_NewDoubleArray,
6380 _Jv_JNI_GetBooleanArrayElements,
6381 _Jv_JNI_GetByteArrayElements,
6382 _Jv_JNI_GetCharArrayElements,
6383 _Jv_JNI_GetShortArrayElements,
6384 _Jv_JNI_GetIntArrayElements,
6385 _Jv_JNI_GetLongArrayElements,
6386 _Jv_JNI_GetFloatArrayElements,
6387 _Jv_JNI_GetDoubleArrayElements,
6389 _Jv_JNI_ReleaseBooleanArrayElements,
6390 _Jv_JNI_ReleaseByteArrayElements,
6391 _Jv_JNI_ReleaseCharArrayElements,
6392 _Jv_JNI_ReleaseShortArrayElements,
6393 _Jv_JNI_ReleaseIntArrayElements,
6394 _Jv_JNI_ReleaseLongArrayElements,
6395 _Jv_JNI_ReleaseFloatArrayElements,
6396 _Jv_JNI_ReleaseDoubleArrayElements,
6398 _Jv_JNI_GetBooleanArrayRegion,
6399 _Jv_JNI_GetByteArrayRegion,
6400 _Jv_JNI_GetCharArrayRegion,
6401 _Jv_JNI_GetShortArrayRegion,
6402 _Jv_JNI_GetIntArrayRegion,
6403 _Jv_JNI_GetLongArrayRegion,
6404 _Jv_JNI_GetFloatArrayRegion,
6405 _Jv_JNI_GetDoubleArrayRegion,
6406 _Jv_JNI_SetBooleanArrayRegion,
6407 _Jv_JNI_SetByteArrayRegion,
6408 _Jv_JNI_SetCharArrayRegion,
6409 _Jv_JNI_SetShortArrayRegion,
6410 _Jv_JNI_SetIntArrayRegion,
6411 _Jv_JNI_SetLongArrayRegion,
6412 _Jv_JNI_SetFloatArrayRegion,
6413 _Jv_JNI_SetDoubleArrayRegion,
6415 _Jv_JNI_RegisterNatives,
6416 _Jv_JNI_UnregisterNatives,
6418 _Jv_JNI_MonitorEnter,
6419 _Jv_JNI_MonitorExit,
6423 /* new JNI 1.2 functions */
6425 _Jv_JNI_GetStringRegion,
6426 _Jv_JNI_GetStringUTFRegion,
6428 _Jv_JNI_GetPrimitiveArrayCritical,
6429 _Jv_JNI_ReleasePrimitiveArrayCritical,
6431 _Jv_JNI_GetStringCritical,
6432 _Jv_JNI_ReleaseStringCritical,
6434 _Jv_JNI_NewWeakGlobalRef,
6435 _Jv_JNI_DeleteWeakGlobalRef,
6437 _Jv_JNI_ExceptionCheck,
6439 /* new JNI 1.4 functions */
6441 _Jv_JNI_NewDirectByteBuffer,
6442 _Jv_JNI_GetDirectBufferAddress,
6443 _Jv_JNI_GetDirectBufferCapacity
6447 /* Invocation API Functions ***************************************************/
6449 /* JNI_GetDefaultJavaVMInitArgs ************************************************
6451 Returns a default configuration for the Java VM.
6453 *******************************************************************************/
6455 jint JNI_GetDefaultJavaVMInitArgs(void *vm_args)
6457 JavaVMInitArgs *_vm_args;
6459 _vm_args = (JavaVMInitArgs *) vm_args;
6461 /* GNU classpath currently supports JNI 1.2 */
6463 switch (_vm_args->version) {
6464 case JNI_VERSION_1_1:
6465 _vm_args->version = JNI_VERSION_1_1;
6468 case JNI_VERSION_1_2:
6469 case JNI_VERSION_1_4:
6470 _vm_args->ignoreUnrecognized = JNI_FALSE;
6471 _vm_args->options = NULL;
6472 _vm_args->nOptions = 0;
6483 /* JNI_GetCreatedJavaVMs *******************************************************
6485 Returns all Java VMs that have been created. Pointers to VMs are written in
6486 the buffer vmBuf in the order they are created. At most bufLen number of
6487 entries will be written. The total number of created VMs is returned in
6490 *******************************************************************************/
6492 jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs)
6494 log_text("JNI_GetCreatedJavaVMs: IMPLEMENT ME!!!");
6500 /* JNI_CreateJavaVM ************************************************************
6502 Loads and initializes a Java VM. The current thread becomes the main thread.
6503 Sets the env argument to the JNI interface pointer of the main thread.
6505 *******************************************************************************/
6507 jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
6509 /* actually create the JVM */
6511 if (!vm_createjvm(p_vm, p_env, vm_args))
6519 * These are local overrides for various environment variables in Emacs.
6520 * Please do not remove this and leave it at the end of the file, where
6521 * Emacs will automagically detect them.
6522 * ---------------------------------------------------------------------
6525 * indent-tabs-mode: t
6529 * vim:noexpandtab:sw=4:ts=4: