1 // jni.cc - JNI implementation, including the jump table.
3 /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
16 // Define this before including jni.h.
17 #define __GCJ_JNI_IMPL__
21 #include <java-assert.h>
27 #include <java/lang/Class.h>
28 #include <java/lang/ClassLoader.h>
29 #include <java/lang/Throwable.h>
30 #include <java/lang/ArrayIndexOutOfBoundsException.h>
31 #include <java/lang/StringIndexOutOfBoundsException.h>
32 #include <java/lang/AbstractMethodError.h>
33 #include <java/lang/InstantiationException.h>
34 #include <java/lang/NoSuchFieldError.h>
35 #include <java/lang/NoSuchMethodError.h>
36 #include <java/lang/reflect/Constructor.h>
37 #include <java/lang/reflect/Method.h>
38 #include <java/lang/reflect/Modifier.h>
39 #include <java/lang/OutOfMemoryError.h>
40 #include <java/util/Hashtable.h>
41 #include <java/lang/Integer.h>
42 #include <java/lang/ThreadGroup.h>
43 #include <gnu/gcj/jni/NativeThread.h>
45 #include <gcj/method.h>
46 #include <gcj/field.h>
48 #include <java-interp.h>
50 // FIXME: remove these defines.
51 #define ClassClass java::lang::Class::class$
52 #define ObjectClass java::lang::Object::class$
53 #define ThrowableClass java::lang::Throwable::class$
54 #define MethodClass java::lang::reflect::Method::class$
55 #define ThreadGroupClass java::lang::ThreadGroup::class$
56 #define NativeThreadClass gnu::gcj::jni::NativeThread::class$
58 // This enum is used to select different template instantiations in
59 // the invocation code.
68 // Forward declarations.
69 extern struct JNINativeInterface _Jv_JNIFunctions
;
70 extern struct JNIInvokeInterface _Jv_JNI_InvokeFunctions
;
72 // Number of slots in the default frame. The VM must allow at least
76 // Mark value indicating this is an overflow frame.
78 // Mark value indicating this is a user frame.
80 // Mark value indicating this is a system frame.
83 // This structure is used to keep track of local references.
84 struct _Jv_JNI_LocalFrame
86 // This is true if this frame object represents a pushed frame (eg
87 // from PushLocalFrame).
90 // Number of elements in frame.
93 // Next frame in chain.
94 _Jv_JNI_LocalFrame
*next
;
96 // The elements. These are allocated using the C "struct hack".
100 // This holds a reference count for all local and global references.
101 static java::util::Hashtable
*ref_table
;
104 static JavaVM
*the_vm
;
107 // The only JVMPI interface description.
108 static JVMPI_Interface _Jv_JVMPI_Interface
;
111 jvmpiEnableEvent (jint event_type
, void *)
115 case JVMPI_EVENT_OBJECT_ALLOC
:
116 _Jv_JVMPI_Notify_OBJECT_ALLOC
= _Jv_JVMPI_Interface
.NotifyEvent
;
119 case JVMPI_EVENT_THREAD_START
:
120 _Jv_JVMPI_Notify_THREAD_START
= _Jv_JVMPI_Interface
.NotifyEvent
;
123 case JVMPI_EVENT_THREAD_END
:
124 _Jv_JVMPI_Notify_THREAD_END
= _Jv_JVMPI_Interface
.NotifyEvent
;
128 return JVMPI_NOT_AVAILABLE
;
131 return JVMPI_SUCCESS
;
135 jvmpiDisableEvent (jint event_type
, void *)
139 case JVMPI_EVENT_OBJECT_ALLOC
:
140 _Jv_JVMPI_Notify_OBJECT_ALLOC
= NULL
;
144 return JVMPI_NOT_AVAILABLE
;
147 return JVMPI_SUCCESS
;
156 ref_table
= new java::util::Hashtable
;
159 _Jv_JVMPI_Interface
.version
= 1;
160 _Jv_JVMPI_Interface
.EnableEvent
= &jvmpiEnableEvent
;
161 _Jv_JVMPI_Interface
.DisableEvent
= &jvmpiDisableEvent
;
162 _Jv_JVMPI_Interface
.EnableGC
= &_Jv_EnableGC
;
163 _Jv_JVMPI_Interface
.DisableGC
= &_Jv_DisableGC
;
164 _Jv_JVMPI_Interface
.RunGC
= &_Jv_RunGC
;
168 // Tell the GC that a certain pointer is live.
170 mark_for_gc (jobject obj
)
172 JvSynchronize
sync (ref_table
);
174 using namespace java::lang
;
175 Integer
*refcount
= (Integer
*) ref_table
->get (obj
);
176 jint val
= (refcount
== NULL
) ? 0 : refcount
->intValue ();
177 // FIXME: what about out of memory error?
178 ref_table
->put (obj
, new Integer (val
+ 1));
183 unmark_for_gc (jobject obj
)
185 JvSynchronize
sync (ref_table
);
187 using namespace java::lang
;
188 Integer
*refcount
= (Integer
*) ref_table
->get (obj
);
190 jint val
= refcount
->intValue () - 1;
192 ref_table
->remove (obj
);
194 // FIXME: what about out of memory error?
195 ref_table
->put (obj
, new Integer (val
));
201 _Jv_JNI_NewGlobalRef (JNIEnv
*, jobject obj
)
208 _Jv_JNI_DeleteGlobalRef (JNIEnv
*, jobject obj
)
214 _Jv_JNI_DeleteLocalRef (JNIEnv
*env
, jobject obj
)
216 _Jv_JNI_LocalFrame
*frame
;
218 for (frame
= env
->locals
; frame
!= NULL
; frame
= frame
->next
)
220 for (int i
= 0; i
< FRAME_SIZE
; ++i
)
222 if (frame
->vec
[i
] == obj
)
224 frame
->vec
[i
] = NULL
;
230 // Don't go past a marked frame.
231 JvAssert (frame
->marker
== MARK_NONE
);
238 _Jv_JNI_EnsureLocalCapacity (JNIEnv
*env
, jint size
)
240 // It is easier to just always allocate a new frame of the requested
241 // size. This isn't the most efficient thing, but for now we don't
242 // care. Note that _Jv_JNI_PushLocalFrame relies on this right now.
244 _Jv_JNI_LocalFrame
*frame
;
247 frame
= (_Jv_JNI_LocalFrame
*) _Jv_Malloc (sizeof (_Jv_JNI_LocalFrame
)
248 + size
* sizeof (jobject
));
256 frame
->marker
= MARK_NONE
;
258 memset (&frame
->vec
[0], 0, size
* sizeof (jobject
));
259 frame
->next
= env
->locals
;
266 _Jv_JNI_PushLocalFrame (JNIEnv
*env
, jint size
)
268 jint r
= _Jv_JNI_EnsureLocalCapacity (env
, size
);
272 // The new frame is on top.
273 env
->locals
->marker
= MARK_USER
;
279 _Jv_JNI_NewLocalRef (JNIEnv
*env
, jobject obj
)
281 // Try to find an open slot somewhere in the topmost frame.
282 _Jv_JNI_LocalFrame
*frame
= env
->locals
;
283 bool done
= false, set
= false;
284 for (; frame
!= NULL
&& ! done
; frame
= frame
->next
)
286 for (int i
= 0; i
< frame
->size
; ++i
)
288 if (frame
->vec
[i
] == NULL
)
297 // If we found a slot, or if the frame we just searched is the
298 // mark frame, then we are done.
299 if (done
|| frame
->marker
!= MARK_NONE
)
305 // No slots, so we allocate a new frame. According to the spec
306 // we could just die here. FIXME: return value.
307 _Jv_JNI_EnsureLocalCapacity (env
, 16);
308 // We know the first element of the new frame will be ok.
309 env
->locals
->vec
[0] = obj
;
317 _Jv_JNI_PopLocalFrame (JNIEnv
*env
, jobject result
, int stop
)
319 _Jv_JNI_LocalFrame
*rf
= env
->locals
;
322 while (rf
!= NULL
&& ! done
)
324 for (int i
= 0; i
< rf
->size
; ++i
)
325 if (rf
->vec
[i
] != NULL
)
326 unmark_for_gc (rf
->vec
[i
]);
328 // If the frame we just freed is the marker frame, we are done.
329 done
= (rf
->marker
== stop
);
331 _Jv_JNI_LocalFrame
*n
= rf
->next
;
332 // When N==NULL, we've reached the stack-allocated frame, and we
333 // must not free it. However, we must be sure to clear all its
334 // elements, since we might conceivably reuse it.
337 memset (&rf
->vec
[0], 0, rf
->size
* sizeof (jobject
));
345 // Update the local frame information.
348 return result
== NULL
? NULL
: _Jv_JNI_NewLocalRef (env
, result
);
352 _Jv_JNI_PopLocalFrame (JNIEnv
*env
, jobject result
)
354 return _Jv_JNI_PopLocalFrame (env
, result
, MARK_USER
);
357 // Pop a `system' frame from the stack. This is `extern "C"' as it is
358 // used by the compiler.
360 _Jv_JNI_PopSystemFrame (JNIEnv
*env
)
362 _Jv_JNI_PopLocalFrame (env
, NULL
, MARK_SYSTEM
);
366 jthrowable t
= env
->ex
;
372 // This function is used from other template functions. It wraps the
373 // return value appropriately; we specialize it so that object returns
374 // are turned into local references.
377 wrap_value (JNIEnv
*, T value
)
382 // This specialization is used for jobject, jclass, jstring, jarray,
386 wrap_value (JNIEnv
*env
, T
*value
)
388 return (value
== NULL
390 : (T
*) _Jv_JNI_NewLocalRef (env
, (jobject
) value
));
396 _Jv_JNI_GetVersion (JNIEnv
*)
398 return JNI_VERSION_1_2
;
402 _Jv_JNI_DefineClass (JNIEnv
*env
, jobject loader
,
403 const jbyte
*buf
, jsize bufLen
)
407 jbyteArray bytes
= JvNewByteArray (bufLen
);
409 jbyte
*elts
= elements (bytes
);
410 memcpy (elts
, buf
, bufLen
* sizeof (jbyte
));
412 java::lang::ClassLoader
*l
413 = reinterpret_cast<java::lang::ClassLoader
*> (loader
);
415 jclass result
= l
->defineClass (bytes
, 0, bufLen
);
416 return (jclass
) wrap_value (env
, result
);
426 _Jv_JNI_FindClass (JNIEnv
*env
, const char *name
)
428 // FIXME: assume that NAME isn't too long.
429 int len
= strlen (name
);
431 for (int i
= 0; i
<= len
; ++i
)
432 s
[i
] = (name
[i
] == '/') ? '.' : name
[i
];
437 // This might throw an out of memory exception.
438 jstring n
= JvNewStringUTF (s
);
440 java::lang::ClassLoader
*loader
= NULL
;
441 if (env
->klass
!= NULL
)
442 loader
= env
->klass
->getClassLoader ();
446 // FIXME: should use getBaseClassLoader, but we don't have that
448 loader
= java::lang::ClassLoader::getSystemClassLoader ();
451 r
= loader
->loadClass (n
);
458 return (jclass
) wrap_value (env
, r
);
462 _Jv_JNI_GetSuperclass (JNIEnv
*env
, jclass clazz
)
464 return (jclass
) wrap_value (env
, clazz
->getSuperclass ());
468 _Jv_JNI_IsAssignableFrom(JNIEnv
*, jclass clazz1
, jclass clazz2
)
470 return clazz1
->isAssignableFrom (clazz2
);
474 _Jv_JNI_Throw (JNIEnv
*env
, jthrowable obj
)
476 // We check in case the user did some funky cast.
477 JvAssert (obj
!= NULL
&& (&ThrowableClass
)->isInstance (obj
));
483 _Jv_JNI_ThrowNew (JNIEnv
*env
, jclass clazz
, const char *message
)
485 using namespace java::lang::reflect
;
487 JvAssert ((&ThrowableClass
)->isAssignableFrom (clazz
));
492 JArray
<jclass
> *argtypes
493 = (JArray
<jclass
> *) JvNewObjectArray (1, &ClassClass
, NULL
);
495 jclass
*elts
= elements (argtypes
);
496 elts
[0] = &StringClass
;
498 Constructor
*cons
= clazz
->getConstructor (argtypes
);
500 jobjectArray values
= JvNewObjectArray (1, &StringClass
, NULL
);
501 jobject
*velts
= elements (values
);
502 velts
[0] = JvNewStringUTF (message
);
504 jobject obj
= cons
->newInstance (values
);
506 env
->ex
= reinterpret_cast<jthrowable
> (obj
);
518 _Jv_JNI_ExceptionOccurred (JNIEnv
*env
)
520 return (jthrowable
) wrap_value (env
, env
->ex
);
524 _Jv_JNI_ExceptionDescribe (JNIEnv
*env
)
527 env
->ex
->printStackTrace();
531 _Jv_JNI_ExceptionClear (JNIEnv
*env
)
537 _Jv_JNI_ExceptionCheck (JNIEnv
*env
)
539 return env
->ex
!= NULL
;
543 _Jv_JNI_FatalError (JNIEnv
*, const char *message
)
551 _Jv_JNI_IsSameObject (JNIEnv
*, jobject obj1
, jobject obj2
)
557 _Jv_JNI_AllocObject (JNIEnv
*env
, jclass clazz
)
560 using namespace java::lang::reflect
;
564 JvAssert (clazz
&& ! clazz
->isArray ());
565 if (clazz
->isInterface() || Modifier::isAbstract(clazz
->getModifiers()))
566 env
->ex
= new java::lang::InstantiationException ();
569 // FIXME: will this work for String?
570 obj
= JvAllocObject (clazz
);
578 return wrap_value (env
, obj
);
582 _Jv_JNI_GetObjectClass (JNIEnv
*env
, jobject obj
)
585 return (jclass
) wrap_value (env
, obj
->getClass());
589 _Jv_JNI_IsInstanceOf (JNIEnv
*, jobject obj
, jclass clazz
)
591 return clazz
->isInstance(obj
);
597 // This section concerns method invocation.
600 template<jboolean is_static
>
602 _Jv_JNI_GetAnyMethodID (JNIEnv
*env
, jclass clazz
,
603 const char *name
, const char *sig
)
607 _Jv_InitClass (clazz
);
609 _Jv_Utf8Const
*name_u
= _Jv_makeUtf8Const ((char *) name
, -1);
611 // FIXME: assume that SIG isn't too long.
612 int len
= strlen (sig
);
614 for (int i
= 0; i
<= len
; ++i
)
615 s
[i
] = (sig
[i
] == '/') ? '.' : sig
[i
];
616 _Jv_Utf8Const
*sig_u
= _Jv_makeUtf8Const ((char *) s
, -1);
618 JvAssert (! clazz
->isPrimitive());
620 using namespace java::lang::reflect
;
622 while (clazz
!= NULL
)
624 jint count
= JvNumMethods (clazz
);
625 jmethodID meth
= JvGetFirstMethod (clazz
);
627 for (jint i
= 0; i
< count
; ++i
)
629 if (((is_static
&& Modifier::isStatic (meth
->accflags
))
630 || (! is_static
&& ! Modifier::isStatic (meth
->accflags
)))
631 && _Jv_equalUtf8Consts (meth
->name
, name_u
)
632 && _Jv_equalUtf8Consts (meth
->signature
, sig_u
))
635 meth
= meth
->getNextMethod();
638 clazz
= clazz
->getSuperclass ();
641 env
->ex
= new java::lang::NoSuchMethodError ();
651 // This is a helper function which turns a va_list into an array of
652 // `jvalue's. It needs signature information in order to do its work.
653 // The array of values must already be allocated.
655 array_from_valist (jvalue
*values
, JArray
<jclass
> *arg_types
, va_list vargs
)
657 jclass
*arg_elts
= elements (arg_types
);
658 for (int i
= 0; i
< arg_types
->length
; ++i
)
660 if (arg_elts
[i
] == JvPrimClass (byte
))
661 values
[i
].b
= va_arg (vargs
, jbyte
);
662 else if (arg_elts
[i
] == JvPrimClass (short))
663 values
[i
].s
= va_arg (vargs
, jshort
);
664 else if (arg_elts
[i
] == JvPrimClass (int))
665 values
[i
].i
= va_arg (vargs
, jint
);
666 else if (arg_elts
[i
] == JvPrimClass (long))
667 values
[i
].j
= va_arg (vargs
, jlong
);
668 else if (arg_elts
[i
] == JvPrimClass (float))
669 values
[i
].f
= va_arg (vargs
, jfloat
);
670 else if (arg_elts
[i
] == JvPrimClass (double))
671 values
[i
].d
= va_arg (vargs
, jdouble
);
672 else if (arg_elts
[i
] == JvPrimClass (boolean
))
673 values
[i
].z
= va_arg (vargs
, jboolean
);
674 else if (arg_elts
[i
] == JvPrimClass (char))
675 values
[i
].c
= va_arg (vargs
, jchar
);
679 values
[i
].l
= va_arg (vargs
, jobject
);
684 // This can call any sort of method: virtual, "nonvirtual", static, or
686 template<typename T
, invocation_type style
>
688 _Jv_JNI_CallAnyMethodV (JNIEnv
*env
, jobject obj
, jclass klass
,
689 jmethodID id
, va_list vargs
)
692 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
694 jclass decl_class
= klass
? klass
: obj
->getClass ();
695 JvAssert (decl_class
!= NULL
);
698 JArray
<jclass
> *arg_types
;
702 _Jv_GetTypesFromSignature (id
, decl_class
,
703 &arg_types
, &return_type
);
705 jvalue args
[arg_types
->length
];
706 array_from_valist (args
, arg_types
, vargs
);
708 // For constructors we need to pass the Class we are instantiating.
709 if (style
== constructor
)
713 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
714 style
== constructor
,
715 arg_types
, args
, &result
);
720 // We cheat a little here. FIXME.
721 return wrap_value (env
, * (T
*) &result
);
728 return wrap_value (env
, (T
) 0);
731 template<typename T
, invocation_type style
>
733 _Jv_JNI_CallAnyMethod (JNIEnv
*env
, jobject obj
, jclass klass
,
734 jmethodID method
, ...)
739 va_start (args
, method
);
740 result
= _Jv_JNI_CallAnyMethodV
<T
, style
> (env
, obj
, klass
, method
, args
);
746 template<typename T
, invocation_type style
>
748 _Jv_JNI_CallAnyMethodA (JNIEnv
*env
, jobject obj
, jclass klass
,
749 jmethodID id
, jvalue
*args
)
752 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
754 jclass decl_class
= klass
? klass
: obj
->getClass ();
755 JvAssert (decl_class
!= NULL
);
758 JArray
<jclass
> *arg_types
;
761 _Jv_GetTypesFromSignature (id
, decl_class
,
762 &arg_types
, &return_type
);
764 // For constructors we need to pass the Class we are instantiating.
765 if (style
== constructor
)
769 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
770 style
== constructor
,
771 arg_types
, args
, &result
);
776 // We cheat a little here. FIXME.
777 return wrap_value (env
, * (T
*) &result
);
784 return wrap_value (env
, (T
) 0);
787 template<invocation_type style
>
789 _Jv_JNI_CallAnyVoidMethodV (JNIEnv
*env
, jobject obj
, jclass klass
,
790 jmethodID id
, va_list vargs
)
793 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
795 jclass decl_class
= klass
? klass
: obj
->getClass ();
796 JvAssert (decl_class
!= NULL
);
799 JArray
<jclass
> *arg_types
;
802 _Jv_GetTypesFromSignature (id
, decl_class
,
803 &arg_types
, &return_type
);
805 jvalue args
[arg_types
->length
];
806 array_from_valist (args
, arg_types
, vargs
);
808 // For constructors we need to pass the Class we are instantiating.
809 if (style
== constructor
)
812 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
813 style
== constructor
,
814 arg_types
, args
, NULL
);
825 template<invocation_type style
>
827 _Jv_JNI_CallAnyVoidMethod (JNIEnv
*env
, jobject obj
, jclass klass
,
828 jmethodID method
, ...)
832 va_start (args
, method
);
833 _Jv_JNI_CallAnyVoidMethodV
<style
> (env
, obj
, klass
, method
, args
);
837 template<invocation_type style
>
839 _Jv_JNI_CallAnyVoidMethodA (JNIEnv
*env
, jobject obj
, jclass klass
,
840 jmethodID id
, jvalue
*args
)
843 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
845 jclass decl_class
= klass
? klass
: obj
->getClass ();
846 JvAssert (decl_class
!= NULL
);
849 JArray
<jclass
> *arg_types
;
852 _Jv_GetTypesFromSignature (id
, decl_class
,
853 &arg_types
, &return_type
);
855 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
856 style
== constructor
,
857 arg_types
, args
, NULL
);
868 // Functions with this signature are used to implement functions in
869 // the CallMethod family.
872 _Jv_JNI_CallMethodV (JNIEnv
*env
, jobject obj
, jmethodID id
, va_list args
)
874 return _Jv_JNI_CallAnyMethodV
<T
, normal
> (env
, obj
, NULL
, id
, args
);
877 // Functions with this signature are used to implement functions in
878 // the CallMethod family.
881 _Jv_JNI_CallMethod (JNIEnv
*env
, jobject obj
, jmethodID id
, ...)
887 result
= _Jv_JNI_CallAnyMethodV
<T
, normal
> (env
, obj
, NULL
, id
, args
);
893 // Functions with this signature are used to implement functions in
894 // the CallMethod family.
897 _Jv_JNI_CallMethodA (JNIEnv
*env
, jobject obj
, jmethodID id
, jvalue
*args
)
899 return _Jv_JNI_CallAnyMethodA
<T
, normal
> (env
, obj
, NULL
, id
, args
);
903 _Jv_JNI_CallVoidMethodV (JNIEnv
*env
, jobject obj
, jmethodID id
, va_list args
)
905 _Jv_JNI_CallAnyVoidMethodV
<normal
> (env
, obj
, NULL
, id
, args
);
909 _Jv_JNI_CallVoidMethod (JNIEnv
*env
, jobject obj
, jmethodID id
, ...)
914 _Jv_JNI_CallAnyVoidMethodV
<normal
> (env
, obj
, NULL
, id
, args
);
919 _Jv_JNI_CallVoidMethodA (JNIEnv
*env
, jobject obj
, jmethodID id
, jvalue
*args
)
921 _Jv_JNI_CallAnyVoidMethodA
<normal
> (env
, obj
, NULL
, id
, args
);
924 // Functions with this signature are used to implement functions in
925 // the CallStaticMethod family.
928 _Jv_JNI_CallStaticMethodV (JNIEnv
*env
, jclass klass
,
929 jmethodID id
, va_list args
)
931 JvAssert (((id
->accflags
) & java::lang::reflect::Modifier::STATIC
));
932 JvAssert ((&ClassClass
)->isInstance (klass
));
934 return _Jv_JNI_CallAnyMethodV
<T
, static_type
> (env
, NULL
, klass
, id
, args
);
937 // Functions with this signature are used to implement functions in
938 // the CallStaticMethod family.
941 _Jv_JNI_CallStaticMethod (JNIEnv
*env
, jclass klass
, jmethodID id
, ...)
946 JvAssert (((id
->accflags
) & java::lang::reflect::Modifier::STATIC
));
947 JvAssert ((&ClassClass
)->isInstance (klass
));
950 result
= _Jv_JNI_CallAnyMethodV
<T
, static_type
> (env
, NULL
, klass
,
957 // Functions with this signature are used to implement functions in
958 // the CallStaticMethod family.
961 _Jv_JNI_CallStaticMethodA (JNIEnv
*env
, jclass klass
, jmethodID id
,
964 JvAssert (((id
->accflags
) & java::lang::reflect::Modifier::STATIC
));
965 JvAssert ((&ClassClass
)->isInstance (klass
));
967 return _Jv_JNI_CallAnyMethodA
<T
, static_type
> (env
, NULL
, klass
, id
, args
);
971 _Jv_JNI_CallStaticVoidMethodV (JNIEnv
*env
, jclass klass
, jmethodID id
,
974 _Jv_JNI_CallAnyVoidMethodV
<static_type
> (env
, NULL
, klass
, id
, args
);
978 _Jv_JNI_CallStaticVoidMethod (JNIEnv
*env
, jclass klass
, jmethodID id
, ...)
983 _Jv_JNI_CallAnyVoidMethodV
<static_type
> (env
, NULL
, klass
, id
, args
);
988 _Jv_JNI_CallStaticVoidMethodA (JNIEnv
*env
, jclass klass
, jmethodID id
,
991 _Jv_JNI_CallAnyVoidMethodA
<static_type
> (env
, NULL
, klass
, id
, args
);
995 _Jv_JNI_NewObjectV (JNIEnv
*env
, jclass klass
,
996 jmethodID id
, va_list args
)
998 JvAssert (klass
&& ! klass
->isArray ());
999 JvAssert (! strcmp (id
->name
->data
, "<init>")
1000 && id
->signature
->length
> 2
1001 && id
->signature
->data
[0] == '('
1002 && ! strcmp (&id
->signature
->data
[id
->signature
->length
- 2],
1005 return _Jv_JNI_CallAnyMethodV
<jobject
, constructor
> (env
, NULL
, klass
,
1010 _Jv_JNI_NewObject (JNIEnv
*env
, jclass klass
, jmethodID id
, ...)
1012 JvAssert (klass
&& ! klass
->isArray ());
1013 JvAssert (! strcmp (id
->name
->data
, "<init>")
1014 && id
->signature
->length
> 2
1015 && id
->signature
->data
[0] == '('
1016 && ! strcmp (&id
->signature
->data
[id
->signature
->length
- 2],
1022 va_start (args
, id
);
1023 result
= _Jv_JNI_CallAnyMethodV
<jobject
, constructor
> (env
, NULL
, klass
,
1031 _Jv_JNI_NewObjectA (JNIEnv
*env
, jclass klass
, jmethodID id
,
1034 JvAssert (klass
&& ! klass
->isArray ());
1035 JvAssert (! strcmp (id
->name
->data
, "<init>")
1036 && id
->signature
->length
> 2
1037 && id
->signature
->data
[0] == '('
1038 && ! strcmp (&id
->signature
->data
[id
->signature
->length
- 2],
1041 return _Jv_JNI_CallAnyMethodA
<jobject
, constructor
> (env
, NULL
, klass
,
1047 template<typename T
>
1049 _Jv_JNI_GetField (JNIEnv
*env
, jobject obj
, jfieldID field
)
1052 T
*ptr
= (T
*) ((char *) obj
+ field
->getOffset ());
1053 return wrap_value (env
, *ptr
);
1056 template<typename T
>
1058 _Jv_JNI_SetField (JNIEnv
*, jobject obj
, jfieldID field
, T value
)
1061 T
*ptr
= (T
*) ((char *) obj
+ field
->getOffset ());
1065 template<jboolean is_static
>
1067 _Jv_JNI_GetAnyFieldID (JNIEnv
*env
, jclass clazz
,
1068 const char *name
, const char *sig
)
1072 _Jv_InitClass (clazz
);
1074 _Jv_Utf8Const
*a_name
= _Jv_makeUtf8Const ((char *) name
, -1);
1076 // FIXME: assume that SIG isn't too long.
1077 int len
= strlen (sig
);
1079 for (int i
= 0; i
<= len
; ++i
)
1080 s
[i
] = (sig
[i
] == '/') ? '.' : sig
[i
];
1081 jclass field_class
= _Jv_FindClassFromSignature ((char *) s
, NULL
);
1083 // FIXME: what if field_class == NULL?
1085 java::lang::ClassLoader
*loader
= clazz
->getClassLoader ();
1086 while (clazz
!= NULL
)
1088 // We acquire the class lock so that fields aren't resolved
1089 // while we are running.
1090 JvSynchronize
sync (clazz
);
1092 jint count
= (is_static
1093 ? JvNumStaticFields (clazz
)
1094 : JvNumInstanceFields (clazz
));
1095 jfieldID field
= (is_static
1096 ? JvGetFirstStaticField (clazz
)
1097 : JvGetFirstInstanceField (clazz
));
1098 for (jint i
= 0; i
< count
; ++i
)
1100 _Jv_Utf8Const
*f_name
= field
->getNameUtf8Const(clazz
);
1102 // The field might be resolved or it might not be. It
1103 // is much simpler to always resolve it.
1104 _Jv_ResolveField (field
, loader
);
1105 if (_Jv_equalUtf8Consts (f_name
, a_name
)
1106 && field
->getClass() == field_class
)
1109 field
= field
->getNextField ();
1112 clazz
= clazz
->getSuperclass ();
1115 env
->ex
= new java::lang::NoSuchFieldError ();
1117 catch (jthrowable t
)
1124 template<typename T
>
1126 _Jv_JNI_GetStaticField (JNIEnv
*env
, jclass
, jfieldID field
)
1128 T
*ptr
= (T
*) field
->u
.addr
;
1129 return wrap_value (env
, *ptr
);
1132 template<typename T
>
1134 _Jv_JNI_SetStaticField (JNIEnv
*, jclass
, jfieldID field
, T value
)
1136 T
*ptr
= (T
*) field
->u
.addr
;
1141 _Jv_JNI_NewString (JNIEnv
*env
, const jchar
*unichars
, jsize len
)
1145 jstring r
= _Jv_NewString (unichars
, len
);
1146 return (jstring
) wrap_value (env
, r
);
1148 catch (jthrowable t
)
1156 _Jv_JNI_GetStringLength (JNIEnv
*, jstring string
)
1158 return string
->length();
1161 static const jchar
*
1162 _Jv_JNI_GetStringChars (JNIEnv
*, jstring string
, jboolean
*isCopy
)
1164 jchar
*result
= _Jv_GetStringChars (string
);
1165 mark_for_gc (string
);
1168 return (const jchar
*) result
;
1172 _Jv_JNI_ReleaseStringChars (JNIEnv
*, jstring string
, const jchar
*)
1174 unmark_for_gc (string
);
1178 _Jv_JNI_NewStringUTF (JNIEnv
*env
, const char *bytes
)
1182 jstring result
= JvNewStringUTF (bytes
);
1183 return (jstring
) wrap_value (env
, result
);
1185 catch (jthrowable t
)
1193 _Jv_JNI_GetStringUTFLength (JNIEnv
*, jstring string
)
1195 return JvGetStringUTFLength (string
);
1199 _Jv_JNI_GetStringUTFChars (JNIEnv
*env
, jstring string
, jboolean
*isCopy
)
1201 jsize len
= JvGetStringUTFLength (string
);
1204 char *r
= (char *) _Jv_Malloc (len
+ 1);
1205 JvGetStringUTFRegion (string
, 0, len
, r
);
1211 return (const char *) r
;
1213 catch (jthrowable t
)
1221 _Jv_JNI_ReleaseStringUTFChars (JNIEnv
*, jstring
, const char *utf
)
1223 _Jv_Free ((void *) utf
);
1227 _Jv_JNI_GetStringRegion (JNIEnv
*env
, jstring string
, jsize start
, jsize len
,
1230 jchar
*result
= _Jv_GetStringChars (string
);
1231 if (start
< 0 || start
> string
->length ()
1232 || len
< 0 || start
+ len
> string
->length ())
1236 env
->ex
= new java::lang::StringIndexOutOfBoundsException ();
1238 catch (jthrowable t
)
1244 memcpy (buf
, &result
[start
], len
* sizeof (jchar
));
1248 _Jv_JNI_GetStringUTFRegion (JNIEnv
*env
, jstring str
, jsize start
,
1249 jsize len
, char *buf
)
1251 if (start
< 0 || start
> str
->length ()
1252 || len
< 0 || start
+ len
> str
->length ())
1256 env
->ex
= new java::lang::StringIndexOutOfBoundsException ();
1258 catch (jthrowable t
)
1264 _Jv_GetStringUTFRegion (str
, start
, len
, buf
);
1267 static const jchar
*
1268 _Jv_JNI_GetStringCritical (JNIEnv
*, jstring str
, jboolean
*isCopy
)
1270 jchar
*result
= _Jv_GetStringChars (str
);
1277 _Jv_JNI_ReleaseStringCritical (JNIEnv
*, jstring
, const jchar
*)
1283 _Jv_JNI_GetArrayLength (JNIEnv
*, jarray array
)
1285 return array
->length
;
1289 _Jv_JNI_NewObjectArray (JNIEnv
*env
, jsize length
, jclass elementClass
,
1294 jarray result
= JvNewObjectArray (length
, elementClass
, init
);
1295 return (jarray
) wrap_value (env
, result
);
1297 catch (jthrowable t
)
1305 _Jv_JNI_GetObjectArrayElement (JNIEnv
*env
, jobjectArray array
, jsize index
)
1307 jobject
*elts
= elements (array
);
1308 return wrap_value (env
, elts
[index
]);
1312 _Jv_JNI_SetObjectArrayElement (JNIEnv
*env
, jobjectArray array
, jsize index
,
1317 _Jv_CheckArrayStore (array
, value
);
1318 jobject
*elts
= elements (array
);
1319 elts
[index
] = value
;
1321 catch (jthrowable t
)
1327 template<typename T
, jclass K
>
1329 _Jv_JNI_NewPrimitiveArray (JNIEnv
*env
, jsize length
)
1333 return (JArray
<T
> *) wrap_value (env
, _Jv_NewPrimArray (K
, length
));
1335 catch (jthrowable t
)
1342 template<typename T
>
1344 _Jv_JNI_GetPrimitiveArrayElements (JNIEnv
*, JArray
<T
> *array
,
1347 T
*elts
= elements (array
);
1350 // We elect never to copy.
1353 mark_for_gc (array
);
1357 template<typename T
>
1359 _Jv_JNI_ReleasePrimitiveArrayElements (JNIEnv
*, JArray
<T
> *array
,
1360 T
*, jint
/* mode */)
1362 // Note that we ignore MODE. We can do this because we never copy
1363 // the array elements. My reading of the JNI documentation is that
1364 // this is an option for the implementor.
1365 unmark_for_gc (array
);
1368 template<typename T
>
1370 _Jv_JNI_GetPrimitiveArrayRegion (JNIEnv
*env
, JArray
<T
> *array
,
1371 jsize start
, jsize len
,
1374 // The cast to unsigned lets us save a comparison.
1375 if (start
< 0 || len
< 0
1376 || (unsigned long) (start
+ len
) > (unsigned long) array
->length
)
1381 env
->ex
= new java::lang::ArrayIndexOutOfBoundsException ();
1383 catch (jthrowable t
)
1385 // Could have thown out of memory error.
1391 T
*elts
= elements (array
) + start
;
1392 memcpy (buf
, elts
, len
* sizeof (T
));
1396 template<typename T
>
1398 _Jv_JNI_SetPrimitiveArrayRegion (JNIEnv
*env
, JArray
<T
> *array
,
1399 jsize start
, jsize len
, T
*buf
)
1401 // The cast to unsigned lets us save a comparison.
1402 if (start
< 0 || len
< 0
1403 || (unsigned long) (start
+ len
) > (unsigned long) array
->length
)
1408 env
->ex
= new java::lang::ArrayIndexOutOfBoundsException ();
1410 catch (jthrowable t
)
1417 T
*elts
= elements (array
) + start
;
1418 memcpy (elts
, buf
, len
* sizeof (T
));
1423 _Jv_JNI_GetPrimitiveArrayCritical (JNIEnv
*, jarray array
,
1426 // FIXME: does this work?
1427 jclass klass
= array
->getClass()->getComponentType();
1428 JvAssert (klass
->isPrimitive ());
1429 char *r
= _Jv_GetArrayElementFromElementType (array
, klass
);
1436 _Jv_JNI_ReleasePrimitiveArrayCritical (JNIEnv
*, jarray
, void *, jint
)
1442 _Jv_JNI_MonitorEnter (JNIEnv
*env
, jobject obj
)
1446 return _Jv_MonitorEnter (obj
);
1448 catch (jthrowable t
)
1456 _Jv_JNI_MonitorExit (JNIEnv
*env
, jobject obj
)
1460 return _Jv_MonitorExit (obj
);
1462 catch (jthrowable t
)
1471 _Jv_JNI_ToReflectedField (JNIEnv
*env
, jclass cls
, jfieldID fieldID
,
1476 java::lang::reflect::Field
*field
= new java::lang::reflect::Field();
1477 field
->declaringClass
= cls
;
1478 field
->offset
= (char*) fieldID
- (char *) cls
->fields
;
1479 field
->name
= _Jv_NewStringUtf8Const (fieldID
->getNameUtf8Const (cls
));
1480 return wrap_value (env
, field
);
1482 catch (jthrowable t
)
1491 _Jv_JNI_FromReflectedField (JNIEnv
*, jobject f
)
1493 using namespace java::lang::reflect
;
1495 Field
*field
= reinterpret_cast<Field
*> (f
);
1496 return _Jv_FromReflectedField (field
);
1500 _Jv_JNI_ToReflectedMethod (JNIEnv
*env
, jclass klass
, jmethodID id
,
1503 using namespace java::lang::reflect
;
1506 static _Jv_Utf8Const
*init_name
= _Jv_makeUtf8Const ("<init>", 6);
1508 jobject result
= NULL
;
1512 if (_Jv_equalUtf8Consts (id
->name
, init_name
))
1515 Constructor
*cons
= new Constructor ();
1516 cons
->offset
= (char *) id
- (char *) &klass
->methods
;
1517 cons
->declaringClass
= klass
;
1522 Method
*meth
= new Method ();
1523 meth
->offset
= (char *) id
- (char *) &klass
->methods
;
1524 meth
->declaringClass
= klass
;
1528 catch (jthrowable t
)
1533 return wrap_value (env
, result
);
1537 _Jv_JNI_FromReflectedMethod (JNIEnv
*, jobject method
)
1539 using namespace java::lang::reflect
;
1540 if ((&MethodClass
)->isInstance (method
))
1541 return _Jv_FromReflectedMethod (reinterpret_cast<Method
*> (method
));
1543 _Jv_FromReflectedConstructor (reinterpret_cast<Constructor
*> (method
));
1547 _Jv_JNI_RegisterNatives (JNIEnv
*env
, jclass k
,
1548 const JNINativeMethod
*methods
,
1552 // For now, this only matters for interpreted methods. FIXME.
1553 if (! _Jv_IsInterpretedClass (k
))
1555 // FIXME: throw exception.
1558 _Jv_InterpClass
*klass
= reinterpret_cast<_Jv_InterpClass
*> (k
);
1560 // Look at each descriptor given us, and find the corresponding
1561 // method in the class.
1562 for (int j
= 0; j
< nMethods
; ++j
)
1566 _Jv_MethodBase
**imeths
= _Jv_GetFirstMethod (klass
);
1567 for (int i
= 0; i
< JvNumMethods (klass
); ++i
)
1569 _Jv_MethodBase
*meth
= imeths
[i
];
1570 _Jv_Method
*self
= meth
->get_method ();
1572 if (! strcmp (self
->name
->data
, methods
[j
].name
)
1573 && ! strcmp (self
->signature
->data
, methods
[j
].signature
))
1575 if (! (self
->accflags
1576 & java::lang::reflect::Modifier::NATIVE
))
1579 // Found a match that is native.
1580 _Jv_JNIMethod
*jmeth
= reinterpret_cast<_Jv_JNIMethod
*> (meth
);
1581 jmeth
->set_function (methods
[i
].fnPtr
);
1589 jstring m
= JvNewStringUTF (methods
[j
].name
);
1592 env
->ex
=new java::lang::NoSuchMethodError (m
);
1594 catch (jthrowable t
)
1603 #else /* INTERPRETER */
1605 #endif /* INTERPRETER */
1609 _Jv_JNI_UnregisterNatives (JNIEnv
*, jclass
)
1616 // Add a character to the buffer, encoding properly.
1618 add_char (char *buf
, jchar c
, int *here
)
1622 buf
[(*here
)++] = '_';
1623 buf
[(*here
)++] = '1';
1627 buf
[(*here
)++] = '_';
1628 buf
[(*here
)++] = '2';
1632 buf
[(*here
)++] = '_';
1633 buf
[(*here
)++] = '3';
1636 // Also check for `.' here because we might be passed an internal
1637 // qualified class name like `foo.bar'.
1638 else if (c
== '/' || c
== '.')
1639 buf
[(*here
)++] = '_';
1640 else if ((c
>= '0' && c
<= '9')
1641 || (c
>= 'a' && c
<= 'z')
1642 || (c
>= 'A' && c
<= 'Z'))
1643 buf
[(*here
)++] = (char) c
;
1646 // "Unicode" character.
1647 buf
[(*here
)++] = '_';
1648 buf
[(*here
)++] = '0';
1649 for (int i
= 0; i
< 4; ++i
)
1652 buf
[(*here
) + 3 - i
] = (val
> 10) ? ('a' + val
- 10) : ('0' + val
);
1659 // Compute a mangled name for a native function. This computes the
1660 // long name, and also returns an index which indicates where a NUL
1661 // can be placed to create the short name. This function assumes that
1662 // the buffer is large enough for its results.
1664 mangled_name (jclass klass
, _Jv_Utf8Const
*func_name
,
1665 _Jv_Utf8Const
*signature
, char *buf
, int *long_start
)
1667 strcpy (buf
, "Java_");
1670 // Add fully qualified class name.
1671 jchar
*chars
= _Jv_GetStringChars (klass
->getName ());
1672 jint len
= klass
->getName ()->length ();
1673 for (int i
= 0; i
< len
; ++i
)
1674 add_char (buf
, chars
[i
], &here
);
1676 // Don't use add_char because we need a literal `_'.
1679 const unsigned char *fn
= (const unsigned char *) func_name
->data
;
1680 const unsigned char *limit
= fn
+ func_name
->length
;
1681 for (int i
= 0; ; ++i
)
1683 int ch
= UTF8_GET (fn
, limit
);
1686 add_char (buf
, ch
, &here
);
1689 // This is where the long signature begins.
1694 const unsigned char *sig
= (const unsigned char *) signature
->data
;
1695 limit
= sig
+ signature
->length
;
1696 JvAssert (sig
[0] == '(');
1700 int ch
= UTF8_GET (sig
, limit
);
1701 if (ch
== ')' || ch
< 0)
1703 add_char (buf
, ch
, &here
);
1709 // Return the current thread's JNIEnv; if one does not exist, create
1710 // it. Also create a new system frame for use. This is `extern "C"'
1711 // because the compiler calls it.
1713 _Jv_GetJNIEnvNewFrame (jclass klass
)
1715 JNIEnv
*env
= _Jv_GetCurrentJNIEnv ();
1718 env
= (JNIEnv
*) _Jv_MallocUnchecked (sizeof (JNIEnv
));
1719 env
->p
= &_Jv_JNIFunctions
;
1724 _Jv_SetCurrentJNIEnv (env
);
1727 _Jv_JNI_LocalFrame
*frame
1728 = (_Jv_JNI_LocalFrame
*) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame
)
1730 * sizeof (jobject
)));
1732 frame
->marker
= MARK_SYSTEM
;
1733 frame
->size
= FRAME_SIZE
;
1734 frame
->next
= env
->locals
;
1735 env
->locals
= frame
;
1737 for (int i
= 0; i
< frame
->size
; ++i
)
1738 frame
->vec
[i
] = NULL
;
1743 // Return the function which implements a particular JNI method. If
1744 // we can't find the function, we throw the appropriate exception.
1745 // This is `extern "C"' because the compiler uses it.
1747 _Jv_LookupJNIMethod (jclass klass
, _Jv_Utf8Const
*name
,
1748 _Jv_Utf8Const
*signature
)
1750 char buf
[10 + 6 * (name
->length
+ signature
->length
)];
1754 mangled_name (klass
, name
, signature
, buf
, &long_start
);
1755 char c
= buf
[long_start
];
1756 buf
[long_start
] = '\0';
1757 function
= _Jv_FindSymbolInExecutable (buf
);
1758 if (function
== NULL
)
1760 buf
[long_start
] = c
;
1761 function
= _Jv_FindSymbolInExecutable (buf
);
1762 if (function
== NULL
)
1764 jstring str
= JvNewStringUTF (name
->data
);
1765 JvThrow (new java::lang::AbstractMethodError (str
));
1774 // This function is the stub which is used to turn an ordinary (CNI)
1775 // method call into a JNI call.
1777 _Jv_JNIMethod::call (ffi_cif
*, void *ret
, ffi_raw
*args
, void *__this
)
1779 _Jv_JNIMethod
* _this
= (_Jv_JNIMethod
*) __this
;
1781 JNIEnv
*env
= _Jv_GetJNIEnvNewFrame (_this
->defining_class
);
1783 // FIXME: we should mark every reference parameter as a local. For
1784 // now we assume a conservative GC, and we assume that the
1785 // references are on the stack somewhere.
1787 // We cache the value that we find, of course, but if we don't find
1788 // a value we don't cache that fact -- we might subsequently load a
1789 // library which finds the function in question.
1790 if (_this
->function
== NULL
)
1791 _this
->function
= _Jv_LookupJNIMethod (_this
->defining_class
,
1793 _this
->self
->signature
);
1795 JvAssert (_this
->args_raw_size
% sizeof (ffi_raw
) == 0);
1796 ffi_raw real_args
[2 + _this
->args_raw_size
/ sizeof (ffi_raw
)];
1799 // First argument is always the environment pointer.
1800 real_args
[offset
++].ptr
= env
;
1802 // For a static method, we pass in the Class. For non-static
1803 // methods, the `this' argument is already handled.
1804 if ((_this
->self
->accflags
& java::lang::reflect::Modifier::STATIC
))
1805 real_args
[offset
++].ptr
= _this
->defining_class
;
1807 // Copy over passed-in arguments.
1808 memcpy (&real_args
[offset
], args
, _this
->args_raw_size
);
1810 // The actual call to the JNI function.
1811 ffi_raw_call (&_this
->jni_cif
, (void (*)()) _this
->function
,
1814 _Jv_JNI_PopSystemFrame (env
);
1817 #endif /* INTERPRETER */
1825 // An internal helper function.
1827 _Jv_JNI_AttachCurrentThread (JavaVM
*, jstring name
, void **penv
, void *args
)
1829 JavaVMAttachArgs
*attach
= reinterpret_cast<JavaVMAttachArgs
*> (args
);
1830 java::lang::ThreadGroup
*group
= NULL
;
1834 // FIXME: do we really want to support 1.1?
1835 if (attach
->version
!= JNI_VERSION_1_2
1836 && attach
->version
!= JNI_VERSION_1_1
)
1837 return JNI_EVERSION
;
1839 JvAssert ((&ThreadGroupClass
)->isInstance (attach
->group
));
1840 group
= reinterpret_cast<java::lang::ThreadGroup
*> (attach
->group
);
1843 // Attaching an already-attached thread is a no-op.
1844 if (_Jv_GetCurrentJNIEnv () != NULL
)
1847 JNIEnv
*env
= (JNIEnv
*) _Jv_MallocUnchecked (sizeof (JNIEnv
));
1850 env
->p
= &_Jv_JNIFunctions
;
1854 = (_Jv_JNI_LocalFrame
*) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame
)
1856 * sizeof (jobject
)));
1857 if (env
->locals
== NULL
)
1862 *penv
= reinterpret_cast<void *> (env
);
1864 // This thread might already be a Java thread -- this function might
1865 // have been called simply to set the new JNIEnv.
1866 if (_Jv_ThreadCurrent () == NULL
)
1870 (void) new gnu::gcj::jni::NativeThread (group
, name
);
1872 catch (jthrowable t
)
1877 _Jv_SetCurrentJNIEnv (env
);
1882 // This is the one actually used by JNI.
1884 _Jv_JNI_AttachCurrentThread (JavaVM
*vm
, void **penv
, void *args
)
1886 return _Jv_JNI_AttachCurrentThread (vm
, NULL
, penv
, args
);
1890 _Jv_JNI_DestroyJavaVM (JavaVM
*vm
)
1892 JvAssert (the_vm
&& vm
== the_vm
);
1895 if (_Jv_ThreadCurrent () != NULL
)
1901 main_name
= JvNewStringLatin1 ("main");
1903 catch (jthrowable t
)
1908 jint r
= _Jv_JNI_AttachCurrentThread (vm
,
1910 reinterpret_cast<void **> (&env
),
1916 env
= _Jv_GetCurrentJNIEnv ();
1920 // Docs say that this always returns an error code.
1925 _Jv_JNI_DetachCurrentThread (JavaVM
*)
1927 java::lang::Thread
*t
= _Jv_ThreadCurrent ();
1929 return JNI_EDETACHED
;
1931 // FIXME: we only allow threads attached via AttachCurrentThread to
1932 // be detached. I have no idea how we could implement detaching
1933 // other threads, given the requirement that we must release all the
1934 // monitors. That just seems evil.
1935 JvAssert ((&NativeThreadClass
)->isInstance (t
));
1937 // FIXME: release the monitors. We'll take this to mean all
1938 // monitors acquired via the JNI interface. This means we have to
1939 // keep track of them.
1941 gnu::gcj::jni::NativeThread
*nt
1942 = reinterpret_cast<gnu::gcj::jni::NativeThread
*> (t
);
1949 _Jv_JNI_GetEnv (JavaVM
*, void **penv
, jint version
)
1951 if (_Jv_ThreadCurrent () == NULL
)
1954 return JNI_EDETACHED
;
1958 // Handle JVMPI requests.
1959 if (version
== JVMPI_VERSION_1
)
1961 *penv
= (void *) &_Jv_JVMPI_Interface
;
1966 // FIXME: do we really want to support 1.1?
1967 if (version
!= JNI_VERSION_1_2
&& version
!= JNI_VERSION_1_1
)
1970 return JNI_EVERSION
;
1973 *penv
= (void *) _Jv_GetCurrentJNIEnv ();
1978 JNI_GetDefaultJavaVMInitArgs (void *args
)
1980 jint version
= * (jint
*) args
;
1981 // Here we only support 1.2.
1982 if (version
!= JNI_VERSION_1_2
)
1983 return JNI_EVERSION
;
1985 JavaVMInitArgs
*ia
= reinterpret_cast<JavaVMInitArgs
*> (args
);
1986 ia
->version
= JNI_VERSION_1_2
;
1989 ia
->ignoreUnrecognized
= true;
1995 JNI_CreateJavaVM (JavaVM
**vm
, void **penv
, void *args
)
1997 JvAssert (! the_vm
);
1998 // FIXME: synchronize
1999 JavaVM
*nvm
= (JavaVM
*) _Jv_MallocUnchecked (sizeof (JavaVM
));
2002 nvm
->functions
= &_Jv_JNI_InvokeFunctions
;
2004 // Parse the arguments.
2007 jint version
= * (jint
*) args
;
2008 // We only support 1.2.
2009 if (version
!= JNI_VERSION_1_2
)
2010 return JNI_EVERSION
;
2011 JavaVMInitArgs
*ia
= reinterpret_cast<JavaVMInitArgs
*> (args
);
2012 for (int i
= 0; i
< ia
->nOptions
; ++i
)
2014 if (! strcmp (ia
->options
[i
].optionString
, "vfprintf")
2015 || ! strcmp (ia
->options
[i
].optionString
, "exit")
2016 || ! strcmp (ia
->options
[i
].optionString
, "abort"))
2018 // We are required to recognize these, but for now we
2019 // don't handle them in any way. FIXME.
2022 else if (! strncmp (ia
->options
[i
].optionString
,
2023 "-verbose", sizeof ("-verbose") - 1))
2025 // We don't do anything with this option either. We
2026 // might want to make sure the argument is valid, but we
2027 // don't really care all that much for now.
2030 else if (! strncmp (ia
->options
[i
].optionString
, "-D", 2))
2035 else if (ia
->ignoreUnrecognized
)
2037 if (ia
->options
[i
].optionString
[0] == '_'
2038 || ! strncmp (ia
->options
[i
].optionString
, "-X", 2))
2046 jint r
=_Jv_JNI_AttachCurrentThread (nvm
, penv
, NULL
);
2056 JNI_GetCreatedJavaVMs (JavaVM
**vm_buffer
, jsize buf_len
, jsize
*n_vms
)
2061 // We only support a single VM.
2064 vm_buffer
[0] = the_vm
;
2075 // FIXME: synchronize
2078 JavaVM
*nvm
= (JavaVM
*) _Jv_MallocUnchecked (sizeof (JavaVM
));
2080 nvm
->functions
= &_Jv_JNI_InvokeFunctions
;
2084 // If this is a Java thread, we want to make sure it has an
2085 // associated JNIEnv.
2086 if (_Jv_ThreadCurrent () != NULL
)
2089 _Jv_JNI_AttachCurrentThread (the_vm
, &ignore
, NULL
);
2096 _Jv_JNI_GetJavaVM (JNIEnv
*, JavaVM
**vm
)
2098 *vm
= _Jv_GetJavaVM ();
2099 return *vm
== NULL
? JNI_ERR
: JNI_OK
;
2104 #define NOT_IMPL NULL
2105 #define RESERVED NULL
2107 struct JNINativeInterface _Jv_JNIFunctions
=
2113 _Jv_JNI_GetVersion
, // GetVersion
2114 _Jv_JNI_DefineClass
, // DefineClass
2115 _Jv_JNI_FindClass
, // FindClass
2116 _Jv_JNI_FromReflectedMethod
, // FromReflectedMethod
2117 _Jv_JNI_FromReflectedField
, // FromReflectedField
2118 _Jv_JNI_ToReflectedMethod
, // ToReflectedMethod
2119 _Jv_JNI_GetSuperclass
, // GetSuperclass
2120 _Jv_JNI_IsAssignableFrom
, // IsAssignableFrom
2121 _Jv_JNI_ToReflectedField
, // ToReflectedField
2122 _Jv_JNI_Throw
, // Throw
2123 _Jv_JNI_ThrowNew
, // ThrowNew
2124 _Jv_JNI_ExceptionOccurred
, // ExceptionOccurred
2125 _Jv_JNI_ExceptionDescribe
, // ExceptionDescribe
2126 _Jv_JNI_ExceptionClear
, // ExceptionClear
2127 _Jv_JNI_FatalError
, // FatalError
2129 _Jv_JNI_PushLocalFrame
, // PushLocalFrame
2130 _Jv_JNI_PopLocalFrame
, // PopLocalFrame
2131 _Jv_JNI_NewGlobalRef
, // NewGlobalRef
2132 _Jv_JNI_DeleteGlobalRef
, // DeleteGlobalRef
2133 _Jv_JNI_DeleteLocalRef
, // DeleteLocalRef
2135 _Jv_JNI_IsSameObject
, // IsSameObject
2137 _Jv_JNI_NewLocalRef
, // NewLocalRef
2138 _Jv_JNI_EnsureLocalCapacity
, // EnsureLocalCapacity
2140 _Jv_JNI_AllocObject
, // AllocObject
2141 _Jv_JNI_NewObject
, // NewObject
2142 _Jv_JNI_NewObjectV
, // NewObjectV
2143 _Jv_JNI_NewObjectA
, // NewObjectA
2144 _Jv_JNI_GetObjectClass
, // GetObjectClass
2145 _Jv_JNI_IsInstanceOf
, // IsInstanceOf
2146 _Jv_JNI_GetAnyMethodID
<false>, // GetMethodID
2148 _Jv_JNI_CallMethod
<jobject
>, // CallObjectMethod
2149 _Jv_JNI_CallMethodV
<jobject
>, // CallObjectMethodV
2150 _Jv_JNI_CallMethodA
<jobject
>, // CallObjectMethodA
2151 _Jv_JNI_CallMethod
<jboolean
>, // CallBooleanMethod
2152 _Jv_JNI_CallMethodV
<jboolean
>, // CallBooleanMethodV
2153 _Jv_JNI_CallMethodA
<jboolean
>, // CallBooleanMethodA
2154 _Jv_JNI_CallMethod
<jbyte
>, // CallByteMethod
2155 _Jv_JNI_CallMethodV
<jbyte
>, // CallByteMethodV
2156 _Jv_JNI_CallMethodA
<jbyte
>, // CallByteMethodA
2157 _Jv_JNI_CallMethod
<jchar
>, // CallCharMethod
2158 _Jv_JNI_CallMethodV
<jchar
>, // CallCharMethodV
2159 _Jv_JNI_CallMethodA
<jchar
>, // CallCharMethodA
2160 _Jv_JNI_CallMethod
<jshort
>, // CallShortMethod
2161 _Jv_JNI_CallMethodV
<jshort
>, // CallShortMethodV
2162 _Jv_JNI_CallMethodA
<jshort
>, // CallShortMethodA
2163 _Jv_JNI_CallMethod
<jint
>, // CallIntMethod
2164 _Jv_JNI_CallMethodV
<jint
>, // CallIntMethodV
2165 _Jv_JNI_CallMethodA
<jint
>, // CallIntMethodA
2166 _Jv_JNI_CallMethod
<jlong
>, // CallLongMethod
2167 _Jv_JNI_CallMethodV
<jlong
>, // CallLongMethodV
2168 _Jv_JNI_CallMethodA
<jlong
>, // CallLongMethodA
2169 _Jv_JNI_CallMethod
<jfloat
>, // CallFloatMethod
2170 _Jv_JNI_CallMethodV
<jfloat
>, // CallFloatMethodV
2171 _Jv_JNI_CallMethodA
<jfloat
>, // CallFloatMethodA
2172 _Jv_JNI_CallMethod
<jdouble
>, // CallDoubleMethod
2173 _Jv_JNI_CallMethodV
<jdouble
>, // CallDoubleMethodV
2174 _Jv_JNI_CallMethodA
<jdouble
>, // CallDoubleMethodA
2175 _Jv_JNI_CallVoidMethod
, // CallVoidMethod
2176 _Jv_JNI_CallVoidMethodV
, // CallVoidMethodV
2177 _Jv_JNI_CallVoidMethodA
, // CallVoidMethodA
2179 // Nonvirtual method invocation functions follow.
2180 _Jv_JNI_CallAnyMethod
<jobject
, nonvirtual
>, // CallNonvirtualObjectMethod
2181 _Jv_JNI_CallAnyMethodV
<jobject
, nonvirtual
>, // CallNonvirtualObjectMethodV
2182 _Jv_JNI_CallAnyMethodA
<jobject
, nonvirtual
>, // CallNonvirtualObjectMethodA
2183 _Jv_JNI_CallAnyMethod
<jboolean
, nonvirtual
>, // CallNonvirtualBooleanMethod
2184 _Jv_JNI_CallAnyMethodV
<jboolean
, nonvirtual
>, // CallNonvirtualBooleanMethodV
2185 _Jv_JNI_CallAnyMethodA
<jboolean
, nonvirtual
>, // CallNonvirtualBooleanMethodA
2186 _Jv_JNI_CallAnyMethod
<jbyte
, nonvirtual
>, // CallNonvirtualByteMethod
2187 _Jv_JNI_CallAnyMethodV
<jbyte
, nonvirtual
>, // CallNonvirtualByteMethodV
2188 _Jv_JNI_CallAnyMethodA
<jbyte
, nonvirtual
>, // CallNonvirtualByteMethodA
2189 _Jv_JNI_CallAnyMethod
<jchar
, nonvirtual
>, // CallNonvirtualCharMethod
2190 _Jv_JNI_CallAnyMethodV
<jchar
, nonvirtual
>, // CallNonvirtualCharMethodV
2191 _Jv_JNI_CallAnyMethodA
<jchar
, nonvirtual
>, // CallNonvirtualCharMethodA
2192 _Jv_JNI_CallAnyMethod
<jshort
, nonvirtual
>, // CallNonvirtualShortMethod
2193 _Jv_JNI_CallAnyMethodV
<jshort
, nonvirtual
>, // CallNonvirtualShortMethodV
2194 _Jv_JNI_CallAnyMethodA
<jshort
, nonvirtual
>, // CallNonvirtualShortMethodA
2195 _Jv_JNI_CallAnyMethod
<jint
, nonvirtual
>, // CallNonvirtualIntMethod
2196 _Jv_JNI_CallAnyMethodV
<jint
, nonvirtual
>, // CallNonvirtualIntMethodV
2197 _Jv_JNI_CallAnyMethodA
<jint
, nonvirtual
>, // CallNonvirtualIntMethodA
2198 _Jv_JNI_CallAnyMethod
<jlong
, nonvirtual
>, // CallNonvirtualLongMethod
2199 _Jv_JNI_CallAnyMethodV
<jlong
, nonvirtual
>, // CallNonvirtualLongMethodV
2200 _Jv_JNI_CallAnyMethodA
<jlong
, nonvirtual
>, // CallNonvirtualLongMethodA
2201 _Jv_JNI_CallAnyMethod
<jfloat
, nonvirtual
>, // CallNonvirtualFloatMethod
2202 _Jv_JNI_CallAnyMethodV
<jfloat
, nonvirtual
>, // CallNonvirtualFloatMethodV
2203 _Jv_JNI_CallAnyMethodA
<jfloat
, nonvirtual
>, // CallNonvirtualFloatMethodA
2204 _Jv_JNI_CallAnyMethod
<jdouble
, nonvirtual
>, // CallNonvirtualDoubleMethod
2205 _Jv_JNI_CallAnyMethodV
<jdouble
, nonvirtual
>, // CallNonvirtualDoubleMethodV
2206 _Jv_JNI_CallAnyMethodA
<jdouble
, nonvirtual
>, // CallNonvirtualDoubleMethodA
2207 _Jv_JNI_CallAnyVoidMethod
<nonvirtual
>, // CallNonvirtualVoidMethod
2208 _Jv_JNI_CallAnyVoidMethodV
<nonvirtual
>, // CallNonvirtualVoidMethodV
2209 _Jv_JNI_CallAnyVoidMethodA
<nonvirtual
>, // CallNonvirtualVoidMethodA
2211 _Jv_JNI_GetAnyFieldID
<false>, // GetFieldID
2212 _Jv_JNI_GetField
<jobject
>, // GetObjectField
2213 _Jv_JNI_GetField
<jboolean
>, // GetBooleanField
2214 _Jv_JNI_GetField
<jbyte
>, // GetByteField
2215 _Jv_JNI_GetField
<jchar
>, // GetCharField
2216 _Jv_JNI_GetField
<jshort
>, // GetShortField
2217 _Jv_JNI_GetField
<jint
>, // GetIntField
2218 _Jv_JNI_GetField
<jlong
>, // GetLongField
2219 _Jv_JNI_GetField
<jfloat
>, // GetFloatField
2220 _Jv_JNI_GetField
<jdouble
>, // GetDoubleField
2221 _Jv_JNI_SetField
, // SetObjectField
2222 _Jv_JNI_SetField
, // SetBooleanField
2223 _Jv_JNI_SetField
, // SetByteField
2224 _Jv_JNI_SetField
, // SetCharField
2225 _Jv_JNI_SetField
, // SetShortField
2226 _Jv_JNI_SetField
, // SetIntField
2227 _Jv_JNI_SetField
, // SetLongField
2228 _Jv_JNI_SetField
, // SetFloatField
2229 _Jv_JNI_SetField
, // SetDoubleField
2230 _Jv_JNI_GetAnyMethodID
<true>, // GetStaticMethodID
2232 _Jv_JNI_CallStaticMethod
<jobject
>, // CallStaticObjectMethod
2233 _Jv_JNI_CallStaticMethodV
<jobject
>, // CallStaticObjectMethodV
2234 _Jv_JNI_CallStaticMethodA
<jobject
>, // CallStaticObjectMethodA
2235 _Jv_JNI_CallStaticMethod
<jboolean
>, // CallStaticBooleanMethod
2236 _Jv_JNI_CallStaticMethodV
<jboolean
>, // CallStaticBooleanMethodV
2237 _Jv_JNI_CallStaticMethodA
<jboolean
>, // CallStaticBooleanMethodA
2238 _Jv_JNI_CallStaticMethod
<jbyte
>, // CallStaticByteMethod
2239 _Jv_JNI_CallStaticMethodV
<jbyte
>, // CallStaticByteMethodV
2240 _Jv_JNI_CallStaticMethodA
<jbyte
>, // CallStaticByteMethodA
2241 _Jv_JNI_CallStaticMethod
<jchar
>, // CallStaticCharMethod
2242 _Jv_JNI_CallStaticMethodV
<jchar
>, // CallStaticCharMethodV
2243 _Jv_JNI_CallStaticMethodA
<jchar
>, // CallStaticCharMethodA
2244 _Jv_JNI_CallStaticMethod
<jshort
>, // CallStaticShortMethod
2245 _Jv_JNI_CallStaticMethodV
<jshort
>, // CallStaticShortMethodV
2246 _Jv_JNI_CallStaticMethodA
<jshort
>, // CallStaticShortMethodA
2247 _Jv_JNI_CallStaticMethod
<jint
>, // CallStaticIntMethod
2248 _Jv_JNI_CallStaticMethodV
<jint
>, // CallStaticIntMethodV
2249 _Jv_JNI_CallStaticMethodA
<jint
>, // CallStaticIntMethodA
2250 _Jv_JNI_CallStaticMethod
<jlong
>, // CallStaticLongMethod
2251 _Jv_JNI_CallStaticMethodV
<jlong
>, // CallStaticLongMethodV
2252 _Jv_JNI_CallStaticMethodA
<jlong
>, // CallStaticLongMethodA
2253 _Jv_JNI_CallStaticMethod
<jfloat
>, // CallStaticFloatMethod
2254 _Jv_JNI_CallStaticMethodV
<jfloat
>, // CallStaticFloatMethodV
2255 _Jv_JNI_CallStaticMethodA
<jfloat
>, // CallStaticFloatMethodA
2256 _Jv_JNI_CallStaticMethod
<jdouble
>, // CallStaticDoubleMethod
2257 _Jv_JNI_CallStaticMethodV
<jdouble
>, // CallStaticDoubleMethodV
2258 _Jv_JNI_CallStaticMethodA
<jdouble
>, // CallStaticDoubleMethodA
2259 _Jv_JNI_CallStaticVoidMethod
, // CallStaticVoidMethod
2260 _Jv_JNI_CallStaticVoidMethodV
, // CallStaticVoidMethodV
2261 _Jv_JNI_CallStaticVoidMethodA
, // CallStaticVoidMethodA
2263 _Jv_JNI_GetAnyFieldID
<true>, // GetStaticFieldID
2264 _Jv_JNI_GetStaticField
<jobject
>, // GetStaticObjectField
2265 _Jv_JNI_GetStaticField
<jboolean
>, // GetStaticBooleanField
2266 _Jv_JNI_GetStaticField
<jbyte
>, // GetStaticByteField
2267 _Jv_JNI_GetStaticField
<jchar
>, // GetStaticCharField
2268 _Jv_JNI_GetStaticField
<jshort
>, // GetStaticShortField
2269 _Jv_JNI_GetStaticField
<jint
>, // GetStaticIntField
2270 _Jv_JNI_GetStaticField
<jlong
>, // GetStaticLongField
2271 _Jv_JNI_GetStaticField
<jfloat
>, // GetStaticFloatField
2272 _Jv_JNI_GetStaticField
<jdouble
>, // GetStaticDoubleField
2273 _Jv_JNI_SetStaticField
, // SetStaticObjectField
2274 _Jv_JNI_SetStaticField
, // SetStaticBooleanField
2275 _Jv_JNI_SetStaticField
, // SetStaticByteField
2276 _Jv_JNI_SetStaticField
, // SetStaticCharField
2277 _Jv_JNI_SetStaticField
, // SetStaticShortField
2278 _Jv_JNI_SetStaticField
, // SetStaticIntField
2279 _Jv_JNI_SetStaticField
, // SetStaticLongField
2280 _Jv_JNI_SetStaticField
, // SetStaticFloatField
2281 _Jv_JNI_SetStaticField
, // SetStaticDoubleField
2282 _Jv_JNI_NewString
, // NewString
2283 _Jv_JNI_GetStringLength
, // GetStringLength
2284 _Jv_JNI_GetStringChars
, // GetStringChars
2285 _Jv_JNI_ReleaseStringChars
, // ReleaseStringChars
2286 _Jv_JNI_NewStringUTF
, // NewStringUTF
2287 _Jv_JNI_GetStringUTFLength
, // GetStringUTFLength
2288 _Jv_JNI_GetStringUTFChars
, // GetStringUTFLength
2289 _Jv_JNI_ReleaseStringUTFChars
, // ReleaseStringUTFChars
2290 _Jv_JNI_GetArrayLength
, // GetArrayLength
2291 _Jv_JNI_NewObjectArray
, // NewObjectArray
2292 _Jv_JNI_GetObjectArrayElement
, // GetObjectArrayElement
2293 _Jv_JNI_SetObjectArrayElement
, // SetObjectArrayElement
2294 _Jv_JNI_NewPrimitiveArray
<jboolean
, JvPrimClass (boolean
)>,
2296 _Jv_JNI_NewPrimitiveArray
<jbyte
, JvPrimClass (byte
)>, // NewByteArray
2297 _Jv_JNI_NewPrimitiveArray
<jchar
, JvPrimClass (char)>, // NewCharArray
2298 _Jv_JNI_NewPrimitiveArray
<jshort
, JvPrimClass (short)>, // NewShortArray
2299 _Jv_JNI_NewPrimitiveArray
<jint
, JvPrimClass (int)>, // NewIntArray
2300 _Jv_JNI_NewPrimitiveArray
<jlong
, JvPrimClass (long)>, // NewLongArray
2301 _Jv_JNI_NewPrimitiveArray
<jfloat
, JvPrimClass (float)>, // NewFloatArray
2302 _Jv_JNI_NewPrimitiveArray
<jdouble
, JvPrimClass (double)>, // NewDoubleArray
2303 _Jv_JNI_GetPrimitiveArrayElements
, // GetBooleanArrayElements
2304 _Jv_JNI_GetPrimitiveArrayElements
, // GetByteArrayElements
2305 _Jv_JNI_GetPrimitiveArrayElements
, // GetCharArrayElements
2306 _Jv_JNI_GetPrimitiveArrayElements
, // GetShortArrayElements
2307 _Jv_JNI_GetPrimitiveArrayElements
, // GetIntArrayElements
2308 _Jv_JNI_GetPrimitiveArrayElements
, // GetLongArrayElements
2309 _Jv_JNI_GetPrimitiveArrayElements
, // GetFloatArrayElements
2310 _Jv_JNI_GetPrimitiveArrayElements
, // GetDoubleArrayElements
2311 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseBooleanArrayElements
2312 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseByteArrayElements
2313 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseCharArrayElements
2314 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseShortArrayElements
2315 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseIntArrayElements
2316 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseLongArrayElements
2317 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseFloatArrayElements
2318 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseDoubleArrayElements
2319 _Jv_JNI_GetPrimitiveArrayRegion
, // GetBooleanArrayRegion
2320 _Jv_JNI_GetPrimitiveArrayRegion
, // GetByteArrayRegion
2321 _Jv_JNI_GetPrimitiveArrayRegion
, // GetCharArrayRegion
2322 _Jv_JNI_GetPrimitiveArrayRegion
, // GetShortArrayRegion
2323 _Jv_JNI_GetPrimitiveArrayRegion
, // GetIntArrayRegion
2324 _Jv_JNI_GetPrimitiveArrayRegion
, // GetLongArrayRegion
2325 _Jv_JNI_GetPrimitiveArrayRegion
, // GetFloatArrayRegion
2326 _Jv_JNI_GetPrimitiveArrayRegion
, // GetDoubleArrayRegion
2327 _Jv_JNI_SetPrimitiveArrayRegion
, // SetBooleanArrayRegion
2328 _Jv_JNI_SetPrimitiveArrayRegion
, // SetByteArrayRegion
2329 _Jv_JNI_SetPrimitiveArrayRegion
, // SetCharArrayRegion
2330 _Jv_JNI_SetPrimitiveArrayRegion
, // SetShortArrayRegion
2331 _Jv_JNI_SetPrimitiveArrayRegion
, // SetIntArrayRegion
2332 _Jv_JNI_SetPrimitiveArrayRegion
, // SetLongArrayRegion
2333 _Jv_JNI_SetPrimitiveArrayRegion
, // SetFloatArrayRegion
2334 _Jv_JNI_SetPrimitiveArrayRegion
, // SetDoubleArrayRegion
2335 _Jv_JNI_RegisterNatives
, // RegisterNatives
2336 _Jv_JNI_UnregisterNatives
, // UnregisterNatives
2337 _Jv_JNI_MonitorEnter
, // MonitorEnter
2338 _Jv_JNI_MonitorExit
, // MonitorExit
2339 _Jv_JNI_GetJavaVM
, // GetJavaVM
2341 _Jv_JNI_GetStringRegion
, // GetStringRegion
2342 _Jv_JNI_GetStringUTFRegion
, // GetStringUTFRegion
2343 _Jv_JNI_GetPrimitiveArrayCritical
, // GetPrimitiveArrayCritical
2344 _Jv_JNI_ReleasePrimitiveArrayCritical
, // ReleasePrimitiveArrayCritical
2345 _Jv_JNI_GetStringCritical
, // GetStringCritical
2346 _Jv_JNI_ReleaseStringCritical
, // ReleaseStringCritical
2348 NOT_IMPL
/* newweakglobalref */,
2349 NOT_IMPL
/* deleteweakglobalref */,
2351 _Jv_JNI_ExceptionCheck
2354 struct JNIInvokeInterface _Jv_JNI_InvokeFunctions
=
2360 _Jv_JNI_DestroyJavaVM
,
2361 _Jv_JNI_AttachCurrentThread
,
2362 _Jv_JNI_DetachCurrentThread
,