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 8268 2007-08-07 13:24:43Z twisti $
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 /* debug **********************************************************************/
122 # define TRACEJNICALLS(format, ...) \
124 if (opt_TraceJNICalls) { \
125 log_println((format), __VA_ARGS__); \
129 # define TRACEJNICALLS(format, ...)
133 /* global variables ***********************************************************/
135 /* global reference table *****************************************************/
137 /* hashsize must be power of 2 */
139 #define HASHTABLE_GLOBAL_REF_SIZE 64 /* initial size of globalref-hash */
141 static hashtable *hashtable_global_ref; /* hashtable for globalrefs */
144 /* direct buffer stuff ********************************************************/
146 #if defined(ENABLE_JAVASE)
147 static classinfo *class_java_nio_Buffer;
148 static classinfo *class_java_nio_DirectByteBufferImpl;
149 static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
151 # if defined(WITH_CLASSPATH_GNU)
152 # if SIZEOF_VOID_P == 8
153 static classinfo *class_gnu_classpath_Pointer64;
155 static classinfo *class_gnu_classpath_Pointer32;
159 static methodinfo *dbbirw_init;
163 /* local reference table ******************************************************/
165 #if !defined(ENABLE_THREADS)
166 localref_table *_no_threads_localref_table;
170 /* accessing instance fields macros *******************************************/
172 #define SET_FIELD(o,type,f,value) \
173 *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) = (type) (value)
175 #define GET_FIELD(o,type,f) \
176 *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset)))
179 /* some forward declarations **************************************************/
181 jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref);
182 jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity);
185 /* jni_init ********************************************************************
187 Initialize the JNI subsystem.
189 *******************************************************************************/
193 /* create global ref hashtable */
195 hashtable_global_ref = NEW(hashtable);
197 hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
200 #if defined(ENABLE_JAVASE)
201 /* direct buffer stuff */
203 if (!(class_java_nio_Buffer =
204 load_class_bootstrap(utf_new_char("java/nio/Buffer"))) ||
205 !link_class(class_java_nio_Buffer))
208 # if defined(WITH_CLASSPATH_GNU)
209 if (!(class_java_nio_DirectByteBufferImpl =
210 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
211 !link_class(class_java_nio_DirectByteBufferImpl))
214 if (!(class_java_nio_DirectByteBufferImpl_ReadWrite =
215 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) ||
216 !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite))
220 class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite,
222 utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
225 # if SIZEOF_VOID_P == 8
226 if (!(class_gnu_classpath_Pointer64 =
227 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) ||
228 !link_class(class_gnu_classpath_Pointer64))
231 if (!(class_gnu_classpath_Pointer32 =
232 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) ||
233 !link_class(class_gnu_classpath_Pointer32))
237 #endif /* defined(ENABLE_JAVASE) */
243 /* jni_init_localref_table *****************************************************
245 Initializes the local references table of the current thread.
247 *******************************************************************************/
249 bool jni_init_localref_table(void)
253 lrt = GCNEW(localref_table);
258 lrt->capacity = LOCALREFTABLE_CAPACITY;
260 lrt->localframes = 1;
261 lrt->prev = LOCALREFTABLE;
263 /* clear the references array (memset is faster then a for-loop) */
265 MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY);
273 /* _Jv_jni_CallObjectMethod ****************************************************
275 Internal function to call Java Object methods.
277 *******************************************************************************/
279 static java_objectheader *_Jv_jni_CallObjectMethod(java_objectheader *o,
281 methodinfo *m, va_list ap)
284 java_objectheader *ro;
286 STATISTICS(jniinvokation());
289 exceptions_throw_nullpointerexception();
293 /* Class initialization is done by the JIT compiler. This is ok
294 since a static method always belongs to the declaring class. */
296 if (m->flags & ACC_STATIC) {
297 /* For static methods we reset the object. */
302 /* for convenience */
307 /* For instance methods we make a virtual function table lookup. */
309 resm = method_vftbl_lookup(vftbl, m);
312 STATISTICS(jnicallXmethodnvokation());
314 ro = vm_call_method_valist(resm, o, ap);
320 /* _Jv_jni_CallObjectMethodA ***************************************************
322 Internal function to call Java Object methods.
324 *******************************************************************************/
326 static java_objectheader *_Jv_jni_CallObjectMethodA(java_objectheader *o,
332 java_objectheader *ro;
334 STATISTICS(jniinvokation());
337 exceptions_throw_nullpointerexception();
341 /* Class initialization is done by the JIT compiler. This is ok
342 since a static method always belongs to the declaring class. */
344 if (m->flags & ACC_STATIC) {
345 /* For static methods we reset the object. */
350 /* for convenience */
355 /* For instance methods we make a virtual function table lookup. */
357 resm = method_vftbl_lookup(vftbl, m);
360 STATISTICS(jnicallXmethodnvokation());
362 ro = vm_call_method_jvalue(resm, o, args);
368 /* _Jv_jni_CallIntMethod *******************************************************
370 Internal function to call Java integer class methods (boolean,
371 byte, char, short, int).
373 *******************************************************************************/
375 static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl,
376 methodinfo *m, va_list ap)
381 STATISTICS(jniinvokation());
384 exceptions_throw_nullpointerexception();
388 /* Class initialization is done by the JIT compiler. This is ok
389 since a static method always belongs to the declaring class. */
391 if (m->flags & ACC_STATIC) {
392 /* For static methods we reset the object. */
397 /* for convenience */
402 /* For instance methods we make a virtual function table lookup. */
404 resm = method_vftbl_lookup(vftbl, m);
407 STATISTICS(jnicallXmethodnvokation());
409 i = vm_call_method_int_valist(resm, o, ap);
415 /* _Jv_jni_CallIntMethodA ******************************************************
417 Internal function to call Java integer class methods (boolean,
418 byte, char, short, int).
420 *******************************************************************************/
422 static jint _Jv_jni_CallIntMethodA(java_objectheader *o, vftbl_t *vftbl,
423 methodinfo *m, const jvalue *args)
428 STATISTICS(jniinvokation());
431 exceptions_throw_nullpointerexception();
435 /* Class initialization is done by the JIT compiler. This is ok
436 since a static method always belongs to the declaring class. */
438 if (m->flags & ACC_STATIC) {
439 /* For static methods we reset the object. */
444 /* for convenience */
449 /* For instance methods we make a virtual function table lookup. */
451 resm = method_vftbl_lookup(vftbl, m);
454 STATISTICS(jnicallXmethodnvokation());
456 i = vm_call_method_int_jvalue(resm, o, args);
462 /* _Jv_jni_CallLongMethod ******************************************************
464 Internal function to call Java long methods.
466 *******************************************************************************/
468 static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl,
469 methodinfo *m, va_list ap)
474 STATISTICS(jniinvokation());
477 exceptions_throw_nullpointerexception();
481 /* Class initialization is done by the JIT compiler. This is ok
482 since a static method always belongs to the declaring class. */
484 if (m->flags & ACC_STATIC) {
485 /* For static methods we reset the object. */
490 /* for convenience */
495 /* For instance methods we make a virtual function table lookup. */
497 resm = method_vftbl_lookup(vftbl, m);
500 STATISTICS(jnicallXmethodnvokation());
502 l = vm_call_method_long_valist(resm, o, ap);
508 /* _Jv_jni_CallLongMethodA *****************************************************
510 Internal function to call Java long methods.
512 *******************************************************************************/
514 static jlong _Jv_jni_CallLongMethodA(java_objectheader *o, vftbl_t *vftbl,
515 methodinfo *m, const jvalue *args)
520 STATISTICS(jniinvokation());
523 exceptions_throw_nullpointerexception();
527 /* Class initialization is done by the JIT compiler. This is ok
528 since a static method always belongs to the declaring class. */
530 if (m->flags & ACC_STATIC) {
531 /* For static methods we reset the object. */
536 /* for convenience */
541 /* For instance methods we make a virtual function table lookup. */
543 resm = method_vftbl_lookup(vftbl, m);
546 STATISTICS(jnicallXmethodnvokation());
548 l = vm_call_method_long_jvalue(resm, o, args);
554 /* _Jv_jni_CallFloatMethod *****************************************************
556 Internal function to call Java float methods.
558 *******************************************************************************/
560 static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl,
561 methodinfo *m, va_list ap)
566 /* Class initialization is done by the JIT compiler. This is ok
567 since a static method always belongs to the declaring class. */
569 if (m->flags & ACC_STATIC) {
570 /* For static methods we reset the object. */
575 /* for convenience */
580 /* For instance methods we make a virtual function table lookup. */
582 resm = method_vftbl_lookup(vftbl, m);
585 STATISTICS(jnicallXmethodnvokation());
587 f = vm_call_method_float_valist(resm, o, ap);
593 /* _Jv_jni_CallFloatMethodA ****************************************************
595 Internal function to call Java float methods.
597 *******************************************************************************/
599 static jfloat _Jv_jni_CallFloatMethodA(java_objectheader *o, vftbl_t *vftbl,
600 methodinfo *m, const jvalue *args)
605 /* Class initialization is done by the JIT compiler. This is ok
606 since a static method always belongs to the declaring class. */
608 if (m->flags & ACC_STATIC) {
609 /* For static methods we reset the object. */
614 /* for convenience */
619 /* For instance methods we make a virtual function table lookup. */
621 resm = method_vftbl_lookup(vftbl, m);
624 STATISTICS(jnicallXmethodnvokation());
626 f = vm_call_method_float_jvalue(resm, o, args);
632 /* _Jv_jni_CallDoubleMethod ****************************************************
634 Internal function to call Java double methods.
636 *******************************************************************************/
638 static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl,
639 methodinfo *m, va_list ap)
644 /* Class initialization is done by the JIT compiler. This is ok
645 since a static method always belongs to the declaring class. */
647 if (m->flags & ACC_STATIC) {
648 /* For static methods we reset the object. */
653 /* for convenience */
658 /* For instance methods we make a virtual function table lookup. */
660 resm = method_vftbl_lookup(vftbl, m);
663 d = vm_call_method_double_valist(resm, o, ap);
669 /* _Jv_jni_CallDoubleMethodA ***************************************************
671 Internal function to call Java double methods.
673 *******************************************************************************/
675 static jdouble _Jv_jni_CallDoubleMethodA(java_objectheader *o, vftbl_t *vftbl,
676 methodinfo *m, const jvalue *args)
681 /* Class initialization is done by the JIT compiler. This is ok
682 since a static method always belongs to the declaring class. */
684 if (m->flags & ACC_STATIC) {
685 /* For static methods we reset the object. */
690 /* for convenience */
695 /* For instance methods we make a virtual function table lookup. */
697 resm = method_vftbl_lookup(vftbl, m);
700 d = vm_call_method_double_jvalue(resm, o, args);
706 /* _Jv_jni_CallVoidMethod ******************************************************
708 Internal function to call Java void methods.
710 *******************************************************************************/
712 static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl,
713 methodinfo *m, va_list ap)
718 exceptions_throw_nullpointerexception();
722 /* Class initialization is done by the JIT compiler. This is ok
723 since a static method always belongs to the declaring class. */
725 if (m->flags & ACC_STATIC) {
726 /* For static methods we reset the object. */
731 /* for convenience */
736 /* For instance methods we make a virtual function table lookup. */
738 resm = method_vftbl_lookup(vftbl, m);
741 STATISTICS(jnicallXmethodnvokation());
743 (void) vm_call_method_valist(resm, o, ap);
747 /* _Jv_jni_CallVoidMethodA *****************************************************
749 Internal function to call Java void methods.
751 *******************************************************************************/
753 static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
754 methodinfo *m, const jvalue *args)
759 exceptions_throw_nullpointerexception();
763 /* Class initialization is done by the JIT compiler. This is ok
764 since a static method always belongs to the declaring class. */
766 if (m->flags & ACC_STATIC) {
767 /* For static methods we reset the object. */
772 /* for convenience */
777 /* For instance methods we make a virtual function table lookup. */
779 resm = method_vftbl_lookup(vftbl, m);
782 STATISTICS(jnicallXmethodnvokation());
784 (void) vm_call_method_jvalue(resm, o, args);
788 /* _Jv_jni_invokeNative ********************************************************
790 Invoke a method on the given object with the given arguments.
792 For instance methods OBJ must be != NULL and the method is looked up
793 in the vftbl of the object.
795 For static methods, OBJ is ignored.
797 *******************************************************************************/
799 #if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
800 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
801 java_objectarray *params)
805 java_objectheader *ro;
808 java_objectheader *xptr;
811 exceptions_throw_nullpointerexception();
815 argcount = m->parseddesc->paramcount;
816 paramcount = argcount;
818 /* if method is non-static, remove the `this' pointer */
820 if (!(m->flags & ACC_STATIC))
823 /* For instance methods the object has to be an instance of the
824 class the method belongs to. For static methods the obj
825 parameter is ignored. */
827 if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
828 exceptions_throw_illegalargumentexception();
832 /* check if we got the right number of arguments */
834 if (((params == NULL) && (paramcount != 0)) ||
835 (params && (params->header.size != paramcount)))
837 exceptions_throw_illegalargumentexception();
841 /* for instance methods we need an object */
843 if (!(m->flags & ACC_STATIC) && (o == NULL)) {
844 /* XXX not sure if that is the correct exception */
845 exceptions_throw_nullpointerexception();
849 /* for static methods, zero object to make subsequent code simpler */
850 if (m->flags & ACC_STATIC)
854 /* for instance methods we must do a vftbl lookup */
855 resm = method_vftbl_lookup(o->vftbl, m);
858 /* for static methods, just for convenience */
862 vmargs = MNEW(vm_arg, argcount);
864 if (!vm_vmargs_from_objectarray(resm, o, vmargs, params)) {
865 MFREE(vmargs, vm_arg, argcount);
869 switch (resm->parseddesc->returntype.decltype) {
871 (void) vm_call_method_vmarg(resm, argcount, vmargs);
876 case PRIMITIVETYPE_BOOLEAN: {
878 java_lang_Boolean *bo;
880 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
882 ro = builtin_new(class_java_lang_Boolean);
884 /* setting the value of the object direct */
886 bo = (java_lang_Boolean *) ro;
891 case PRIMITIVETYPE_BYTE: {
895 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
897 ro = builtin_new(class_java_lang_Byte);
899 /* setting the value of the object direct */
901 bo = (java_lang_Byte *) ro;
906 case PRIMITIVETYPE_CHAR: {
908 java_lang_Character *co;
910 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
912 ro = builtin_new(class_java_lang_Character);
914 /* setting the value of the object direct */
916 co = (java_lang_Character *) ro;
921 case PRIMITIVETYPE_SHORT: {
925 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
927 ro = builtin_new(class_java_lang_Short);
929 /* setting the value of the object direct */
931 so = (java_lang_Short *) ro;
936 case PRIMITIVETYPE_INT: {
938 java_lang_Integer *io;
940 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
942 ro = builtin_new(class_java_lang_Integer);
944 /* setting the value of the object direct */
946 io = (java_lang_Integer *) ro;
951 case PRIMITIVETYPE_LONG: {
955 l = vm_call_method_long_vmarg(resm, argcount, vmargs);
957 ro = builtin_new(class_java_lang_Long);
959 /* setting the value of the object direct */
961 lo = (java_lang_Long *) ro;
966 case PRIMITIVETYPE_FLOAT: {
970 f = vm_call_method_float_vmarg(resm, argcount, vmargs);
972 ro = builtin_new(class_java_lang_Float);
974 /* setting the value of the object direct */
976 fo = (java_lang_Float *) ro;
981 case PRIMITIVETYPE_DOUBLE: {
983 java_lang_Double *_do;
985 d = vm_call_method_double_vmarg(resm, argcount, vmargs);
987 ro = builtin_new(class_java_lang_Double);
989 /* setting the value of the object direct */
991 _do = (java_lang_Double *) ro;
997 ro = vm_call_method_vmarg(resm, argcount, vmargs);
1001 /* if this happens the exception has already been set by
1002 fill_callblock_from_objectarray */
1004 MFREE(vmargs, vm_arg, argcount);
1009 MFREE(vmargs, vm_arg, argcount);
1011 xptr = exceptions_get_exception();
1014 /* clear exception pointer, we are calling JIT code again */
1016 exceptions_clear_exception();
1018 exceptions_throw_invocationtargetexception(xptr);
1024 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
1025 java_objectarray *params)
1028 java_objectheader *ro;
1031 java_objectheader *xptr;
1036 exceptions_throw_nullpointerexception();
1040 argcount = m->parseddesc->paramcount;
1041 paramcount = argcount;
1043 /* if method is non-static, remove the `this' pointer */
1045 if (!(m->flags & ACC_STATIC))
1048 /* For instance methods the object has to be an instance of the
1049 class the method belongs to. For static methods the obj
1050 parameter is ignored. */
1052 if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
1053 exceptions_throw_illegalargumentexception();
1057 /* check if we got the right number of arguments */
1059 if (((params == NULL) && (paramcount != 0)) ||
1060 (params && (params->header.size != paramcount)))
1062 exceptions_throw_illegalargumentexception();
1066 /* for instance methods we need an object */
1068 if (!(m->flags & ACC_STATIC) && (o == NULL)) {
1069 /* XXX not sure if that is the correct exception */
1070 exceptions_throw_nullpointerexception();
1074 /* for static methods, zero object to make subsequent code simpler */
1075 if (m->flags & ACC_STATIC)
1079 /* for instance methods we must do a vftbl lookup */
1080 resm = method_vftbl_lookup(o->vftbl, m);
1083 /* for static methods, just for convenience */
1087 /* mark start of dump memory area */
1089 dumpsize = dump_size();
1091 /* Fill the argument array from a object-array. */
1093 array = vm_array_from_objectarray(resm, o, params);
1095 /* The array can be NULL if we don't have any arguments to pass
1096 and the architecture does not have any argument registers
1097 (e.g. i386). In that case we additionally check for an
1098 exception thrown. */
1100 if ((array == NULL) && (exceptions_get_exception() != NULL)) {
1101 /* release dump area */
1103 dump_release(dumpsize);
1108 switch (resm->parseddesc->returntype.decltype) {
1110 (void) vm_call_array(resm, array);
1115 case PRIMITIVETYPE_BOOLEAN: {
1117 java_lang_Boolean *bo;
1119 i = vm_call_int_array(resm, array);
1121 ro = builtin_new(class_java_lang_Boolean);
1123 /* setting the value of the object direct */
1125 bo = (java_lang_Boolean *) ro;
1130 case PRIMITIVETYPE_BYTE: {
1134 i = vm_call_int_array(resm, array);
1136 ro = builtin_new(class_java_lang_Byte);
1138 /* setting the value of the object direct */
1140 bo = (java_lang_Byte *) ro;
1145 case PRIMITIVETYPE_CHAR: {
1147 java_lang_Character *co;
1149 i = vm_call_int_array(resm, array);
1151 ro = builtin_new(class_java_lang_Character);
1153 /* setting the value of the object direct */
1155 co = (java_lang_Character *) ro;
1160 case PRIMITIVETYPE_SHORT: {
1162 java_lang_Short *so;
1164 i = vm_call_int_array(resm, array);
1166 ro = builtin_new(class_java_lang_Short);
1168 /* setting the value of the object direct */
1170 so = (java_lang_Short *) ro;
1175 case PRIMITIVETYPE_INT: {
1177 java_lang_Integer *io;
1179 i = vm_call_int_array(resm, array);
1181 ro = builtin_new(class_java_lang_Integer);
1183 /* setting the value of the object direct */
1185 io = (java_lang_Integer *) ro;
1190 case PRIMITIVETYPE_LONG: {
1194 l = vm_call_long_array(resm, array);
1196 ro = builtin_new(class_java_lang_Long);
1198 /* setting the value of the object direct */
1200 lo = (java_lang_Long *) ro;
1205 case PRIMITIVETYPE_FLOAT: {
1207 java_lang_Float *fo;
1209 f = vm_call_float_array(resm, array);
1211 ro = builtin_new(class_java_lang_Float);
1213 /* setting the value of the object direct */
1215 fo = (java_lang_Float *) ro;
1220 case PRIMITIVETYPE_DOUBLE: {
1222 java_lang_Double *_do;
1224 d = vm_call_double_array(resm, array);
1226 ro = builtin_new(class_java_lang_Double);
1228 /* setting the value of the object direct */
1230 _do = (java_lang_Double *) ro;
1236 ro = vm_call_array(resm, array);
1240 /* if this happens the exception has already been set by
1241 fill_callblock_from_objectarray */
1243 /* release dump area */
1245 dump_release(dumpsize);
1250 xptr = exceptions_get_exception();
1253 /* clear exception pointer, we are calling JIT code again */
1255 exceptions_clear_exception();
1257 exceptions_throw_invocationtargetexception(xptr);
1260 /* release dump area */
1262 dump_release(dumpsize);
1269 /* GetVersion ******************************************************************
1271 Returns the major version number in the higher 16 bits and the
1272 minor version number in the lower 16 bits.
1274 *******************************************************************************/
1276 jint _Jv_JNI_GetVersion(JNIEnv *env)
1278 STATISTICS(jniinvokation());
1280 /* we support JNI 1.4 */
1282 return JNI_VERSION_1_4;
1286 /* Class Operations ***********************************************************/
1288 /* DefineClass *****************************************************************
1290 Loads a class from a buffer of raw class data. The buffer
1291 containing the raw class data is not referenced by the VM after the
1292 DefineClass call returns, and it may be discarded if desired.
1294 *******************************************************************************/
1296 jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
1297 const jbyte *buf, jsize bufLen)
1299 #if defined(ENABLE_JAVASE)
1301 java_objectheader *cl;
1304 TRACEJNICALLS("_Jv_JNI_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d", env, name, loader, buf, bufLen);
1306 u = utf_new_char(name);
1307 cl = (java_objectheader *) loader;
1309 c = class_define(u, cl, bufLen, (const uint8_t *) buf);
1311 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1313 vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration");
1315 /* keep compiler happy */
1322 /* FindClass *******************************************************************
1324 This function loads a locally-defined class. It searches the
1325 directories and zip files specified by the CLASSPATH environment
1326 variable for the class with the specified name.
1328 *******************************************************************************/
1330 jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
1332 #if defined(ENABLE_JAVASE)
1337 STATISTICS(jniinvokation());
1339 u = utf_new_char_classname((char *) name);
1341 /* Check stacktrace for classloader, if one found use it,
1342 otherwise use the system classloader. */
1344 /* Quote from the JNI documentation:
1346 In the Java 2 Platform, FindClass locates the class loader
1347 associated with the current native method. If the native code
1348 belongs to a system class, no class loader will be
1349 involved. Otherwise, the proper class loader will be invoked to
1350 load and link the named class. When FindClass is called through
1351 the Invocation Interface, there is no current native method or
1352 its associated class loader. In that case, the result of
1353 ClassLoader.getBaseClassLoader is used." */
1355 cc = stacktrace_getCurrentClass();
1358 c = load_class_from_sysloader(u);
1360 c = load_class_from_classloader(u, cc->classloader);
1368 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1370 vm_abort("_Jv_JNI_FindClass: not implemented in this configuration");
1372 /* keep compiler happy */
1379 /* GetSuperclass ***************************************************************
1381 If clazz represents any class other than the class Object, then
1382 this function returns the object that represents the superclass of
1383 the class specified by clazz.
1385 *******************************************************************************/
1387 jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
1392 TRACEJNICALLS("_Jv_JNI_GetSuperclass(env=%p, sub=%p)", env, sub);
1394 c = (classinfo *) sub;
1399 super = class_get_superclass(c);
1401 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) super);
1405 /* IsAssignableFrom ************************************************************
1407 Determines whether an object of sub can be safely cast to sup.
1409 *******************************************************************************/
1411 jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
1413 java_lang_Class *csup;
1414 java_lang_Class *csub;
1416 csup = (java_lang_Class *) sup;
1417 csub = (java_lang_Class *) sub;
1419 STATISTICS(jniinvokation());
1421 return _Jv_java_lang_Class_isAssignableFrom(csup, csub);
1425 /* Throw ***********************************************************************
1427 Causes a java.lang.Throwable object to be thrown.
1429 *******************************************************************************/
1431 jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj)
1433 java_objectheader *o;
1435 STATISTICS(jniinvokation());
1437 o = (java_objectheader *) obj;
1439 exceptions_set_exception(o);
1445 /* ThrowNew ********************************************************************
1447 Constructs an exception object from the specified class with the
1448 message specified by message and causes that exception to be
1451 *******************************************************************************/
1453 jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg)
1456 java_objectheader *o;
1457 java_objectheader *s;
1459 STATISTICS(jniinvokation());
1461 c = (classinfo *) clazz;
1464 s = javastring_new_from_utf_string(msg);
1466 /* instantiate exception object */
1468 o = native_new_and_init_string(c, s);
1473 exceptions_set_exception(o);
1479 /* ExceptionOccurred ***********************************************************
1481 Determines if an exception is being thrown. The exception stays
1482 being thrown until either the native code calls ExceptionClear(),
1483 or the Java code handles the exception.
1485 *******************************************************************************/
1487 jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env)
1489 java_objectheader *o;
1491 STATISTICS(jniinvokation());
1493 o = exceptions_get_exception();
1495 return _Jv_JNI_NewLocalRef(env, (jthrowable) o);
1499 /* ExceptionDescribe ***********************************************************
1501 Prints an exception and a backtrace of the stack to a system
1502 error-reporting channel, such as stderr. This is a convenience
1503 routine provided for debugging.
1505 *******************************************************************************/
1507 void _Jv_JNI_ExceptionDescribe(JNIEnv *env)
1509 java_objectheader *o;
1512 STATISTICS(jniinvokation());
1514 o = exceptions_get_exception();
1517 /* clear exception, because we are calling jit code again */
1519 exceptions_clear_exception();
1521 /* get printStackTrace method from exception class */
1523 m = class_resolveclassmethod(o->vftbl->class,
1524 utf_printStackTrace,
1530 /* XXX what should we do? */
1533 /* print the stacktrace */
1535 (void) vm_call_method(m, o);
1540 /* ExceptionClear **************************************************************
1542 Clears any exception that is currently being thrown. If no
1543 exception is currently being thrown, this routine has no effect.
1545 *******************************************************************************/
1547 void _Jv_JNI_ExceptionClear(JNIEnv *env)
1549 STATISTICS(jniinvokation());
1551 exceptions_clear_exception();
1555 /* FatalError ******************************************************************
1557 Raises a fatal error and does not expect the VM to recover. This
1558 function does not return.
1560 *******************************************************************************/
1562 void _Jv_JNI_FatalError(JNIEnv *env, const char *msg)
1564 STATISTICS(jniinvokation());
1566 /* this seems to be the best way */
1568 vm_abort("JNI Fatal error: %s", msg);
1572 /* PushLocalFrame **************************************************************
1574 Creates a new local reference frame, in which at least a given
1575 number of local references can be created.
1577 *******************************************************************************/
1579 jint _Jv_JNI_PushLocalFrame(JNIEnv* env, jint capacity)
1582 localref_table *lrt;
1583 localref_table *nlrt;
1585 STATISTICS(jniinvokation());
1590 /* Allocate new local reference table on Java heap. Calculate the
1591 additional memory we have to allocate. */
1593 if (capacity > LOCALREFTABLE_CAPACITY)
1594 additionalrefs = capacity - LOCALREFTABLE_CAPACITY;
1598 nlrt = GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
1603 /* get current local reference table from thread */
1605 lrt = LOCALREFTABLE;
1607 /* Set up the new local reference table and add it to the local
1610 nlrt->capacity = capacity;
1612 nlrt->localframes = lrt->localframes + 1;
1615 /* store new local reference table in thread */
1617 LOCALREFTABLE = nlrt;
1623 /* PopLocalFrame ***************************************************************
1625 Pops off the current local reference frame, frees all the local
1626 references, and returns a local reference in the previous local
1627 reference frame for the given result object.
1629 *******************************************************************************/
1631 jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result)
1633 localref_table *lrt;
1634 localref_table *plrt;
1637 STATISTICS(jniinvokation());
1639 /* get current local reference table from thread */
1641 lrt = LOCALREFTABLE;
1643 localframes = lrt->localframes;
1645 /* Don't delete the top local frame, as this one is allocated in
1646 the native stub on the stack and is freed automagically on
1649 if (localframes == 1)
1650 return _Jv_JNI_NewLocalRef(env, result);
1652 /* release all current local frames */
1654 for (; localframes >= 1; localframes--) {
1655 /* get previous frame */
1659 /* clear all reference entries */
1661 MSET(&lrt->refs[0], 0, java_objectheader*, lrt->capacity);
1665 /* set new local references table */
1670 /* store new local reference table in thread */
1672 LOCALREFTABLE = lrt;
1674 /* add local reference and return the value */
1676 return _Jv_JNI_NewLocalRef(env, result);
1680 /* DeleteLocalRef **************************************************************
1682 Deletes the local reference pointed to by localRef.
1684 *******************************************************************************/
1686 void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef)
1688 java_objectheader *o;
1689 localref_table *lrt;
1692 STATISTICS(jniinvokation());
1694 o = (java_objectheader *) localRef;
1696 /* get local reference table (thread specific) */
1698 lrt = LOCALREFTABLE;
1700 /* go through all local frames */
1702 for (; lrt != NULL; lrt = lrt->prev) {
1704 /* and try to remove the reference */
1706 for (i = 0; i < lrt->capacity; i++) {
1707 if (lrt->refs[i] == o) {
1708 lrt->refs[i] = NULL;
1716 /* this should not happen */
1718 /* if (opt_checkjni) */
1719 /* FatalError(env, "Bad global or local ref passed to JNI"); */
1720 log_text("JNI-DeleteLocalRef: Local ref passed to JNI not found");
1724 /* IsSameObject ****************************************************************
1726 Tests whether two references refer to the same Java object.
1728 *******************************************************************************/
1730 jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2)
1732 STATISTICS(jniinvokation());
1741 /* NewLocalRef *****************************************************************
1743 Creates a new local reference that refers to the same object as ref.
1745 *******************************************************************************/
1747 jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref)
1749 localref_table *lrt;
1752 STATISTICS(jniinvokation());
1757 /* get local reference table (thread specific) */
1759 lrt = LOCALREFTABLE;
1761 /* Check if we have space for the requested reference? No,
1762 allocate a new frame. This is actually not what the spec says,
1763 but for compatibility reasons... */
1765 if (lrt->used == lrt->capacity) {
1766 if (_Jv_JNI_EnsureLocalCapacity(env, 16) != 0)
1769 /* get the new local reference table */
1771 lrt = LOCALREFTABLE;
1774 /* insert the reference */
1776 for (i = 0; i < lrt->capacity; i++) {
1777 if (lrt->refs[i] == NULL) {
1778 lrt->refs[i] = (java_objectheader *) ref;
1785 /* should not happen, just to be sure */
1789 /* keep compiler happy */
1795 /* EnsureLocalCapacity *********************************************************
1797 Ensures that at least a given number of local references can be
1798 created in the current thread
1800 *******************************************************************************/
1802 jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity)
1804 localref_table *lrt;
1806 STATISTICS(jniinvokation());
1808 /* get local reference table (thread specific) */
1810 lrt = LOCALREFTABLE;
1812 /* check if capacity elements are available in the local references table */
1814 if ((lrt->used + capacity) > lrt->capacity)
1815 return _Jv_JNI_PushLocalFrame(env, capacity);
1821 /* AllocObject *****************************************************************
1823 Allocates a new Java object without invoking any of the
1824 constructors for the object. Returns a reference to the object.
1826 *******************************************************************************/
1828 jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
1831 java_objectheader *o;
1833 STATISTICS(jniinvokation());
1835 c = (classinfo *) clazz;
1837 if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
1838 exceptions_throw_instantiationexception(c);
1844 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1848 /* NewObject *******************************************************************
1850 Programmers place all arguments that are to be passed to the
1851 constructor immediately following the methodID
1852 argument. NewObject() accepts these arguments and passes them to
1853 the Java method that the programmer wishes to invoke.
1855 *******************************************************************************/
1857 jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
1859 java_objectheader *o;
1864 STATISTICS(jniinvokation());
1866 c = (classinfo *) clazz;
1867 m = (methodinfo *) methodID;
1876 /* call constructor */
1878 va_start(ap, methodID);
1879 _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
1882 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1886 /* NewObjectV ******************************************************************
1888 Programmers place all arguments that are to be passed to the
1889 constructor in an args argument of type va_list that immediately
1890 follows the methodID argument. NewObjectV() accepts these
1891 arguments, and, in turn, passes them to the Java method that the
1892 programmer wishes to invoke.
1894 *******************************************************************************/
1896 jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
1899 java_objectheader *o;
1903 STATISTICS(jniinvokation());
1905 c = (classinfo *) clazz;
1906 m = (methodinfo *) methodID;
1915 /* call constructor */
1917 _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
1919 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1923 /* NewObjectA *****************************************************************
1925 Programmers place all arguments that are to be passed to the
1926 constructor in an args array of jvalues that immediately follows
1927 the methodID argument. NewObjectA() accepts the arguments in this
1928 array, and, in turn, passes them to the Java method that the
1929 programmer wishes to invoke.
1931 *******************************************************************************/
1933 jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
1936 java_objectheader *o;
1940 STATISTICS(jniinvokation());
1942 c = (classinfo *) clazz;
1943 m = (methodinfo *) methodID;
1952 /* call constructor */
1954 _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
1956 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1960 /* GetObjectClass **************************************************************
1962 Returns the class of an object.
1964 *******************************************************************************/
1966 jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj)
1968 java_objectheader *o;
1971 STATISTICS(jniinvokation());
1973 o = (java_objectheader *) obj;
1975 if ((o == NULL) || (o->vftbl == NULL))
1978 c = o->vftbl->class;
1980 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1984 /* IsInstanceOf ****************************************************************
1986 Tests whether an object is an instance of a class.
1988 *******************************************************************************/
1990 jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
1993 java_lang_Object *o;
1995 STATISTICS(jniinvokation());
1997 c = (java_lang_Class *) clazz;
1998 o = (java_lang_Object *) obj;
2000 return _Jv_java_lang_Class_isInstance(c, o);
2004 /* Reflection Support *********************************************************/
2006 /* FromReflectedMethod *********************************************************
2008 Converts java.lang.reflect.Method or java.lang.reflect.Constructor
2009 object to a method ID.
2011 *******************************************************************************/
2013 jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
2015 #if defined(ENABLE_JAVASE)
2016 java_objectheader *o;
2021 STATISTICS(jniinvokation());
2023 o = (java_objectheader *) method;
2028 if (builtin_instanceof(o, class_java_lang_reflect_Method)) {
2029 java_lang_reflect_Method *rm;
2031 rm = (java_lang_reflect_Method *) method;
2032 c = (classinfo *) (rm->clazz);
2035 else if (builtin_instanceof(o, class_java_lang_reflect_Constructor)) {
2036 java_lang_reflect_Constructor *rc;
2038 rc = (java_lang_reflect_Constructor *) method;
2039 c = (classinfo *) (rc->clazz);
2045 m = &(c->methods[slot]);
2047 return (jmethodID) m;
2049 vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
2051 /* keep compiler happy */
2058 /* FromReflectedField **********************************************************
2060 Converts a java.lang.reflect.Field to a field ID.
2062 *******************************************************************************/
2064 jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
2066 #if defined(ENABLE_JAVASE)
2067 java_lang_reflect_Field *rf;
2071 STATISTICS(jniinvokation());
2073 rf = (java_lang_reflect_Field *) field;
2078 c = (classinfo *) rf->clazz;
2079 f = &(c->fields[rf->slot]);
2081 return (jfieldID) f;
2083 vm_abort("_Jv_JNI_FromReflectedField: not implemented in this configuration");
2085 /* keep compiler happy */
2092 /* ToReflectedMethod ***********************************************************
2094 Converts a method ID derived from cls to an instance of the
2095 java.lang.reflect.Method class or to an instance of the
2096 java.lang.reflect.Constructor class.
2098 *******************************************************************************/
2100 jobject _Jv_JNI_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID,
2103 #if defined(ENABLE_JAVASE)
2105 java_lang_reflect_Constructor *rc;
2106 java_lang_reflect_Method *rm;
2108 STATISTICS(jniinvokation());
2110 m = (methodinfo *) methodID;
2112 /* HotSpot does the same assert. */
2114 assert(((m->flags & ACC_STATIC) != 0) == (isStatic != 0));
2116 if (m->name == utf_init) {
2117 rc = reflect_constructor_new(m);
2119 return (jobject) rc;
2122 rm = reflect_method_new(m);
2124 return (jobject) rm;
2127 vm_abort("_Jv_JNI_ToReflectedMethod: not implemented in this configuration");
2129 /* keep compiler happy */
2136 /* ToReflectedField ************************************************************
2138 Converts a field ID derived from cls to an instance of the
2139 java.lang.reflect.Field class.
2141 *******************************************************************************/
2143 jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID,
2146 STATISTICS(jniinvokation());
2148 log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!");
2154 /* Calling Instance Methods ***************************************************/
2156 /* GetMethodID *****************************************************************
2158 Returns the method ID for an instance (nonstatic) method of a class
2159 or interface. The method may be defined in one of the clazz's
2160 superclasses and inherited by clazz. The method is determined by
2161 its name and signature.
2163 GetMethodID() causes an uninitialized class to be initialized.
2165 *******************************************************************************/
2167 jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
2175 STATISTICS(jniinvokation());
2177 c = (classinfo *) clazz;
2182 if (!(c->state & CLASS_INITIALIZED))
2183 if (!initialize_class(c))
2186 /* try to get the method of the class or one of it's superclasses */
2188 uname = utf_new_char((char *) name);
2189 udesc = utf_new_char((char *) sig);
2191 m = class_resolvemethod(c, uname, udesc);
2193 if ((m == NULL) || (m->flags & ACC_STATIC)) {
2194 exceptions_throw_nosuchmethoderror(c, uname, udesc);
2199 return (jmethodID) m;
2203 /* JNI-functions for calling instance methods *********************************/
2205 jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2208 java_objectheader *o;
2210 java_objectheader *ret;
2213 o = (java_objectheader *) obj;
2214 m = (methodinfo *) methodID;
2216 va_start(ap, methodID);
2217 ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, ap);
2220 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2224 jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2227 java_objectheader *o;
2229 java_objectheader *ret;
2231 o = (java_objectheader *) obj;
2232 m = (methodinfo *) methodID;
2234 ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, args);
2236 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2240 jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2243 java_objectheader *o;
2245 java_objectheader *ret;
2247 o = (java_objectheader *) obj;
2248 m = (methodinfo *) methodID;
2250 ret = _Jv_jni_CallObjectMethodA(o, o->vftbl, m, args);
2252 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2256 jboolean _Jv_JNI_CallBooleanMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2259 java_objectheader *o;
2264 o = (java_objectheader *) obj;
2265 m = (methodinfo *) methodID;
2267 va_start(ap, methodID);
2268 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2275 jboolean _Jv_JNI_CallBooleanMethodV(JNIEnv *env, jobject obj,
2276 jmethodID methodID, va_list args)
2278 java_objectheader *o;
2282 o = (java_objectheader *) obj;
2283 m = (methodinfo *) methodID;
2285 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2291 jboolean _Jv_JNI_CallBooleanMethodA(JNIEnv *env, jobject obj,
2292 jmethodID methodID, const jvalue *args)
2294 java_objectheader *o;
2298 o = (java_objectheader *) obj;
2299 m = (methodinfo *) methodID;
2301 b = _Jv_jni_CallIntMethodA(o, o->vftbl, m, args);
2307 jbyte _Jv_JNI_CallByteMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2309 java_objectheader *o;
2314 o = (java_objectheader *) obj;
2315 m = (methodinfo *) methodID;
2317 va_start(ap, methodID);
2318 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2326 jbyte _Jv_JNI_CallByteMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2329 java_objectheader *o;
2333 o = (java_objectheader *) obj;
2334 m = (methodinfo *) methodID;
2336 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2342 jbyte _Jv_JNI_CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2345 log_text("JNI-Call: CallByteMethodA: IMPLEMENT ME!");
2351 jchar _Jv_JNI_CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2353 java_objectheader *o;
2358 o = (java_objectheader *) obj;
2359 m = (methodinfo *) methodID;
2361 va_start(ap, methodID);
2362 c = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2369 jchar _Jv_JNI_CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2372 java_objectheader *o;
2376 o = (java_objectheader *) obj;
2377 m = (methodinfo *) methodID;
2379 c = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2385 jchar _Jv_JNI_CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2388 log_text("JNI-Call: CallCharMethodA: IMPLEMENT ME!");
2394 jshort _Jv_JNI_CallShortMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2397 java_objectheader *o;
2402 o = (java_objectheader *) obj;
2403 m = (methodinfo *) methodID;
2405 va_start(ap, methodID);
2406 s = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2413 jshort _Jv_JNI_CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2416 java_objectheader *o;
2420 o = (java_objectheader *) obj;
2421 m = (methodinfo *) methodID;
2423 s = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2429 jshort _Jv_JNI_CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2432 log_text("JNI-Call: CallShortMethodA: IMPLEMENT ME!");
2439 jint _Jv_JNI_CallIntMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2441 java_objectheader *o;
2446 o = (java_objectheader *) obj;
2447 m = (methodinfo *) methodID;
2449 va_start(ap, methodID);
2450 i = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2457 jint _Jv_JNI_CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2460 java_objectheader *o;
2464 o = (java_objectheader *) obj;
2465 m = (methodinfo *) methodID;
2467 i = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2473 jint _Jv_JNI_CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2476 log_text("JNI-Call: CallIntMethodA: IMPLEMENT ME!");
2483 jlong _Jv_JNI_CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2485 java_objectheader *o;
2490 o = (java_objectheader *) obj;
2491 m = (methodinfo *) methodID;
2493 va_start(ap, methodID);
2494 l = _Jv_jni_CallLongMethod(o, o->vftbl, m, ap);
2501 jlong _Jv_JNI_CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2504 java_objectheader *o;
2508 o = (java_objectheader *) obj;
2509 m = (methodinfo *) methodID;
2511 l = _Jv_jni_CallLongMethod(o, o->vftbl, m, args);
2517 jlong _Jv_JNI_CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2520 log_text("JNI-Call: CallLongMethodA: IMPLEMENT ME!");
2527 jfloat _Jv_JNI_CallFloatMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2530 java_objectheader *o;
2535 o = (java_objectheader *) obj;
2536 m = (methodinfo *) methodID;
2538 va_start(ap, methodID);
2539 f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, ap);
2546 jfloat _Jv_JNI_CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2549 java_objectheader *o;
2553 o = (java_objectheader *) obj;
2554 m = (methodinfo *) methodID;
2556 f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, args);
2562 jfloat _Jv_JNI_CallFloatMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2565 log_text("JNI-Call: CallFloatMethodA: IMPLEMENT ME!");
2572 jdouble _Jv_JNI_CallDoubleMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2575 java_objectheader *o;
2580 o = (java_objectheader *) obj;
2581 m = (methodinfo *) methodID;
2583 va_start(ap, methodID);
2584 d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, ap);
2591 jdouble _Jv_JNI_CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2594 java_objectheader *o;
2598 o = (java_objectheader *) obj;
2599 m = (methodinfo *) methodID;
2601 d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, args);
2607 jdouble _Jv_JNI_CallDoubleMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2610 log_text("JNI-Call: CallDoubleMethodA: IMPLEMENT ME!");
2617 void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2619 java_objectheader *o;
2623 o = (java_objectheader *) obj;
2624 m = (methodinfo *) methodID;
2626 va_start(ap, methodID);
2627 _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
2632 void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2635 java_objectheader *o;
2638 o = (java_objectheader *) obj;
2639 m = (methodinfo *) methodID;
2641 _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
2645 void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2648 java_objectheader *o;
2651 o = (java_objectheader *) obj;
2652 m = (methodinfo *) methodID;
2654 _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
2659 jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
2660 jclass clazz, jmethodID methodID,
2663 java_objectheader *o;
2666 java_objectheader *r;
2669 o = (java_objectheader *) obj;
2670 c = (classinfo *) clazz;
2671 m = (methodinfo *) methodID;
2673 va_start(ap, methodID);
2674 r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
2677 return _Jv_JNI_NewLocalRef(env, (jobject) r);
2681 jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
2682 jclass clazz, jmethodID methodID,
2685 java_objectheader *o;
2688 java_objectheader *r;
2690 o = (java_objectheader *) obj;
2691 c = (classinfo *) clazz;
2692 m = (methodinfo *) methodID;
2694 r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
2696 return _Jv_JNI_NewLocalRef(env, (jobject) r);
2700 jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj,
2701 jclass clazz, jmethodID methodID,
2704 log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
2706 return _Jv_JNI_NewLocalRef(env, NULL);
2711 jboolean _Jv_JNI_CallNonvirtualBooleanMethod(JNIEnv *env, jobject obj,
2712 jclass clazz, jmethodID methodID,
2715 java_objectheader *o;
2721 o = (java_objectheader *) obj;
2722 c = (classinfo *) clazz;
2723 m = (methodinfo *) methodID;
2725 va_start(ap, methodID);
2726 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2733 jboolean _Jv_JNI_CallNonvirtualBooleanMethodV(JNIEnv *env, jobject obj,
2734 jclass clazz, jmethodID methodID,
2737 java_objectheader *o;
2742 o = (java_objectheader *) obj;
2743 c = (classinfo *) clazz;
2744 m = (methodinfo *) methodID;
2746 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2752 jboolean _Jv_JNI_CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj,
2753 jclass clazz, jmethodID methodID,
2756 log_text("JNI-Call: CallNonvirtualBooleanMethodA: IMPLEMENT ME!");
2762 jbyte _Jv_JNI_CallNonvirtualByteMethod(JNIEnv *env, jobject obj, jclass clazz,
2763 jmethodID methodID, ...)
2765 java_objectheader *o;
2771 o = (java_objectheader *) obj;
2772 c = (classinfo *) clazz;
2773 m = (methodinfo *) methodID;
2775 va_start(ap, methodID);
2776 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2783 jbyte _Jv_JNI_CallNonvirtualByteMethodV(JNIEnv *env, jobject obj, jclass clazz,
2784 jmethodID methodID, va_list args)
2786 java_objectheader *o;
2791 o = (java_objectheader *) obj;
2792 c = (classinfo *) clazz;
2793 m = (methodinfo *) methodID;
2795 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2801 jbyte _Jv_JNI_CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz,
2802 jmethodID methodID, const jvalue *args)
2804 log_text("JNI-Call: CallNonvirtualByteMethodA: IMPLEMENT ME!");
2811 jchar _Jv_JNI_CallNonvirtualCharMethod(JNIEnv *env, jobject obj, jclass clazz,
2812 jmethodID methodID, ...)
2814 java_objectheader *o;
2820 o = (java_objectheader *) obj;
2821 c = (classinfo *) clazz;
2822 m = (methodinfo *) methodID;
2824 va_start(ap, methodID);
2825 ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2832 jchar _Jv_JNI_CallNonvirtualCharMethodV(JNIEnv *env, jobject obj, jclass clazz,
2833 jmethodID methodID, va_list args)
2835 java_objectheader *o;
2840 o = (java_objectheader *) obj;
2841 c = (classinfo *) clazz;
2842 m = (methodinfo *) methodID;
2844 ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2850 jchar _Jv_JNI_CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz,
2851 jmethodID methodID, const jvalue *args)
2853 log_text("JNI-Call: CallNonvirtualCharMethodA: IMPLEMENT ME!");
2860 jshort _Jv_JNI_CallNonvirtualShortMethod(JNIEnv *env, jobject obj,
2861 jclass clazz, jmethodID methodID, ...)
2863 java_objectheader *o;
2869 o = (java_objectheader *) obj;
2870 c = (classinfo *) clazz;
2871 m = (methodinfo *) methodID;
2873 va_start(ap, methodID);
2874 s = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2881 jshort _Jv_JNI_CallNonvirtualShortMethodV(JNIEnv *env, jobject obj,
2882 jclass clazz, jmethodID methodID,
2885 java_objectheader *o;
2890 o = (java_objectheader *) obj;
2891 c = (classinfo *) clazz;
2892 m = (methodinfo *) methodID;
2894 s = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2900 jshort _Jv_JNI_CallNonvirtualShortMethodA(JNIEnv *env, jobject obj,
2901 jclass clazz, jmethodID methodID,
2904 log_text("JNI-Call: CallNonvirtualShortMethodA: IMPLEMENT ME!");
2911 jint _Jv_JNI_CallNonvirtualIntMethod(JNIEnv *env, jobject obj, jclass clazz,
2912 jmethodID methodID, ...)
2914 java_objectheader *o;
2920 o = (java_objectheader *) obj;
2921 c = (classinfo *) clazz;
2922 m = (methodinfo *) methodID;
2924 va_start(ap, methodID);
2925 i = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2932 jint _Jv_JNI_CallNonvirtualIntMethodV(JNIEnv *env, jobject obj, jclass clazz,
2933 jmethodID methodID, va_list args)
2935 java_objectheader *o;
2940 o = (java_objectheader *) obj;
2941 c = (classinfo *) clazz;
2942 m = (methodinfo *) methodID;
2944 i = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2950 jint _Jv_JNI_CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz,
2951 jmethodID methodID, const jvalue *args)
2953 log_text("JNI-Call: CallNonvirtualIntMethodA: IMPLEMENT ME!");
2960 jlong _Jv_JNI_CallNonvirtualLongMethod(JNIEnv *env, jobject obj, jclass clazz,
2961 jmethodID methodID, ...)
2963 java_objectheader *o;
2969 o = (java_objectheader *) obj;
2970 c = (classinfo *) clazz;
2971 m = (methodinfo *) methodID;
2973 va_start(ap, methodID);
2974 l = _Jv_jni_CallLongMethod(o, c->vftbl, m, ap);
2981 jlong _Jv_JNI_CallNonvirtualLongMethodV(JNIEnv *env, jobject obj, jclass clazz,
2982 jmethodID methodID, va_list args)
2984 java_objectheader *o;
2989 o = (java_objectheader *) obj;
2990 c = (classinfo *) clazz;
2991 m = (methodinfo *) methodID;
2993 l = _Jv_jni_CallLongMethod(o, c->vftbl, m, args);
2999 jlong _Jv_JNI_CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz,
3000 jmethodID methodID, const jvalue *args)
3002 log_text("JNI-Call: CallNonvirtualLongMethodA: IMPLEMENT ME!");
3009 jfloat _Jv_JNI_CallNonvirtualFloatMethod(JNIEnv *env, jobject obj,
3010 jclass clazz, jmethodID methodID, ...)
3012 java_objectheader *o;
3018 o = (java_objectheader *) obj;
3019 c = (classinfo *) clazz;
3020 m = (methodinfo *) methodID;
3022 va_start(ap, methodID);
3023 f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, ap);
3030 jfloat _Jv_JNI_CallNonvirtualFloatMethodV(JNIEnv *env, jobject obj,
3031 jclass clazz, jmethodID methodID,
3034 java_objectheader *o;
3039 o = (java_objectheader *) obj;
3040 c = (classinfo *) clazz;
3041 m = (methodinfo *) methodID;
3043 f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, args);
3049 jfloat _Jv_JNI_CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj,
3050 jclass clazz, jmethodID methodID,
3053 log_text("JNI-Call: CallNonvirtualFloatMethodA: IMPLEMENT ME!");
3060 jdouble _Jv_JNI_CallNonvirtualDoubleMethod(JNIEnv *env, jobject obj,
3061 jclass clazz, jmethodID methodID,
3064 java_objectheader *o;
3070 o = (java_objectheader *) obj;
3071 c = (classinfo *) clazz;
3072 m = (methodinfo *) methodID;
3074 va_start(ap, methodID);
3075 d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, ap);
3082 jdouble _Jv_JNI_CallNonvirtualDoubleMethodV(JNIEnv *env, jobject obj,
3083 jclass clazz, jmethodID methodID,
3086 java_objectheader *o;
3091 o = (java_objectheader *) obj;
3092 c = (classinfo *) clazz;
3093 m = (methodinfo *) methodID;
3095 d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, args);
3101 jdouble _Jv_JNI_CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj,
3102 jclass clazz, jmethodID methodID,
3105 log_text("JNI-Call: CallNonvirtualDoubleMethodA: IMPLEMENT ME!");
3112 void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz,
3113 jmethodID methodID, ...)
3115 java_objectheader *o;
3120 o = (java_objectheader *) obj;
3121 c = (classinfo *) clazz;
3122 m = (methodinfo *) methodID;
3124 va_start(ap, methodID);
3125 _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap);
3130 void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
3131 jmethodID methodID, va_list args)
3133 java_objectheader *o;
3137 o = (java_objectheader *) obj;
3138 c = (classinfo *) clazz;
3139 m = (methodinfo *) methodID;
3141 _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
3145 void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
3146 jmethodID methodID, const jvalue * args)
3148 java_objectheader *o;
3152 o = (java_objectheader *) obj;
3153 c = (classinfo *) clazz;
3154 m = (methodinfo *) methodID;
3156 _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
3160 /* Accessing Fields of Objects ************************************************/
3162 /* GetFieldID ******************************************************************
3164 Returns the field ID for an instance (nonstatic) field of a
3165 class. The field is specified by its name and signature. The
3166 Get<type>Field and Set<type>Field families of accessor functions
3167 use field IDs to retrieve object fields.
3169 *******************************************************************************/
3171 jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
3179 STATISTICS(jniinvokation());
3181 c = (classinfo *) clazz;
3183 /* XXX NPE check? */
3185 uname = utf_new_char((char *) name);
3186 udesc = utf_new_char((char *) sig);
3188 f = class_findfield(c, uname, udesc);
3191 exceptions_throw_nosuchfielderror(c, uname);
3193 return (jfieldID) f;
3197 /* Get<type>Field Routines *****************************************************
3199 This family of accessor routines returns the value of an instance
3200 (nonstatic) field of an object. The field to access is specified by
3201 a field ID obtained by calling GetFieldID().
3203 *******************************************************************************/
3205 jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)
3207 java_objectheader *o;
3209 STATISTICS(jniinvokation());
3211 o = GET_FIELD(obj, java_objectheader*, fieldID);
3213 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3217 jboolean _Jv_JNI_GetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID)
3221 STATISTICS(jniinvokation());
3223 i = GET_FIELD(obj, s4, fieldID);
3225 return (jboolean) i;
3229 jbyte _Jv_JNI_GetByteField(JNIEnv *env, jobject obj, jfieldID fieldID)
3233 STATISTICS(jniinvokation());
3235 i = GET_FIELD(obj, s4, fieldID);
3241 jchar _Jv_JNI_GetCharField(JNIEnv *env, jobject obj, jfieldID fieldID)
3245 STATISTICS(jniinvokation());
3247 i = GET_FIELD(obj, s4, fieldID);
3253 jshort _Jv_JNI_GetShortField(JNIEnv *env, jobject obj, jfieldID fieldID)
3257 STATISTICS(jniinvokation());
3259 i = GET_FIELD(obj, s4, fieldID);
3265 jint _Jv_JNI_GetIntField(JNIEnv *env, jobject obj, jfieldID fieldID)
3267 java_objectheader *o;
3271 STATISTICS(jniinvokation());
3273 o = (java_objectheader *) obj;
3274 f = (fieldinfo *) fieldID;
3276 i = GET_FIELD(o, s4, f);
3282 jlong _Jv_JNI_GetLongField(JNIEnv *env, jobject obj, jfieldID fieldID)
3286 STATISTICS(jniinvokation());
3288 l = GET_FIELD(obj, s8, fieldID);
3294 jfloat _Jv_JNI_GetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID)
3298 STATISTICS(jniinvokation());
3300 f = GET_FIELD(obj, float, fieldID);
3306 jdouble _Jv_JNI_GetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID)
3310 STATISTICS(jniinvokation());
3312 d = GET_FIELD(obj, double, fieldID);
3318 /* Set<type>Field Routines *****************************************************
3320 This family of accessor routines sets the value of an instance
3321 (nonstatic) field of an object. The field to access is specified by
3322 a field ID obtained by calling GetFieldID().
3324 *******************************************************************************/
3326 void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID,
3329 STATISTICS(jniinvokation());
3331 SET_FIELD(obj, java_objectheader*, fieldID, value);
3335 void _Jv_JNI_SetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID,
3338 STATISTICS(jniinvokation());
3340 SET_FIELD(obj, s4, fieldID, value);
3344 void _Jv_JNI_SetByteField(JNIEnv *env, jobject obj, jfieldID fieldID,
3347 STATISTICS(jniinvokation());
3349 SET_FIELD(obj, s4, fieldID, value);
3353 void _Jv_JNI_SetCharField(JNIEnv *env, jobject obj, jfieldID fieldID,
3356 STATISTICS(jniinvokation());
3358 SET_FIELD(obj, s4, fieldID, value);
3362 void _Jv_JNI_SetShortField(JNIEnv *env, jobject obj, jfieldID fieldID,
3365 STATISTICS(jniinvokation());
3367 SET_FIELD(obj, s4, fieldID, value);
3371 void _Jv_JNI_SetIntField(JNIEnv *env, jobject obj, jfieldID fieldID, jint value)
3373 STATISTICS(jniinvokation());
3375 SET_FIELD(obj, s4, fieldID, value);
3379 void _Jv_JNI_SetLongField(JNIEnv *env, jobject obj, jfieldID fieldID,
3382 STATISTICS(jniinvokation());
3384 SET_FIELD(obj, s8, fieldID, value);
3388 void _Jv_JNI_SetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID,
3391 STATISTICS(jniinvokation());
3393 SET_FIELD(obj, float, fieldID, value);
3397 void _Jv_JNI_SetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID,
3400 STATISTICS(jniinvokation());
3402 SET_FIELD(obj, double, fieldID, value);
3406 /* Calling Static Methods *****************************************************/
3408 /* GetStaticMethodID ***********************************************************
3410 Returns the method ID for a static method of a class. The method is
3411 specified by its name and signature.
3413 GetStaticMethodID() causes an uninitialized class to be
3416 *******************************************************************************/
3418 jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name,
3426 STATISTICS(jniinvokation());
3428 c = (classinfo *) clazz;
3433 if (!(c->state & CLASS_INITIALIZED))
3434 if (!initialize_class(c))
3437 /* try to get the static method of the class */
3439 uname = utf_new_char((char *) name);
3440 udesc = utf_new_char((char *) sig);
3442 m = class_resolvemethod(c, uname, udesc);
3444 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
3445 exceptions_throw_nosuchmethoderror(c, uname, udesc);
3450 return (jmethodID) m;
3454 jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz,
3455 jmethodID methodID, ...)
3458 java_objectheader *o;
3461 m = (methodinfo *) methodID;
3463 va_start(ap, methodID);
3464 o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
3467 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3471 jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz,
3472 jmethodID methodID, va_list args)
3475 java_objectheader *o;
3477 m = (methodinfo *) methodID;
3479 o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
3481 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3485 jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
3486 jmethodID methodID, const jvalue *args)
3489 java_objectheader *o;
3491 m = (methodinfo *) methodID;
3493 o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
3495 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3499 jboolean _Jv_JNI_CallStaticBooleanMethod(JNIEnv *env, jclass clazz,
3500 jmethodID methodID, ...)
3506 m = (methodinfo *) methodID;
3508 va_start(ap, methodID);
3509 b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3516 jboolean _Jv_JNI_CallStaticBooleanMethodV(JNIEnv *env, jclass clazz,
3517 jmethodID methodID, va_list args)
3522 m = (methodinfo *) methodID;
3524 b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3530 jboolean _Jv_JNI_CallStaticBooleanMethodA(JNIEnv *env, jclass clazz,
3531 jmethodID methodID, const jvalue *args)
3536 m = (methodinfo *) methodID;
3538 b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3544 jbyte _Jv_JNI_CallStaticByteMethod(JNIEnv *env, jclass clazz,
3545 jmethodID methodID, ...)
3551 m = (methodinfo *) methodID;
3553 va_start(ap, methodID);
3554 b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3561 jbyte _Jv_JNI_CallStaticByteMethodV(JNIEnv *env, jclass clazz,
3562 jmethodID methodID, va_list args)
3567 m = (methodinfo *) methodID;
3569 b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3575 jbyte _Jv_JNI_CallStaticByteMethodA(JNIEnv *env, jclass clazz,
3576 jmethodID methodID, const jvalue *args)
3581 m = (methodinfo *) methodID;
3583 b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3589 jchar _Jv_JNI_CallStaticCharMethod(JNIEnv *env, jclass clazz,
3590 jmethodID methodID, ...)
3596 m = (methodinfo *) methodID;
3598 va_start(ap, methodID);
3599 c = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3606 jchar _Jv_JNI_CallStaticCharMethodV(JNIEnv *env, jclass clazz,
3607 jmethodID methodID, va_list args)
3612 m = (methodinfo *) methodID;
3614 c = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3620 jchar _Jv_JNI_CallStaticCharMethodA(JNIEnv *env, jclass clazz,
3621 jmethodID methodID, const jvalue *args)
3626 m = (methodinfo *) methodID;
3628 c = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3634 jshort _Jv_JNI_CallStaticShortMethod(JNIEnv *env, jclass clazz,
3635 jmethodID methodID, ...)
3641 m = (methodinfo *) methodID;
3643 va_start(ap, methodID);
3644 s = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3651 jshort _Jv_JNI_CallStaticShortMethodV(JNIEnv *env, jclass clazz,
3652 jmethodID methodID, va_list args)
3657 m = (methodinfo *) methodID;
3659 s = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3665 jshort _Jv_JNI_CallStaticShortMethodA(JNIEnv *env, jclass clazz,
3666 jmethodID methodID, const jvalue *args)
3671 m = (methodinfo *) methodID;
3673 s = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3679 jint _Jv_JNI_CallStaticIntMethod(JNIEnv *env, jclass clazz, jmethodID methodID,
3686 m = (methodinfo *) methodID;
3688 va_start(ap, methodID);
3689 i = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3696 jint _Jv_JNI_CallStaticIntMethodV(JNIEnv *env, jclass clazz,
3697 jmethodID methodID, va_list args)
3702 m = (methodinfo *) methodID;
3704 i = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3710 jint _Jv_JNI_CallStaticIntMethodA(JNIEnv *env, jclass clazz,
3711 jmethodID methodID, const jvalue *args)
3716 m = (methodinfo *) methodID;
3718 i = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3724 jlong _Jv_JNI_CallStaticLongMethod(JNIEnv *env, jclass clazz,
3725 jmethodID methodID, ...)
3731 m = (methodinfo *) methodID;
3733 va_start(ap, methodID);
3734 l = _Jv_jni_CallLongMethod(NULL, NULL, m, ap);
3741 jlong _Jv_JNI_CallStaticLongMethodV(JNIEnv *env, jclass clazz,
3742 jmethodID methodID, va_list args)
3747 m = (methodinfo *) methodID;
3749 l = _Jv_jni_CallLongMethod(NULL, NULL, m, args);
3755 jlong _Jv_JNI_CallStaticLongMethodA(JNIEnv *env, jclass clazz,
3756 jmethodID methodID, const jvalue *args)
3761 m = (methodinfo *) methodID;
3763 l = _Jv_jni_CallLongMethodA(NULL, NULL, m, args);
3770 jfloat _Jv_JNI_CallStaticFloatMethod(JNIEnv *env, jclass clazz,
3771 jmethodID methodID, ...)
3777 m = (methodinfo *) methodID;
3779 va_start(ap, methodID);
3780 f = _Jv_jni_CallFloatMethod(NULL, NULL, m, ap);
3787 jfloat _Jv_JNI_CallStaticFloatMethodV(JNIEnv *env, jclass clazz,
3788 jmethodID methodID, va_list args)
3793 m = (methodinfo *) methodID;
3795 f = _Jv_jni_CallFloatMethod(NULL, NULL, m, args);
3801 jfloat _Jv_JNI_CallStaticFloatMethodA(JNIEnv *env, jclass clazz,
3802 jmethodID methodID, const jvalue *args)
3807 m = (methodinfo *) methodID;
3809 f = _Jv_jni_CallFloatMethodA(NULL, NULL, m, args);
3815 jdouble _Jv_JNI_CallStaticDoubleMethod(JNIEnv *env, jclass clazz,
3816 jmethodID methodID, ...)
3822 m = (methodinfo *) methodID;
3824 va_start(ap, methodID);
3825 d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, ap);
3832 jdouble _Jv_JNI_CallStaticDoubleMethodV(JNIEnv *env, jclass clazz,
3833 jmethodID methodID, va_list args)
3838 m = (methodinfo *) methodID;
3840 d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, args);
3846 jdouble _Jv_JNI_CallStaticDoubleMethodA(JNIEnv *env, jclass clazz,
3847 jmethodID methodID, const jvalue *args)
3852 m = (methodinfo *) methodID;
3854 d = _Jv_jni_CallDoubleMethodA(NULL, NULL, m, args);
3860 void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz,
3861 jmethodID methodID, ...)
3866 m = (methodinfo *) methodID;
3868 va_start(ap, methodID);
3869 _Jv_jni_CallVoidMethod(NULL, NULL, m, ap);
3874 void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz,
3875 jmethodID methodID, va_list args)
3879 m = (methodinfo *) methodID;
3881 _Jv_jni_CallVoidMethod(NULL, NULL, m, args);
3885 void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz,
3886 jmethodID methodID, const jvalue * args)
3890 m = (methodinfo *) methodID;
3892 _Jv_jni_CallVoidMethodA(NULL, NULL, m, args);
3896 /* Accessing Static Fields ****************************************************/
3898 /* GetStaticFieldID ************************************************************
3900 Returns the field ID for a static field of a class. The field is
3901 specified by its name and signature. The GetStatic<type>Field and
3902 SetStatic<type>Field families of accessor functions use field IDs
3903 to retrieve static fields.
3905 *******************************************************************************/
3907 jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
3915 STATISTICS(jniinvokation());
3917 c = (classinfo *) clazz;
3919 uname = utf_new_char((char *) name);
3920 usig = utf_new_char((char *) sig);
3922 f = class_findfield(c, uname, usig);
3925 exceptions_throw_nosuchfielderror(c, uname);
3927 return (jfieldID) f;
3931 /* GetStatic<type>Field ********************************************************
3933 This family of accessor routines returns the value of a static
3936 *******************************************************************************/
3938 jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz,
3944 STATISTICS(jniinvokation());
3946 c = (classinfo *) clazz;
3947 f = (fieldinfo *) fieldID;
3949 if (!(c->state & CLASS_INITIALIZED))
3950 if (!initialize_class(c))
3953 return _Jv_JNI_NewLocalRef(env, f->value->a);
3957 jboolean _Jv_JNI_GetStaticBooleanField(JNIEnv *env, jclass clazz,
3963 STATISTICS(jniinvokation());
3965 c = (classinfo *) clazz;
3966 f = (fieldinfo *) fieldID;
3968 if (!(c->state & CLASS_INITIALIZED))
3969 if (!initialize_class(c))
3976 jbyte _Jv_JNI_GetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID)
3981 STATISTICS(jniinvokation());
3983 c = (classinfo *) clazz;
3984 f = (fieldinfo *) fieldID;
3986 if (!(c->state & CLASS_INITIALIZED))
3987 if (!initialize_class(c))
3994 jchar _Jv_JNI_GetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID)
3999 STATISTICS(jniinvokation());
4001 c = (classinfo *) clazz;
4002 f = (fieldinfo *) fieldID;
4004 if (!(c->state & CLASS_INITIALIZED))
4005 if (!initialize_class(c))
4012 jshort _Jv_JNI_GetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4017 STATISTICS(jniinvokation());
4019 c = (classinfo *) clazz;
4020 f = (fieldinfo *) fieldID;
4022 if (!(c->state & CLASS_INITIALIZED))
4023 if (!initialize_class(c))
4030 jint _Jv_JNI_GetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4035 STATISTICS(jniinvokation());
4037 c = (classinfo *) clazz;
4038 f = (fieldinfo *) fieldID;
4040 if (!(c->state & CLASS_INITIALIZED))
4041 if (!initialize_class(c))
4048 jlong _Jv_JNI_GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4053 STATISTICS(jniinvokation());
4055 c = (classinfo *) clazz;
4056 f = (fieldinfo *) fieldID;
4058 if (!(c->state & CLASS_INITIALIZED))
4059 if (!initialize_class(c))
4066 jfloat _Jv_JNI_GetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4071 STATISTICS(jniinvokation());
4073 c = (classinfo *) clazz;
4074 f = (fieldinfo *) fieldID;
4076 if (!(c->state & CLASS_INITIALIZED))
4077 if (!initialize_class(c))
4084 jdouble _Jv_JNI_GetStaticDoubleField(JNIEnv *env, jclass clazz,
4090 STATISTICS(jniinvokation());
4092 c = (classinfo *) clazz;
4093 f = (fieldinfo *) fieldID;
4095 if (!(c->state & CLASS_INITIALIZED))
4096 if (!initialize_class(c))
4103 /* SetStatic<type>Field *******************************************************
4105 This family of accessor routines sets the value of a static field
4108 *******************************************************************************/
4110 void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4116 STATISTICS(jniinvokation());
4118 c = (classinfo *) clazz;
4119 f = (fieldinfo *) fieldID;
4121 if (!(c->state & CLASS_INITIALIZED))
4122 if (!initialize_class(c))
4125 f->value->a = value;
4129 void _Jv_JNI_SetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4135 STATISTICS(jniinvokation());
4137 c = (classinfo *) clazz;
4138 f = (fieldinfo *) fieldID;
4140 if (!(c->state & CLASS_INITIALIZED))
4141 if (!initialize_class(c))
4144 f->value->i = value;
4148 void _Jv_JNI_SetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4154 STATISTICS(jniinvokation());
4156 c = (classinfo *) clazz;
4157 f = (fieldinfo *) fieldID;
4159 if (!(c->state & CLASS_INITIALIZED))
4160 if (!initialize_class(c))
4163 f->value->i = value;
4167 void _Jv_JNI_SetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4173 STATISTICS(jniinvokation());
4175 c = (classinfo *) clazz;
4176 f = (fieldinfo *) fieldID;
4178 if (!(c->state & CLASS_INITIALIZED))
4179 if (!initialize_class(c))
4182 f->value->i = value;
4186 void _Jv_JNI_SetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4192 STATISTICS(jniinvokation());
4194 c = (classinfo *) clazz;
4195 f = (fieldinfo *) fieldID;
4197 if (!(c->state & CLASS_INITIALIZED))
4198 if (!initialize_class(c))
4201 f->value->i = value;
4205 void _Jv_JNI_SetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4211 STATISTICS(jniinvokation());
4213 c = (classinfo *) clazz;
4214 f = (fieldinfo *) fieldID;
4216 if (!(c->state & CLASS_INITIALIZED))
4217 if (!initialize_class(c))
4220 f->value->i = value;
4224 void _Jv_JNI_SetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4230 STATISTICS(jniinvokation());
4232 c = (classinfo *) clazz;
4233 f = (fieldinfo *) fieldID;
4235 if (!(c->state & CLASS_INITIALIZED))
4236 if (!initialize_class(c))
4239 f->value->l = value;
4243 void _Jv_JNI_SetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4249 STATISTICS(jniinvokation());
4251 c = (classinfo *) clazz;
4252 f = (fieldinfo *) fieldID;
4254 if (!(c->state & CLASS_INITIALIZED))
4255 if (!initialize_class(c))
4258 f->value->f = value;
4262 void _Jv_JNI_SetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4268 STATISTICS(jniinvokation());
4270 c = (classinfo *) clazz;
4271 f = (fieldinfo *) fieldID;
4273 if (!(c->state & CLASS_INITIALIZED))
4274 if (!initialize_class(c))
4277 f->value->d = value;
4281 /* String Operations **********************************************************/
4283 /* NewString *******************************************************************
4285 Create new java.lang.String object from an array of Unicode
4288 *******************************************************************************/
4290 jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len)
4292 java_lang_String *s;
4296 STATISTICS(jniinvokation());
4298 s = (java_lang_String *) builtin_new(class_java_lang_String);
4299 a = builtin_newarray_char(len);
4301 /* javastring or characterarray could not be created */
4302 if ((a == NULL) || (s == NULL))
4306 for (i = 0; i < len; i++)
4307 a->data[i] = buf[i];
4313 return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
4317 static jchar emptyStringJ[]={0,0};
4319 /* GetStringLength *************************************************************
4321 Returns the length (the count of Unicode characters) of a Java
4324 *******************************************************************************/
4326 jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str)
4328 java_lang_String *s;
4330 TRACEJNICALLS("_Jv_JNI_GetStringLength(env=%p, str=%p)", env, str);
4332 s = (java_lang_String *) str;
4338 /******************** convertes javastring to u2-array ****************************/
4340 u2 *javastring_tou2(jstring so)
4342 java_lang_String *s;
4347 STATISTICS(jniinvokation());
4349 s = (java_lang_String *) so;
4359 /* allocate memory */
4361 stringbuffer = MNEW(u2, s->count + 1);
4365 for (i = 0; i < s->count; i++)
4366 stringbuffer[i] = a->data[s->offset + i];
4368 /* terminate string */
4370 stringbuffer[i] = '\0';
4372 return stringbuffer;
4376 /* GetStringChars **************************************************************
4378 Returns a pointer to the array of Unicode characters of the
4379 string. This pointer is valid until ReleaseStringChars() is called.
4381 *******************************************************************************/
4383 const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy)
4387 STATISTICS(jniinvokation());
4389 jc = javastring_tou2(str);
4401 return emptyStringJ;
4405 /* ReleaseStringChars **********************************************************
4407 Informs the VM that the native code no longer needs access to
4408 chars. The chars argument is a pointer obtained from string using
4411 *******************************************************************************/
4413 void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
4415 STATISTICS(jniinvokation());
4417 if (chars == emptyStringJ)
4420 MFREE(((jchar *) chars), jchar, ((java_lang_String *) str)->count + 1);
4424 /* NewStringUTF ****************************************************************
4426 Constructs a new java.lang.String object from an array of UTF-8
4429 *******************************************************************************/
4431 jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
4433 java_lang_String *s;
4435 TRACEJNICALLS("_Jv_JNI_NewStringUTF(env=%p, bytes=%s)", env, bytes);
4437 s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
4439 return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
4443 /****************** returns the utf8 length in bytes of a string *******************/
4445 jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string)
4447 java_lang_String *s;
4450 TRACEJNICALLS("_Jv_JNI_GetStringUTFLength(env=%p, string=%p)", env, string);
4452 s = (java_lang_String *) string;
4454 length = u2_utflength(s->value->data, s->count);
4460 /* GetStringUTFChars ***********************************************************
4462 Returns a pointer to an array of UTF-8 characters of the
4463 string. This array is valid until it is released by
4464 ReleaseStringUTFChars().
4466 *******************************************************************************/
4468 const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string,
4473 STATISTICS(jniinvokation());
4481 u = javastring_toutf((java_objectheader *) string, false);
4490 /* ReleaseStringUTFChars *******************************************************
4492 Informs the VM that the native code no longer needs access to
4493 utf. The utf argument is a pointer derived from string using
4494 GetStringUTFChars().
4496 *******************************************************************************/
4498 void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf)
4500 STATISTICS(jniinvokation());
4502 /* XXX we don't release utf chars right now, perhaps that should be done
4503 later. Since there is always one reference the garbage collector will
4508 /* Array Operations ***********************************************************/
4510 /* GetArrayLength **************************************************************
4512 Returns the number of elements in the array.
4514 *******************************************************************************/
4516 jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array)
4518 java_arrayheader *a;
4520 STATISTICS(jniinvokation());
4522 a = (java_arrayheader *) array;
4528 /* NewObjectArray **************************************************************
4530 Constructs a new array holding objects in class elementClass. All
4531 elements are initially set to initialElement.
4533 *******************************************************************************/
4535 jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
4536 jclass elementClass, jobject initialElement)
4539 java_objectheader *o;
4540 java_objectarray *oa;
4543 STATISTICS(jniinvokation());
4545 c = (classinfo *) elementClass;
4546 o = (java_objectheader *) initialElement;
4549 exceptions_throw_negativearraysizeexception();
4553 oa = builtin_anewarray(length, c);
4558 /* set all elements to initialElement */
4560 for (i = 0; i < length; i++)
4563 return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa);
4567 jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
4570 java_objectarray *oa;
4571 java_objectheader *o;
4573 STATISTICS(jniinvokation());
4575 oa = (java_objectarray *) array;
4577 if (index >= oa->header.size) {
4578 exceptions_throw_arrayindexoutofboundsexception();
4582 o = oa->data[index];
4584 return _Jv_JNI_NewLocalRef(env, (jobject) o);
4588 void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
4589 jsize index, jobject val)
4591 java_objectarray *oa;
4592 java_objectheader *o;
4594 STATISTICS(jniinvokation());
4596 oa = (java_objectarray *) array;
4597 o = (java_objectheader *) val;
4599 if (index >= oa->header.size) {
4600 exceptions_throw_arrayindexoutofboundsexception();
4604 /* check if the class of value is a subclass of the element class
4607 if (!builtin_canstore(oa, o))
4610 oa->data[index] = o;
4614 jbooleanArray _Jv_JNI_NewBooleanArray(JNIEnv *env, jsize len)
4616 java_booleanarray *ba;
4618 STATISTICS(jniinvokation());
4621 exceptions_throw_negativearraysizeexception();
4625 ba = builtin_newarray_boolean(len);
4627 return (jbooleanArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
4631 jbyteArray _Jv_JNI_NewByteArray(JNIEnv *env, jsize len)
4635 STATISTICS(jniinvokation());
4638 exceptions_throw_negativearraysizeexception();
4642 ba = builtin_newarray_byte(len);
4644 return (jbyteArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
4648 jcharArray _Jv_JNI_NewCharArray(JNIEnv *env, jsize len)
4652 STATISTICS(jniinvokation());
4655 exceptions_throw_negativearraysizeexception();
4659 ca = builtin_newarray_char(len);
4661 return (jcharArray) _Jv_JNI_NewLocalRef(env, (jobject) ca);
4665 jshortArray _Jv_JNI_NewShortArray(JNIEnv *env, jsize len)
4667 java_shortarray *sa;
4669 STATISTICS(jniinvokation());
4672 exceptions_throw_negativearraysizeexception();
4676 sa = builtin_newarray_short(len);
4678 return (jshortArray) _Jv_JNI_NewLocalRef(env, (jobject) sa);
4682 jintArray _Jv_JNI_NewIntArray(JNIEnv *env, jsize len)
4686 STATISTICS(jniinvokation());
4689 exceptions_throw_negativearraysizeexception();
4693 ia = builtin_newarray_int(len);
4695 return (jintArray) _Jv_JNI_NewLocalRef(env, (jobject) ia);
4699 jlongArray _Jv_JNI_NewLongArray(JNIEnv *env, jsize len)
4703 STATISTICS(jniinvokation());
4706 exceptions_throw_negativearraysizeexception();
4710 la = builtin_newarray_long(len);
4712 return (jlongArray) _Jv_JNI_NewLocalRef(env, (jobject) la);
4716 jfloatArray _Jv_JNI_NewFloatArray(JNIEnv *env, jsize len)
4718 java_floatarray *fa;
4720 STATISTICS(jniinvokation());
4723 exceptions_throw_negativearraysizeexception();
4727 fa = builtin_newarray_float(len);
4729 return (jfloatArray) _Jv_JNI_NewLocalRef(env, (jobject) fa);
4733 jdoubleArray _Jv_JNI_NewDoubleArray(JNIEnv *env, jsize len)
4735 java_doublearray *da;
4737 STATISTICS(jniinvokation());
4740 exceptions_throw_negativearraysizeexception();
4744 da = builtin_newarray_double(len);
4746 return (jdoubleArray) _Jv_JNI_NewLocalRef(env, (jobject) da);
4750 /* Get<PrimitiveType>ArrayElements *********************************************
4752 A family of functions that returns the body of the primitive array.
4754 *******************************************************************************/
4756 jboolean *_Jv_JNI_GetBooleanArrayElements(JNIEnv *env, jbooleanArray array,
4759 java_booleanarray *ba;
4761 STATISTICS(jniinvokation());
4763 ba = (java_booleanarray *) array;
4766 *isCopy = JNI_FALSE;
4772 jbyte *_Jv_JNI_GetByteArrayElements(JNIEnv *env, jbyteArray array,
4777 STATISTICS(jniinvokation());
4779 ba = (java_bytearray *) array;
4782 *isCopy = JNI_FALSE;
4788 jchar *_Jv_JNI_GetCharArrayElements(JNIEnv *env, jcharArray array,
4793 STATISTICS(jniinvokation());
4795 ca = (java_chararray *) array;
4798 *isCopy = JNI_FALSE;
4804 jshort *_Jv_JNI_GetShortArrayElements(JNIEnv *env, jshortArray array,
4807 java_shortarray *sa;
4809 STATISTICS(jniinvokation());
4811 sa = (java_shortarray *) array;
4814 *isCopy = JNI_FALSE;
4820 jint *_Jv_JNI_GetIntArrayElements(JNIEnv *env, jintArray array,
4825 STATISTICS(jniinvokation());
4827 ia = (java_intarray *) array;
4830 *isCopy = JNI_FALSE;
4836 jlong *_Jv_JNI_GetLongArrayElements(JNIEnv *env, jlongArray array,
4841 STATISTICS(jniinvokation());
4843 la = (java_longarray *) array;
4846 *isCopy = JNI_FALSE;
4848 /* We cast this one to prevent a compiler warning on 64-bit
4849 systems since GNU Classpath typedef jlong to long long. */
4851 return (jlong *) la->data;
4855 jfloat *_Jv_JNI_GetFloatArrayElements(JNIEnv *env, jfloatArray array,
4858 java_floatarray *fa;
4860 STATISTICS(jniinvokation());
4862 fa = (java_floatarray *) array;
4865 *isCopy = JNI_FALSE;
4871 jdouble *_Jv_JNI_GetDoubleArrayElements(JNIEnv *env, jdoubleArray array,
4874 java_doublearray *da;
4876 STATISTICS(jniinvokation());
4878 da = (java_doublearray *) array;
4881 *isCopy = JNI_FALSE;
4887 /* Release<PrimitiveType>ArrayElements *****************************************
4889 A family of functions that informs the VM that the native code no
4890 longer needs access to elems. The elems argument is a pointer
4891 derived from array using the corresponding
4892 Get<PrimitiveType>ArrayElements() function. If necessary, this
4893 function copies back all changes made to elems to the original
4896 *******************************************************************************/
4898 void _Jv_JNI_ReleaseBooleanArrayElements(JNIEnv *env, jbooleanArray array,
4899 jboolean *elems, jint mode)
4901 java_booleanarray *ba;
4903 STATISTICS(jniinvokation());
4905 ba = (java_booleanarray *) array;
4907 if (elems != ba->data) {
4910 MCOPY(ba->data, elems, u1, ba->header.size);
4913 MCOPY(ba->data, elems, u1, ba->header.size);
4914 /* XXX TWISTI how should it be freed? */
4917 /* XXX TWISTI how should it be freed? */
4924 void _Jv_JNI_ReleaseByteArrayElements(JNIEnv *env, jbyteArray array,
4925 jbyte *elems, jint mode)
4929 STATISTICS(jniinvokation());
4931 ba = (java_bytearray *) array;
4933 if (elems != ba->data) {
4936 MCOPY(ba->data, elems, s1, ba->header.size);
4939 MCOPY(ba->data, elems, s1, ba->header.size);
4940 /* XXX TWISTI how should it be freed? */
4943 /* XXX TWISTI how should it be freed? */
4950 void _Jv_JNI_ReleaseCharArrayElements(JNIEnv *env, jcharArray array,
4951 jchar *elems, jint mode)
4955 STATISTICS(jniinvokation());
4957 ca = (java_chararray *) array;
4959 if (elems != ca->data) {
4962 MCOPY(ca->data, elems, u2, ca->header.size);
4965 MCOPY(ca->data, elems, u2, ca->header.size);
4966 /* XXX TWISTI how should it be freed? */
4969 /* XXX TWISTI how should it be freed? */
4976 void _Jv_JNI_ReleaseShortArrayElements(JNIEnv *env, jshortArray array,
4977 jshort *elems, jint mode)
4979 java_shortarray *sa;
4981 STATISTICS(jniinvokation());
4983 sa = (java_shortarray *) array;
4985 if (elems != sa->data) {
4988 MCOPY(sa->data, elems, s2, sa->header.size);
4991 MCOPY(sa->data, elems, s2, sa->header.size);
4992 /* XXX TWISTI how should it be freed? */
4995 /* XXX TWISTI how should it be freed? */
5002 void _Jv_JNI_ReleaseIntArrayElements(JNIEnv *env, jintArray array, jint *elems,
5007 STATISTICS(jniinvokation());
5009 ia = (java_intarray *) array;
5011 if (elems != ia->data) {
5014 MCOPY(ia->data, elems, s4, ia->header.size);
5017 MCOPY(ia->data, elems, s4, ia->header.size);
5018 /* XXX TWISTI how should it be freed? */
5021 /* XXX TWISTI how should it be freed? */
5028 void _Jv_JNI_ReleaseLongArrayElements(JNIEnv *env, jlongArray array,
5029 jlong *elems, jint mode)
5033 STATISTICS(jniinvokation());
5035 la = (java_longarray *) array;
5037 /* We cast this one to prevent a compiler warning on 64-bit
5038 systems since GNU Classpath typedef jlong to long long. */
5040 if ((s8 *) elems != la->data) {
5043 MCOPY(la->data, elems, s8, la->header.size);
5046 MCOPY(la->data, elems, s8, la->header.size);
5047 /* XXX TWISTI how should it be freed? */
5050 /* XXX TWISTI how should it be freed? */
5057 void _Jv_JNI_ReleaseFloatArrayElements(JNIEnv *env, jfloatArray array,
5058 jfloat *elems, jint mode)
5060 java_floatarray *fa;
5062 STATISTICS(jniinvokation());
5064 fa = (java_floatarray *) array;
5066 if (elems != fa->data) {
5069 MCOPY(fa->data, elems, float, fa->header.size);
5072 MCOPY(fa->data, elems, float, fa->header.size);
5073 /* XXX TWISTI how should it be freed? */
5076 /* XXX TWISTI how should it be freed? */
5083 void _Jv_JNI_ReleaseDoubleArrayElements(JNIEnv *env, jdoubleArray array,
5084 jdouble *elems, jint mode)
5086 java_doublearray *da;
5088 STATISTICS(jniinvokation());
5090 da = (java_doublearray *) array;
5092 if (elems != da->data) {
5095 MCOPY(da->data, elems, double, da->header.size);
5098 MCOPY(da->data, elems, double, da->header.size);
5099 /* XXX TWISTI how should it be freed? */
5102 /* XXX TWISTI how should it be freed? */
5109 /* Get<PrimitiveType>ArrayRegion **********************************************
5111 A family of functions that copies a region of a primitive array
5114 *******************************************************************************/
5116 void _Jv_JNI_GetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
5117 jsize start, jsize len, jboolean *buf)
5119 java_booleanarray *ba;
5121 STATISTICS(jniinvokation());
5123 ba = (java_booleanarray *) array;
5125 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5126 exceptions_throw_arrayindexoutofboundsexception();
5128 MCOPY(buf, &ba->data[start], u1, len);
5132 void _Jv_JNI_GetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
5133 jsize len, jbyte *buf)
5137 STATISTICS(jniinvokation());
5139 ba = (java_bytearray *) array;
5141 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5142 exceptions_throw_arrayindexoutofboundsexception();
5144 MCOPY(buf, &ba->data[start], s1, len);
5148 void _Jv_JNI_GetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
5149 jsize len, jchar *buf)
5153 STATISTICS(jniinvokation());
5155 ca = (java_chararray *) array;
5157 if ((start < 0) || (len < 0) || (start + len > ca->header.size))
5158 exceptions_throw_arrayindexoutofboundsexception();
5160 MCOPY(buf, &ca->data[start], u2, len);
5164 void _Jv_JNI_GetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
5165 jsize len, jshort *buf)
5167 java_shortarray *sa;
5169 STATISTICS(jniinvokation());
5171 sa = (java_shortarray *) array;
5173 if ((start < 0) || (len < 0) || (start + len > sa->header.size))
5174 exceptions_throw_arrayindexoutofboundsexception();
5176 MCOPY(buf, &sa->data[start], s2, len);
5180 void _Jv_JNI_GetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
5181 jsize len, jint *buf)
5185 STATISTICS(jniinvokation());
5187 ia = (java_intarray *) array;
5189 if ((start < 0) || (len < 0) || (start + len > ia->header.size))
5190 exceptions_throw_arrayindexoutofboundsexception();
5192 MCOPY(buf, &ia->data[start], s4, len);
5196 void _Jv_JNI_GetLongArrayRegion(JNIEnv *env, jlongArray array, jsize start,
5197 jsize len, jlong *buf)
5201 STATISTICS(jniinvokation());
5203 la = (java_longarray *) array;
5205 if ((start < 0) || (len < 0) || (start + len > la->header.size))
5206 exceptions_throw_arrayindexoutofboundsexception();
5208 MCOPY(buf, &la->data[start], s8, len);
5212 void _Jv_JNI_GetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
5213 jsize len, jfloat *buf)
5215 java_floatarray *fa;
5217 STATISTICS(jniinvokation());
5219 fa = (java_floatarray *) array;
5221 if ((start < 0) || (len < 0) || (start + len > fa->header.size))
5222 exceptions_throw_arrayindexoutofboundsexception();
5224 MCOPY(buf, &fa->data[start], float, len);
5228 void _Jv_JNI_GetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
5229 jsize len, jdouble *buf)
5231 java_doublearray *da;
5233 STATISTICS(jniinvokation());
5235 da = (java_doublearray *) array;
5237 if ((start < 0) || (len < 0) || (start + len > da->header.size))
5238 exceptions_throw_arrayindexoutofboundsexception();
5240 MCOPY(buf, &da->data[start], double, len);
5244 /* Set<PrimitiveType>ArrayRegion **********************************************
5246 A family of functions that copies back a region of a primitive
5247 array from a buffer.
5249 *******************************************************************************/
5251 void _Jv_JNI_SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
5252 jsize start, jsize len, const jboolean *buf)
5254 java_booleanarray *ba;
5256 STATISTICS(jniinvokation());
5258 ba = (java_booleanarray *) array;
5260 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5261 exceptions_throw_arrayindexoutofboundsexception();
5263 MCOPY(&ba->data[start], buf, u1, len);
5267 void _Jv_JNI_SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
5268 jsize len, const jbyte *buf)
5272 STATISTICS(jniinvokation());
5274 ba = (java_bytearray *) array;
5276 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5277 exceptions_throw_arrayindexoutofboundsexception();
5279 MCOPY(&ba->data[start], buf, s1, len);
5283 void _Jv_JNI_SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
5284 jsize len, const jchar *buf)
5288 STATISTICS(jniinvokation());
5290 ca = (java_chararray *) array;
5292 if ((start < 0) || (len < 0) || (start + len > ca->header.size))
5293 exceptions_throw_arrayindexoutofboundsexception();
5295 MCOPY(&ca->data[start], buf, u2, len);
5299 void _Jv_JNI_SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
5300 jsize len, const jshort *buf)
5302 java_shortarray *sa;
5304 STATISTICS(jniinvokation());
5306 sa = (java_shortarray *) array;
5308 if ((start < 0) || (len < 0) || (start + len > sa->header.size))
5309 exceptions_throw_arrayindexoutofboundsexception();
5311 MCOPY(&sa->data[start], buf, s2, len);
5315 void _Jv_JNI_SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
5316 jsize len, const jint *buf)
5320 STATISTICS(jniinvokation());
5322 ia = (java_intarray *) array;
5324 if ((start < 0) || (len < 0) || (start + len > ia->header.size))
5325 exceptions_throw_arrayindexoutofboundsexception();
5327 MCOPY(&ia->data[start], buf, s4, len);
5331 void _Jv_JNI_SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start,
5332 jsize len, const jlong *buf)
5336 STATISTICS(jniinvokation());
5338 la = (java_longarray *) array;
5340 if ((start < 0) || (len < 0) || (start + len > la->header.size))
5341 exceptions_throw_arrayindexoutofboundsexception();
5343 MCOPY(&la->data[start], buf, s8, len);
5347 void _Jv_JNI_SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
5348 jsize len, const jfloat *buf)
5350 java_floatarray *fa;
5352 STATISTICS(jniinvokation());
5354 fa = (java_floatarray *) array;
5356 if ((start < 0) || (len < 0) || (start + len > fa->header.size))
5357 exceptions_throw_arrayindexoutofboundsexception();
5359 MCOPY(&fa->data[start], buf, float, len);
5363 void _Jv_JNI_SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
5364 jsize len, const jdouble *buf)
5366 java_doublearray *da;
5368 STATISTICS(jniinvokation());
5370 da = (java_doublearray *) array;
5372 if ((start < 0) || (len < 0) || (start + len > da->header.size))
5373 exceptions_throw_arrayindexoutofboundsexception();
5375 MCOPY(&da->data[start], buf, double, len);
5379 /* Registering Native Methods *************************************************/
5381 /* RegisterNatives *************************************************************
5383 Registers native methods with the class specified by the clazz
5384 argument. The methods parameter specifies an array of
5385 JNINativeMethod structures that contain the names, signatures, and
5386 function pointers of the native methods. The nMethods parameter
5387 specifies the number of native methods in the array.
5389 *******************************************************************************/
5391 jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz,
5392 const JNINativeMethod *methods, jint nMethods)
5396 STATISTICS(jniinvokation());
5398 c = (classinfo *) clazz;
5400 /* XXX: if implemented this needs a call to jvmti_NativeMethodBind
5401 if (jvmti) jvmti_NativeMethodBind(method, address, new_address_ptr);
5404 native_method_register(c->name, methods, nMethods);
5410 /* UnregisterNatives ***********************************************************
5412 Unregisters native methods of a class. The class goes back to the
5413 state before it was linked or registered with its native method
5416 This function should not be used in normal native code. Instead, it
5417 provides special programs a way to reload and relink native
5420 *******************************************************************************/
5422 jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz)
5424 STATISTICS(jniinvokation());
5426 /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */
5428 log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!");
5434 /* Monitor Operations *********************************************************/
5436 /* MonitorEnter ****************************************************************
5438 Enters the monitor associated with the underlying Java object
5441 *******************************************************************************/
5443 jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj)
5445 STATISTICS(jniinvokation());
5448 exceptions_throw_nullpointerexception();
5452 LOCK_MONITOR_ENTER(obj);
5458 /* MonitorExit *****************************************************************
5460 The current thread must be the owner of the monitor associated with
5461 the underlying Java object referred to by obj. The thread
5462 decrements the counter indicating the number of times it has
5463 entered this monitor. If the value of the counter becomes zero, the
5464 current thread releases the monitor.
5466 *******************************************************************************/
5468 jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj)
5470 STATISTICS(jniinvokation());
5473 exceptions_throw_nullpointerexception();
5477 LOCK_MONITOR_EXIT(obj);
5483 /* JavaVM Interface ***********************************************************/
5485 /* GetJavaVM *******************************************************************
5487 Returns the Java VM interface (used in the Invocation API)
5488 associated with the current thread. The result is placed at the
5489 location pointed to by the second argument, vm.
5491 *******************************************************************************/
5493 jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **vm)
5495 STATISTICS(jniinvokation());
5497 *vm = (JavaVM *) _Jv_jvm;
5503 /* GetStringRegion *************************************************************
5505 Copies len number of Unicode characters beginning at offset start
5506 to the given buffer buf.
5508 Throws StringIndexOutOfBoundsException on index overflow.
5510 *******************************************************************************/
5512 void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len,
5515 java_lang_String *s;
5518 STATISTICS(jniinvokation());
5520 s = (java_lang_String *) str;
5523 if ((start < 0) || (len < 0) || (start > s->count) ||
5524 (start + len > s->count)) {
5525 exceptions_throw_stringindexoutofboundsexception();
5529 MCOPY(buf, &ca->data[start], u2, len);
5533 /* GetStringUTFRegion **********************************************************
5535 Translates len number of Unicode characters beginning at offset
5536 start into UTF-8 format and place the result in the given buffer
5539 Throws StringIndexOutOfBoundsException on index overflow.
5541 *******************************************************************************/
5543 void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start,
5544 jsize len, char *buf)
5546 java_lang_String *s;
5550 TRACEJNICALLS("_Jv_JNI_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf);
5552 s = (java_lang_String *) str;
5555 if ((start < 0) || (len < 0) || (start > s->count) ||
5556 (start + len > s->count)) {
5557 exceptions_throw_stringindexoutofboundsexception();
5561 for (i = 0; i < len; i++)
5562 buf[i] = ca->data[s->offset + start + i];
5568 /* GetPrimitiveArrayCritical ***************************************************
5570 Obtain a direct pointer to array elements.
5572 *******************************************************************************/
5574 void *_Jv_JNI_GetPrimitiveArrayCritical(JNIEnv *env, jarray array,
5580 ba = (java_bytearray *) array;
5582 /* do the same as Kaffe does */
5584 bp = _Jv_JNI_GetByteArrayElements(env, (jbyteArray) ba, isCopy);
5590 /* ReleasePrimitiveArrayCritical ***********************************************
5592 No specific documentation.
5594 *******************************************************************************/
5596 void _Jv_JNI_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array,
5597 void *carray, jint mode)
5599 STATISTICS(jniinvokation());
5601 /* do the same as Kaffe does */
5603 _Jv_JNI_ReleaseByteArrayElements(env, (jbyteArray) array, (jbyte *) carray,
5608 /* GetStringCritical ***********************************************************
5610 The semantics of these two functions are similar to the existing
5611 Get/ReleaseStringChars functions.
5613 *******************************************************************************/
5615 const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string,
5618 STATISTICS(jniinvokation());
5620 return _Jv_JNI_GetStringChars(env, string, isCopy);
5624 void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string,
5625 const jchar *cstring)
5627 STATISTICS(jniinvokation());
5629 _Jv_JNI_ReleaseStringChars(env, string, cstring);
5633 jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj)
5635 STATISTICS(jniinvokation());
5637 log_text("JNI-Call: NewWeakGlobalRef: IMPLEMENT ME!");
5643 void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref)
5645 STATISTICS(jniinvokation());
5647 log_text("JNI-Call: DeleteWeakGlobalRef: IMPLEMENT ME");
5651 /* NewGlobalRef ****************************************************************
5653 Creates a new global reference to the object referred to by the obj
5656 *******************************************************************************/
5658 jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
5660 hashtable_global_ref_entry *gre;
5661 u4 key; /* hashkey */
5662 u4 slot; /* slot in hashtable */
5663 java_objectheader *o;
5665 STATISTICS(jniinvokation());
5667 o = (java_objectheader *) obj;
5669 LOCK_MONITOR_ENTER(hashtable_global_ref->header);
5671 /* normally addresses are aligned to 4, 8 or 16 bytes */
5673 key = ((u4) (ptrint) obj) >> 4; /* align to 16-byte boundaries */
5674 slot = key & (hashtable_global_ref->size - 1);
5675 gre = hashtable_global_ref->ptr[slot];
5677 /* search external hash chain for the entry */
5681 /* global object found, increment the reference */
5685 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5690 gre = gre->hashlink; /* next element in external chain */
5693 /* global ref not found, create a new one */
5695 gre = NEW(hashtable_global_ref_entry);
5700 /* insert entry into hashtable */
5702 gre->hashlink = hashtable_global_ref->ptr[slot];
5704 hashtable_global_ref->ptr[slot] = gre;
5706 /* update number of hashtable-entries */
5708 hashtable_global_ref->entries++;
5710 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5716 /* DeleteGlobalRef *************************************************************
5718 Deletes the global reference pointed to by globalRef.
5720 *******************************************************************************/
5722 void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
5724 hashtable_global_ref_entry *gre;
5725 hashtable_global_ref_entry *prevgre;
5726 u4 key; /* hashkey */
5727 u4 slot; /* slot in hashtable */
5728 java_objectheader *o;
5730 STATISTICS(jniinvokation());
5732 o = (java_objectheader *) globalRef;
5734 LOCK_MONITOR_ENTER(hashtable_global_ref->header);
5736 /* normally addresses are aligned to 4, 8 or 16 bytes */
5738 key = ((u4) (ptrint) globalRef) >> 4; /* align to 16-byte boundaries */
5739 slot = key & (hashtable_global_ref->size - 1);
5740 gre = hashtable_global_ref->ptr[slot];
5742 /* initialize prevgre */
5746 /* search external hash chain for the entry */
5750 /* global object found, decrement the reference count */
5754 /* if reference count is 0, remove the entry */
5756 if (gre->refs == 0) {
5757 /* special handling if it's the first in the chain */
5759 if (prevgre == NULL)
5760 hashtable_global_ref->ptr[slot] = gre->hashlink;
5762 prevgre->hashlink = gre->hashlink;
5764 FREE(gre, hashtable_global_ref_entry);
5767 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5772 prevgre = gre; /* save current pointer for removal */
5773 gre = gre->hashlink; /* next element in external chain */
5776 log_println("JNI-DeleteGlobalRef: global reference not found");
5778 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5782 /* ExceptionCheck **************************************************************
5784 Returns JNI_TRUE when there is a pending exception; otherwise,
5787 *******************************************************************************/
5789 jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
5791 java_objectheader *o;
5793 STATISTICS(jniinvokation());
5795 o = exceptions_get_exception();
5797 return (o != NULL) ? JNI_TRUE : JNI_FALSE;
5801 /* New JNI 1.4 functions ******************************************************/
5803 /* NewDirectByteBuffer *********************************************************
5805 Allocates and returns a direct java.nio.ByteBuffer referring to the
5806 block of memory starting at the memory address address and
5807 extending capacity bytes.
5809 *******************************************************************************/
5811 jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
5813 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5814 java_objectheader *nbuf;
5816 # if SIZEOF_VOID_P == 8
5817 gnu_classpath_Pointer64 *paddress;
5819 gnu_classpath_Pointer32 *paddress;
5822 STATISTICS(jniinvokation());
5824 /* alocate a gnu.classpath.Pointer{32,64} object */
5826 # if SIZEOF_VOID_P == 8
5827 if (!(paddress = (gnu_classpath_Pointer64 *)
5828 builtin_new(class_gnu_classpath_Pointer64)))
5830 if (!(paddress = (gnu_classpath_Pointer32 *)
5831 builtin_new(class_gnu_classpath_Pointer32)))
5835 /* fill gnu.classpath.Pointer{32,64} with address */
5837 paddress->data = (ptrint) address;
5839 /* create a java.nio.DirectByteBufferImpl$ReadWrite object */
5841 nbuf = (*env)->NewObject(env, class_java_nio_DirectByteBufferImpl_ReadWrite,
5842 (jmethodID) dbbirw_init, NULL, paddress,
5843 (jint) capacity, (jint) capacity, (jint) 0);
5845 /* add local reference and return the value */
5847 return _Jv_JNI_NewLocalRef(env, nbuf);
5849 vm_abort("_Jv_JNI_NewDirectByteBuffer: not implemented in this configuration");
5851 /* keep compiler happy */
5858 /* GetDirectBufferAddress ******************************************************
5860 Fetches and returns the starting address of the memory region
5861 referenced by the given direct java.nio.Buffer.
5863 *******************************************************************************/
5865 void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
5867 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5868 java_nio_DirectByteBufferImpl *nbuf;
5869 # if SIZEOF_VOID_P == 8
5870 gnu_classpath_Pointer64 *address;
5872 gnu_classpath_Pointer32 *address;
5875 STATISTICS(jniinvokation());
5877 if (!builtin_instanceof(buf, class_java_nio_Buffer))
5880 nbuf = (java_nio_DirectByteBufferImpl *) buf;
5882 # if SIZEOF_VOID_P == 8
5883 address = (gnu_classpath_Pointer64 *) nbuf->address;
5885 address = (gnu_classpath_Pointer32 *) nbuf->address;
5888 if (address == NULL)
5891 return (void *) address->data;
5893 vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration");
5895 /* keep compiler happy */
5902 /* GetDirectBufferCapacity *****************************************************
5904 Fetches and returns the capacity in bytes of the memory region
5905 referenced by the given direct java.nio.Buffer.
5907 *******************************************************************************/
5909 jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
5911 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5912 java_objectheader *o;
5913 java_nio_Buffer *nbuf;
5915 STATISTICS(jniinvokation());
5917 o = (java_objectheader *) buf;
5919 if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl))
5922 nbuf = (java_nio_Buffer *) o;
5924 return (jlong) nbuf->cap;
5926 vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration");
5928 /* keep compiler happy */
5935 /* DestroyJavaVM ***************************************************************
5937 Unloads a Java VM and reclaims its resources. Only the main thread
5938 can unload the VM. The system waits until the main thread is only
5939 remaining user thread before it destroys the VM.
5941 *******************************************************************************/
5943 jint _Jv_JNI_DestroyJavaVM(JavaVM *vm)
5947 STATISTICS(jniinvokation());
5949 status = vm_destroy(vm);
5955 /* AttachCurrentThread *********************************************************
5957 Attaches the current thread to a Java VM. Returns a JNI interface
5958 pointer in the JNIEnv argument.
5960 Trying to attach a thread that is already attached is a no-op.
5962 A native thread cannot be attached simultaneously to two Java VMs.
5964 When a thread is attached to the VM, the context class loader is
5965 the bootstrap loader.
5967 *******************************************************************************/
5969 static s4 jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon)
5971 JavaVMAttachArgs *vm_aargs;
5973 #if defined(ENABLE_THREADS)
5974 if (threads_get_current_threadobject() == NULL) {
5975 vm_aargs = (JavaVMAttachArgs *) thr_args;
5977 if (vm_aargs != NULL) {
5978 if ((vm_aargs->version != JNI_VERSION_1_2) &&
5979 (vm_aargs->version != JNI_VERSION_1_4))
5980 return JNI_EVERSION;
5983 if (!threads_attach_current_thread(vm_aargs, false))
5986 if (!jni_init_localref_table())
5997 jint _Jv_JNI_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args)
5999 STATISTICS(jniinvokation());
6001 return jni_attach_current_thread(p_env, thr_args, false);
6005 /* DetachCurrentThread *********************************************************
6007 Detaches the current thread from a Java VM. All Java monitors held
6008 by this thread are released. All Java threads waiting for this
6009 thread to die are notified.
6011 In JDK 1.1, the main thread cannot be detached from the VM. It must
6012 call DestroyJavaVM to unload the entire VM.
6014 In the JDK, the main thread can be detached from the VM.
6016 The main thread, which is the thread that created the Java VM,
6017 cannot be detached from the VM. Instead, the main thread must call
6018 JNI_DestroyJavaVM() to unload the entire VM.
6020 *******************************************************************************/
6022 jint _Jv_JNI_DetachCurrentThread(JavaVM *vm)
6024 #if defined(ENABLE_THREADS)
6025 threadobject *thread;
6027 STATISTICS(jniinvokation());
6029 thread = threads_get_current_threadobject();
6034 if (!threads_detach_thread(thread))
6042 /* GetEnv **********************************************************************
6044 If the current thread is not attached to the VM, sets *env to NULL,
6045 and returns JNI_EDETACHED. If the specified version is not
6046 supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise,
6047 sets *env to the appropriate interface, and returns JNI_OK.
6049 *******************************************************************************/
6051 jint _Jv_JNI_GetEnv(JavaVM *vm, void **env, jint version)
6053 STATISTICS(jniinvokation());
6055 #if defined(ENABLE_THREADS)
6056 if (threads_get_current_threadobject() == NULL) {
6059 return JNI_EDETACHED;
6063 /* check the JNI version */
6066 case JNI_VERSION_1_1:
6067 case JNI_VERSION_1_2:
6068 case JNI_VERSION_1_4:
6076 #if defined(ENABLE_JVMTI)
6077 if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE)
6078 == JVMTI_VERSION_INTERFACE_JVMTI) {
6080 *env = (void *) jvmti_new_environment();
6089 return JNI_EVERSION;
6093 /* AttachCurrentThreadAsDaemon *************************************************
6095 Same semantics as AttachCurrentThread, but the newly-created
6096 java.lang.Thread instance is a daemon.
6098 If the thread has already been attached via either
6099 AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine
6100 simply sets the value pointed to by penv to the JNIEnv of the
6101 current thread. In this case neither AttachCurrentThread nor this
6102 routine have any effect on the daemon status of the thread.
6104 *******************************************************************************/
6106 jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
6108 STATISTICS(jniinvokation());
6110 return jni_attach_current_thread(penv, args, true);
6114 /* JNI invocation table *******************************************************/
6116 const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = {
6121 _Jv_JNI_DestroyJavaVM,
6122 _Jv_JNI_AttachCurrentThread,
6123 _Jv_JNI_DetachCurrentThread,
6125 _Jv_JNI_AttachCurrentThreadAsDaemon
6129 /* JNI function table *********************************************************/
6131 struct JNINativeInterface_ _Jv_JNINativeInterface = {
6138 _Jv_JNI_DefineClass,
6140 _Jv_JNI_FromReflectedMethod,
6141 _Jv_JNI_FromReflectedField,
6142 _Jv_JNI_ToReflectedMethod,
6143 _Jv_JNI_GetSuperclass,
6144 _Jv_JNI_IsAssignableFrom,
6145 _Jv_JNI_ToReflectedField,
6149 _Jv_JNI_ExceptionOccurred,
6150 _Jv_JNI_ExceptionDescribe,
6151 _Jv_JNI_ExceptionClear,
6153 _Jv_JNI_PushLocalFrame,
6154 _Jv_JNI_PopLocalFrame,
6156 _Jv_JNI_NewGlobalRef,
6157 _Jv_JNI_DeleteGlobalRef,
6158 _Jv_JNI_DeleteLocalRef,
6159 _Jv_JNI_IsSameObject,
6160 _Jv_JNI_NewLocalRef,
6161 _Jv_JNI_EnsureLocalCapacity,
6163 _Jv_JNI_AllocObject,
6168 _Jv_JNI_GetObjectClass,
6169 _Jv_JNI_IsInstanceOf,
6171 _Jv_JNI_GetMethodID,
6173 _Jv_JNI_CallObjectMethod,
6174 _Jv_JNI_CallObjectMethodV,
6175 _Jv_JNI_CallObjectMethodA,
6176 _Jv_JNI_CallBooleanMethod,
6177 _Jv_JNI_CallBooleanMethodV,
6178 _Jv_JNI_CallBooleanMethodA,
6179 _Jv_JNI_CallByteMethod,
6180 _Jv_JNI_CallByteMethodV,
6181 _Jv_JNI_CallByteMethodA,
6182 _Jv_JNI_CallCharMethod,
6183 _Jv_JNI_CallCharMethodV,
6184 _Jv_JNI_CallCharMethodA,
6185 _Jv_JNI_CallShortMethod,
6186 _Jv_JNI_CallShortMethodV,
6187 _Jv_JNI_CallShortMethodA,
6188 _Jv_JNI_CallIntMethod,
6189 _Jv_JNI_CallIntMethodV,
6190 _Jv_JNI_CallIntMethodA,
6191 _Jv_JNI_CallLongMethod,
6192 _Jv_JNI_CallLongMethodV,
6193 _Jv_JNI_CallLongMethodA,
6194 _Jv_JNI_CallFloatMethod,
6195 _Jv_JNI_CallFloatMethodV,
6196 _Jv_JNI_CallFloatMethodA,
6197 _Jv_JNI_CallDoubleMethod,
6198 _Jv_JNI_CallDoubleMethodV,
6199 _Jv_JNI_CallDoubleMethodA,
6200 _Jv_JNI_CallVoidMethod,
6201 _Jv_JNI_CallVoidMethodV,
6202 _Jv_JNI_CallVoidMethodA,
6204 _Jv_JNI_CallNonvirtualObjectMethod,
6205 _Jv_JNI_CallNonvirtualObjectMethodV,
6206 _Jv_JNI_CallNonvirtualObjectMethodA,
6207 _Jv_JNI_CallNonvirtualBooleanMethod,
6208 _Jv_JNI_CallNonvirtualBooleanMethodV,
6209 _Jv_JNI_CallNonvirtualBooleanMethodA,
6210 _Jv_JNI_CallNonvirtualByteMethod,
6211 _Jv_JNI_CallNonvirtualByteMethodV,
6212 _Jv_JNI_CallNonvirtualByteMethodA,
6213 _Jv_JNI_CallNonvirtualCharMethod,
6214 _Jv_JNI_CallNonvirtualCharMethodV,
6215 _Jv_JNI_CallNonvirtualCharMethodA,
6216 _Jv_JNI_CallNonvirtualShortMethod,
6217 _Jv_JNI_CallNonvirtualShortMethodV,
6218 _Jv_JNI_CallNonvirtualShortMethodA,
6219 _Jv_JNI_CallNonvirtualIntMethod,
6220 _Jv_JNI_CallNonvirtualIntMethodV,
6221 _Jv_JNI_CallNonvirtualIntMethodA,
6222 _Jv_JNI_CallNonvirtualLongMethod,
6223 _Jv_JNI_CallNonvirtualLongMethodV,
6224 _Jv_JNI_CallNonvirtualLongMethodA,
6225 _Jv_JNI_CallNonvirtualFloatMethod,
6226 _Jv_JNI_CallNonvirtualFloatMethodV,
6227 _Jv_JNI_CallNonvirtualFloatMethodA,
6228 _Jv_JNI_CallNonvirtualDoubleMethod,
6229 _Jv_JNI_CallNonvirtualDoubleMethodV,
6230 _Jv_JNI_CallNonvirtualDoubleMethodA,
6231 _Jv_JNI_CallNonvirtualVoidMethod,
6232 _Jv_JNI_CallNonvirtualVoidMethodV,
6233 _Jv_JNI_CallNonvirtualVoidMethodA,
6237 _Jv_JNI_GetObjectField,
6238 _Jv_JNI_GetBooleanField,
6239 _Jv_JNI_GetByteField,
6240 _Jv_JNI_GetCharField,
6241 _Jv_JNI_GetShortField,
6242 _Jv_JNI_GetIntField,
6243 _Jv_JNI_GetLongField,
6244 _Jv_JNI_GetFloatField,
6245 _Jv_JNI_GetDoubleField,
6246 _Jv_JNI_SetObjectField,
6247 _Jv_JNI_SetBooleanField,
6248 _Jv_JNI_SetByteField,
6249 _Jv_JNI_SetCharField,
6250 _Jv_JNI_SetShortField,
6251 _Jv_JNI_SetIntField,
6252 _Jv_JNI_SetLongField,
6253 _Jv_JNI_SetFloatField,
6254 _Jv_JNI_SetDoubleField,
6256 _Jv_JNI_GetStaticMethodID,
6258 _Jv_JNI_CallStaticObjectMethod,
6259 _Jv_JNI_CallStaticObjectMethodV,
6260 _Jv_JNI_CallStaticObjectMethodA,
6261 _Jv_JNI_CallStaticBooleanMethod,
6262 _Jv_JNI_CallStaticBooleanMethodV,
6263 _Jv_JNI_CallStaticBooleanMethodA,
6264 _Jv_JNI_CallStaticByteMethod,
6265 _Jv_JNI_CallStaticByteMethodV,
6266 _Jv_JNI_CallStaticByteMethodA,
6267 _Jv_JNI_CallStaticCharMethod,
6268 _Jv_JNI_CallStaticCharMethodV,
6269 _Jv_JNI_CallStaticCharMethodA,
6270 _Jv_JNI_CallStaticShortMethod,
6271 _Jv_JNI_CallStaticShortMethodV,
6272 _Jv_JNI_CallStaticShortMethodA,
6273 _Jv_JNI_CallStaticIntMethod,
6274 _Jv_JNI_CallStaticIntMethodV,
6275 _Jv_JNI_CallStaticIntMethodA,
6276 _Jv_JNI_CallStaticLongMethod,
6277 _Jv_JNI_CallStaticLongMethodV,
6278 _Jv_JNI_CallStaticLongMethodA,
6279 _Jv_JNI_CallStaticFloatMethod,
6280 _Jv_JNI_CallStaticFloatMethodV,
6281 _Jv_JNI_CallStaticFloatMethodA,
6282 _Jv_JNI_CallStaticDoubleMethod,
6283 _Jv_JNI_CallStaticDoubleMethodV,
6284 _Jv_JNI_CallStaticDoubleMethodA,
6285 _Jv_JNI_CallStaticVoidMethod,
6286 _Jv_JNI_CallStaticVoidMethodV,
6287 _Jv_JNI_CallStaticVoidMethodA,
6289 _Jv_JNI_GetStaticFieldID,
6291 _Jv_JNI_GetStaticObjectField,
6292 _Jv_JNI_GetStaticBooleanField,
6293 _Jv_JNI_GetStaticByteField,
6294 _Jv_JNI_GetStaticCharField,
6295 _Jv_JNI_GetStaticShortField,
6296 _Jv_JNI_GetStaticIntField,
6297 _Jv_JNI_GetStaticLongField,
6298 _Jv_JNI_GetStaticFloatField,
6299 _Jv_JNI_GetStaticDoubleField,
6300 _Jv_JNI_SetStaticObjectField,
6301 _Jv_JNI_SetStaticBooleanField,
6302 _Jv_JNI_SetStaticByteField,
6303 _Jv_JNI_SetStaticCharField,
6304 _Jv_JNI_SetStaticShortField,
6305 _Jv_JNI_SetStaticIntField,
6306 _Jv_JNI_SetStaticLongField,
6307 _Jv_JNI_SetStaticFloatField,
6308 _Jv_JNI_SetStaticDoubleField,
6311 _Jv_JNI_GetStringLength,
6312 _Jv_JNI_GetStringChars,
6313 _Jv_JNI_ReleaseStringChars,
6315 _Jv_JNI_NewStringUTF,
6316 _Jv_JNI_GetStringUTFLength,
6317 _Jv_JNI_GetStringUTFChars,
6318 _Jv_JNI_ReleaseStringUTFChars,
6320 _Jv_JNI_GetArrayLength,
6322 _Jv_JNI_NewObjectArray,
6323 _Jv_JNI_GetObjectArrayElement,
6324 _Jv_JNI_SetObjectArrayElement,
6326 _Jv_JNI_NewBooleanArray,
6327 _Jv_JNI_NewByteArray,
6328 _Jv_JNI_NewCharArray,
6329 _Jv_JNI_NewShortArray,
6330 _Jv_JNI_NewIntArray,
6331 _Jv_JNI_NewLongArray,
6332 _Jv_JNI_NewFloatArray,
6333 _Jv_JNI_NewDoubleArray,
6335 _Jv_JNI_GetBooleanArrayElements,
6336 _Jv_JNI_GetByteArrayElements,
6337 _Jv_JNI_GetCharArrayElements,
6338 _Jv_JNI_GetShortArrayElements,
6339 _Jv_JNI_GetIntArrayElements,
6340 _Jv_JNI_GetLongArrayElements,
6341 _Jv_JNI_GetFloatArrayElements,
6342 _Jv_JNI_GetDoubleArrayElements,
6344 _Jv_JNI_ReleaseBooleanArrayElements,
6345 _Jv_JNI_ReleaseByteArrayElements,
6346 _Jv_JNI_ReleaseCharArrayElements,
6347 _Jv_JNI_ReleaseShortArrayElements,
6348 _Jv_JNI_ReleaseIntArrayElements,
6349 _Jv_JNI_ReleaseLongArrayElements,
6350 _Jv_JNI_ReleaseFloatArrayElements,
6351 _Jv_JNI_ReleaseDoubleArrayElements,
6353 _Jv_JNI_GetBooleanArrayRegion,
6354 _Jv_JNI_GetByteArrayRegion,
6355 _Jv_JNI_GetCharArrayRegion,
6356 _Jv_JNI_GetShortArrayRegion,
6357 _Jv_JNI_GetIntArrayRegion,
6358 _Jv_JNI_GetLongArrayRegion,
6359 _Jv_JNI_GetFloatArrayRegion,
6360 _Jv_JNI_GetDoubleArrayRegion,
6361 _Jv_JNI_SetBooleanArrayRegion,
6362 _Jv_JNI_SetByteArrayRegion,
6363 _Jv_JNI_SetCharArrayRegion,
6364 _Jv_JNI_SetShortArrayRegion,
6365 _Jv_JNI_SetIntArrayRegion,
6366 _Jv_JNI_SetLongArrayRegion,
6367 _Jv_JNI_SetFloatArrayRegion,
6368 _Jv_JNI_SetDoubleArrayRegion,
6370 _Jv_JNI_RegisterNatives,
6371 _Jv_JNI_UnregisterNatives,
6373 _Jv_JNI_MonitorEnter,
6374 _Jv_JNI_MonitorExit,
6378 /* new JNI 1.2 functions */
6380 _Jv_JNI_GetStringRegion,
6381 _Jv_JNI_GetStringUTFRegion,
6383 _Jv_JNI_GetPrimitiveArrayCritical,
6384 _Jv_JNI_ReleasePrimitiveArrayCritical,
6386 _Jv_JNI_GetStringCritical,
6387 _Jv_JNI_ReleaseStringCritical,
6389 _Jv_JNI_NewWeakGlobalRef,
6390 _Jv_JNI_DeleteWeakGlobalRef,
6392 _Jv_JNI_ExceptionCheck,
6394 /* new JNI 1.4 functions */
6396 _Jv_JNI_NewDirectByteBuffer,
6397 _Jv_JNI_GetDirectBufferAddress,
6398 _Jv_JNI_GetDirectBufferCapacity
6402 /* Invocation API Functions ***************************************************/
6404 /* JNI_GetDefaultJavaVMInitArgs ************************************************
6406 Returns a default configuration for the Java VM.
6408 *******************************************************************************/
6410 jint JNI_GetDefaultJavaVMInitArgs(void *vm_args)
6412 JavaVMInitArgs *_vm_args;
6414 _vm_args = (JavaVMInitArgs *) vm_args;
6416 /* GNU classpath currently supports JNI 1.2 */
6418 switch (_vm_args->version) {
6419 case JNI_VERSION_1_1:
6420 _vm_args->version = JNI_VERSION_1_1;
6423 case JNI_VERSION_1_2:
6424 case JNI_VERSION_1_4:
6425 _vm_args->ignoreUnrecognized = JNI_FALSE;
6426 _vm_args->options = NULL;
6427 _vm_args->nOptions = 0;
6438 /* JNI_GetCreatedJavaVMs *******************************************************
6440 Returns all Java VMs that have been created. Pointers to VMs are written in
6441 the buffer vmBuf in the order they are created. At most bufLen number of
6442 entries will be written. The total number of created VMs is returned in
6445 *******************************************************************************/
6447 jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs)
6449 TRACEJNICALLS("JNI_GetCreatedJavaVMs(vmBuf=%p, jsize=%d, jsize=%p)", vmBuf, bufLen, nVMs);
6454 /* We currently only support 1 VM running. */
6456 vmBuf[0] = (JavaVM *) _Jv_jvm;
6463 /* JNI_CreateJavaVM ************************************************************
6465 Loads and initializes a Java VM. The current thread becomes the main thread.
6466 Sets the env argument to the JNI interface pointer of the main thread.
6468 *******************************************************************************/
6470 jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
6472 TRACEJNICALLS("JNI_CreateJavaVM(p_vm=%p, p_env=%p, vm_args=%p)", p_vm, p_env, vm_args);
6474 /* actually create the JVM */
6476 if (!vm_createjvm(p_vm, p_env, vm_args))
6484 * These are local overrides for various environment variables in Emacs.
6485 * Please do not remove this and leave it at the end of the file, where
6486 * Emacs will automagically detect them.
6487 * ---------------------------------------------------------------------
6490 * indent-tabs-mode: t
6494 * vim:noexpandtab:sw=4:ts=4: