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 8137 2007-06-22 16:41:36Z michi $
38 #include "mm/gc-common.h"
39 #include "mm/memory.h"
40 #include "native/jni.h"
41 #include "native/native.h"
43 #if defined(ENABLE_JAVASE)
44 # if defined(WITH_CLASSPATH_GNU)
45 # include "native/include/gnu_classpath_Pointer.h"
47 # if SIZEOF_VOID_P == 8
48 # include "native/include/gnu_classpath_Pointer64.h"
50 # include "native/include/gnu_classpath_Pointer32.h"
55 #include "native/include/java_lang_Object.h"
56 #include "native/include/java_lang_Byte.h"
57 #include "native/include/java_lang_Character.h"
58 #include "native/include/java_lang_Short.h"
59 #include "native/include/java_lang_Integer.h"
60 #include "native/include/java_lang_Boolean.h"
61 #include "native/include/java_lang_Long.h"
62 #include "native/include/java_lang_Float.h"
63 #include "native/include/java_lang_Double.h"
64 #include "native/include/java_lang_String.h"
65 #include "native/include/java_lang_Throwable.h"
67 #if defined(ENABLE_JAVASE)
68 # if defined(WITH_CLASSPATH_SUN)
69 # include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
72 # include "native/include/java_lang_ClassLoader.h"
74 # include "native/include/java_lang_reflect_Constructor.h"
75 # include "native/include/java_lang_reflect_Field.h"
76 # include "native/include/java_lang_reflect_Method.h"
78 # include "native/include/java_nio_Buffer.h"
80 # if defined(WITH_CLASSPATH_GNU)
81 # include "native/include/java_nio_DirectByteBufferImpl.h"
85 #if defined(ENABLE_JVMTI)
86 # include "native/jvmti/cacaodbg.h"
89 #include "native/vm/java_lang_Class.h"
91 #if defined(ENABLE_JAVASE)
92 # include "native/vm/java_lang_ClassLoader.h"
95 #include "threads/lock-common.h"
96 #include "threads/threads-common.h"
98 #include "toolbox/logging.h"
100 #include "vm/builtin.h"
101 #include "vm/exceptions.h"
102 #include "vm/global.h"
103 #include "vm/initialize.h"
104 #include "vm/resolve.h"
105 #include "vm/stringlocal.h"
108 #include "vm/jit/asmpart.h"
109 #include "vm/jit/jit.h"
110 #include "vm/jit/stacktrace.h"
112 #include "vmcore/loader.h"
113 #include "vmcore/options.h"
114 #include "vmcore/primitive.h"
115 #include "vmcore/statistics.h"
118 /* global variables ***********************************************************/
120 /* global reference table *****************************************************/
122 /* hashsize must be power of 2 */
124 #define HASHTABLE_GLOBAL_REF_SIZE 64 /* initial size of globalref-hash */
126 static hashtable *hashtable_global_ref; /* hashtable for globalrefs */
129 /* direct buffer stuff ********************************************************/
131 #if defined(ENABLE_JAVASE)
132 static classinfo *class_java_nio_Buffer;
133 static classinfo *class_java_nio_DirectByteBufferImpl;
134 static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
136 # if defined(WITH_CLASSPATH_GNU)
137 # if SIZEOF_VOID_P == 8
138 static classinfo *class_gnu_classpath_Pointer64;
140 static classinfo *class_gnu_classpath_Pointer32;
144 static methodinfo *dbbirw_init;
148 /* local reference table ******************************************************/
150 #if !defined(ENABLE_THREADS)
151 localref_table *_no_threads_localref_table;
155 /* accessing instance fields macros *******************************************/
157 #define SET_FIELD(o,type,f,value) \
158 *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset)) = (type) (value)
160 #define GET_FIELD(o,type,f) \
161 *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset))
164 /* some forward declarations **************************************************/
166 jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref);
167 jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity);
170 /* jni_init ********************************************************************
172 Initialize the JNI subsystem.
174 *******************************************************************************/
178 /* create global ref hashtable */
180 hashtable_global_ref = NEW(hashtable);
182 hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
185 #if defined(ENABLE_JAVASE)
186 /* direct buffer stuff */
188 if (!(class_java_nio_Buffer =
189 load_class_bootstrap(utf_new_char("java/nio/Buffer"))) ||
190 !link_class(class_java_nio_Buffer))
193 # if defined(WITH_CLASSPATH_GNU)
194 if (!(class_java_nio_DirectByteBufferImpl =
195 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
196 !link_class(class_java_nio_DirectByteBufferImpl))
199 if (!(class_java_nio_DirectByteBufferImpl_ReadWrite =
200 load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) ||
201 !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite))
205 class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite,
207 utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
210 # if SIZEOF_VOID_P == 8
211 if (!(class_gnu_classpath_Pointer64 =
212 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) ||
213 !link_class(class_gnu_classpath_Pointer64))
216 if (!(class_gnu_classpath_Pointer32 =
217 load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) ||
218 !link_class(class_gnu_classpath_Pointer32))
222 #endif /* defined(ENABLE_JAVASE) */
228 /* jni_init_localref_table *****************************************************
230 Initializes the local references table of the current thread.
232 *******************************************************************************/
234 bool jni_init_localref_table(void)
238 #if defined(ENABLE_GC_CACAO)
239 /* XXX this one will never get freed for the main thread;
240 call jni_free_localref_table() if you want to do it! */
241 lrt = NEW(localref_table);
243 lrt = GCNEW(localref_table);
249 lrt->capacity = LOCALREFTABLE_CAPACITY;
251 lrt->localframes = 1;
252 lrt->prev = LOCALREFTABLE;
254 /* clear the references array (memset is faster then a for-loop) */
256 MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY);
264 /* jni_init_localref_table *****************************************************
266 Frees the local references table of the current thread.
268 *******************************************************************************/
270 bool jni_free_localref_table(void)
274 #if defined(ENABLE_GC_CACAO)
278 assert(lrt->prev == NULL);
280 FREE(lrt, localref_table);
282 LOCALREFTABLE = NULL;
289 /* _Jv_jni_CallObjectMethod ****************************************************
291 Internal function to call Java Object methods.
293 *******************************************************************************/
295 static java_objectheader *_Jv_jni_CallObjectMethod(java_objectheader *o,
297 methodinfo *m, va_list ap)
300 java_objectheader *ro;
302 STATISTICS(jniinvokation());
305 exceptions_throw_nullpointerexception();
309 /* Class initialization is done by the JIT compiler. This is ok
310 since a static method always belongs to the declaring class. */
312 if (m->flags & ACC_STATIC) {
313 /* For static methods we reset the object. */
318 /* for convenience */
323 /* For instance methods we make a virtual function table lookup. */
325 resm = method_vftbl_lookup(vftbl, m);
328 STATISTICS(jnicallXmethodnvokation());
330 ro = vm_call_method_valist(resm, o, ap);
336 /* _Jv_jni_CallObjectMethodA ***************************************************
338 Internal function to call Java Object methods.
340 *******************************************************************************/
342 static java_objectheader *_Jv_jni_CallObjectMethodA(java_objectheader *o,
348 java_objectheader *ro;
350 STATISTICS(jniinvokation());
353 exceptions_throw_nullpointerexception();
357 /* Class initialization is done by the JIT compiler. This is ok
358 since a static method always belongs to the declaring class. */
360 if (m->flags & ACC_STATIC) {
361 /* For static methods we reset the object. */
366 /* for convenience */
371 /* For instance methods we make a virtual function table lookup. */
373 resm = method_vftbl_lookup(vftbl, m);
376 STATISTICS(jnicallXmethodnvokation());
378 ro = vm_call_method_jvalue(resm, o, args);
384 /* _Jv_jni_CallIntMethod *******************************************************
386 Internal function to call Java integer class methods (boolean,
387 byte, char, short, int).
389 *******************************************************************************/
391 static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl,
392 methodinfo *m, va_list ap)
397 STATISTICS(jniinvokation());
400 exceptions_throw_nullpointerexception();
404 /* Class initialization is done by the JIT compiler. This is ok
405 since a static method always belongs to the declaring class. */
407 if (m->flags & ACC_STATIC) {
408 /* For static methods we reset the object. */
413 /* for convenience */
418 /* For instance methods we make a virtual function table lookup. */
420 resm = method_vftbl_lookup(vftbl, m);
423 STATISTICS(jnicallXmethodnvokation());
425 i = vm_call_method_int_valist(resm, o, ap);
431 /* _Jv_jni_CallIntMethodA ******************************************************
433 Internal function to call Java integer class methods (boolean,
434 byte, char, short, int).
436 *******************************************************************************/
438 static jint _Jv_jni_CallIntMethodA(java_objectheader *o, vftbl_t *vftbl,
439 methodinfo *m, const jvalue *args)
444 STATISTICS(jniinvokation());
447 exceptions_throw_nullpointerexception();
451 /* Class initialization is done by the JIT compiler. This is ok
452 since a static method always belongs to the declaring class. */
454 if (m->flags & ACC_STATIC) {
455 /* For static methods we reset the object. */
460 /* for convenience */
465 /* For instance methods we make a virtual function table lookup. */
467 resm = method_vftbl_lookup(vftbl, m);
470 STATISTICS(jnicallXmethodnvokation());
472 i = vm_call_method_int_jvalue(resm, o, args);
478 /* _Jv_jni_CallLongMethod ******************************************************
480 Internal function to call Java long methods.
482 *******************************************************************************/
484 static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl,
485 methodinfo *m, va_list ap)
490 STATISTICS(jniinvokation());
493 exceptions_throw_nullpointerexception();
497 /* Class initialization is done by the JIT compiler. This is ok
498 since a static method always belongs to the declaring class. */
500 if (m->flags & ACC_STATIC) {
501 /* For static methods we reset the object. */
506 /* for convenience */
511 /* For instance methods we make a virtual function table lookup. */
513 resm = method_vftbl_lookup(vftbl, m);
516 STATISTICS(jnicallXmethodnvokation());
518 l = vm_call_method_long_valist(resm, o, ap);
524 /* _Jv_jni_CallLongMethodA *****************************************************
526 Internal function to call Java long methods.
528 *******************************************************************************/
530 static jlong _Jv_jni_CallLongMethodA(java_objectheader *o, vftbl_t *vftbl,
531 methodinfo *m, const jvalue *args)
536 STATISTICS(jniinvokation());
539 exceptions_throw_nullpointerexception();
543 /* Class initialization is done by the JIT compiler. This is ok
544 since a static method always belongs to the declaring class. */
546 if (m->flags & ACC_STATIC) {
547 /* For static methods we reset the object. */
552 /* for convenience */
557 /* For instance methods we make a virtual function table lookup. */
559 resm = method_vftbl_lookup(vftbl, m);
562 STATISTICS(jnicallXmethodnvokation());
564 l = vm_call_method_long_jvalue(resm, o, args);
570 /* _Jv_jni_CallFloatMethod *****************************************************
572 Internal function to call Java float methods.
574 *******************************************************************************/
576 static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl,
577 methodinfo *m, va_list ap)
582 /* Class initialization is done by the JIT compiler. This is ok
583 since a static method always belongs to the declaring class. */
585 if (m->flags & ACC_STATIC) {
586 /* For static methods we reset the object. */
591 /* for convenience */
596 /* For instance methods we make a virtual function table lookup. */
598 resm = method_vftbl_lookup(vftbl, m);
601 STATISTICS(jnicallXmethodnvokation());
603 f = vm_call_method_float_valist(resm, o, ap);
609 /* _Jv_jni_CallFloatMethodA ****************************************************
611 Internal function to call Java float methods.
613 *******************************************************************************/
615 static jfloat _Jv_jni_CallFloatMethodA(java_objectheader *o, vftbl_t *vftbl,
616 methodinfo *m, const jvalue *args)
621 /* Class initialization is done by the JIT compiler. This is ok
622 since a static method always belongs to the declaring class. */
624 if (m->flags & ACC_STATIC) {
625 /* For static methods we reset the object. */
630 /* for convenience */
635 /* For instance methods we make a virtual function table lookup. */
637 resm = method_vftbl_lookup(vftbl, m);
640 STATISTICS(jnicallXmethodnvokation());
642 f = vm_call_method_float_jvalue(resm, o, args);
648 /* _Jv_jni_CallDoubleMethod ****************************************************
650 Internal function to call Java double methods.
652 *******************************************************************************/
654 static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl,
655 methodinfo *m, va_list ap)
660 /* Class initialization is done by the JIT compiler. This is ok
661 since a static method always belongs to the declaring class. */
663 if (m->flags & ACC_STATIC) {
664 /* For static methods we reset the object. */
669 /* for convenience */
674 /* For instance methods we make a virtual function table lookup. */
676 resm = method_vftbl_lookup(vftbl, m);
679 d = vm_call_method_double_valist(resm, o, ap);
685 /* _Jv_jni_CallDoubleMethodA ***************************************************
687 Internal function to call Java double methods.
689 *******************************************************************************/
691 static jdouble _Jv_jni_CallDoubleMethodA(java_objectheader *o, vftbl_t *vftbl,
692 methodinfo *m, const jvalue *args)
697 /* Class initialization is done by the JIT compiler. This is ok
698 since a static method always belongs to the declaring class. */
700 if (m->flags & ACC_STATIC) {
701 /* For static methods we reset the object. */
706 /* for convenience */
711 /* For instance methods we make a virtual function table lookup. */
713 resm = method_vftbl_lookup(vftbl, m);
716 d = vm_call_method_double_jvalue(resm, o, args);
722 /* _Jv_jni_CallVoidMethod ******************************************************
724 Internal function to call Java void methods.
726 *******************************************************************************/
728 static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl,
729 methodinfo *m, va_list ap)
734 exceptions_throw_nullpointerexception();
738 /* Class initialization is done by the JIT compiler. This is ok
739 since a static method always belongs to the declaring class. */
741 if (m->flags & ACC_STATIC) {
742 /* For static methods we reset the object. */
747 /* for convenience */
752 /* For instance methods we make a virtual function table lookup. */
754 resm = method_vftbl_lookup(vftbl, m);
757 STATISTICS(jnicallXmethodnvokation());
759 (void) vm_call_method_valist(resm, o, ap);
763 /* _Jv_jni_CallVoidMethodA *****************************************************
765 Internal function to call Java void methods.
767 *******************************************************************************/
769 static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
770 methodinfo *m, const jvalue *args)
775 exceptions_throw_nullpointerexception();
779 /* Class initialization is done by the JIT compiler. This is ok
780 since a static method always belongs to the declaring class. */
782 if (m->flags & ACC_STATIC) {
783 /* For static methods we reset the object. */
788 /* for convenience */
793 /* For instance methods we make a virtual function table lookup. */
795 resm = method_vftbl_lookup(vftbl, m);
798 STATISTICS(jnicallXmethodnvokation());
800 (void) vm_call_method_jvalue(resm, o, args);
804 /* _Jv_jni_invokeNative ********************************************************
806 Invoke a method on the given object with the given arguments.
808 For instance methods OBJ must be != NULL and the method is looked up
809 in the vftbl of the object.
811 For static methods, OBJ is ignored.
813 *******************************************************************************/
815 #if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__M68K__) & !defined(__ARM__)
816 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
817 java_objectarray *params)
821 java_objectheader *ro;
824 java_objectheader *xptr;
827 exceptions_throw_nullpointerexception();
831 argcount = m->parseddesc->paramcount;
832 paramcount = argcount;
834 /* if method is non-static, remove the `this' pointer */
836 if (!(m->flags & ACC_STATIC))
839 /* For instance methods the object has to be an instance of the
840 class the method belongs to. For static methods the obj
841 parameter is ignored. */
843 if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
844 exceptions_throw_illegalargumentexception();
848 /* check if we got the right number of arguments */
850 if (((params == NULL) && (paramcount != 0)) ||
851 (params && (params->header.size != paramcount)))
853 exceptions_throw_illegalargumentexception();
857 /* for instance methods we need an object */
859 if (!(m->flags & ACC_STATIC) && (o == NULL)) {
860 /* XXX not sure if that is the correct exception */
861 exceptions_throw_nullpointerexception();
865 /* for static methods, zero object to make subsequent code simpler */
866 if (m->flags & ACC_STATIC)
870 /* for instance methods we must do a vftbl lookup */
871 resm = method_vftbl_lookup(o->vftbl, m);
874 /* for static methods, just for convenience */
878 vmargs = MNEW(vm_arg, argcount);
880 if (!vm_vmargs_from_objectarray(resm, o, vmargs, params)) {
881 MFREE(vmargs, vm_arg, argcount);
885 switch (resm->parseddesc->returntype.decltype) {
887 (void) vm_call_method_vmarg(resm, argcount, vmargs);
892 case PRIMITIVETYPE_BOOLEAN: {
894 java_lang_Boolean *bo;
896 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
898 ro = builtin_new(class_java_lang_Boolean);
900 /* setting the value of the object direct */
902 bo = (java_lang_Boolean *) ro;
907 case PRIMITIVETYPE_BYTE: {
911 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
913 ro = builtin_new(class_java_lang_Byte);
915 /* setting the value of the object direct */
917 bo = (java_lang_Byte *) ro;
922 case PRIMITIVETYPE_CHAR: {
924 java_lang_Character *co;
926 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
928 ro = builtin_new(class_java_lang_Character);
930 /* setting the value of the object direct */
932 co = (java_lang_Character *) ro;
937 case PRIMITIVETYPE_SHORT: {
941 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
943 ro = builtin_new(class_java_lang_Short);
945 /* setting the value of the object direct */
947 so = (java_lang_Short *) ro;
952 case PRIMITIVETYPE_INT: {
954 java_lang_Integer *io;
956 i = vm_call_method_int_vmarg(resm, argcount, vmargs);
958 ro = builtin_new(class_java_lang_Integer);
960 /* setting the value of the object direct */
962 io = (java_lang_Integer *) ro;
967 case PRIMITIVETYPE_LONG: {
971 l = vm_call_method_long_vmarg(resm, argcount, vmargs);
973 ro = builtin_new(class_java_lang_Long);
975 /* setting the value of the object direct */
977 lo = (java_lang_Long *) ro;
982 case PRIMITIVETYPE_FLOAT: {
986 f = vm_call_method_float_vmarg(resm, argcount, vmargs);
988 ro = builtin_new(class_java_lang_Float);
990 /* setting the value of the object direct */
992 fo = (java_lang_Float *) ro;
997 case PRIMITIVETYPE_DOUBLE: {
999 java_lang_Double *_do;
1001 d = vm_call_method_double_vmarg(resm, argcount, vmargs);
1003 ro = builtin_new(class_java_lang_Double);
1005 /* setting the value of the object direct */
1007 _do = (java_lang_Double *) ro;
1013 ro = vm_call_method_vmarg(resm, argcount, vmargs);
1017 /* if this happens the exception has already been set by
1018 fill_callblock_from_objectarray */
1020 MFREE(vmargs, vm_arg, argcount);
1025 MFREE(vmargs, vm_arg, argcount);
1027 xptr = exceptions_get_exception();
1030 /* clear exception pointer, we are calling JIT code again */
1032 exceptions_clear_exception();
1034 exceptions_throw_invocationtargetexception(xptr);
1040 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
1041 java_objectarray *params)
1044 java_objectheader *ro;
1047 java_objectheader *xptr;
1052 exceptions_throw_nullpointerexception();
1056 argcount = m->parseddesc->paramcount;
1057 paramcount = argcount;
1059 /* if method is non-static, remove the `this' pointer */
1061 if (!(m->flags & ACC_STATIC))
1064 /* For instance methods the object has to be an instance of the
1065 class the method belongs to. For static methods the obj
1066 parameter is ignored. */
1068 if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
1069 exceptions_throw_illegalargumentexception();
1073 /* check if we got the right number of arguments */
1075 if (((params == NULL) && (paramcount != 0)) ||
1076 (params && (params->header.size != paramcount)))
1078 exceptions_throw_illegalargumentexception();
1082 /* for instance methods we need an object */
1084 if (!(m->flags & ACC_STATIC) && (o == NULL)) {
1085 /* XXX not sure if that is the correct exception */
1086 exceptions_throw_nullpointerexception();
1090 /* for static methods, zero object to make subsequent code simpler */
1091 if (m->flags & ACC_STATIC)
1095 /* for instance methods we must do a vftbl lookup */
1096 resm = method_vftbl_lookup(o->vftbl, m);
1099 /* for static methods, just for convenience */
1103 /* mark start of dump memory area */
1105 dumpsize = dump_size();
1107 /* fill the argument array from a object-array */
1109 array = vm_array_from_objectarray(resm, o, params);
1111 if (array == NULL) {
1112 /* release dump area */
1114 dump_release(dumpsize);
1119 switch (resm->parseddesc->returntype.decltype) {
1121 (void) vm_call_array(resm, array);
1126 case PRIMITIVETYPE_BOOLEAN: {
1128 java_lang_Boolean *bo;
1130 i = vm_call_int_array(resm, array);
1132 ro = builtin_new(class_java_lang_Boolean);
1134 /* setting the value of the object direct */
1136 bo = (java_lang_Boolean *) ro;
1141 case PRIMITIVETYPE_BYTE: {
1145 i = vm_call_int_array(resm, array);
1147 ro = builtin_new(class_java_lang_Byte);
1149 /* setting the value of the object direct */
1151 bo = (java_lang_Byte *) ro;
1156 case PRIMITIVETYPE_CHAR: {
1158 java_lang_Character *co;
1160 i = vm_call_int_array(resm, array);
1162 ro = builtin_new(class_java_lang_Character);
1164 /* setting the value of the object direct */
1166 co = (java_lang_Character *) ro;
1171 case PRIMITIVETYPE_SHORT: {
1173 java_lang_Short *so;
1175 i = vm_call_int_array(resm, array);
1177 ro = builtin_new(class_java_lang_Short);
1179 /* setting the value of the object direct */
1181 so = (java_lang_Short *) ro;
1186 case PRIMITIVETYPE_INT: {
1188 java_lang_Integer *io;
1190 i = vm_call_int_array(resm, array);
1192 ro = builtin_new(class_java_lang_Integer);
1194 /* setting the value of the object direct */
1196 io = (java_lang_Integer *) ro;
1201 case PRIMITIVETYPE_LONG: {
1205 l = vm_call_long_array(resm, array);
1207 ro = builtin_new(class_java_lang_Long);
1209 /* setting the value of the object direct */
1211 lo = (java_lang_Long *) ro;
1216 case PRIMITIVETYPE_FLOAT: {
1218 java_lang_Float *fo;
1220 f = vm_call_float_array(resm, array);
1222 ro = builtin_new(class_java_lang_Float);
1224 /* setting the value of the object direct */
1226 fo = (java_lang_Float *) ro;
1231 case PRIMITIVETYPE_DOUBLE: {
1233 java_lang_Double *_do;
1235 d = vm_call_double_array(resm, array);
1237 ro = builtin_new(class_java_lang_Double);
1239 /* setting the value of the object direct */
1241 _do = (java_lang_Double *) ro;
1247 ro = vm_call_array(resm, array);
1251 /* if this happens the exception has already been set by
1252 fill_callblock_from_objectarray */
1254 /* release dump area */
1256 dump_release(dumpsize);
1261 xptr = exceptions_get_exception();
1264 /* clear exception pointer, we are calling JIT code again */
1266 exceptions_clear_exception();
1268 exceptions_throw_invocationtargetexception(xptr);
1271 /* release dump area */
1273 dump_release(dumpsize);
1280 /* GetVersion ******************************************************************
1282 Returns the major version number in the higher 16 bits and the
1283 minor version number in the lower 16 bits.
1285 *******************************************************************************/
1287 jint _Jv_JNI_GetVersion(JNIEnv *env)
1289 STATISTICS(jniinvokation());
1291 /* we support JNI 1.4 */
1293 return JNI_VERSION_1_4;
1297 /* Class Operations ***********************************************************/
1299 /* DefineClass *****************************************************************
1301 Loads a class from a buffer of raw class data. The buffer
1302 containing the raw class data is not referenced by the VM after the
1303 DefineClass call returns, and it may be discarded if desired.
1305 *******************************************************************************/
1307 jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
1308 const jbyte *buf, jsize bufLen)
1310 #if defined(ENABLE_JAVASE)
1311 java_lang_ClassLoader *cl;
1312 java_lang_String *s;
1316 STATISTICS(jniinvokation());
1318 cl = (java_lang_ClassLoader *) loader;
1319 s = (java_lang_String *) javastring_new_from_utf_string(name);
1320 ba = (java_bytearray *) buf;
1322 c = (jclass) _Jv_java_lang_ClassLoader_defineClass(cl, s, ba, 0, bufLen,
1325 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1327 vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration");
1329 /* keep compiler happy */
1336 /* FindClass *******************************************************************
1338 This function loads a locally-defined class. It searches the
1339 directories and zip files specified by the CLASSPATH environment
1340 variable for the class with the specified name.
1342 *******************************************************************************/
1344 jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
1346 #if defined(ENABLE_JAVASE)
1351 STATISTICS(jniinvokation());
1353 u = utf_new_char_classname((char *) name);
1355 /* Check stacktrace for classloader, if one found use it,
1356 otherwise use the system classloader. */
1358 /* Quote from the JNI documentation:
1360 In the Java 2 Platform, FindClass locates the class loader
1361 associated with the current native method. If the native code
1362 belongs to a system class, no class loader will be
1363 involved. Otherwise, the proper class loader will be invoked to
1364 load and link the named class. When FindClass is called through
1365 the Invocation Interface, there is no current native method or
1366 its associated class loader. In that case, the result of
1367 ClassLoader.getBaseClassLoader is used." */
1369 cc = stacktrace_getCurrentClass();
1372 c = load_class_from_sysloader(u);
1374 c = load_class_from_classloader(u, cc->classloader);
1382 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1384 vm_abort("_Jv_JNI_FindClass: not implemented in this configuration");
1386 /* keep compiler happy */
1393 /* GetSuperclass ***************************************************************
1395 If clazz represents any class other than the class Object, then
1396 this function returns the object that represents the superclass of
1397 the class specified by clazz.
1399 *******************************************************************************/
1401 jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
1405 STATISTICS(jniinvokation());
1407 c = ((classinfo *) sub)->super.cls;
1412 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
1416 /* IsAssignableFrom ************************************************************
1418 Determines whether an object of sub can be safely cast to sup.
1420 *******************************************************************************/
1422 jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
1424 java_lang_Class *csup;
1425 java_lang_Class *csub;
1427 csup = (java_lang_Class *) sup;
1428 csub = (java_lang_Class *) sub;
1430 STATISTICS(jniinvokation());
1432 return _Jv_java_lang_Class_isAssignableFrom(csup, csub);
1436 /* Throw ***********************************************************************
1438 Causes a java.lang.Throwable object to be thrown.
1440 *******************************************************************************/
1442 jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj)
1444 java_objectheader *o;
1446 STATISTICS(jniinvokation());
1448 o = (java_objectheader *) obj;
1450 exceptions_set_exception(o);
1456 /* ThrowNew ********************************************************************
1458 Constructs an exception object from the specified class with the
1459 message specified by message and causes that exception to be
1462 *******************************************************************************/
1464 jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg)
1467 java_objectheader *o;
1468 java_objectheader *s;
1470 STATISTICS(jniinvokation());
1472 c = (classinfo *) clazz;
1475 s = javastring_new_from_utf_string(msg);
1477 /* instantiate exception object */
1479 o = native_new_and_init_string(c, s);
1484 exceptions_set_exception(o);
1490 /* ExceptionOccurred ***********************************************************
1492 Determines if an exception is being thrown. The exception stays
1493 being thrown until either the native code calls ExceptionClear(),
1494 or the Java code handles the exception.
1496 *******************************************************************************/
1498 jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env)
1500 java_objectheader *o;
1502 STATISTICS(jniinvokation());
1504 o = exceptions_get_exception();
1506 return _Jv_JNI_NewLocalRef(env, (jthrowable) o);
1510 /* ExceptionDescribe ***********************************************************
1512 Prints an exception and a backtrace of the stack to a system
1513 error-reporting channel, such as stderr. This is a convenience
1514 routine provided for debugging.
1516 *******************************************************************************/
1518 void _Jv_JNI_ExceptionDescribe(JNIEnv *env)
1520 java_objectheader *o;
1523 STATISTICS(jniinvokation());
1525 o = exceptions_get_exception();
1528 /* clear exception, because we are calling jit code again */
1530 exceptions_clear_exception();
1532 /* get printStackTrace method from exception class */
1534 m = class_resolveclassmethod(o->vftbl->class,
1535 utf_printStackTrace,
1541 /* XXX what should we do? */
1544 /* print the stacktrace */
1546 (void) vm_call_method(m, o);
1551 /* ExceptionClear **************************************************************
1553 Clears any exception that is currently being thrown. If no
1554 exception is currently being thrown, this routine has no effect.
1556 *******************************************************************************/
1558 void _Jv_JNI_ExceptionClear(JNIEnv *env)
1560 STATISTICS(jniinvokation());
1562 exceptions_clear_exception();
1566 /* FatalError ******************************************************************
1568 Raises a fatal error and does not expect the VM to recover. This
1569 function does not return.
1571 *******************************************************************************/
1573 void _Jv_JNI_FatalError(JNIEnv *env, const char *msg)
1575 STATISTICS(jniinvokation());
1577 /* this seems to be the best way */
1579 vm_abort("JNI Fatal error: %s", msg);
1583 /* PushLocalFrame **************************************************************
1585 Creates a new local reference frame, in which at least a given
1586 number of local references can be created.
1588 *******************************************************************************/
1590 jint _Jv_JNI_PushLocalFrame(JNIEnv* env, jint capacity)
1593 localref_table *lrt;
1594 localref_table *nlrt;
1596 STATISTICS(jniinvokation());
1601 /* Allocate new local reference table on Java heap. Calculate the
1602 additional memory we have to allocate. */
1604 if (capacity > LOCALREFTABLE_CAPACITY)
1605 additionalrefs = capacity - LOCALREFTABLE_CAPACITY;
1609 #if defined(ENABLE_GC_CACAO)
1610 nlrt = MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
1612 nlrt = GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
1618 /* get current local reference table from thread */
1620 lrt = LOCALREFTABLE;
1622 /* Set up the new local reference table and add it to the local
1625 nlrt->capacity = capacity;
1627 nlrt->localframes = lrt->localframes + 1;
1630 /* store new local reference table in thread */
1632 LOCALREFTABLE = nlrt;
1638 /* PopLocalFrame ***************************************************************
1640 Pops off the current local reference frame, frees all the local
1641 references, and returns a local reference in the previous local
1642 reference frame for the given result object.
1644 *******************************************************************************/
1646 jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result)
1648 localref_table *lrt;
1649 localref_table *plrt;
1653 STATISTICS(jniinvokation());
1655 /* get current local reference table from thread */
1657 lrt = LOCALREFTABLE;
1659 localframes = lrt->localframes;
1661 /* Don't delete the top local frame, as this one is allocated in
1662 the native stub on the stack and is freed automagically on
1665 if (localframes == 1)
1666 return _Jv_JNI_NewLocalRef(env, result);
1668 /* release all current local frames */
1670 for (; localframes >= 1; localframes--) {
1671 /* get previous frame */
1675 /* clear all reference entries */
1677 MSET(&lrt->refs[0], 0, java_objectheader*, lrt->capacity);
1681 #if defined(ENABLE_GC_CACAO)
1682 /* for the exact GC local reference tables are not on the heap,
1683 so we need to free them explicitly here. */
1685 if (lrt->capacity > LOCALREFTABLE_CAPACITY)
1686 additionalrefs = lrt->capacity - LOCALREFTABLE_CAPACITY;
1690 MFREE(lrt, u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
1693 /* set new local references table */
1698 /* store new local reference table in thread */
1700 LOCALREFTABLE = lrt;
1702 /* add local reference and return the value */
1704 return _Jv_JNI_NewLocalRef(env, result);
1708 /* DeleteLocalRef **************************************************************
1710 Deletes the local reference pointed to by localRef.
1712 *******************************************************************************/
1714 void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef)
1716 java_objectheader *o;
1717 localref_table *lrt;
1720 STATISTICS(jniinvokation());
1722 o = (java_objectheader *) localRef;
1724 /* get local reference table (thread specific) */
1726 lrt = LOCALREFTABLE;
1728 /* go through all local frames */
1730 for (; lrt != NULL; lrt = lrt->prev) {
1732 /* and try to remove the reference */
1734 for (i = 0; i < lrt->capacity; i++) {
1735 if (lrt->refs[i] == o) {
1736 lrt->refs[i] = NULL;
1744 /* this should not happen */
1746 /* if (opt_checkjni) */
1747 /* FatalError(env, "Bad global or local ref passed to JNI"); */
1748 log_text("JNI-DeleteLocalRef: Local ref passed to JNI not found");
1752 /* IsSameObject ****************************************************************
1754 Tests whether two references refer to the same Java object.
1756 *******************************************************************************/
1758 jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2)
1760 STATISTICS(jniinvokation());
1769 /* NewLocalRef *****************************************************************
1771 Creates a new local reference that refers to the same object as ref.
1773 *******************************************************************************/
1775 jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref)
1777 localref_table *lrt;
1780 STATISTICS(jniinvokation());
1785 /* get local reference table (thread specific) */
1787 lrt = LOCALREFTABLE;
1789 /* Check if we have space for the requested reference? No,
1790 allocate a new frame. This is actually not what the spec says,
1791 but for compatibility reasons... */
1793 if (lrt->used == lrt->capacity) {
1794 if (_Jv_JNI_EnsureLocalCapacity(env, 16) != 0)
1797 /* get the new local reference table */
1799 lrt = LOCALREFTABLE;
1802 /* insert the reference */
1804 for (i = 0; i < lrt->capacity; i++) {
1805 if (lrt->refs[i] == NULL) {
1806 lrt->refs[i] = (java_objectheader *) ref;
1813 /* should not happen, just to be sure */
1817 /* keep compiler happy */
1823 /* EnsureLocalCapacity *********************************************************
1825 Ensures that at least a given number of local references can be
1826 created in the current thread
1828 *******************************************************************************/
1830 jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity)
1832 localref_table *lrt;
1834 STATISTICS(jniinvokation());
1836 /* get local reference table (thread specific) */
1838 lrt = LOCALREFTABLE;
1840 /* check if capacity elements are available in the local references table */
1842 if ((lrt->used + capacity) > lrt->capacity)
1843 return _Jv_JNI_PushLocalFrame(env, capacity);
1849 /* AllocObject *****************************************************************
1851 Allocates a new Java object without invoking any of the
1852 constructors for the object. Returns a reference to the object.
1854 *******************************************************************************/
1856 jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
1859 java_objectheader *o;
1861 STATISTICS(jniinvokation());
1863 c = (classinfo *) clazz;
1865 if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
1866 exceptions_throw_instantiationexception(c);
1872 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1876 /* NewObject *******************************************************************
1878 Programmers place all arguments that are to be passed to the
1879 constructor immediately following the methodID
1880 argument. NewObject() accepts these arguments and passes them to
1881 the Java method that the programmer wishes to invoke.
1883 *******************************************************************************/
1885 jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
1887 java_objectheader *o;
1892 STATISTICS(jniinvokation());
1894 c = (classinfo *) clazz;
1895 m = (methodinfo *) methodID;
1904 /* call constructor */
1906 va_start(ap, methodID);
1907 _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
1910 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1914 /* NewObjectV ******************************************************************
1916 Programmers place all arguments that are to be passed to the
1917 constructor in an args argument of type va_list that immediately
1918 follows the methodID argument. NewObjectV() accepts these
1919 arguments, and, in turn, passes them to the Java method that the
1920 programmer wishes to invoke.
1922 *******************************************************************************/
1924 jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
1927 java_objectheader *o;
1931 STATISTICS(jniinvokation());
1933 c = (classinfo *) clazz;
1934 m = (methodinfo *) methodID;
1943 /* call constructor */
1945 _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
1947 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1951 /* NewObjectA *****************************************************************
1953 Programmers place all arguments that are to be passed to the
1954 constructor in an args array of jvalues that immediately follows
1955 the methodID argument. NewObjectA() accepts the arguments in this
1956 array, and, in turn, passes them to the Java method that the
1957 programmer wishes to invoke.
1959 *******************************************************************************/
1961 jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
1964 java_objectheader *o;
1968 STATISTICS(jniinvokation());
1970 c = (classinfo *) clazz;
1971 m = (methodinfo *) methodID;
1980 /* call constructor */
1982 _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
1984 return _Jv_JNI_NewLocalRef(env, (jobject) o);
1988 /* GetObjectClass **************************************************************
1990 Returns the class of an object.
1992 *******************************************************************************/
1994 jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj)
1996 java_objectheader *o;
1999 STATISTICS(jniinvokation());
2001 o = (java_objectheader *) obj;
2003 if ((o == NULL) || (o->vftbl == NULL))
2006 c = o->vftbl->class;
2008 return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
2012 /* IsInstanceOf ****************************************************************
2014 Tests whether an object is an instance of a class.
2016 *******************************************************************************/
2018 jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
2021 java_lang_Object *o;
2023 STATISTICS(jniinvokation());
2025 c = (java_lang_Class *) clazz;
2026 o = (java_lang_Object *) obj;
2028 return _Jv_java_lang_Class_isInstance(c, o);
2032 /* Reflection Support *********************************************************/
2034 /* FromReflectedMethod *********************************************************
2036 Converts java.lang.reflect.Method or java.lang.reflect.Constructor
2037 object to a method ID.
2039 *******************************************************************************/
2041 jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
2043 #if defined(ENABLE_JAVASE)
2044 java_objectheader *o;
2049 STATISTICS(jniinvokation());
2051 o = (java_objectheader *) method;
2056 if (builtin_instanceof(o, class_java_lang_reflect_Method)) {
2057 java_lang_reflect_Method *rm;
2059 rm = (java_lang_reflect_Method *) method;
2060 c = (classinfo *) (rm->clazz);
2063 else if (builtin_instanceof(o, class_java_lang_reflect_Constructor)) {
2064 java_lang_reflect_Constructor *rc;
2066 rc = (java_lang_reflect_Constructor *) method;
2067 c = (classinfo *) (rc->clazz);
2073 m = &(c->methods[slot]);
2075 return (jmethodID) m;
2077 vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
2079 /* keep compiler happy */
2086 /* FromReflectedField **********************************************************
2088 Converts a java.lang.reflect.Field to a field ID.
2090 *******************************************************************************/
2092 jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
2094 #if defined(ENABLE_JAVASE)
2095 java_lang_reflect_Field *rf;
2099 STATISTICS(jniinvokation());
2101 rf = (java_lang_reflect_Field *) field;
2106 c = (classinfo *) rf->clazz;
2107 f = &(c->fields[rf->slot]);
2109 return (jfieldID) f;
2111 vm_abort("_Jv_JNI_FromReflectedField: not implemented in this configuration");
2113 /* keep compiler happy */
2120 /* ToReflectedMethod ***********************************************************
2122 Converts a method ID derived from cls to an instance of the
2123 java.lang.reflect.Method class or to an instance of the
2124 java.lang.reflect.Constructor class.
2126 *******************************************************************************/
2128 jobject _Jv_JNI_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID,
2131 STATISTICS(jniinvokation());
2133 log_text("JNI-Call: ToReflectedMethod: IMPLEMENT ME!");
2139 /* ToReflectedField ************************************************************
2141 Converts a field ID derived from cls to an instance of the
2142 java.lang.reflect.Field class.
2144 *******************************************************************************/
2146 jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID,
2149 STATISTICS(jniinvokation());
2151 log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!");
2157 /* Calling Instance Methods ***************************************************/
2159 /* GetMethodID *****************************************************************
2161 Returns the method ID for an instance (nonstatic) method of a class
2162 or interface. The method may be defined in one of the clazz's
2163 superclasses and inherited by clazz. The method is determined by
2164 its name and signature.
2166 GetMethodID() causes an uninitialized class to be initialized.
2168 *******************************************************************************/
2170 jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
2178 STATISTICS(jniinvokation());
2180 c = (classinfo *) clazz;
2185 if (!(c->state & CLASS_INITIALIZED))
2186 if (!initialize_class(c))
2189 /* try to get the method of the class or one of it's superclasses */
2191 uname = utf_new_char((char *) name);
2192 udesc = utf_new_char((char *) sig);
2194 m = class_resolvemethod(c, uname, udesc);
2196 if ((m == NULL) || (m->flags & ACC_STATIC)) {
2197 exceptions_throw_nosuchmethoderror(c, uname, udesc);
2202 return (jmethodID) m;
2206 /* JNI-functions for calling instance methods *********************************/
2208 jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2211 java_objectheader *o;
2213 java_objectheader *ret;
2216 o = (java_objectheader *) obj;
2217 m = (methodinfo *) methodID;
2219 va_start(ap, methodID);
2220 ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, ap);
2223 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2227 jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2230 java_objectheader *o;
2232 java_objectheader *ret;
2234 o = (java_objectheader *) obj;
2235 m = (methodinfo *) methodID;
2237 ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, args);
2239 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2243 jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2246 java_objectheader *o;
2248 java_objectheader *ret;
2250 o = (java_objectheader *) obj;
2251 m = (methodinfo *) methodID;
2253 ret = _Jv_jni_CallObjectMethodA(o, o->vftbl, m, args);
2255 return _Jv_JNI_NewLocalRef(env, (jobject) ret);
2259 jboolean _Jv_JNI_CallBooleanMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2262 java_objectheader *o;
2267 o = (java_objectheader *) obj;
2268 m = (methodinfo *) methodID;
2270 va_start(ap, methodID);
2271 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2278 jboolean _Jv_JNI_CallBooleanMethodV(JNIEnv *env, jobject obj,
2279 jmethodID methodID, va_list args)
2281 java_objectheader *o;
2285 o = (java_objectheader *) obj;
2286 m = (methodinfo *) methodID;
2288 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2294 jboolean _Jv_JNI_CallBooleanMethodA(JNIEnv *env, jobject obj,
2295 jmethodID methodID, const jvalue *args)
2297 java_objectheader *o;
2301 o = (java_objectheader *) obj;
2302 m = (methodinfo *) methodID;
2304 b = _Jv_jni_CallIntMethodA(o, o->vftbl, m, args);
2310 jbyte _Jv_JNI_CallByteMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2312 java_objectheader *o;
2317 o = (java_objectheader *) obj;
2318 m = (methodinfo *) methodID;
2320 va_start(ap, methodID);
2321 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2329 jbyte _Jv_JNI_CallByteMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2332 java_objectheader *o;
2336 o = (java_objectheader *) obj;
2337 m = (methodinfo *) methodID;
2339 b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2345 jbyte _Jv_JNI_CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2348 log_text("JNI-Call: CallByteMethodA: IMPLEMENT ME!");
2354 jchar _Jv_JNI_CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2356 java_objectheader *o;
2361 o = (java_objectheader *) obj;
2362 m = (methodinfo *) methodID;
2364 va_start(ap, methodID);
2365 c = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2372 jchar _Jv_JNI_CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2375 java_objectheader *o;
2379 o = (java_objectheader *) obj;
2380 m = (methodinfo *) methodID;
2382 c = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2388 jchar _Jv_JNI_CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2391 log_text("JNI-Call: CallCharMethodA: IMPLEMENT ME!");
2397 jshort _Jv_JNI_CallShortMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2400 java_objectheader *o;
2405 o = (java_objectheader *) obj;
2406 m = (methodinfo *) methodID;
2408 va_start(ap, methodID);
2409 s = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2416 jshort _Jv_JNI_CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2419 java_objectheader *o;
2423 o = (java_objectheader *) obj;
2424 m = (methodinfo *) methodID;
2426 s = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2432 jshort _Jv_JNI_CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2435 log_text("JNI-Call: CallShortMethodA: IMPLEMENT ME!");
2442 jint _Jv_JNI_CallIntMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2444 java_objectheader *o;
2449 o = (java_objectheader *) obj;
2450 m = (methodinfo *) methodID;
2452 va_start(ap, methodID);
2453 i = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
2460 jint _Jv_JNI_CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2463 java_objectheader *o;
2467 o = (java_objectheader *) obj;
2468 m = (methodinfo *) methodID;
2470 i = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
2476 jint _Jv_JNI_CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2479 log_text("JNI-Call: CallIntMethodA: IMPLEMENT ME!");
2486 jlong _Jv_JNI_CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2488 java_objectheader *o;
2493 o = (java_objectheader *) obj;
2494 m = (methodinfo *) methodID;
2496 va_start(ap, methodID);
2497 l = _Jv_jni_CallLongMethod(o, o->vftbl, m, ap);
2504 jlong _Jv_JNI_CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2507 java_objectheader *o;
2511 o = (java_objectheader *) obj;
2512 m = (methodinfo *) methodID;
2514 l = _Jv_jni_CallLongMethod(o, o->vftbl, m, args);
2520 jlong _Jv_JNI_CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2523 log_text("JNI-Call: CallLongMethodA: IMPLEMENT ME!");
2530 jfloat _Jv_JNI_CallFloatMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2533 java_objectheader *o;
2538 o = (java_objectheader *) obj;
2539 m = (methodinfo *) methodID;
2541 va_start(ap, methodID);
2542 f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, ap);
2549 jfloat _Jv_JNI_CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2552 java_objectheader *o;
2556 o = (java_objectheader *) obj;
2557 m = (methodinfo *) methodID;
2559 f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, args);
2565 jfloat _Jv_JNI_CallFloatMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2568 log_text("JNI-Call: CallFloatMethodA: IMPLEMENT ME!");
2575 jdouble _Jv_JNI_CallDoubleMethod(JNIEnv *env, jobject obj, jmethodID methodID,
2578 java_objectheader *o;
2583 o = (java_objectheader *) obj;
2584 m = (methodinfo *) methodID;
2586 va_start(ap, methodID);
2587 d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, ap);
2594 jdouble _Jv_JNI_CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2597 java_objectheader *o;
2601 o = (java_objectheader *) obj;
2602 m = (methodinfo *) methodID;
2604 d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, args);
2610 jdouble _Jv_JNI_CallDoubleMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2613 log_text("JNI-Call: CallDoubleMethodA: IMPLEMENT ME!");
2620 void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
2622 java_objectheader *o;
2626 o = (java_objectheader *) obj;
2627 m = (methodinfo *) methodID;
2629 va_start(ap, methodID);
2630 _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
2635 void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
2638 java_objectheader *o;
2641 o = (java_objectheader *) obj;
2642 m = (methodinfo *) methodID;
2644 _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
2648 void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
2651 java_objectheader *o;
2654 o = (java_objectheader *) obj;
2655 m = (methodinfo *) methodID;
2657 _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
2662 jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
2663 jclass clazz, jmethodID methodID,
2666 java_objectheader *o;
2669 java_objectheader *r;
2672 o = (java_objectheader *) obj;
2673 c = (classinfo *) clazz;
2674 m = (methodinfo *) methodID;
2676 va_start(ap, methodID);
2677 r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
2680 return _Jv_JNI_NewLocalRef(env, (jobject) r);
2684 jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
2685 jclass clazz, jmethodID methodID,
2688 java_objectheader *o;
2691 java_objectheader *r;
2693 o = (java_objectheader *) obj;
2694 c = (classinfo *) clazz;
2695 m = (methodinfo *) methodID;
2697 r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
2699 return _Jv_JNI_NewLocalRef(env, (jobject) r);
2703 jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj,
2704 jclass clazz, jmethodID methodID,
2707 log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
2709 return _Jv_JNI_NewLocalRef(env, NULL);
2714 jboolean _Jv_JNI_CallNonvirtualBooleanMethod(JNIEnv *env, jobject obj,
2715 jclass clazz, jmethodID methodID,
2718 java_objectheader *o;
2724 o = (java_objectheader *) obj;
2725 c = (classinfo *) clazz;
2726 m = (methodinfo *) methodID;
2728 va_start(ap, methodID);
2729 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2736 jboolean _Jv_JNI_CallNonvirtualBooleanMethodV(JNIEnv *env, jobject obj,
2737 jclass clazz, jmethodID methodID,
2740 java_objectheader *o;
2745 o = (java_objectheader *) obj;
2746 c = (classinfo *) clazz;
2747 m = (methodinfo *) methodID;
2749 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2755 jboolean _Jv_JNI_CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj,
2756 jclass clazz, jmethodID methodID,
2759 log_text("JNI-Call: CallNonvirtualBooleanMethodA: IMPLEMENT ME!");
2765 jbyte _Jv_JNI_CallNonvirtualByteMethod(JNIEnv *env, jobject obj, jclass clazz,
2766 jmethodID methodID, ...)
2768 java_objectheader *o;
2774 o = (java_objectheader *) obj;
2775 c = (classinfo *) clazz;
2776 m = (methodinfo *) methodID;
2778 va_start(ap, methodID);
2779 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2786 jbyte _Jv_JNI_CallNonvirtualByteMethodV(JNIEnv *env, jobject obj, jclass clazz,
2787 jmethodID methodID, va_list args)
2789 java_objectheader *o;
2794 o = (java_objectheader *) obj;
2795 c = (classinfo *) clazz;
2796 m = (methodinfo *) methodID;
2798 b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2804 jbyte _Jv_JNI_CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz,
2805 jmethodID methodID, const jvalue *args)
2807 log_text("JNI-Call: CallNonvirtualByteMethodA: IMPLEMENT ME!");
2814 jchar _Jv_JNI_CallNonvirtualCharMethod(JNIEnv *env, jobject obj, jclass clazz,
2815 jmethodID methodID, ...)
2817 java_objectheader *o;
2823 o = (java_objectheader *) obj;
2824 c = (classinfo *) clazz;
2825 m = (methodinfo *) methodID;
2827 va_start(ap, methodID);
2828 ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2835 jchar _Jv_JNI_CallNonvirtualCharMethodV(JNIEnv *env, jobject obj, jclass clazz,
2836 jmethodID methodID, va_list args)
2838 java_objectheader *o;
2843 o = (java_objectheader *) obj;
2844 c = (classinfo *) clazz;
2845 m = (methodinfo *) methodID;
2847 ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2853 jchar _Jv_JNI_CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz,
2854 jmethodID methodID, const jvalue *args)
2856 log_text("JNI-Call: CallNonvirtualCharMethodA: IMPLEMENT ME!");
2863 jshort _Jv_JNI_CallNonvirtualShortMethod(JNIEnv *env, jobject obj,
2864 jclass clazz, jmethodID methodID, ...)
2866 java_objectheader *o;
2872 o = (java_objectheader *) obj;
2873 c = (classinfo *) clazz;
2874 m = (methodinfo *) methodID;
2876 va_start(ap, methodID);
2877 s = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2884 jshort _Jv_JNI_CallNonvirtualShortMethodV(JNIEnv *env, jobject obj,
2885 jclass clazz, jmethodID methodID,
2888 java_objectheader *o;
2893 o = (java_objectheader *) obj;
2894 c = (classinfo *) clazz;
2895 m = (methodinfo *) methodID;
2897 s = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2903 jshort _Jv_JNI_CallNonvirtualShortMethodA(JNIEnv *env, jobject obj,
2904 jclass clazz, jmethodID methodID,
2907 log_text("JNI-Call: CallNonvirtualShortMethodA: IMPLEMENT ME!");
2914 jint _Jv_JNI_CallNonvirtualIntMethod(JNIEnv *env, jobject obj, jclass clazz,
2915 jmethodID methodID, ...)
2917 java_objectheader *o;
2923 o = (java_objectheader *) obj;
2924 c = (classinfo *) clazz;
2925 m = (methodinfo *) methodID;
2927 va_start(ap, methodID);
2928 i = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
2935 jint _Jv_JNI_CallNonvirtualIntMethodV(JNIEnv *env, jobject obj, jclass clazz,
2936 jmethodID methodID, va_list args)
2938 java_objectheader *o;
2943 o = (java_objectheader *) obj;
2944 c = (classinfo *) clazz;
2945 m = (methodinfo *) methodID;
2947 i = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
2953 jint _Jv_JNI_CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz,
2954 jmethodID methodID, const jvalue *args)
2956 log_text("JNI-Call: CallNonvirtualIntMethodA: IMPLEMENT ME!");
2963 jlong _Jv_JNI_CallNonvirtualLongMethod(JNIEnv *env, jobject obj, jclass clazz,
2964 jmethodID methodID, ...)
2966 java_objectheader *o;
2972 o = (java_objectheader *) obj;
2973 c = (classinfo *) clazz;
2974 m = (methodinfo *) methodID;
2976 va_start(ap, methodID);
2977 l = _Jv_jni_CallLongMethod(o, c->vftbl, m, ap);
2984 jlong _Jv_JNI_CallNonvirtualLongMethodV(JNIEnv *env, jobject obj, jclass clazz,
2985 jmethodID methodID, va_list args)
2987 java_objectheader *o;
2992 o = (java_objectheader *) obj;
2993 c = (classinfo *) clazz;
2994 m = (methodinfo *) methodID;
2996 l = _Jv_jni_CallLongMethod(o, c->vftbl, m, args);
3002 jlong _Jv_JNI_CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz,
3003 jmethodID methodID, const jvalue *args)
3005 log_text("JNI-Call: CallNonvirtualLongMethodA: IMPLEMENT ME!");
3012 jfloat _Jv_JNI_CallNonvirtualFloatMethod(JNIEnv *env, jobject obj,
3013 jclass clazz, jmethodID methodID, ...)
3015 java_objectheader *o;
3021 o = (java_objectheader *) obj;
3022 c = (classinfo *) clazz;
3023 m = (methodinfo *) methodID;
3025 va_start(ap, methodID);
3026 f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, ap);
3033 jfloat _Jv_JNI_CallNonvirtualFloatMethodV(JNIEnv *env, jobject obj,
3034 jclass clazz, jmethodID methodID,
3037 java_objectheader *o;
3042 o = (java_objectheader *) obj;
3043 c = (classinfo *) clazz;
3044 m = (methodinfo *) methodID;
3046 f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, args);
3052 jfloat _Jv_JNI_CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj,
3053 jclass clazz, jmethodID methodID,
3056 log_text("JNI-Call: CallNonvirtualFloatMethodA: IMPLEMENT ME!");
3063 jdouble _Jv_JNI_CallNonvirtualDoubleMethod(JNIEnv *env, jobject obj,
3064 jclass clazz, jmethodID methodID,
3067 java_objectheader *o;
3073 o = (java_objectheader *) obj;
3074 c = (classinfo *) clazz;
3075 m = (methodinfo *) methodID;
3077 va_start(ap, methodID);
3078 d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, ap);
3085 jdouble _Jv_JNI_CallNonvirtualDoubleMethodV(JNIEnv *env, jobject obj,
3086 jclass clazz, jmethodID methodID,
3089 java_objectheader *o;
3094 o = (java_objectheader *) obj;
3095 c = (classinfo *) clazz;
3096 m = (methodinfo *) methodID;
3098 d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, args);
3104 jdouble _Jv_JNI_CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj,
3105 jclass clazz, jmethodID methodID,
3108 log_text("JNI-Call: CallNonvirtualDoubleMethodA: IMPLEMENT ME!");
3115 void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz,
3116 jmethodID methodID, ...)
3118 java_objectheader *o;
3123 o = (java_objectheader *) obj;
3124 c = (classinfo *) clazz;
3125 m = (methodinfo *) methodID;
3127 va_start(ap, methodID);
3128 _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap);
3133 void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
3134 jmethodID methodID, va_list args)
3136 java_objectheader *o;
3140 o = (java_objectheader *) obj;
3141 c = (classinfo *) clazz;
3142 m = (methodinfo *) methodID;
3144 _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
3148 void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
3149 jmethodID methodID, const jvalue * args)
3151 java_objectheader *o;
3155 o = (java_objectheader *) obj;
3156 c = (classinfo *) clazz;
3157 m = (methodinfo *) methodID;
3159 _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
3163 /* Accessing Fields of Objects ************************************************/
3165 /* GetFieldID ******************************************************************
3167 Returns the field ID for an instance (nonstatic) field of a
3168 class. The field is specified by its name and signature. The
3169 Get<type>Field and Set<type>Field families of accessor functions
3170 use field IDs to retrieve object fields.
3172 *******************************************************************************/
3174 jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
3182 STATISTICS(jniinvokation());
3184 c = (classinfo *) clazz;
3186 /* XXX NPE check? */
3188 uname = utf_new_char((char *) name);
3189 udesc = utf_new_char((char *) sig);
3191 f = class_findfield(c, uname, udesc);
3194 exceptions_throw_nosuchfielderror(c, uname);
3196 return (jfieldID) f;
3200 /* Get<type>Field Routines *****************************************************
3202 This family of accessor routines returns the value of an instance
3203 (nonstatic) field of an object. The field to access is specified by
3204 a field ID obtained by calling GetFieldID().
3206 *******************************************************************************/
3208 jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)
3210 java_objectheader *o;
3212 STATISTICS(jniinvokation());
3214 o = GET_FIELD(obj, java_objectheader*, fieldID);
3216 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3220 jboolean _Jv_JNI_GetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID)
3224 STATISTICS(jniinvokation());
3226 i = GET_FIELD(obj, s4, fieldID);
3228 return (jboolean) i;
3232 jbyte _Jv_JNI_GetByteField(JNIEnv *env, jobject obj, jfieldID fieldID)
3236 STATISTICS(jniinvokation());
3238 i = GET_FIELD(obj, s4, fieldID);
3244 jchar _Jv_JNI_GetCharField(JNIEnv *env, jobject obj, jfieldID fieldID)
3248 STATISTICS(jniinvokation());
3250 i = GET_FIELD(obj, s4, fieldID);
3256 jshort _Jv_JNI_GetShortField(JNIEnv *env, jobject obj, jfieldID fieldID)
3260 STATISTICS(jniinvokation());
3262 i = GET_FIELD(obj, s4, fieldID);
3268 jint _Jv_JNI_GetIntField(JNIEnv *env, jobject obj, jfieldID fieldID)
3270 java_objectheader *o;
3274 STATISTICS(jniinvokation());
3276 o = (java_objectheader *) obj;
3277 f = (fieldinfo *) fieldID;
3279 i = GET_FIELD(o, s4, f);
3285 jlong _Jv_JNI_GetLongField(JNIEnv *env, jobject obj, jfieldID fieldID)
3289 STATISTICS(jniinvokation());
3291 l = GET_FIELD(obj, s8, fieldID);
3297 jfloat _Jv_JNI_GetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID)
3301 STATISTICS(jniinvokation());
3303 f = GET_FIELD(obj, float, fieldID);
3309 jdouble _Jv_JNI_GetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID)
3313 STATISTICS(jniinvokation());
3315 d = GET_FIELD(obj, double, fieldID);
3321 /* Set<type>Field Routines *****************************************************
3323 This family of accessor routines sets the value of an instance
3324 (nonstatic) field of an object. The field to access is specified by
3325 a field ID obtained by calling GetFieldID().
3327 *******************************************************************************/
3329 void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID,
3332 STATISTICS(jniinvokation());
3334 SET_FIELD(obj, java_objectheader*, fieldID, value);
3338 void _Jv_JNI_SetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID,
3341 STATISTICS(jniinvokation());
3343 SET_FIELD(obj, s4, fieldID, value);
3347 void _Jv_JNI_SetByteField(JNIEnv *env, jobject obj, jfieldID fieldID,
3350 STATISTICS(jniinvokation());
3352 SET_FIELD(obj, s4, fieldID, value);
3356 void _Jv_JNI_SetCharField(JNIEnv *env, jobject obj, jfieldID fieldID,
3359 STATISTICS(jniinvokation());
3361 SET_FIELD(obj, s4, fieldID, value);
3365 void _Jv_JNI_SetShortField(JNIEnv *env, jobject obj, jfieldID fieldID,
3368 STATISTICS(jniinvokation());
3370 SET_FIELD(obj, s4, fieldID, value);
3374 void _Jv_JNI_SetIntField(JNIEnv *env, jobject obj, jfieldID fieldID, jint value)
3376 STATISTICS(jniinvokation());
3378 SET_FIELD(obj, s4, fieldID, value);
3382 void _Jv_JNI_SetLongField(JNIEnv *env, jobject obj, jfieldID fieldID,
3385 STATISTICS(jniinvokation());
3387 SET_FIELD(obj, s8, fieldID, value);
3391 void _Jv_JNI_SetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID,
3394 STATISTICS(jniinvokation());
3396 SET_FIELD(obj, float, fieldID, value);
3400 void _Jv_JNI_SetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID,
3403 STATISTICS(jniinvokation());
3405 SET_FIELD(obj, double, fieldID, value);
3409 /* Calling Static Methods *****************************************************/
3411 /* GetStaticMethodID ***********************************************************
3413 Returns the method ID for a static method of a class. The method is
3414 specified by its name and signature.
3416 GetStaticMethodID() causes an uninitialized class to be
3419 *******************************************************************************/
3421 jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name,
3429 STATISTICS(jniinvokation());
3431 c = (classinfo *) clazz;
3436 if (!(c->state & CLASS_INITIALIZED))
3437 if (!initialize_class(c))
3440 /* try to get the static method of the class */
3442 uname = utf_new_char((char *) name);
3443 udesc = utf_new_char((char *) sig);
3445 m = class_resolvemethod(c, uname, udesc);
3447 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
3448 exceptions_throw_nosuchmethoderror(c, uname, udesc);
3453 return (jmethodID) m;
3457 jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz,
3458 jmethodID methodID, ...)
3461 java_objectheader *o;
3464 m = (methodinfo *) methodID;
3466 va_start(ap, methodID);
3467 o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
3470 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3474 jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz,
3475 jmethodID methodID, va_list args)
3478 java_objectheader *o;
3480 m = (methodinfo *) methodID;
3482 o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
3484 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3488 jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
3489 jmethodID methodID, const jvalue *args)
3492 java_objectheader *o;
3494 m = (methodinfo *) methodID;
3496 o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
3498 return _Jv_JNI_NewLocalRef(env, (jobject) o);
3502 jboolean _Jv_JNI_CallStaticBooleanMethod(JNIEnv *env, jclass clazz,
3503 jmethodID methodID, ...)
3509 m = (methodinfo *) methodID;
3511 va_start(ap, methodID);
3512 b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3519 jboolean _Jv_JNI_CallStaticBooleanMethodV(JNIEnv *env, jclass clazz,
3520 jmethodID methodID, va_list args)
3525 m = (methodinfo *) methodID;
3527 b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3533 jboolean _Jv_JNI_CallStaticBooleanMethodA(JNIEnv *env, jclass clazz,
3534 jmethodID methodID, const jvalue *args)
3539 m = (methodinfo *) methodID;
3541 b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3547 jbyte _Jv_JNI_CallStaticByteMethod(JNIEnv *env, jclass clazz,
3548 jmethodID methodID, ...)
3554 m = (methodinfo *) methodID;
3556 va_start(ap, methodID);
3557 b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3564 jbyte _Jv_JNI_CallStaticByteMethodV(JNIEnv *env, jclass clazz,
3565 jmethodID methodID, va_list args)
3570 m = (methodinfo *) methodID;
3572 b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3578 jbyte _Jv_JNI_CallStaticByteMethodA(JNIEnv *env, jclass clazz,
3579 jmethodID methodID, const jvalue *args)
3584 m = (methodinfo *) methodID;
3586 b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3592 jchar _Jv_JNI_CallStaticCharMethod(JNIEnv *env, jclass clazz,
3593 jmethodID methodID, ...)
3599 m = (methodinfo *) methodID;
3601 va_start(ap, methodID);
3602 c = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3609 jchar _Jv_JNI_CallStaticCharMethodV(JNIEnv *env, jclass clazz,
3610 jmethodID methodID, va_list args)
3615 m = (methodinfo *) methodID;
3617 c = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3623 jchar _Jv_JNI_CallStaticCharMethodA(JNIEnv *env, jclass clazz,
3624 jmethodID methodID, const jvalue *args)
3629 m = (methodinfo *) methodID;
3631 c = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3637 jshort _Jv_JNI_CallStaticShortMethod(JNIEnv *env, jclass clazz,
3638 jmethodID methodID, ...)
3644 m = (methodinfo *) methodID;
3646 va_start(ap, methodID);
3647 s = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3654 jshort _Jv_JNI_CallStaticShortMethodV(JNIEnv *env, jclass clazz,
3655 jmethodID methodID, va_list args)
3660 m = (methodinfo *) methodID;
3662 s = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3668 jshort _Jv_JNI_CallStaticShortMethodA(JNIEnv *env, jclass clazz,
3669 jmethodID methodID, const jvalue *args)
3674 m = (methodinfo *) methodID;
3676 s = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3682 jint _Jv_JNI_CallStaticIntMethod(JNIEnv *env, jclass clazz, jmethodID methodID,
3689 m = (methodinfo *) methodID;
3691 va_start(ap, methodID);
3692 i = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
3699 jint _Jv_JNI_CallStaticIntMethodV(JNIEnv *env, jclass clazz,
3700 jmethodID methodID, va_list args)
3705 m = (methodinfo *) methodID;
3707 i = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
3713 jint _Jv_JNI_CallStaticIntMethodA(JNIEnv *env, jclass clazz,
3714 jmethodID methodID, const jvalue *args)
3719 m = (methodinfo *) methodID;
3721 i = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
3727 jlong _Jv_JNI_CallStaticLongMethod(JNIEnv *env, jclass clazz,
3728 jmethodID methodID, ...)
3734 m = (methodinfo *) methodID;
3736 va_start(ap, methodID);
3737 l = _Jv_jni_CallLongMethod(NULL, NULL, m, ap);
3744 jlong _Jv_JNI_CallStaticLongMethodV(JNIEnv *env, jclass clazz,
3745 jmethodID methodID, va_list args)
3750 m = (methodinfo *) methodID;
3752 l = _Jv_jni_CallLongMethod(NULL, NULL, m, args);
3758 jlong _Jv_JNI_CallStaticLongMethodA(JNIEnv *env, jclass clazz,
3759 jmethodID methodID, const jvalue *args)
3764 m = (methodinfo *) methodID;
3766 l = _Jv_jni_CallLongMethodA(NULL, NULL, m, args);
3773 jfloat _Jv_JNI_CallStaticFloatMethod(JNIEnv *env, jclass clazz,
3774 jmethodID methodID, ...)
3780 m = (methodinfo *) methodID;
3782 va_start(ap, methodID);
3783 f = _Jv_jni_CallFloatMethod(NULL, NULL, m, ap);
3790 jfloat _Jv_JNI_CallStaticFloatMethodV(JNIEnv *env, jclass clazz,
3791 jmethodID methodID, va_list args)
3796 m = (methodinfo *) methodID;
3798 f = _Jv_jni_CallFloatMethod(NULL, NULL, m, args);
3804 jfloat _Jv_JNI_CallStaticFloatMethodA(JNIEnv *env, jclass clazz,
3805 jmethodID methodID, const jvalue *args)
3810 m = (methodinfo *) methodID;
3812 f = _Jv_jni_CallFloatMethodA(NULL, NULL, m, args);
3818 jdouble _Jv_JNI_CallStaticDoubleMethod(JNIEnv *env, jclass clazz,
3819 jmethodID methodID, ...)
3825 m = (methodinfo *) methodID;
3827 va_start(ap, methodID);
3828 d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, ap);
3835 jdouble _Jv_JNI_CallStaticDoubleMethodV(JNIEnv *env, jclass clazz,
3836 jmethodID methodID, va_list args)
3841 m = (methodinfo *) methodID;
3843 d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, args);
3849 jdouble _Jv_JNI_CallStaticDoubleMethodA(JNIEnv *env, jclass clazz,
3850 jmethodID methodID, const jvalue *args)
3855 m = (methodinfo *) methodID;
3857 d = _Jv_jni_CallDoubleMethodA(NULL, NULL, m, args);
3863 void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz,
3864 jmethodID methodID, ...)
3869 m = (methodinfo *) methodID;
3871 va_start(ap, methodID);
3872 _Jv_jni_CallVoidMethod(NULL, NULL, m, ap);
3877 void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz,
3878 jmethodID methodID, va_list args)
3882 m = (methodinfo *) methodID;
3884 _Jv_jni_CallVoidMethod(NULL, NULL, m, args);
3888 void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz,
3889 jmethodID methodID, const jvalue * args)
3893 m = (methodinfo *) methodID;
3895 _Jv_jni_CallVoidMethodA(NULL, NULL, m, args);
3899 /* Accessing Static Fields ****************************************************/
3901 /* GetStaticFieldID ************************************************************
3903 Returns the field ID for a static field of a class. The field is
3904 specified by its name and signature. The GetStatic<type>Field and
3905 SetStatic<type>Field families of accessor functions use field IDs
3906 to retrieve static fields.
3908 *******************************************************************************/
3910 jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
3918 STATISTICS(jniinvokation());
3920 c = (classinfo *) clazz;
3922 uname = utf_new_char((char *) name);
3923 usig = utf_new_char((char *) sig);
3925 f = class_findfield(c, uname, usig);
3928 exceptions_throw_nosuchfielderror(c, uname);
3930 return (jfieldID) f;
3934 /* GetStatic<type>Field ********************************************************
3936 This family of accessor routines returns the value of a static
3939 *******************************************************************************/
3941 jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz,
3947 STATISTICS(jniinvokation());
3949 c = (classinfo *) clazz;
3950 f = (fieldinfo *) fieldID;
3952 if (!(c->state & CLASS_INITIALIZED))
3953 if (!initialize_class(c))
3956 return _Jv_JNI_NewLocalRef(env, f->value.a);
3960 jboolean _Jv_JNI_GetStaticBooleanField(JNIEnv *env, jclass clazz,
3966 STATISTICS(jniinvokation());
3968 c = (classinfo *) clazz;
3969 f = (fieldinfo *) fieldID;
3971 if (!(c->state & CLASS_INITIALIZED))
3972 if (!initialize_class(c))
3979 jbyte _Jv_JNI_GetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID)
3984 STATISTICS(jniinvokation());
3986 c = (classinfo *) clazz;
3987 f = (fieldinfo *) fieldID;
3989 if (!(c->state & CLASS_INITIALIZED))
3990 if (!initialize_class(c))
3997 jchar _Jv_JNI_GetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4002 STATISTICS(jniinvokation());
4004 c = (classinfo *) clazz;
4005 f = (fieldinfo *) fieldID;
4007 if (!(c->state & CLASS_INITIALIZED))
4008 if (!initialize_class(c))
4015 jshort _Jv_JNI_GetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4020 STATISTICS(jniinvokation());
4022 c = (classinfo *) clazz;
4023 f = (fieldinfo *) fieldID;
4025 if (!(c->state & CLASS_INITIALIZED))
4026 if (!initialize_class(c))
4033 jint _Jv_JNI_GetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4038 STATISTICS(jniinvokation());
4040 c = (classinfo *) clazz;
4041 f = (fieldinfo *) fieldID;
4043 if (!(c->state & CLASS_INITIALIZED))
4044 if (!initialize_class(c))
4051 jlong _Jv_JNI_GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4056 STATISTICS(jniinvokation());
4058 c = (classinfo *) clazz;
4059 f = (fieldinfo *) fieldID;
4061 if (!(c->state & CLASS_INITIALIZED))
4062 if (!initialize_class(c))
4069 jfloat _Jv_JNI_GetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID)
4074 STATISTICS(jniinvokation());
4076 c = (classinfo *) clazz;
4077 f = (fieldinfo *) fieldID;
4079 if (!(c->state & CLASS_INITIALIZED))
4080 if (!initialize_class(c))
4087 jdouble _Jv_JNI_GetStaticDoubleField(JNIEnv *env, jclass clazz,
4093 STATISTICS(jniinvokation());
4095 c = (classinfo *) clazz;
4096 f = (fieldinfo *) fieldID;
4098 if (!(c->state & CLASS_INITIALIZED))
4099 if (!initialize_class(c))
4106 /* SetStatic<type>Field *******************************************************
4108 This family of accessor routines sets the value of a static field
4111 *******************************************************************************/
4113 void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4119 STATISTICS(jniinvokation());
4121 c = (classinfo *) clazz;
4122 f = (fieldinfo *) fieldID;
4124 if (!(c->state & CLASS_INITIALIZED))
4125 if (!initialize_class(c))
4132 void _Jv_JNI_SetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4138 STATISTICS(jniinvokation());
4140 c = (classinfo *) clazz;
4141 f = (fieldinfo *) fieldID;
4143 if (!(c->state & CLASS_INITIALIZED))
4144 if (!initialize_class(c))
4151 void _Jv_JNI_SetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4157 STATISTICS(jniinvokation());
4159 c = (classinfo *) clazz;
4160 f = (fieldinfo *) fieldID;
4162 if (!(c->state & CLASS_INITIALIZED))
4163 if (!initialize_class(c))
4170 void _Jv_JNI_SetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4176 STATISTICS(jniinvokation());
4178 c = (classinfo *) clazz;
4179 f = (fieldinfo *) fieldID;
4181 if (!(c->state & CLASS_INITIALIZED))
4182 if (!initialize_class(c))
4189 void _Jv_JNI_SetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4195 STATISTICS(jniinvokation());
4197 c = (classinfo *) clazz;
4198 f = (fieldinfo *) fieldID;
4200 if (!(c->state & CLASS_INITIALIZED))
4201 if (!initialize_class(c))
4208 void _Jv_JNI_SetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4214 STATISTICS(jniinvokation());
4216 c = (classinfo *) clazz;
4217 f = (fieldinfo *) fieldID;
4219 if (!(c->state & CLASS_INITIALIZED))
4220 if (!initialize_class(c))
4227 void _Jv_JNI_SetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4233 STATISTICS(jniinvokation());
4235 c = (classinfo *) clazz;
4236 f = (fieldinfo *) fieldID;
4238 if (!(c->state & CLASS_INITIALIZED))
4239 if (!initialize_class(c))
4246 void _Jv_JNI_SetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4252 STATISTICS(jniinvokation());
4254 c = (classinfo *) clazz;
4255 f = (fieldinfo *) fieldID;
4257 if (!(c->state & CLASS_INITIALIZED))
4258 if (!initialize_class(c))
4265 void _Jv_JNI_SetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID,
4271 STATISTICS(jniinvokation());
4273 c = (classinfo *) clazz;
4274 f = (fieldinfo *) fieldID;
4276 if (!(c->state & CLASS_INITIALIZED))
4277 if (!initialize_class(c))
4284 /* String Operations **********************************************************/
4286 /* NewString *******************************************************************
4288 Create new java.lang.String object from an array of Unicode
4291 *******************************************************************************/
4293 jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len)
4295 java_lang_String *s;
4299 STATISTICS(jniinvokation());
4301 s = (java_lang_String *) builtin_new(class_java_lang_String);
4302 a = builtin_newarray_char(len);
4304 /* javastring or characterarray could not be created */
4305 if ((a == NULL) || (s == NULL))
4309 for (i = 0; i < len; i++)
4310 a->data[i] = buf[i];
4316 return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
4320 static jchar emptyStringJ[]={0,0};
4322 /* GetStringLength *************************************************************
4324 Returns the length (the count of Unicode characters) of a Java
4327 *******************************************************************************/
4329 jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str)
4331 java_lang_String *s;
4333 s = (java_lang_String *) str;
4339 /******************** convertes javastring to u2-array ****************************/
4341 u2 *javastring_tou2(jstring so)
4343 java_lang_String *s;
4348 STATISTICS(jniinvokation());
4350 s = (java_lang_String *) so;
4360 /* allocate memory */
4362 stringbuffer = MNEW(u2, s->count + 1);
4366 for (i = 0; i < s->count; i++)
4367 stringbuffer[i] = a->data[s->offset + i];
4369 /* terminate string */
4371 stringbuffer[i] = '\0';
4373 return stringbuffer;
4377 /* GetStringChars **************************************************************
4379 Returns a pointer to the array of Unicode characters of the
4380 string. This pointer is valid until ReleaseStringChars() is called.
4382 *******************************************************************************/
4384 const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy)
4388 STATISTICS(jniinvokation());
4390 jc = javastring_tou2(str);
4402 return emptyStringJ;
4406 /* ReleaseStringChars **********************************************************
4408 Informs the VM that the native code no longer needs access to
4409 chars. The chars argument is a pointer obtained from string using
4412 *******************************************************************************/
4414 void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
4416 STATISTICS(jniinvokation());
4418 if (chars == emptyStringJ)
4421 MFREE(((jchar *) chars), jchar, ((java_lang_String *) str)->count + 1);
4425 /* NewStringUTF ****************************************************************
4427 Constructs a new java.lang.String object from an array of UTF-8
4430 *******************************************************************************/
4432 jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
4434 java_lang_String *s;
4436 STATISTICS(jniinvokation());
4438 s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
4440 return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
4444 /****************** returns the utf8 length in bytes of a string *******************/
4446 jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string)
4448 java_lang_String *s;
4451 STATISTICS(jniinvokation());
4453 s = (java_lang_String *) string;
4455 length = u2_utflength(s->value->data, s->count);
4461 /* GetStringUTFChars ***********************************************************
4463 Returns a pointer to an array of UTF-8 characters of the
4464 string. This array is valid until it is released by
4465 ReleaseStringUTFChars().
4467 *******************************************************************************/
4469 const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string,
4474 STATISTICS(jniinvokation());
4482 u = javastring_toutf((java_objectheader *) string, false);
4491 /* ReleaseStringUTFChars *******************************************************
4493 Informs the VM that the native code no longer needs access to
4494 utf. The utf argument is a pointer derived from string using
4495 GetStringUTFChars().
4497 *******************************************************************************/
4499 void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf)
4501 STATISTICS(jniinvokation());
4503 /* XXX we don't release utf chars right now, perhaps that should be done
4504 later. Since there is always one reference the garbage collector will
4509 /* Array Operations ***********************************************************/
4511 /* GetArrayLength **************************************************************
4513 Returns the number of elements in the array.
4515 *******************************************************************************/
4517 jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array)
4519 java_arrayheader *a;
4521 STATISTICS(jniinvokation());
4523 a = (java_arrayheader *) array;
4529 /* NewObjectArray **************************************************************
4531 Constructs a new array holding objects in class elementClass. All
4532 elements are initially set to initialElement.
4534 *******************************************************************************/
4536 jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
4537 jclass elementClass, jobject initialElement)
4540 java_objectheader *o;
4541 java_objectarray *oa;
4544 STATISTICS(jniinvokation());
4546 c = (classinfo *) elementClass;
4547 o = (java_objectheader *) initialElement;
4550 exceptions_throw_negativearraysizeexception();
4554 oa = builtin_anewarray(length, c);
4559 /* set all elements to initialElement */
4561 for (i = 0; i < length; i++)
4564 return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa);
4568 jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
4571 java_objectarray *oa;
4572 java_objectheader *o;
4574 STATISTICS(jniinvokation());
4576 oa = (java_objectarray *) array;
4578 if (index >= oa->header.size) {
4579 exceptions_throw_arrayindexoutofboundsexception();
4583 o = oa->data[index];
4585 return _Jv_JNI_NewLocalRef(env, (jobject) o);
4589 void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
4590 jsize index, jobject val)
4592 java_objectarray *oa;
4593 java_objectheader *o;
4595 STATISTICS(jniinvokation());
4597 oa = (java_objectarray *) array;
4598 o = (java_objectheader *) val;
4600 if (index >= oa->header.size) {
4601 exceptions_throw_arrayindexoutofboundsexception();
4605 /* check if the class of value is a subclass of the element class
4608 if (!builtin_canstore(oa, o))
4611 oa->data[index] = o;
4615 jbooleanArray _Jv_JNI_NewBooleanArray(JNIEnv *env, jsize len)
4617 java_booleanarray *ba;
4619 STATISTICS(jniinvokation());
4622 exceptions_throw_negativearraysizeexception();
4626 ba = builtin_newarray_boolean(len);
4628 return (jbooleanArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
4632 jbyteArray _Jv_JNI_NewByteArray(JNIEnv *env, jsize len)
4636 STATISTICS(jniinvokation());
4639 exceptions_throw_negativearraysizeexception();
4643 ba = builtin_newarray_byte(len);
4645 return (jbyteArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
4649 jcharArray _Jv_JNI_NewCharArray(JNIEnv *env, jsize len)
4653 STATISTICS(jniinvokation());
4656 exceptions_throw_negativearraysizeexception();
4660 ca = builtin_newarray_char(len);
4662 return (jcharArray) _Jv_JNI_NewLocalRef(env, (jobject) ca);
4666 jshortArray _Jv_JNI_NewShortArray(JNIEnv *env, jsize len)
4668 java_shortarray *sa;
4670 STATISTICS(jniinvokation());
4673 exceptions_throw_negativearraysizeexception();
4677 sa = builtin_newarray_short(len);
4679 return (jshortArray) _Jv_JNI_NewLocalRef(env, (jobject) sa);
4683 jintArray _Jv_JNI_NewIntArray(JNIEnv *env, jsize len)
4687 STATISTICS(jniinvokation());
4690 exceptions_throw_negativearraysizeexception();
4694 ia = builtin_newarray_int(len);
4696 return (jintArray) _Jv_JNI_NewLocalRef(env, (jobject) ia);
4700 jlongArray _Jv_JNI_NewLongArray(JNIEnv *env, jsize len)
4704 STATISTICS(jniinvokation());
4707 exceptions_throw_negativearraysizeexception();
4711 la = builtin_newarray_long(len);
4713 return (jlongArray) _Jv_JNI_NewLocalRef(env, (jobject) la);
4717 jfloatArray _Jv_JNI_NewFloatArray(JNIEnv *env, jsize len)
4719 java_floatarray *fa;
4721 STATISTICS(jniinvokation());
4724 exceptions_throw_negativearraysizeexception();
4728 fa = builtin_newarray_float(len);
4730 return (jfloatArray) _Jv_JNI_NewLocalRef(env, (jobject) fa);
4734 jdoubleArray _Jv_JNI_NewDoubleArray(JNIEnv *env, jsize len)
4736 java_doublearray *da;
4738 STATISTICS(jniinvokation());
4741 exceptions_throw_negativearraysizeexception();
4745 da = builtin_newarray_double(len);
4747 return (jdoubleArray) _Jv_JNI_NewLocalRef(env, (jobject) da);
4751 /* Get<PrimitiveType>ArrayElements *********************************************
4753 A family of functions that returns the body of the primitive array.
4755 *******************************************************************************/
4757 jboolean *_Jv_JNI_GetBooleanArrayElements(JNIEnv *env, jbooleanArray array,
4760 java_booleanarray *ba;
4762 STATISTICS(jniinvokation());
4764 ba = (java_booleanarray *) array;
4767 *isCopy = JNI_FALSE;
4773 jbyte *_Jv_JNI_GetByteArrayElements(JNIEnv *env, jbyteArray array,
4778 STATISTICS(jniinvokation());
4780 ba = (java_bytearray *) array;
4783 *isCopy = JNI_FALSE;
4789 jchar *_Jv_JNI_GetCharArrayElements(JNIEnv *env, jcharArray array,
4794 STATISTICS(jniinvokation());
4796 ca = (java_chararray *) array;
4799 *isCopy = JNI_FALSE;
4805 jshort *_Jv_JNI_GetShortArrayElements(JNIEnv *env, jshortArray array,
4808 java_shortarray *sa;
4810 STATISTICS(jniinvokation());
4812 sa = (java_shortarray *) array;
4815 *isCopy = JNI_FALSE;
4821 jint *_Jv_JNI_GetIntArrayElements(JNIEnv *env, jintArray array,
4826 STATISTICS(jniinvokation());
4828 ia = (java_intarray *) array;
4831 *isCopy = JNI_FALSE;
4837 jlong *_Jv_JNI_GetLongArrayElements(JNIEnv *env, jlongArray array,
4842 STATISTICS(jniinvokation());
4844 la = (java_longarray *) array;
4847 *isCopy = JNI_FALSE;
4849 /* We cast this one to prevent a compiler warning on 64-bit
4850 systems since GNU Classpath typedef jlong to long long. */
4852 return (jlong *) la->data;
4856 jfloat *_Jv_JNI_GetFloatArrayElements(JNIEnv *env, jfloatArray array,
4859 java_floatarray *fa;
4861 STATISTICS(jniinvokation());
4863 fa = (java_floatarray *) array;
4866 *isCopy = JNI_FALSE;
4872 jdouble *_Jv_JNI_GetDoubleArrayElements(JNIEnv *env, jdoubleArray array,
4875 java_doublearray *da;
4877 STATISTICS(jniinvokation());
4879 da = (java_doublearray *) array;
4882 *isCopy = JNI_FALSE;
4888 /* Release<PrimitiveType>ArrayElements *****************************************
4890 A family of functions that informs the VM that the native code no
4891 longer needs access to elems. The elems argument is a pointer
4892 derived from array using the corresponding
4893 Get<PrimitiveType>ArrayElements() function. If necessary, this
4894 function copies back all changes made to elems to the original
4897 *******************************************************************************/
4899 void _Jv_JNI_ReleaseBooleanArrayElements(JNIEnv *env, jbooleanArray array,
4900 jboolean *elems, jint mode)
4902 java_booleanarray *ba;
4904 STATISTICS(jniinvokation());
4906 ba = (java_booleanarray *) array;
4908 if (elems != ba->data) {
4911 MCOPY(ba->data, elems, u1, ba->header.size);
4914 MCOPY(ba->data, elems, u1, ba->header.size);
4915 /* XXX TWISTI how should it be freed? */
4918 /* XXX TWISTI how should it be freed? */
4925 void _Jv_JNI_ReleaseByteArrayElements(JNIEnv *env, jbyteArray array,
4926 jbyte *elems, jint mode)
4930 STATISTICS(jniinvokation());
4932 ba = (java_bytearray *) array;
4934 if (elems != ba->data) {
4937 MCOPY(ba->data, elems, s1, ba->header.size);
4940 MCOPY(ba->data, elems, s1, ba->header.size);
4941 /* XXX TWISTI how should it be freed? */
4944 /* XXX TWISTI how should it be freed? */
4951 void _Jv_JNI_ReleaseCharArrayElements(JNIEnv *env, jcharArray array,
4952 jchar *elems, jint mode)
4956 STATISTICS(jniinvokation());
4958 ca = (java_chararray *) array;
4960 if (elems != ca->data) {
4963 MCOPY(ca->data, elems, u2, ca->header.size);
4966 MCOPY(ca->data, elems, u2, ca->header.size);
4967 /* XXX TWISTI how should it be freed? */
4970 /* XXX TWISTI how should it be freed? */
4977 void _Jv_JNI_ReleaseShortArrayElements(JNIEnv *env, jshortArray array,
4978 jshort *elems, jint mode)
4980 java_shortarray *sa;
4982 STATISTICS(jniinvokation());
4984 sa = (java_shortarray *) array;
4986 if (elems != sa->data) {
4989 MCOPY(sa->data, elems, s2, sa->header.size);
4992 MCOPY(sa->data, elems, s2, sa->header.size);
4993 /* XXX TWISTI how should it be freed? */
4996 /* XXX TWISTI how should it be freed? */
5003 void _Jv_JNI_ReleaseIntArrayElements(JNIEnv *env, jintArray array, jint *elems,
5008 STATISTICS(jniinvokation());
5010 ia = (java_intarray *) array;
5012 if (elems != ia->data) {
5015 MCOPY(ia->data, elems, s4, ia->header.size);
5018 MCOPY(ia->data, elems, s4, ia->header.size);
5019 /* XXX TWISTI how should it be freed? */
5022 /* XXX TWISTI how should it be freed? */
5029 void _Jv_JNI_ReleaseLongArrayElements(JNIEnv *env, jlongArray array,
5030 jlong *elems, jint mode)
5034 STATISTICS(jniinvokation());
5036 la = (java_longarray *) array;
5038 /* We cast this one to prevent a compiler warning on 64-bit
5039 systems since GNU Classpath typedef jlong to long long. */
5041 if ((s8 *) elems != la->data) {
5044 MCOPY(la->data, elems, s8, la->header.size);
5047 MCOPY(la->data, elems, s8, la->header.size);
5048 /* XXX TWISTI how should it be freed? */
5051 /* XXX TWISTI how should it be freed? */
5058 void _Jv_JNI_ReleaseFloatArrayElements(JNIEnv *env, jfloatArray array,
5059 jfloat *elems, jint mode)
5061 java_floatarray *fa;
5063 STATISTICS(jniinvokation());
5065 fa = (java_floatarray *) array;
5067 if (elems != fa->data) {
5070 MCOPY(fa->data, elems, float, fa->header.size);
5073 MCOPY(fa->data, elems, float, fa->header.size);
5074 /* XXX TWISTI how should it be freed? */
5077 /* XXX TWISTI how should it be freed? */
5084 void _Jv_JNI_ReleaseDoubleArrayElements(JNIEnv *env, jdoubleArray array,
5085 jdouble *elems, jint mode)
5087 java_doublearray *da;
5089 STATISTICS(jniinvokation());
5091 da = (java_doublearray *) array;
5093 if (elems != da->data) {
5096 MCOPY(da->data, elems, double, da->header.size);
5099 MCOPY(da->data, elems, double, da->header.size);
5100 /* XXX TWISTI how should it be freed? */
5103 /* XXX TWISTI how should it be freed? */
5110 /* Get<PrimitiveType>ArrayRegion **********************************************
5112 A family of functions that copies a region of a primitive array
5115 *******************************************************************************/
5117 void _Jv_JNI_GetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
5118 jsize start, jsize len, jboolean *buf)
5120 java_booleanarray *ba;
5122 STATISTICS(jniinvokation());
5124 ba = (java_booleanarray *) array;
5126 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5127 exceptions_throw_arrayindexoutofboundsexception();
5129 MCOPY(buf, &ba->data[start], u1, len);
5133 void _Jv_JNI_GetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
5134 jsize len, jbyte *buf)
5138 STATISTICS(jniinvokation());
5140 ba = (java_bytearray *) array;
5142 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5143 exceptions_throw_arrayindexoutofboundsexception();
5145 MCOPY(buf, &ba->data[start], s1, len);
5149 void _Jv_JNI_GetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
5150 jsize len, jchar *buf)
5154 STATISTICS(jniinvokation());
5156 ca = (java_chararray *) array;
5158 if ((start < 0) || (len < 0) || (start + len > ca->header.size))
5159 exceptions_throw_arrayindexoutofboundsexception();
5161 MCOPY(buf, &ca->data[start], u2, len);
5165 void _Jv_JNI_GetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
5166 jsize len, jshort *buf)
5168 java_shortarray *sa;
5170 STATISTICS(jniinvokation());
5172 sa = (java_shortarray *) array;
5174 if ((start < 0) || (len < 0) || (start + len > sa->header.size))
5175 exceptions_throw_arrayindexoutofboundsexception();
5177 MCOPY(buf, &sa->data[start], s2, len);
5181 void _Jv_JNI_GetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
5182 jsize len, jint *buf)
5186 STATISTICS(jniinvokation());
5188 ia = (java_intarray *) array;
5190 if ((start < 0) || (len < 0) || (start + len > ia->header.size))
5191 exceptions_throw_arrayindexoutofboundsexception();
5193 MCOPY(buf, &ia->data[start], s4, len);
5197 void _Jv_JNI_GetLongArrayRegion(JNIEnv *env, jlongArray array, jsize start,
5198 jsize len, jlong *buf)
5202 STATISTICS(jniinvokation());
5204 la = (java_longarray *) array;
5206 if ((start < 0) || (len < 0) || (start + len > la->header.size))
5207 exceptions_throw_arrayindexoutofboundsexception();
5209 MCOPY(buf, &la->data[start], s8, len);
5213 void _Jv_JNI_GetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
5214 jsize len, jfloat *buf)
5216 java_floatarray *fa;
5218 STATISTICS(jniinvokation());
5220 fa = (java_floatarray *) array;
5222 if ((start < 0) || (len < 0) || (start + len > fa->header.size))
5223 exceptions_throw_arrayindexoutofboundsexception();
5225 MCOPY(buf, &fa->data[start], float, len);
5229 void _Jv_JNI_GetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
5230 jsize len, jdouble *buf)
5232 java_doublearray *da;
5234 STATISTICS(jniinvokation());
5236 da = (java_doublearray *) array;
5238 if ((start < 0) || (len < 0) || (start + len > da->header.size))
5239 exceptions_throw_arrayindexoutofboundsexception();
5241 MCOPY(buf, &da->data[start], double, len);
5245 /* Set<PrimitiveType>ArrayRegion **********************************************
5247 A family of functions that copies back a region of a primitive
5248 array from a buffer.
5250 *******************************************************************************/
5252 void _Jv_JNI_SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
5253 jsize start, jsize len, const jboolean *buf)
5255 java_booleanarray *ba;
5257 STATISTICS(jniinvokation());
5259 ba = (java_booleanarray *) array;
5261 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5262 exceptions_throw_arrayindexoutofboundsexception();
5264 MCOPY(&ba->data[start], buf, u1, len);
5268 void _Jv_JNI_SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
5269 jsize len, const jbyte *buf)
5273 STATISTICS(jniinvokation());
5275 ba = (java_bytearray *) array;
5277 if ((start < 0) || (len < 0) || (start + len > ba->header.size))
5278 exceptions_throw_arrayindexoutofboundsexception();
5280 MCOPY(&ba->data[start], buf, s1, len);
5284 void _Jv_JNI_SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
5285 jsize len, const jchar *buf)
5289 STATISTICS(jniinvokation());
5291 ca = (java_chararray *) array;
5293 if ((start < 0) || (len < 0) || (start + len > ca->header.size))
5294 exceptions_throw_arrayindexoutofboundsexception();
5296 MCOPY(&ca->data[start], buf, u2, len);
5300 void _Jv_JNI_SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
5301 jsize len, const jshort *buf)
5303 java_shortarray *sa;
5305 STATISTICS(jniinvokation());
5307 sa = (java_shortarray *) array;
5309 if ((start < 0) || (len < 0) || (start + len > sa->header.size))
5310 exceptions_throw_arrayindexoutofboundsexception();
5312 MCOPY(&sa->data[start], buf, s2, len);
5316 void _Jv_JNI_SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
5317 jsize len, const jint *buf)
5321 STATISTICS(jniinvokation());
5323 ia = (java_intarray *) array;
5325 if ((start < 0) || (len < 0) || (start + len > ia->header.size))
5326 exceptions_throw_arrayindexoutofboundsexception();
5328 MCOPY(&ia->data[start], buf, s4, len);
5332 void _Jv_JNI_SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start,
5333 jsize len, const jlong *buf)
5337 STATISTICS(jniinvokation());
5339 la = (java_longarray *) array;
5341 if ((start < 0) || (len < 0) || (start + len > la->header.size))
5342 exceptions_throw_arrayindexoutofboundsexception();
5344 MCOPY(&la->data[start], buf, s8, len);
5348 void _Jv_JNI_SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
5349 jsize len, const jfloat *buf)
5351 java_floatarray *fa;
5353 STATISTICS(jniinvokation());
5355 fa = (java_floatarray *) array;
5357 if ((start < 0) || (len < 0) || (start + len > fa->header.size))
5358 exceptions_throw_arrayindexoutofboundsexception();
5360 MCOPY(&fa->data[start], buf, float, len);
5364 void _Jv_JNI_SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
5365 jsize len, const jdouble *buf)
5367 java_doublearray *da;
5369 STATISTICS(jniinvokation());
5371 da = (java_doublearray *) array;
5373 if ((start < 0) || (len < 0) || (start + len > da->header.size))
5374 exceptions_throw_arrayindexoutofboundsexception();
5376 MCOPY(&da->data[start], buf, double, len);
5380 /* Registering Native Methods *************************************************/
5382 /* RegisterNatives *************************************************************
5384 Registers native methods with the class specified by the clazz
5385 argument. The methods parameter specifies an array of
5386 JNINativeMethod structures that contain the names, signatures, and
5387 function pointers of the native methods. The nMethods parameter
5388 specifies the number of native methods in the array.
5390 *******************************************************************************/
5392 jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz,
5393 const JNINativeMethod *methods, jint nMethods)
5397 STATISTICS(jniinvokation());
5399 c = (classinfo *) clazz;
5401 /* XXX: if implemented this needs a call to jvmti_NativeMethodBind
5402 if (jvmti) jvmti_NativeMethodBind(method, address, new_address_ptr);
5405 native_method_register(c->name, methods, nMethods);
5411 /* UnregisterNatives ***********************************************************
5413 Unregisters native methods of a class. The class goes back to the
5414 state before it was linked or registered with its native method
5417 This function should not be used in normal native code. Instead, it
5418 provides special programs a way to reload and relink native
5421 *******************************************************************************/
5423 jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz)
5425 STATISTICS(jniinvokation());
5427 /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */
5429 log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!");
5435 /* Monitor Operations *********************************************************/
5437 /* MonitorEnter ****************************************************************
5439 Enters the monitor associated with the underlying Java object
5442 *******************************************************************************/
5444 jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj)
5446 STATISTICS(jniinvokation());
5449 exceptions_throw_nullpointerexception();
5453 LOCK_MONITOR_ENTER(obj);
5459 /* MonitorExit *****************************************************************
5461 The current thread must be the owner of the monitor associated with
5462 the underlying Java object referred to by obj. The thread
5463 decrements the counter indicating the number of times it has
5464 entered this monitor. If the value of the counter becomes zero, the
5465 current thread releases the monitor.
5467 *******************************************************************************/
5469 jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj)
5471 STATISTICS(jniinvokation());
5474 exceptions_throw_nullpointerexception();
5478 LOCK_MONITOR_EXIT(obj);
5484 /* JavaVM Interface ***********************************************************/
5486 /* GetJavaVM *******************************************************************
5488 Returns the Java VM interface (used in the Invocation API)
5489 associated with the current thread. The result is placed at the
5490 location pointed to by the second argument, vm.
5492 *******************************************************************************/
5494 jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **vm)
5496 STATISTICS(jniinvokation());
5498 *vm = (JavaVM *) _Jv_jvm;
5504 /* GetStringRegion *************************************************************
5506 Copies len number of Unicode characters beginning at offset start
5507 to the given buffer buf.
5509 Throws StringIndexOutOfBoundsException on index overflow.
5511 *******************************************************************************/
5513 void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len,
5516 java_lang_String *s;
5519 STATISTICS(jniinvokation());
5521 s = (java_lang_String *) str;
5524 if ((start < 0) || (len < 0) || (start > s->count) ||
5525 (start + len > s->count)) {
5526 exceptions_throw_stringindexoutofboundsexception();
5530 MCOPY(buf, &ca->data[start], u2, len);
5534 /* GetStringUTFRegion **********************************************************
5536 Translates len number of Unicode characters beginning at offset
5537 start into UTF-8 format and place the result in the given buffer
5540 Throws StringIndexOutOfBoundsException on index overflow.
5542 *******************************************************************************/
5544 void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start,
5545 jsize len, char *buf)
5547 java_lang_String *s;
5551 STATISTICS(jniinvokation());
5553 s = (java_lang_String *) str;
5556 if ((start < 0) || (len < 0) || (start > s->count) ||
5557 (start + len > s->count)) {
5558 exceptions_throw_stringindexoutofboundsexception();
5562 /* XXX not sure if this is correct */
5564 for (i = 0; i < len; i++)
5565 buf[i] = ca->data[start + i];
5571 /* GetPrimitiveArrayCritical ***************************************************
5573 Obtain a direct pointer to array elements.
5575 *******************************************************************************/
5577 void *_Jv_JNI_GetPrimitiveArrayCritical(JNIEnv *env, jarray array,
5583 ba = (java_bytearray *) array;
5585 /* do the same as Kaffe does */
5587 bp = _Jv_JNI_GetByteArrayElements(env, (jbyteArray) ba, isCopy);
5593 /* ReleasePrimitiveArrayCritical ***********************************************
5595 No specific documentation.
5597 *******************************************************************************/
5599 void _Jv_JNI_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array,
5600 void *carray, jint mode)
5602 STATISTICS(jniinvokation());
5604 /* do the same as Kaffe does */
5606 _Jv_JNI_ReleaseByteArrayElements(env, (jbyteArray) array, (jbyte *) carray,
5611 /* GetStringCritical ***********************************************************
5613 The semantics of these two functions are similar to the existing
5614 Get/ReleaseStringChars functions.
5616 *******************************************************************************/
5618 const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string,
5621 STATISTICS(jniinvokation());
5623 return _Jv_JNI_GetStringChars(env, string, isCopy);
5627 void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string,
5628 const jchar *cstring)
5630 STATISTICS(jniinvokation());
5632 _Jv_JNI_ReleaseStringChars(env, string, cstring);
5636 jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj)
5638 STATISTICS(jniinvokation());
5640 log_text("JNI-Call: NewWeakGlobalRef: IMPLEMENT ME!");
5646 void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref)
5648 STATISTICS(jniinvokation());
5650 log_text("JNI-Call: DeleteWeakGlobalRef: IMPLEMENT ME");
5654 /* NewGlobalRef ****************************************************************
5656 Creates a new global reference to the object referred to by the obj
5659 *******************************************************************************/
5661 jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
5663 hashtable_global_ref_entry *gre;
5664 u4 key; /* hashkey */
5665 u4 slot; /* slot in hashtable */
5666 java_objectheader *o;
5668 STATISTICS(jniinvokation());
5670 o = (java_objectheader *) obj;
5672 LOCK_MONITOR_ENTER(hashtable_global_ref->header);
5674 /* normally addresses are aligned to 4, 8 or 16 bytes */
5676 key = ((u4) (ptrint) obj) >> 4; /* align to 16-byte boundaries */
5677 slot = key & (hashtable_global_ref->size - 1);
5678 gre = hashtable_global_ref->ptr[slot];
5680 /* search external hash chain for the entry */
5684 /* global object found, increment the reference */
5688 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5693 gre = gre->hashlink; /* next element in external chain */
5696 /* global ref not found, create a new one */
5698 gre = NEW(hashtable_global_ref_entry);
5700 #if defined(ENABLE_GC_CACAO)
5701 /* register global ref with the GC */
5703 gc_reference_register(&(gre->o));
5709 /* insert entry into hashtable */
5711 gre->hashlink = hashtable_global_ref->ptr[slot];
5713 hashtable_global_ref->ptr[slot] = gre;
5715 /* update number of hashtable-entries */
5717 hashtable_global_ref->entries++;
5719 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5725 /* DeleteGlobalRef *************************************************************
5727 Deletes the global reference pointed to by globalRef.
5729 *******************************************************************************/
5731 void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
5733 hashtable_global_ref_entry *gre;
5734 hashtable_global_ref_entry *prevgre;
5735 u4 key; /* hashkey */
5736 u4 slot; /* slot in hashtable */
5737 java_objectheader *o;
5739 STATISTICS(jniinvokation());
5741 o = (java_objectheader *) globalRef;
5743 LOCK_MONITOR_ENTER(hashtable_global_ref->header);
5745 /* normally addresses are aligned to 4, 8 or 16 bytes */
5747 key = ((u4) (ptrint) globalRef) >> 4; /* align to 16-byte boundaries */
5748 slot = key & (hashtable_global_ref->size - 1);
5749 gre = hashtable_global_ref->ptr[slot];
5751 /* initialize prevgre */
5755 /* search external hash chain for the entry */
5759 /* global object found, decrement the reference count */
5763 /* if reference count is 0, remove the entry */
5765 if (gre->refs == 0) {
5766 /* special handling if it's the first in the chain */
5768 if (prevgre == NULL)
5769 hashtable_global_ref->ptr[slot] = gre->hashlink;
5771 prevgre->hashlink = gre->hashlink;
5773 #if defined(ENABLE_GC_CACAO)
5774 /* unregister global ref with the GC */
5776 gc_reference_unregister(&(gre->o));
5779 FREE(gre, hashtable_global_ref_entry);
5782 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5787 prevgre = gre; /* save current pointer for removal */
5788 gre = gre->hashlink; /* next element in external chain */
5791 log_println("JNI-DeleteGlobalRef: global reference not found");
5793 LOCK_MONITOR_EXIT(hashtable_global_ref->header);
5797 /* ExceptionCheck **************************************************************
5799 Returns JNI_TRUE when there is a pending exception; otherwise,
5802 *******************************************************************************/
5804 jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
5806 java_objectheader *o;
5808 STATISTICS(jniinvokation());
5810 o = exceptions_get_exception();
5812 return (o != NULL) ? JNI_TRUE : JNI_FALSE;
5816 /* New JNI 1.4 functions ******************************************************/
5818 /* NewDirectByteBuffer *********************************************************
5820 Allocates and returns a direct java.nio.ByteBuffer referring to the
5821 block of memory starting at the memory address address and
5822 extending capacity bytes.
5824 *******************************************************************************/
5826 jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
5828 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5829 java_objectheader *nbuf;
5831 # if SIZEOF_VOID_P == 8
5832 gnu_classpath_Pointer64 *paddress;
5834 gnu_classpath_Pointer32 *paddress;
5837 STATISTICS(jniinvokation());
5839 /* alocate a gnu.classpath.Pointer{32,64} object */
5841 # if SIZEOF_VOID_P == 8
5842 if (!(paddress = (gnu_classpath_Pointer64 *)
5843 builtin_new(class_gnu_classpath_Pointer64)))
5845 if (!(paddress = (gnu_classpath_Pointer32 *)
5846 builtin_new(class_gnu_classpath_Pointer32)))
5850 /* fill gnu.classpath.Pointer{32,64} with address */
5852 paddress->data = (ptrint) address;
5854 /* create a java.nio.DirectByteBufferImpl$ReadWrite object */
5856 nbuf = (*env)->NewObject(env, class_java_nio_DirectByteBufferImpl_ReadWrite,
5857 (jmethodID) dbbirw_init, NULL, paddress,
5858 (jint) capacity, (jint) capacity, (jint) 0);
5860 /* add local reference and return the value */
5862 return _Jv_JNI_NewLocalRef(env, nbuf);
5864 vm_abort("_Jv_JNI_NewDirectByteBuffer: not implemented in this configuration");
5866 /* keep compiler happy */
5873 /* GetDirectBufferAddress ******************************************************
5875 Fetches and returns the starting address of the memory region
5876 referenced by the given direct java.nio.Buffer.
5878 *******************************************************************************/
5880 void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
5882 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5883 java_nio_DirectByteBufferImpl *nbuf;
5884 # if SIZEOF_VOID_P == 8
5885 gnu_classpath_Pointer64 *address;
5887 gnu_classpath_Pointer32 *address;
5890 STATISTICS(jniinvokation());
5892 if (!builtin_instanceof(buf, class_java_nio_Buffer))
5895 nbuf = (java_nio_DirectByteBufferImpl *) buf;
5897 # if SIZEOF_VOID_P == 8
5898 address = (gnu_classpath_Pointer64 *) nbuf->address;
5900 address = (gnu_classpath_Pointer32 *) nbuf->address;
5903 if (address == NULL)
5906 return (void *) address->data;
5908 vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration");
5910 /* keep compiler happy */
5917 /* GetDirectBufferCapacity *****************************************************
5919 Fetches and returns the capacity in bytes of the memory region
5920 referenced by the given direct java.nio.Buffer.
5922 *******************************************************************************/
5924 jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
5926 #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
5927 java_objectheader *o;
5928 java_nio_Buffer *nbuf;
5930 STATISTICS(jniinvokation());
5932 o = (java_objectheader *) buf;
5934 if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl))
5937 nbuf = (java_nio_Buffer *) o;
5939 return (jlong) nbuf->cap;
5941 vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration");
5943 /* keep compiler happy */
5950 /* DestroyJavaVM ***************************************************************
5952 Unloads a Java VM and reclaims its resources. Only the main thread
5953 can unload the VM. The system waits until the main thread is only
5954 remaining user thread before it destroys the VM.
5956 *******************************************************************************/
5958 jint _Jv_JNI_DestroyJavaVM(JavaVM *vm)
5962 STATISTICS(jniinvokation());
5964 status = vm_destroy(vm);
5970 /* AttachCurrentThread *********************************************************
5972 Attaches the current thread to a Java VM. Returns a JNI interface
5973 pointer in the JNIEnv argument.
5975 Trying to attach a thread that is already attached is a no-op.
5977 A native thread cannot be attached simultaneously to two Java VMs.
5979 When a thread is attached to the VM, the context class loader is
5980 the bootstrap loader.
5982 *******************************************************************************/
5984 static s4 jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon)
5986 JavaVMAttachArgs *vm_aargs;
5988 #if defined(ENABLE_THREADS)
5989 if (threads_get_current_threadobject() == NULL) {
5990 vm_aargs = (JavaVMAttachArgs *) thr_args;
5992 if (vm_aargs != NULL) {
5993 if ((vm_aargs->version != JNI_VERSION_1_2) &&
5994 (vm_aargs->version != JNI_VERSION_1_4))
5995 return JNI_EVERSION;
5998 if (!threads_attach_current_thread(vm_aargs, false))
6001 if (!jni_init_localref_table())
6012 jint _Jv_JNI_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args)
6014 STATISTICS(jniinvokation());
6016 return jni_attach_current_thread(p_env, thr_args, false);
6020 /* DetachCurrentThread *********************************************************
6022 Detaches the current thread from a Java VM. All Java monitors held
6023 by this thread are released. All Java threads waiting for this
6024 thread to die are notified.
6026 In JDK 1.1, the main thread cannot be detached from the VM. It must
6027 call DestroyJavaVM to unload the entire VM.
6029 In the JDK, the main thread can be detached from the VM.
6031 The main thread, which is the thread that created the Java VM,
6032 cannot be detached from the VM. Instead, the main thread must call
6033 JNI_DestroyJavaVM() to unload the entire VM.
6035 *******************************************************************************/
6037 jint _Jv_JNI_DetachCurrentThread(JavaVM *vm)
6039 #if defined(ENABLE_THREADS)
6040 threadobject *thread;
6042 STATISTICS(jniinvokation());
6044 thread = threads_get_current_threadobject();
6049 if (!jni_free_localref_table())
6052 if (!threads_detach_thread(thread))
6060 /* GetEnv **********************************************************************
6062 If the current thread is not attached to the VM, sets *env to NULL,
6063 and returns JNI_EDETACHED. If the specified version is not
6064 supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise,
6065 sets *env to the appropriate interface, and returns JNI_OK.
6067 *******************************************************************************/
6069 jint _Jv_JNI_GetEnv(JavaVM *vm, void **env, jint version)
6071 STATISTICS(jniinvokation());
6073 #if defined(ENABLE_THREADS)
6074 if (threads_get_current_threadobject() == NULL) {
6077 return JNI_EDETACHED;
6081 /* check the JNI version */
6084 case JNI_VERSION_1_1:
6085 case JNI_VERSION_1_2:
6086 case JNI_VERSION_1_4:
6094 #if defined(ENABLE_JVMTI)
6095 if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE)
6096 == JVMTI_VERSION_INTERFACE_JVMTI) {
6098 *env = (void *) jvmti_new_environment();
6107 return JNI_EVERSION;
6111 /* AttachCurrentThreadAsDaemon *************************************************
6113 Same semantics as AttachCurrentThread, but the newly-created
6114 java.lang.Thread instance is a daemon.
6116 If the thread has already been attached via either
6117 AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine
6118 simply sets the value pointed to by penv to the JNIEnv of the
6119 current thread. In this case neither AttachCurrentThread nor this
6120 routine have any effect on the daemon status of the thread.
6122 *******************************************************************************/
6124 jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
6126 STATISTICS(jniinvokation());
6128 return jni_attach_current_thread(penv, args, true);
6132 /* JNI invocation table *******************************************************/
6134 const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = {
6139 _Jv_JNI_DestroyJavaVM,
6140 _Jv_JNI_AttachCurrentThread,
6141 _Jv_JNI_DetachCurrentThread,
6143 _Jv_JNI_AttachCurrentThreadAsDaemon
6147 /* JNI function table *********************************************************/
6149 struct JNINativeInterface_ _Jv_JNINativeInterface = {
6156 _Jv_JNI_DefineClass,
6158 _Jv_JNI_FromReflectedMethod,
6159 _Jv_JNI_FromReflectedField,
6160 _Jv_JNI_ToReflectedMethod,
6161 _Jv_JNI_GetSuperclass,
6162 _Jv_JNI_IsAssignableFrom,
6163 _Jv_JNI_ToReflectedField,
6167 _Jv_JNI_ExceptionOccurred,
6168 _Jv_JNI_ExceptionDescribe,
6169 _Jv_JNI_ExceptionClear,
6171 _Jv_JNI_PushLocalFrame,
6172 _Jv_JNI_PopLocalFrame,
6174 _Jv_JNI_NewGlobalRef,
6175 _Jv_JNI_DeleteGlobalRef,
6176 _Jv_JNI_DeleteLocalRef,
6177 _Jv_JNI_IsSameObject,
6178 _Jv_JNI_NewLocalRef,
6179 _Jv_JNI_EnsureLocalCapacity,
6181 _Jv_JNI_AllocObject,
6186 _Jv_JNI_GetObjectClass,
6187 _Jv_JNI_IsInstanceOf,
6189 _Jv_JNI_GetMethodID,
6191 _Jv_JNI_CallObjectMethod,
6192 _Jv_JNI_CallObjectMethodV,
6193 _Jv_JNI_CallObjectMethodA,
6194 _Jv_JNI_CallBooleanMethod,
6195 _Jv_JNI_CallBooleanMethodV,
6196 _Jv_JNI_CallBooleanMethodA,
6197 _Jv_JNI_CallByteMethod,
6198 _Jv_JNI_CallByteMethodV,
6199 _Jv_JNI_CallByteMethodA,
6200 _Jv_JNI_CallCharMethod,
6201 _Jv_JNI_CallCharMethodV,
6202 _Jv_JNI_CallCharMethodA,
6203 _Jv_JNI_CallShortMethod,
6204 _Jv_JNI_CallShortMethodV,
6205 _Jv_JNI_CallShortMethodA,
6206 _Jv_JNI_CallIntMethod,
6207 _Jv_JNI_CallIntMethodV,
6208 _Jv_JNI_CallIntMethodA,
6209 _Jv_JNI_CallLongMethod,
6210 _Jv_JNI_CallLongMethodV,
6211 _Jv_JNI_CallLongMethodA,
6212 _Jv_JNI_CallFloatMethod,
6213 _Jv_JNI_CallFloatMethodV,
6214 _Jv_JNI_CallFloatMethodA,
6215 _Jv_JNI_CallDoubleMethod,
6216 _Jv_JNI_CallDoubleMethodV,
6217 _Jv_JNI_CallDoubleMethodA,
6218 _Jv_JNI_CallVoidMethod,
6219 _Jv_JNI_CallVoidMethodV,
6220 _Jv_JNI_CallVoidMethodA,
6222 _Jv_JNI_CallNonvirtualObjectMethod,
6223 _Jv_JNI_CallNonvirtualObjectMethodV,
6224 _Jv_JNI_CallNonvirtualObjectMethodA,
6225 _Jv_JNI_CallNonvirtualBooleanMethod,
6226 _Jv_JNI_CallNonvirtualBooleanMethodV,
6227 _Jv_JNI_CallNonvirtualBooleanMethodA,
6228 _Jv_JNI_CallNonvirtualByteMethod,
6229 _Jv_JNI_CallNonvirtualByteMethodV,
6230 _Jv_JNI_CallNonvirtualByteMethodA,
6231 _Jv_JNI_CallNonvirtualCharMethod,
6232 _Jv_JNI_CallNonvirtualCharMethodV,
6233 _Jv_JNI_CallNonvirtualCharMethodA,
6234 _Jv_JNI_CallNonvirtualShortMethod,
6235 _Jv_JNI_CallNonvirtualShortMethodV,
6236 _Jv_JNI_CallNonvirtualShortMethodA,
6237 _Jv_JNI_CallNonvirtualIntMethod,
6238 _Jv_JNI_CallNonvirtualIntMethodV,
6239 _Jv_JNI_CallNonvirtualIntMethodA,
6240 _Jv_JNI_CallNonvirtualLongMethod,
6241 _Jv_JNI_CallNonvirtualLongMethodV,
6242 _Jv_JNI_CallNonvirtualLongMethodA,
6243 _Jv_JNI_CallNonvirtualFloatMethod,
6244 _Jv_JNI_CallNonvirtualFloatMethodV,
6245 _Jv_JNI_CallNonvirtualFloatMethodA,
6246 _Jv_JNI_CallNonvirtualDoubleMethod,
6247 _Jv_JNI_CallNonvirtualDoubleMethodV,
6248 _Jv_JNI_CallNonvirtualDoubleMethodA,
6249 _Jv_JNI_CallNonvirtualVoidMethod,
6250 _Jv_JNI_CallNonvirtualVoidMethodV,
6251 _Jv_JNI_CallNonvirtualVoidMethodA,
6255 _Jv_JNI_GetObjectField,
6256 _Jv_JNI_GetBooleanField,
6257 _Jv_JNI_GetByteField,
6258 _Jv_JNI_GetCharField,
6259 _Jv_JNI_GetShortField,
6260 _Jv_JNI_GetIntField,
6261 _Jv_JNI_GetLongField,
6262 _Jv_JNI_GetFloatField,
6263 _Jv_JNI_GetDoubleField,
6264 _Jv_JNI_SetObjectField,
6265 _Jv_JNI_SetBooleanField,
6266 _Jv_JNI_SetByteField,
6267 _Jv_JNI_SetCharField,
6268 _Jv_JNI_SetShortField,
6269 _Jv_JNI_SetIntField,
6270 _Jv_JNI_SetLongField,
6271 _Jv_JNI_SetFloatField,
6272 _Jv_JNI_SetDoubleField,
6274 _Jv_JNI_GetStaticMethodID,
6276 _Jv_JNI_CallStaticObjectMethod,
6277 _Jv_JNI_CallStaticObjectMethodV,
6278 _Jv_JNI_CallStaticObjectMethodA,
6279 _Jv_JNI_CallStaticBooleanMethod,
6280 _Jv_JNI_CallStaticBooleanMethodV,
6281 _Jv_JNI_CallStaticBooleanMethodA,
6282 _Jv_JNI_CallStaticByteMethod,
6283 _Jv_JNI_CallStaticByteMethodV,
6284 _Jv_JNI_CallStaticByteMethodA,
6285 _Jv_JNI_CallStaticCharMethod,
6286 _Jv_JNI_CallStaticCharMethodV,
6287 _Jv_JNI_CallStaticCharMethodA,
6288 _Jv_JNI_CallStaticShortMethod,
6289 _Jv_JNI_CallStaticShortMethodV,
6290 _Jv_JNI_CallStaticShortMethodA,
6291 _Jv_JNI_CallStaticIntMethod,
6292 _Jv_JNI_CallStaticIntMethodV,
6293 _Jv_JNI_CallStaticIntMethodA,
6294 _Jv_JNI_CallStaticLongMethod,
6295 _Jv_JNI_CallStaticLongMethodV,
6296 _Jv_JNI_CallStaticLongMethodA,
6297 _Jv_JNI_CallStaticFloatMethod,
6298 _Jv_JNI_CallStaticFloatMethodV,
6299 _Jv_JNI_CallStaticFloatMethodA,
6300 _Jv_JNI_CallStaticDoubleMethod,
6301 _Jv_JNI_CallStaticDoubleMethodV,
6302 _Jv_JNI_CallStaticDoubleMethodA,
6303 _Jv_JNI_CallStaticVoidMethod,
6304 _Jv_JNI_CallStaticVoidMethodV,
6305 _Jv_JNI_CallStaticVoidMethodA,
6307 _Jv_JNI_GetStaticFieldID,
6309 _Jv_JNI_GetStaticObjectField,
6310 _Jv_JNI_GetStaticBooleanField,
6311 _Jv_JNI_GetStaticByteField,
6312 _Jv_JNI_GetStaticCharField,
6313 _Jv_JNI_GetStaticShortField,
6314 _Jv_JNI_GetStaticIntField,
6315 _Jv_JNI_GetStaticLongField,
6316 _Jv_JNI_GetStaticFloatField,
6317 _Jv_JNI_GetStaticDoubleField,
6318 _Jv_JNI_SetStaticObjectField,
6319 _Jv_JNI_SetStaticBooleanField,
6320 _Jv_JNI_SetStaticByteField,
6321 _Jv_JNI_SetStaticCharField,
6322 _Jv_JNI_SetStaticShortField,
6323 _Jv_JNI_SetStaticIntField,
6324 _Jv_JNI_SetStaticLongField,
6325 _Jv_JNI_SetStaticFloatField,
6326 _Jv_JNI_SetStaticDoubleField,
6329 _Jv_JNI_GetStringLength,
6330 _Jv_JNI_GetStringChars,
6331 _Jv_JNI_ReleaseStringChars,
6333 _Jv_JNI_NewStringUTF,
6334 _Jv_JNI_GetStringUTFLength,
6335 _Jv_JNI_GetStringUTFChars,
6336 _Jv_JNI_ReleaseStringUTFChars,
6338 _Jv_JNI_GetArrayLength,
6340 _Jv_JNI_NewObjectArray,
6341 _Jv_JNI_GetObjectArrayElement,
6342 _Jv_JNI_SetObjectArrayElement,
6344 _Jv_JNI_NewBooleanArray,
6345 _Jv_JNI_NewByteArray,
6346 _Jv_JNI_NewCharArray,
6347 _Jv_JNI_NewShortArray,
6348 _Jv_JNI_NewIntArray,
6349 _Jv_JNI_NewLongArray,
6350 _Jv_JNI_NewFloatArray,
6351 _Jv_JNI_NewDoubleArray,
6353 _Jv_JNI_GetBooleanArrayElements,
6354 _Jv_JNI_GetByteArrayElements,
6355 _Jv_JNI_GetCharArrayElements,
6356 _Jv_JNI_GetShortArrayElements,
6357 _Jv_JNI_GetIntArrayElements,
6358 _Jv_JNI_GetLongArrayElements,
6359 _Jv_JNI_GetFloatArrayElements,
6360 _Jv_JNI_GetDoubleArrayElements,
6362 _Jv_JNI_ReleaseBooleanArrayElements,
6363 _Jv_JNI_ReleaseByteArrayElements,
6364 _Jv_JNI_ReleaseCharArrayElements,
6365 _Jv_JNI_ReleaseShortArrayElements,
6366 _Jv_JNI_ReleaseIntArrayElements,
6367 _Jv_JNI_ReleaseLongArrayElements,
6368 _Jv_JNI_ReleaseFloatArrayElements,
6369 _Jv_JNI_ReleaseDoubleArrayElements,
6371 _Jv_JNI_GetBooleanArrayRegion,
6372 _Jv_JNI_GetByteArrayRegion,
6373 _Jv_JNI_GetCharArrayRegion,
6374 _Jv_JNI_GetShortArrayRegion,
6375 _Jv_JNI_GetIntArrayRegion,
6376 _Jv_JNI_GetLongArrayRegion,
6377 _Jv_JNI_GetFloatArrayRegion,
6378 _Jv_JNI_GetDoubleArrayRegion,
6379 _Jv_JNI_SetBooleanArrayRegion,
6380 _Jv_JNI_SetByteArrayRegion,
6381 _Jv_JNI_SetCharArrayRegion,
6382 _Jv_JNI_SetShortArrayRegion,
6383 _Jv_JNI_SetIntArrayRegion,
6384 _Jv_JNI_SetLongArrayRegion,
6385 _Jv_JNI_SetFloatArrayRegion,
6386 _Jv_JNI_SetDoubleArrayRegion,
6388 _Jv_JNI_RegisterNatives,
6389 _Jv_JNI_UnregisterNatives,
6391 _Jv_JNI_MonitorEnter,
6392 _Jv_JNI_MonitorExit,
6396 /* new JNI 1.2 functions */
6398 _Jv_JNI_GetStringRegion,
6399 _Jv_JNI_GetStringUTFRegion,
6401 _Jv_JNI_GetPrimitiveArrayCritical,
6402 _Jv_JNI_ReleasePrimitiveArrayCritical,
6404 _Jv_JNI_GetStringCritical,
6405 _Jv_JNI_ReleaseStringCritical,
6407 _Jv_JNI_NewWeakGlobalRef,
6408 _Jv_JNI_DeleteWeakGlobalRef,
6410 _Jv_JNI_ExceptionCheck,
6412 /* new JNI 1.4 functions */
6414 _Jv_JNI_NewDirectByteBuffer,
6415 _Jv_JNI_GetDirectBufferAddress,
6416 _Jv_JNI_GetDirectBufferCapacity
6420 /* Invocation API Functions ***************************************************/
6422 /* JNI_GetDefaultJavaVMInitArgs ************************************************
6424 Returns a default configuration for the Java VM.
6426 *******************************************************************************/
6428 jint JNI_GetDefaultJavaVMInitArgs(void *vm_args)
6430 JavaVMInitArgs *_vm_args;
6432 _vm_args = (JavaVMInitArgs *) vm_args;
6434 /* GNU classpath currently supports JNI 1.2 */
6436 switch (_vm_args->version) {
6437 case JNI_VERSION_1_1:
6438 _vm_args->version = JNI_VERSION_1_1;
6441 case JNI_VERSION_1_2:
6442 case JNI_VERSION_1_4:
6443 _vm_args->ignoreUnrecognized = JNI_FALSE;
6444 _vm_args->options = NULL;
6445 _vm_args->nOptions = 0;
6456 /* JNI_GetCreatedJavaVMs *******************************************************
6458 Returns all Java VMs that have been created. Pointers to VMs are written in
6459 the buffer vmBuf in the order they are created. At most bufLen number of
6460 entries will be written. The total number of created VMs is returned in
6463 *******************************************************************************/
6465 jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs)
6467 log_text("JNI_GetCreatedJavaVMs: IMPLEMENT ME!!!");
6473 /* JNI_CreateJavaVM ************************************************************
6475 Loads and initializes a Java VM. The current thread becomes the main thread.
6476 Sets the env argument to the JNI interface pointer of the main thread.
6478 *******************************************************************************/
6480 jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
6482 /* actually create the JVM */
6484 if (!vm_createjvm(p_vm, p_env, vm_args))
6492 * These are local overrides for various environment variables in Emacs.
6493 * Please do not remove this and leave it at the end of the file, where
6494 * Emacs will automagically detect them.
6495 * ---------------------------------------------------------------------
6498 * indent-tabs-mode: t
6502 * vim:noexpandtab:sw=4:ts=4: