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/IdentityHashMap.h>
41 #include <java/lang/Integer.h>
42 #include <java/lang/ThreadGroup.h>
43 #include <java/lang/Thread.h>
45 #include <gcj/method.h>
46 #include <gcj/field.h>
48 #include <java-interp.h>
49 #include <java-threads.h>
51 // This enum is used to select different template instantiations in
52 // the invocation code.
61 // Forward declarations.
62 extern struct JNINativeInterface _Jv_JNIFunctions
;
63 extern struct JNIInvokeInterface _Jv_JNI_InvokeFunctions
;
65 // Number of slots in the default frame. The VM must allow at least
69 // Mark value indicating this is an overflow frame.
71 // Mark value indicating this is a user frame.
73 // Mark value indicating this is a system frame.
76 // This structure is used to keep track of local references.
77 struct _Jv_JNI_LocalFrame
79 // This is true if this frame object represents a pushed frame (eg
80 // from PushLocalFrame).
83 // Number of elements in frame.
86 // Next frame in chain.
87 _Jv_JNI_LocalFrame
*next
;
89 // The elements. These are allocated using the C "struct hack".
93 // This holds a reference count for all local references.
94 static java::util::IdentityHashMap
*local_ref_table
;
95 // This holds a reference count for all global references.
96 static java::util::IdentityHashMap
*global_ref_table
;
99 static JavaVM
*the_vm
;
102 // The only JVMPI interface description.
103 static JVMPI_Interface _Jv_JVMPI_Interface
;
106 jvmpiEnableEvent (jint event_type
, void *)
110 case JVMPI_EVENT_OBJECT_ALLOC
:
111 _Jv_JVMPI_Notify_OBJECT_ALLOC
= _Jv_JVMPI_Interface
.NotifyEvent
;
114 case JVMPI_EVENT_THREAD_START
:
115 _Jv_JVMPI_Notify_THREAD_START
= _Jv_JVMPI_Interface
.NotifyEvent
;
118 case JVMPI_EVENT_THREAD_END
:
119 _Jv_JVMPI_Notify_THREAD_END
= _Jv_JVMPI_Interface
.NotifyEvent
;
123 return JVMPI_NOT_AVAILABLE
;
126 return JVMPI_SUCCESS
;
130 jvmpiDisableEvent (jint event_type
, void *)
134 case JVMPI_EVENT_OBJECT_ALLOC
:
135 _Jv_JVMPI_Notify_OBJECT_ALLOC
= NULL
;
139 return JVMPI_NOT_AVAILABLE
;
142 return JVMPI_SUCCESS
;
151 local_ref_table
= new java::util::IdentityHashMap
;
152 global_ref_table
= new java::util::IdentityHashMap
;
155 _Jv_JVMPI_Interface
.version
= 1;
156 _Jv_JVMPI_Interface
.EnableEvent
= &jvmpiEnableEvent
;
157 _Jv_JVMPI_Interface
.DisableEvent
= &jvmpiDisableEvent
;
158 _Jv_JVMPI_Interface
.EnableGC
= &_Jv_EnableGC
;
159 _Jv_JVMPI_Interface
.DisableGC
= &_Jv_DisableGC
;
160 _Jv_JVMPI_Interface
.RunGC
= &_Jv_RunGC
;
164 // Tell the GC that a certain pointer is live.
166 mark_for_gc (jobject obj
, java::util::IdentityHashMap
*ref_table
)
168 JvSynchronize
sync (ref_table
);
170 using namespace java::lang
;
171 Integer
*refcount
= (Integer
*) ref_table
->get (obj
);
172 jint val
= (refcount
== NULL
) ? 0 : refcount
->intValue ();
173 // FIXME: what about out of memory error?
174 ref_table
->put (obj
, new Integer (val
+ 1));
179 unmark_for_gc (jobject obj
, java::util::IdentityHashMap
*ref_table
)
181 JvSynchronize
sync (ref_table
);
183 using namespace java::lang
;
184 Integer
*refcount
= (Integer
*) ref_table
->get (obj
);
186 jint val
= refcount
->intValue () - 1;
189 ref_table
->remove (obj
);
191 // FIXME: what about out of memory error?
192 ref_table
->put (obj
, new Integer (val
));
198 _Jv_JNI_NewGlobalRef (JNIEnv
*, jobject obj
)
200 mark_for_gc (obj
, global_ref_table
);
205 _Jv_JNI_DeleteGlobalRef (JNIEnv
*, jobject obj
)
207 unmark_for_gc (obj
, global_ref_table
);
211 _Jv_JNI_DeleteLocalRef (JNIEnv
*env
, jobject obj
)
213 _Jv_JNI_LocalFrame
*frame
;
215 for (frame
= env
->locals
; frame
!= NULL
; frame
= frame
->next
)
217 for (int i
= 0; i
< FRAME_SIZE
; ++i
)
219 if (frame
->vec
[i
] == obj
)
221 frame
->vec
[i
] = NULL
;
222 unmark_for_gc (obj
, local_ref_table
);
227 // Don't go past a marked frame.
228 JvAssert (frame
->marker
== MARK_NONE
);
235 _Jv_JNI_EnsureLocalCapacity (JNIEnv
*env
, jint size
)
237 // It is easier to just always allocate a new frame of the requested
238 // size. This isn't the most efficient thing, but for now we don't
239 // care. Note that _Jv_JNI_PushLocalFrame relies on this right now.
241 _Jv_JNI_LocalFrame
*frame
;
244 frame
= (_Jv_JNI_LocalFrame
*) _Jv_Malloc (sizeof (_Jv_JNI_LocalFrame
)
245 + size
* sizeof (jobject
));
253 frame
->marker
= MARK_NONE
;
255 memset (&frame
->vec
[0], 0, size
* sizeof (jobject
));
256 frame
->next
= env
->locals
;
263 _Jv_JNI_PushLocalFrame (JNIEnv
*env
, jint size
)
265 jint r
= _Jv_JNI_EnsureLocalCapacity (env
, size
);
269 // The new frame is on top.
270 env
->locals
->marker
= MARK_USER
;
276 _Jv_JNI_NewLocalRef (JNIEnv
*env
, jobject obj
)
278 // Try to find an open slot somewhere in the topmost frame.
279 _Jv_JNI_LocalFrame
*frame
= env
->locals
;
280 bool done
= false, set
= false;
281 for (; frame
!= NULL
&& ! done
; frame
= frame
->next
)
283 for (int i
= 0; i
< frame
->size
; ++i
)
285 if (frame
->vec
[i
] == NULL
)
294 // If we found a slot, or if the frame we just searched is the
295 // mark frame, then we are done.
296 if (done
|| frame
->marker
!= MARK_NONE
)
302 // No slots, so we allocate a new frame. According to the spec
303 // we could just die here. FIXME: return value.
304 _Jv_JNI_EnsureLocalCapacity (env
, 16);
305 // We know the first element of the new frame will be ok.
306 env
->locals
->vec
[0] = obj
;
309 mark_for_gc (obj
, local_ref_table
);
314 _Jv_JNI_PopLocalFrame (JNIEnv
*env
, jobject result
, int stop
)
316 _Jv_JNI_LocalFrame
*rf
= env
->locals
;
319 while (rf
!= NULL
&& ! done
)
321 for (int i
= 0; i
< rf
->size
; ++i
)
322 if (rf
->vec
[i
] != NULL
)
323 unmark_for_gc (rf
->vec
[i
], local_ref_table
);
325 // If the frame we just freed is the marker frame, we are done.
326 done
= (rf
->marker
== stop
);
328 _Jv_JNI_LocalFrame
*n
= rf
->next
;
329 // When N==NULL, we've reached the stack-allocated frame, and we
330 // must not free it. However, we must be sure to clear all its
331 // elements, since we might conceivably reuse it.
334 memset (&rf
->vec
[0], 0, rf
->size
* sizeof (jobject
));
342 // Update the local frame information.
345 return result
== NULL
? NULL
: _Jv_JNI_NewLocalRef (env
, result
);
349 _Jv_JNI_PopLocalFrame (JNIEnv
*env
, jobject result
)
351 return _Jv_JNI_PopLocalFrame (env
, result
, MARK_USER
);
354 // Pop a `system' frame from the stack. This is `extern "C"' as it is
355 // used by the compiler.
357 _Jv_JNI_PopSystemFrame (JNIEnv
*env
)
359 _Jv_JNI_PopLocalFrame (env
, NULL
, MARK_SYSTEM
);
363 jthrowable t
= env
->ex
;
369 // This function is used from other template functions. It wraps the
370 // return value appropriately; we specialize it so that object returns
371 // are turned into local references.
374 wrap_value (JNIEnv
*, T value
)
379 // This specialization is used for jobject, jclass, jstring, jarray,
383 wrap_value (JNIEnv
*env
, T
*value
)
385 return (value
== NULL
387 : (T
*) _Jv_JNI_NewLocalRef (env
, (jobject
) value
));
393 _Jv_JNI_GetVersion (JNIEnv
*)
395 return JNI_VERSION_1_2
;
399 _Jv_JNI_DefineClass (JNIEnv
*env
, jobject loader
,
400 const jbyte
*buf
, jsize bufLen
)
404 jbyteArray bytes
= JvNewByteArray (bufLen
);
406 jbyte
*elts
= elements (bytes
);
407 memcpy (elts
, buf
, bufLen
* sizeof (jbyte
));
409 java::lang::ClassLoader
*l
410 = reinterpret_cast<java::lang::ClassLoader
*> (loader
);
412 jclass result
= l
->defineClass (bytes
, 0, bufLen
);
413 return (jclass
) wrap_value (env
, result
);
423 _Jv_JNI_FindClass (JNIEnv
*env
, const char *name
)
425 // FIXME: assume that NAME isn't too long.
426 int len
= strlen (name
);
428 for (int i
= 0; i
<= len
; ++i
)
429 s
[i
] = (name
[i
] == '/') ? '.' : name
[i
];
434 // This might throw an out of memory exception.
435 jstring n
= JvNewStringUTF (s
);
437 java::lang::ClassLoader
*loader
= NULL
;
438 if (env
->klass
!= NULL
)
439 loader
= env
->klass
->getClassLoader ();
443 // FIXME: should use getBaseClassLoader, but we don't have that
445 loader
= java::lang::ClassLoader::getSystemClassLoader ();
448 r
= loader
->loadClass (n
);
455 return (jclass
) wrap_value (env
, r
);
459 _Jv_JNI_GetSuperclass (JNIEnv
*env
, jclass clazz
)
461 return (jclass
) wrap_value (env
, clazz
->getSuperclass ());
465 _Jv_JNI_IsAssignableFrom(JNIEnv
*, jclass clazz1
, jclass clazz2
)
467 return clazz1
->isAssignableFrom (clazz2
);
471 _Jv_JNI_Throw (JNIEnv
*env
, jthrowable obj
)
473 // We check in case the user did some funky cast.
474 JvAssert (obj
!= NULL
&& java::lang::Throwable::class$
.isInstance (obj
));
480 _Jv_JNI_ThrowNew (JNIEnv
*env
, jclass clazz
, const char *message
)
482 using namespace java::lang::reflect
;
484 JvAssert (java::lang::Throwable::class$
.isAssignableFrom (clazz
));
489 JArray
<jclass
> *argtypes
490 = (JArray
<jclass
> *) JvNewObjectArray (1, &java::lang::Class::class$
,
493 jclass
*elts
= elements (argtypes
);
494 elts
[0] = &StringClass
;
496 Constructor
*cons
= clazz
->getConstructor (argtypes
);
498 jobjectArray values
= JvNewObjectArray (1, &StringClass
, NULL
);
499 jobject
*velts
= elements (values
);
500 velts
[0] = JvNewStringUTF (message
);
502 jobject obj
= cons
->newInstance (values
);
504 env
->ex
= reinterpret_cast<jthrowable
> (obj
);
516 _Jv_JNI_ExceptionOccurred (JNIEnv
*env
)
518 return (jthrowable
) wrap_value (env
, env
->ex
);
522 _Jv_JNI_ExceptionDescribe (JNIEnv
*env
)
525 env
->ex
->printStackTrace();
529 _Jv_JNI_ExceptionClear (JNIEnv
*env
)
535 _Jv_JNI_ExceptionCheck (JNIEnv
*env
)
537 return env
->ex
!= NULL
;
541 _Jv_JNI_FatalError (JNIEnv
*, const char *message
)
549 _Jv_JNI_IsSameObject (JNIEnv
*, jobject obj1
, jobject obj2
)
555 _Jv_JNI_AllocObject (JNIEnv
*env
, jclass clazz
)
558 using namespace java::lang::reflect
;
562 JvAssert (clazz
&& ! clazz
->isArray ());
563 if (clazz
->isInterface() || Modifier::isAbstract(clazz
->getModifiers()))
564 env
->ex
= new java::lang::InstantiationException ();
567 // FIXME: will this work for String?
568 obj
= JvAllocObject (clazz
);
576 return wrap_value (env
, obj
);
580 _Jv_JNI_GetObjectClass (JNIEnv
*env
, jobject obj
)
583 return (jclass
) wrap_value (env
, obj
->getClass());
587 _Jv_JNI_IsInstanceOf (JNIEnv
*, jobject obj
, jclass clazz
)
589 return clazz
->isInstance(obj
);
595 // This section concerns method invocation.
598 template<jboolean is_static
>
600 _Jv_JNI_GetAnyMethodID (JNIEnv
*env
, jclass clazz
,
601 const char *name
, const char *sig
)
605 _Jv_InitClass (clazz
);
607 _Jv_Utf8Const
*name_u
= _Jv_makeUtf8Const ((char *) name
, -1);
609 // FIXME: assume that SIG isn't too long.
610 int len
= strlen (sig
);
612 for (int i
= 0; i
<= len
; ++i
)
613 s
[i
] = (sig
[i
] == '/') ? '.' : sig
[i
];
614 _Jv_Utf8Const
*sig_u
= _Jv_makeUtf8Const ((char *) s
, -1);
616 JvAssert (! clazz
->isPrimitive());
618 using namespace java::lang::reflect
;
620 while (clazz
!= NULL
)
622 jint count
= JvNumMethods (clazz
);
623 jmethodID meth
= JvGetFirstMethod (clazz
);
625 for (jint i
= 0; i
< count
; ++i
)
627 if (((is_static
&& Modifier::isStatic (meth
->accflags
))
628 || (! is_static
&& ! Modifier::isStatic (meth
->accflags
)))
629 && _Jv_equalUtf8Consts (meth
->name
, name_u
)
630 && _Jv_equalUtf8Consts (meth
->signature
, sig_u
))
633 meth
= meth
->getNextMethod();
636 clazz
= clazz
->getSuperclass ();
639 env
->ex
= new java::lang::NoSuchMethodError ();
649 // This is a helper function which turns a va_list into an array of
650 // `jvalue's. It needs signature information in order to do its work.
651 // The array of values must already be allocated.
653 array_from_valist (jvalue
*values
, JArray
<jclass
> *arg_types
, va_list vargs
)
655 jclass
*arg_elts
= elements (arg_types
);
656 for (int i
= 0; i
< arg_types
->length
; ++i
)
658 if (arg_elts
[i
] == JvPrimClass (byte
))
659 values
[i
].b
= va_arg (vargs
, jbyte
);
660 else if (arg_elts
[i
] == JvPrimClass (short))
661 values
[i
].s
= va_arg (vargs
, jshort
);
662 else if (arg_elts
[i
] == JvPrimClass (int))
663 values
[i
].i
= va_arg (vargs
, jint
);
664 else if (arg_elts
[i
] == JvPrimClass (long))
665 values
[i
].j
= va_arg (vargs
, jlong
);
666 else if (arg_elts
[i
] == JvPrimClass (float))
667 values
[i
].f
= va_arg (vargs
, jfloat
);
668 else if (arg_elts
[i
] == JvPrimClass (double))
669 values
[i
].d
= va_arg (vargs
, jdouble
);
670 else if (arg_elts
[i
] == JvPrimClass (boolean
))
671 values
[i
].z
= va_arg (vargs
, jboolean
);
672 else if (arg_elts
[i
] == JvPrimClass (char))
673 values
[i
].c
= va_arg (vargs
, jchar
);
677 values
[i
].l
= va_arg (vargs
, jobject
);
682 // This can call any sort of method: virtual, "nonvirtual", static, or
684 template<typename T
, invocation_type style
>
686 _Jv_JNI_CallAnyMethodV (JNIEnv
*env
, jobject obj
, jclass klass
,
687 jmethodID id
, va_list vargs
)
690 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
692 jclass decl_class
= klass
? klass
: obj
->getClass ();
693 JvAssert (decl_class
!= NULL
);
696 JArray
<jclass
> *arg_types
;
700 _Jv_GetTypesFromSignature (id
, decl_class
,
701 &arg_types
, &return_type
);
703 jvalue args
[arg_types
->length
];
704 array_from_valist (args
, arg_types
, vargs
);
706 // For constructors we need to pass the Class we are instantiating.
707 if (style
== constructor
)
711 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
712 style
== constructor
,
713 arg_types
, args
, &result
);
718 // We cheat a little here. FIXME.
719 return wrap_value (env
, * (T
*) &result
);
726 return wrap_value (env
, (T
) 0);
729 template<typename T
, invocation_type style
>
731 _Jv_JNI_CallAnyMethod (JNIEnv
*env
, jobject obj
, jclass klass
,
732 jmethodID method
, ...)
737 va_start (args
, method
);
738 result
= _Jv_JNI_CallAnyMethodV
<T
, style
> (env
, obj
, klass
, method
, args
);
744 template<typename T
, invocation_type style
>
746 _Jv_JNI_CallAnyMethodA (JNIEnv
*env
, jobject obj
, jclass klass
,
747 jmethodID id
, jvalue
*args
)
750 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
752 jclass decl_class
= klass
? klass
: obj
->getClass ();
753 JvAssert (decl_class
!= NULL
);
756 JArray
<jclass
> *arg_types
;
759 _Jv_GetTypesFromSignature (id
, decl_class
,
760 &arg_types
, &return_type
);
762 // For constructors we need to pass the Class we are instantiating.
763 if (style
== constructor
)
767 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
768 style
== constructor
,
769 arg_types
, args
, &result
);
774 // We cheat a little here. FIXME.
775 return wrap_value (env
, * (T
*) &result
);
782 return wrap_value (env
, (T
) 0);
785 template<invocation_type style
>
787 _Jv_JNI_CallAnyVoidMethodV (JNIEnv
*env
, jobject obj
, jclass klass
,
788 jmethodID id
, va_list vargs
)
791 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
793 jclass decl_class
= klass
? klass
: obj
->getClass ();
794 JvAssert (decl_class
!= NULL
);
797 JArray
<jclass
> *arg_types
;
800 _Jv_GetTypesFromSignature (id
, decl_class
,
801 &arg_types
, &return_type
);
803 jvalue args
[arg_types
->length
];
804 array_from_valist (args
, arg_types
, vargs
);
806 // For constructors we need to pass the Class we are instantiating.
807 if (style
== constructor
)
810 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
811 style
== constructor
,
812 arg_types
, args
, NULL
);
823 template<invocation_type style
>
825 _Jv_JNI_CallAnyVoidMethod (JNIEnv
*env
, jobject obj
, jclass klass
,
826 jmethodID method
, ...)
830 va_start (args
, method
);
831 _Jv_JNI_CallAnyVoidMethodV
<style
> (env
, obj
, klass
, method
, args
);
835 template<invocation_type style
>
837 _Jv_JNI_CallAnyVoidMethodA (JNIEnv
*env
, jobject obj
, jclass klass
,
838 jmethodID id
, jvalue
*args
)
841 id
= _Jv_LookupDeclaredMethod (obj
->getClass (), id
->name
, id
->signature
);
843 jclass decl_class
= klass
? klass
: obj
->getClass ();
844 JvAssert (decl_class
!= NULL
);
847 JArray
<jclass
> *arg_types
;
850 _Jv_GetTypesFromSignature (id
, decl_class
,
851 &arg_types
, &return_type
);
853 jthrowable ex
= _Jv_CallAnyMethodA (obj
, return_type
, id
,
854 style
== constructor
,
855 arg_types
, args
, NULL
);
866 // Functions with this signature are used to implement functions in
867 // the CallMethod family.
870 _Jv_JNI_CallMethodV (JNIEnv
*env
, jobject obj
, jmethodID id
, va_list args
)
872 return _Jv_JNI_CallAnyMethodV
<T
, normal
> (env
, obj
, NULL
, id
, args
);
875 // Functions with this signature are used to implement functions in
876 // the CallMethod family.
879 _Jv_JNI_CallMethod (JNIEnv
*env
, jobject obj
, jmethodID id
, ...)
885 result
= _Jv_JNI_CallAnyMethodV
<T
, normal
> (env
, obj
, NULL
, id
, args
);
891 // Functions with this signature are used to implement functions in
892 // the CallMethod family.
895 _Jv_JNI_CallMethodA (JNIEnv
*env
, jobject obj
, jmethodID id
, jvalue
*args
)
897 return _Jv_JNI_CallAnyMethodA
<T
, normal
> (env
, obj
, NULL
, id
, args
);
901 _Jv_JNI_CallVoidMethodV (JNIEnv
*env
, jobject obj
, jmethodID id
, va_list args
)
903 _Jv_JNI_CallAnyVoidMethodV
<normal
> (env
, obj
, NULL
, id
, args
);
907 _Jv_JNI_CallVoidMethod (JNIEnv
*env
, jobject obj
, jmethodID id
, ...)
912 _Jv_JNI_CallAnyVoidMethodV
<normal
> (env
, obj
, NULL
, id
, args
);
917 _Jv_JNI_CallVoidMethodA (JNIEnv
*env
, jobject obj
, jmethodID id
, jvalue
*args
)
919 _Jv_JNI_CallAnyVoidMethodA
<normal
> (env
, obj
, NULL
, id
, args
);
922 // Functions with this signature are used to implement functions in
923 // the CallStaticMethod family.
926 _Jv_JNI_CallStaticMethodV (JNIEnv
*env
, jclass klass
,
927 jmethodID id
, va_list args
)
929 JvAssert (((id
->accflags
) & java::lang::reflect::Modifier::STATIC
));
930 JvAssert (java::lang::Class::class$
.isInstance (klass
));
932 return _Jv_JNI_CallAnyMethodV
<T
, static_type
> (env
, NULL
, klass
, id
, args
);
935 // Functions with this signature are used to implement functions in
936 // the CallStaticMethod family.
939 _Jv_JNI_CallStaticMethod (JNIEnv
*env
, jclass klass
, jmethodID id
, ...)
944 JvAssert (((id
->accflags
) & java::lang::reflect::Modifier::STATIC
));
945 JvAssert (java::lang::Class::class$
.isInstance (klass
));
948 result
= _Jv_JNI_CallAnyMethodV
<T
, static_type
> (env
, NULL
, klass
,
955 // Functions with this signature are used to implement functions in
956 // the CallStaticMethod family.
959 _Jv_JNI_CallStaticMethodA (JNIEnv
*env
, jclass klass
, jmethodID id
,
962 JvAssert (((id
->accflags
) & java::lang::reflect::Modifier::STATIC
));
963 JvAssert (java::lang::Class::class$
.isInstance (klass
));
965 return _Jv_JNI_CallAnyMethodA
<T
, static_type
> (env
, NULL
, klass
, id
, args
);
969 _Jv_JNI_CallStaticVoidMethodV (JNIEnv
*env
, jclass klass
, jmethodID id
,
972 _Jv_JNI_CallAnyVoidMethodV
<static_type
> (env
, NULL
, klass
, id
, args
);
976 _Jv_JNI_CallStaticVoidMethod (JNIEnv
*env
, jclass klass
, jmethodID id
, ...)
981 _Jv_JNI_CallAnyVoidMethodV
<static_type
> (env
, NULL
, klass
, id
, args
);
986 _Jv_JNI_CallStaticVoidMethodA (JNIEnv
*env
, jclass klass
, jmethodID id
,
989 _Jv_JNI_CallAnyVoidMethodA
<static_type
> (env
, NULL
, klass
, id
, args
);
993 _Jv_JNI_NewObjectV (JNIEnv
*env
, jclass klass
,
994 jmethodID id
, va_list args
)
996 JvAssert (klass
&& ! klass
->isArray ());
997 JvAssert (! strcmp (id
->name
->data
, "<init>")
998 && id
->signature
->length
> 2
999 && id
->signature
->data
[0] == '('
1000 && ! strcmp (&id
->signature
->data
[id
->signature
->length
- 2],
1003 return _Jv_JNI_CallAnyMethodV
<jobject
, constructor
> (env
, NULL
, klass
,
1008 _Jv_JNI_NewObject (JNIEnv
*env
, jclass klass
, jmethodID id
, ...)
1010 JvAssert (klass
&& ! klass
->isArray ());
1011 JvAssert (! strcmp (id
->name
->data
, "<init>")
1012 && id
->signature
->length
> 2
1013 && id
->signature
->data
[0] == '('
1014 && ! strcmp (&id
->signature
->data
[id
->signature
->length
- 2],
1020 va_start (args
, id
);
1021 result
= _Jv_JNI_CallAnyMethodV
<jobject
, constructor
> (env
, NULL
, klass
,
1029 _Jv_JNI_NewObjectA (JNIEnv
*env
, jclass klass
, jmethodID id
,
1032 JvAssert (klass
&& ! klass
->isArray ());
1033 JvAssert (! strcmp (id
->name
->data
, "<init>")
1034 && id
->signature
->length
> 2
1035 && id
->signature
->data
[0] == '('
1036 && ! strcmp (&id
->signature
->data
[id
->signature
->length
- 2],
1039 return _Jv_JNI_CallAnyMethodA
<jobject
, constructor
> (env
, NULL
, klass
,
1045 template<typename T
>
1047 _Jv_JNI_GetField (JNIEnv
*env
, jobject obj
, jfieldID field
)
1050 T
*ptr
= (T
*) ((char *) obj
+ field
->getOffset ());
1051 return wrap_value (env
, *ptr
);
1054 template<typename T
>
1056 _Jv_JNI_SetField (JNIEnv
*, jobject obj
, jfieldID field
, T value
)
1059 T
*ptr
= (T
*) ((char *) obj
+ field
->getOffset ());
1063 template<jboolean is_static
>
1065 _Jv_JNI_GetAnyFieldID (JNIEnv
*env
, jclass clazz
,
1066 const char *name
, const char *sig
)
1070 _Jv_InitClass (clazz
);
1072 _Jv_Utf8Const
*a_name
= _Jv_makeUtf8Const ((char *) name
, -1);
1074 // FIXME: assume that SIG isn't too long.
1075 int len
= strlen (sig
);
1077 for (int i
= 0; i
<= len
; ++i
)
1078 s
[i
] = (sig
[i
] == '/') ? '.' : sig
[i
];
1079 jclass field_class
= _Jv_FindClassFromSignature ((char *) s
, NULL
);
1081 // FIXME: what if field_class == NULL?
1083 java::lang::ClassLoader
*loader
= clazz
->getClassLoader ();
1084 while (clazz
!= NULL
)
1086 // We acquire the class lock so that fields aren't resolved
1087 // while we are running.
1088 JvSynchronize
sync (clazz
);
1090 jint count
= (is_static
1091 ? JvNumStaticFields (clazz
)
1092 : JvNumInstanceFields (clazz
));
1093 jfieldID field
= (is_static
1094 ? JvGetFirstStaticField (clazz
)
1095 : JvGetFirstInstanceField (clazz
));
1096 for (jint i
= 0; i
< count
; ++i
)
1098 _Jv_Utf8Const
*f_name
= field
->getNameUtf8Const(clazz
);
1100 // The field might be resolved or it might not be. It
1101 // is much simpler to always resolve it.
1102 _Jv_ResolveField (field
, loader
);
1103 if (_Jv_equalUtf8Consts (f_name
, a_name
)
1104 && field
->getClass() == field_class
)
1107 field
= field
->getNextField ();
1110 clazz
= clazz
->getSuperclass ();
1113 env
->ex
= new java::lang::NoSuchFieldError ();
1115 catch (jthrowable t
)
1122 template<typename T
>
1124 _Jv_JNI_GetStaticField (JNIEnv
*env
, jclass
, jfieldID field
)
1126 T
*ptr
= (T
*) field
->u
.addr
;
1127 return wrap_value (env
, *ptr
);
1130 template<typename T
>
1132 _Jv_JNI_SetStaticField (JNIEnv
*, jclass
, jfieldID field
, T value
)
1134 T
*ptr
= (T
*) field
->u
.addr
;
1139 _Jv_JNI_NewString (JNIEnv
*env
, const jchar
*unichars
, jsize len
)
1143 jstring r
= _Jv_NewString (unichars
, len
);
1144 return (jstring
) wrap_value (env
, r
);
1146 catch (jthrowable t
)
1154 _Jv_JNI_GetStringLength (JNIEnv
*, jstring string
)
1156 return string
->length();
1159 static const jchar
*
1160 _Jv_JNI_GetStringChars (JNIEnv
*, jstring string
, jboolean
*isCopy
)
1162 jchar
*result
= _Jv_GetStringChars (string
);
1163 mark_for_gc (string
, global_ref_table
);
1166 return (const jchar
*) result
;
1170 _Jv_JNI_ReleaseStringChars (JNIEnv
*, jstring string
, const jchar
*)
1172 unmark_for_gc (string
, global_ref_table
);
1176 _Jv_JNI_NewStringUTF (JNIEnv
*env
, const char *bytes
)
1180 jstring result
= JvNewStringUTF (bytes
);
1181 return (jstring
) wrap_value (env
, result
);
1183 catch (jthrowable t
)
1191 _Jv_JNI_GetStringUTFLength (JNIEnv
*, jstring string
)
1193 return JvGetStringUTFLength (string
);
1197 _Jv_JNI_GetStringUTFChars (JNIEnv
*env
, jstring string
, jboolean
*isCopy
)
1199 jsize len
= JvGetStringUTFLength (string
);
1202 char *r
= (char *) _Jv_Malloc (len
+ 1);
1203 JvGetStringUTFRegion (string
, 0, len
, r
);
1209 return (const char *) r
;
1211 catch (jthrowable t
)
1219 _Jv_JNI_ReleaseStringUTFChars (JNIEnv
*, jstring
, const char *utf
)
1221 _Jv_Free ((void *) utf
);
1225 _Jv_JNI_GetStringRegion (JNIEnv
*env
, jstring string
, jsize start
, jsize len
,
1228 jchar
*result
= _Jv_GetStringChars (string
);
1229 if (start
< 0 || start
> string
->length ()
1230 || len
< 0 || start
+ len
> string
->length ())
1234 env
->ex
= new java::lang::StringIndexOutOfBoundsException ();
1236 catch (jthrowable t
)
1242 memcpy (buf
, &result
[start
], len
* sizeof (jchar
));
1246 _Jv_JNI_GetStringUTFRegion (JNIEnv
*env
, jstring str
, jsize start
,
1247 jsize len
, char *buf
)
1249 if (start
< 0 || start
> str
->length ()
1250 || len
< 0 || start
+ len
> str
->length ())
1254 env
->ex
= new java::lang::StringIndexOutOfBoundsException ();
1256 catch (jthrowable t
)
1262 _Jv_GetStringUTFRegion (str
, start
, len
, buf
);
1265 static const jchar
*
1266 _Jv_JNI_GetStringCritical (JNIEnv
*, jstring str
, jboolean
*isCopy
)
1268 jchar
*result
= _Jv_GetStringChars (str
);
1275 _Jv_JNI_ReleaseStringCritical (JNIEnv
*, jstring
, const jchar
*)
1281 _Jv_JNI_GetArrayLength (JNIEnv
*, jarray array
)
1283 return array
->length
;
1287 _Jv_JNI_NewObjectArray (JNIEnv
*env
, jsize length
, jclass elementClass
,
1292 jarray result
= JvNewObjectArray (length
, elementClass
, init
);
1293 return (jarray
) wrap_value (env
, result
);
1295 catch (jthrowable t
)
1303 _Jv_JNI_GetObjectArrayElement (JNIEnv
*env
, jobjectArray array
, jsize index
)
1305 jobject
*elts
= elements (array
);
1306 return wrap_value (env
, elts
[index
]);
1310 _Jv_JNI_SetObjectArrayElement (JNIEnv
*env
, jobjectArray array
, jsize index
,
1315 _Jv_CheckArrayStore (array
, value
);
1316 jobject
*elts
= elements (array
);
1317 elts
[index
] = value
;
1319 catch (jthrowable t
)
1325 template<typename T
, jclass K
>
1327 _Jv_JNI_NewPrimitiveArray (JNIEnv
*env
, jsize length
)
1331 return (JArray
<T
> *) wrap_value (env
, _Jv_NewPrimArray (K
, length
));
1333 catch (jthrowable t
)
1340 template<typename T
>
1342 _Jv_JNI_GetPrimitiveArrayElements (JNIEnv
*, JArray
<T
> *array
,
1345 T
*elts
= elements (array
);
1348 // We elect never to copy.
1351 mark_for_gc (array
, global_ref_table
);
1355 template<typename T
>
1357 _Jv_JNI_ReleasePrimitiveArrayElements (JNIEnv
*, JArray
<T
> *array
,
1358 T
*, jint
/* mode */)
1360 // Note that we ignore MODE. We can do this because we never copy
1361 // the array elements. My reading of the JNI documentation is that
1362 // this is an option for the implementor.
1363 unmark_for_gc (array
, global_ref_table
);
1366 template<typename T
>
1368 _Jv_JNI_GetPrimitiveArrayRegion (JNIEnv
*env
, JArray
<T
> *array
,
1369 jsize start
, jsize len
,
1372 // The cast to unsigned lets us save a comparison.
1373 if (start
< 0 || len
< 0
1374 || (unsigned long) (start
+ len
) > (unsigned long) array
->length
)
1379 env
->ex
= new java::lang::ArrayIndexOutOfBoundsException ();
1381 catch (jthrowable t
)
1383 // Could have thown out of memory error.
1389 T
*elts
= elements (array
) + start
;
1390 memcpy (buf
, elts
, len
* sizeof (T
));
1394 template<typename T
>
1396 _Jv_JNI_SetPrimitiveArrayRegion (JNIEnv
*env
, JArray
<T
> *array
,
1397 jsize start
, jsize len
, T
*buf
)
1399 // The cast to unsigned lets us save a comparison.
1400 if (start
< 0 || len
< 0
1401 || (unsigned long) (start
+ len
) > (unsigned long) array
->length
)
1406 env
->ex
= new java::lang::ArrayIndexOutOfBoundsException ();
1408 catch (jthrowable t
)
1415 T
*elts
= elements (array
) + start
;
1416 memcpy (elts
, buf
, len
* sizeof (T
));
1421 _Jv_JNI_GetPrimitiveArrayCritical (JNIEnv
*, jarray array
,
1424 // FIXME: does this work?
1425 jclass klass
= array
->getClass()->getComponentType();
1426 JvAssert (klass
->isPrimitive ());
1427 char *r
= _Jv_GetArrayElementFromElementType (array
, klass
);
1434 _Jv_JNI_ReleasePrimitiveArrayCritical (JNIEnv
*, jarray
, void *, jint
)
1440 _Jv_JNI_MonitorEnter (JNIEnv
*env
, jobject obj
)
1444 _Jv_MonitorEnter (obj
);
1447 catch (jthrowable t
)
1455 _Jv_JNI_MonitorExit (JNIEnv
*env
, jobject obj
)
1459 _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 (Method::class$
.isInstance (method
))
1541 return _Jv_FromReflectedMethod (reinterpret_cast<Method
*> (method
));
1543 _Jv_FromReflectedConstructor (reinterpret_cast<Constructor
*> (method
));
1548 // Hash table of native methods.
1549 static JNINativeMethod
*nathash
;
1550 // Number of slots used.
1551 static int nathash_count
= 0;
1552 // Number of slots available. Must be power of 2.
1553 static int nathash_size
= 0;
1555 #define DELETED_ENTRY ((char *) (~0))
1557 // Compute a hash value for a native method descriptor.
1559 hash (const JNINativeMethod
*method
)
1566 hash
= (31 * hash
) + *ptr
++;
1568 ptr
= method
->signature
;
1570 hash
= (31 * hash
) + *ptr
++;
1575 // Find the slot where a native method goes.
1576 static JNINativeMethod
*
1577 nathash_find_slot (const JNINativeMethod
*method
)
1579 jint h
= hash (method
);
1580 int step
= (h
^ (h
>> 16)) | 1;
1581 int w
= h
& (nathash_size
- 1);
1586 JNINativeMethod
*slotp
= &nathash
[w
];
1587 if (slotp
->name
== NULL
)
1590 return &nathash
[del
];
1594 else if (slotp
->name
== DELETED_ENTRY
)
1596 else if (! strcmp (slotp
->name
, method
->name
)
1597 && ! strcmp (slotp
->signature
, method
->signature
))
1599 w
= (w
+ step
) & (nathash_size
- 1);
1603 // Find a method. Return NULL if it isn't in the hash table.
1605 nathash_find (JNINativeMethod
*method
)
1607 if (nathash
== NULL
)
1609 JNINativeMethod
*slot
= nathash_find_slot (method
);
1610 if (slot
->name
== NULL
|| slot
->name
== DELETED_ENTRY
)
1618 if (nathash
== NULL
)
1620 nathash_size
= 1024;
1622 (JNINativeMethod
*) _Jv_AllocBytes (nathash_size
1623 * sizeof (JNINativeMethod
));
1624 memset (nathash
, 0, nathash_size
* sizeof (JNINativeMethod
));
1628 int savesize
= nathash_size
;
1629 JNINativeMethod
*savehash
= nathash
;
1632 (JNINativeMethod
*) _Jv_AllocBytes (nathash_size
1633 * sizeof (JNINativeMethod
));
1634 memset (nathash
, 0, nathash_size
* sizeof (JNINativeMethod
));
1636 for (int i
= 0; i
< savesize
; ++i
)
1638 if (savehash
[i
].name
!= NULL
&& savehash
[i
].name
!= DELETED_ENTRY
)
1640 JNINativeMethod
*slot
= nathash_find_slot (&savehash
[i
]);
1641 *slot
= savehash
[i
];
1648 nathash_add (const JNINativeMethod
*method
)
1650 if (3 * nathash_count
>= 2 * nathash_size
)
1652 JNINativeMethod
*slot
= nathash_find_slot (method
);
1653 // If the slot has a real entry in it, then there is no work to do.
1654 if (slot
->name
!= NULL
&& slot
->name
!= DELETED_ENTRY
)
1657 slot
->name
= strdup (method
->name
);
1658 slot
->signature
= strdup (method
->signature
);
1659 slot
->fnPtr
= method
->fnPtr
;
1663 _Jv_JNI_RegisterNatives (JNIEnv
*env
, jclass klass
,
1664 const JNINativeMethod
*methods
,
1667 // Synchronize while we do the work. This must match
1668 // synchronization in some other functions that manipulate or use
1669 // the nathash table.
1670 JvSynchronize
sync (global_ref_table
);
1672 // Look at each descriptor given us, and find the corresponding
1673 // method in the class.
1674 for (int j
= 0; j
< nMethods
; ++j
)
1678 _Jv_Method
*imeths
= JvGetFirstMethod (klass
);
1679 for (int i
= 0; i
< JvNumMethods (klass
); ++i
)
1681 _Jv_Method
*self
= &imeths
[i
];
1683 if (! strcmp (self
->name
->data
, methods
[j
].name
)
1684 && ! strcmp (self
->signature
->data
, methods
[j
].signature
))
1686 if (! (self
->accflags
1687 & java::lang::reflect::Modifier::NATIVE
))
1690 // Found a match that is native.
1692 nathash_add (&methods
[j
]);
1700 jstring m
= JvNewStringUTF (methods
[j
].name
);
1703 env
->ex
=new java::lang::NoSuchMethodError (m
);
1705 catch (jthrowable t
)
1717 _Jv_JNI_UnregisterNatives (JNIEnv
*, jclass
)
1719 // FIXME -- we could implement this.
1725 // Add a character to the buffer, encoding properly.
1727 add_char (char *buf
, jchar c
, int *here
)
1731 buf
[(*here
)++] = '_';
1732 buf
[(*here
)++] = '1';
1736 buf
[(*here
)++] = '_';
1737 buf
[(*here
)++] = '2';
1741 buf
[(*here
)++] = '_';
1742 buf
[(*here
)++] = '3';
1745 // Also check for `.' here because we might be passed an internal
1746 // qualified class name like `foo.bar'.
1747 else if (c
== '/' || c
== '.')
1748 buf
[(*here
)++] = '_';
1749 else if ((c
>= '0' && c
<= '9')
1750 || (c
>= 'a' && c
<= 'z')
1751 || (c
>= 'A' && c
<= 'Z'))
1752 buf
[(*here
)++] = (char) c
;
1755 // "Unicode" character.
1756 buf
[(*here
)++] = '_';
1757 buf
[(*here
)++] = '0';
1758 for (int i
= 0; i
< 4; ++i
)
1761 buf
[(*here
) + 3 - i
] = (val
> 10) ? ('a' + val
- 10) : ('0' + val
);
1768 // Compute a mangled name for a native function. This computes the
1769 // long name, and also returns an index which indicates where a NUL
1770 // can be placed to create the short name. This function assumes that
1771 // the buffer is large enough for its results.
1773 mangled_name (jclass klass
, _Jv_Utf8Const
*func_name
,
1774 _Jv_Utf8Const
*signature
, char *buf
, int *long_start
)
1776 strcpy (buf
, "Java_");
1779 // Add fully qualified class name.
1780 jchar
*chars
= _Jv_GetStringChars (klass
->getName ());
1781 jint len
= klass
->getName ()->length ();
1782 for (int i
= 0; i
< len
; ++i
)
1783 add_char (buf
, chars
[i
], &here
);
1785 // Don't use add_char because we need a literal `_'.
1788 const unsigned char *fn
= (const unsigned char *) func_name
->data
;
1789 const unsigned char *limit
= fn
+ func_name
->length
;
1790 for (int i
= 0; ; ++i
)
1792 int ch
= UTF8_GET (fn
, limit
);
1795 add_char (buf
, ch
, &here
);
1798 // This is where the long signature begins.
1803 const unsigned char *sig
= (const unsigned char *) signature
->data
;
1804 limit
= sig
+ signature
->length
;
1805 JvAssert (sig
[0] == '(');
1809 int ch
= UTF8_GET (sig
, limit
);
1810 if (ch
== ')' || ch
< 0)
1812 add_char (buf
, ch
, &here
);
1818 // Return the current thread's JNIEnv; if one does not exist, create
1819 // it. Also create a new system frame for use. This is `extern "C"'
1820 // because the compiler calls it.
1822 _Jv_GetJNIEnvNewFrame (jclass klass
)
1824 JNIEnv
*env
= _Jv_GetCurrentJNIEnv ();
1827 env
= (JNIEnv
*) _Jv_MallocUnchecked (sizeof (JNIEnv
));
1828 env
->p
= &_Jv_JNIFunctions
;
1833 _Jv_SetCurrentJNIEnv (env
);
1836 _Jv_JNI_LocalFrame
*frame
1837 = (_Jv_JNI_LocalFrame
*) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame
)
1839 * sizeof (jobject
)));
1841 frame
->marker
= MARK_SYSTEM
;
1842 frame
->size
= FRAME_SIZE
;
1843 frame
->next
= env
->locals
;
1844 env
->locals
= frame
;
1846 for (int i
= 0; i
< frame
->size
; ++i
)
1847 frame
->vec
[i
] = NULL
;
1852 // Return the function which implements a particular JNI method. If
1853 // we can't find the function, we throw the appropriate exception.
1854 // This is `extern "C"' because the compiler uses it.
1856 _Jv_LookupJNIMethod (jclass klass
, _Jv_Utf8Const
*name
,
1857 _Jv_Utf8Const
*signature
)
1859 char buf
[10 + 6 * (name
->length
+ signature
->length
)];
1863 // Synchronize on something convenient. Right now we use the hash.
1864 JvSynchronize
sync (global_ref_table
);
1866 // First see if we have an override in the hash table.
1867 strncpy (buf
, name
->data
, name
->length
);
1868 buf
[name
->length
] = '\0';
1869 strncpy (buf
+ name
->length
+ 1, signature
->data
, signature
->length
);
1870 buf
[name
->length
+ signature
->length
+ 1] = '\0';
1871 JNINativeMethod meth
;
1873 meth
.signature
= buf
+ name
->length
+ 1;
1874 function
= nathash_find (&meth
);
1875 if (function
!= NULL
)
1878 // If there was no override, then look in the symbol table.
1879 mangled_name (klass
, name
, signature
, buf
, &long_start
);
1880 char c
= buf
[long_start
];
1881 buf
[long_start
] = '\0';
1882 function
= _Jv_FindSymbolInExecutable (buf
);
1883 if (function
== NULL
)
1885 buf
[long_start
] = c
;
1886 function
= _Jv_FindSymbolInExecutable (buf
);
1887 if (function
== NULL
)
1889 jstring str
= JvNewStringUTF (name
->data
);
1890 throw new java::lang::AbstractMethodError (str
);
1899 // This function is the stub which is used to turn an ordinary (CNI)
1900 // method call into a JNI call.
1902 _Jv_JNIMethod::call (ffi_cif
*, void *ret
, ffi_raw
*args
, void *__this
)
1904 _Jv_JNIMethod
* _this
= (_Jv_JNIMethod
*) __this
;
1906 JNIEnv
*env
= _Jv_GetJNIEnvNewFrame (_this
->defining_class
);
1908 // FIXME: we should mark every reference parameter as a local. For
1909 // now we assume a conservative GC, and we assume that the
1910 // references are on the stack somewhere.
1912 // We cache the value that we find, of course, but if we don't find
1913 // a value we don't cache that fact -- we might subsequently load a
1914 // library which finds the function in question.
1916 // Synchronize on a convenient object to ensure sanity in case two
1917 // threads reach this point for the same function at the same
1919 JvSynchronize
sync (global_ref_table
);
1920 if (_this
->function
== NULL
)
1921 _this
->function
= _Jv_LookupJNIMethod (_this
->defining_class
,
1923 _this
->self
->signature
);
1926 JvAssert (_this
->args_raw_size
% sizeof (ffi_raw
) == 0);
1927 ffi_raw real_args
[2 + _this
->args_raw_size
/ sizeof (ffi_raw
)];
1930 // First argument is always the environment pointer.
1931 real_args
[offset
++].ptr
= env
;
1933 // For a static method, we pass in the Class. For non-static
1934 // methods, the `this' argument is already handled.
1935 if ((_this
->self
->accflags
& java::lang::reflect::Modifier::STATIC
))
1936 real_args
[offset
++].ptr
= _this
->defining_class
;
1938 // Copy over passed-in arguments.
1939 memcpy (&real_args
[offset
], args
, _this
->args_raw_size
);
1941 // The actual call to the JNI function.
1942 ffi_raw_call (&_this
->jni_cif
, (void (*)()) _this
->function
,
1945 _Jv_JNI_PopSystemFrame (env
);
1948 #endif /* INTERPRETER */
1956 // An internal helper function.
1958 _Jv_JNI_AttachCurrentThread (JavaVM
*, jstring name
, void **penv
, void *args
)
1960 JavaVMAttachArgs
*attach
= reinterpret_cast<JavaVMAttachArgs
*> (args
);
1961 java::lang::ThreadGroup
*group
= NULL
;
1965 // FIXME: do we really want to support 1.1?
1966 if (attach
->version
!= JNI_VERSION_1_2
1967 && attach
->version
!= JNI_VERSION_1_1
)
1968 return JNI_EVERSION
;
1970 JvAssert (java::lang::ThreadGroup::class$
.isInstance (attach
->group
));
1971 group
= reinterpret_cast<java::lang::ThreadGroup
*> (attach
->group
);
1974 // Attaching an already-attached thread is a no-op.
1975 if (_Jv_GetCurrentJNIEnv () != NULL
)
1978 JNIEnv
*env
= (JNIEnv
*) _Jv_MallocUnchecked (sizeof (JNIEnv
));
1981 env
->p
= &_Jv_JNIFunctions
;
1985 = (_Jv_JNI_LocalFrame
*) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame
)
1987 * sizeof (jobject
)));
1988 if (env
->locals
== NULL
)
1993 *penv
= reinterpret_cast<void *> (env
);
1995 // This thread might already be a Java thread -- this function might
1996 // have been called simply to set the new JNIEnv.
1997 if (_Jv_ThreadCurrent () == NULL
)
2001 _Jv_AttachCurrentThread (name
, group
);
2003 catch (jthrowable t
)
2008 _Jv_SetCurrentJNIEnv (env
);
2013 // This is the one actually used by JNI.
2015 _Jv_JNI_AttachCurrentThread (JavaVM
*vm
, void **penv
, void *args
)
2017 return _Jv_JNI_AttachCurrentThread (vm
, NULL
, penv
, args
);
2021 _Jv_JNI_DestroyJavaVM (JavaVM
*vm
)
2023 JvAssert (the_vm
&& vm
== the_vm
);
2026 if (_Jv_ThreadCurrent () != NULL
)
2032 main_name
= JvNewStringLatin1 ("main");
2034 catch (jthrowable t
)
2039 jint r
= _Jv_JNI_AttachCurrentThread (vm
,
2041 reinterpret_cast<void **> (&env
),
2047 env
= _Jv_GetCurrentJNIEnv ();
2051 // Docs say that this always returns an error code.
2056 _Jv_JNI_DetachCurrentThread (JavaVM
*)
2058 jint code
= _Jv_DetachCurrentThread ();
2059 return code
? JNI_EDETACHED
: 0;
2063 _Jv_JNI_GetEnv (JavaVM
*, void **penv
, jint version
)
2065 if (_Jv_ThreadCurrent () == NULL
)
2068 return JNI_EDETACHED
;
2072 // Handle JVMPI requests.
2073 if (version
== JVMPI_VERSION_1
)
2075 *penv
= (void *) &_Jv_JVMPI_Interface
;
2080 // FIXME: do we really want to support 1.1?
2081 if (version
!= JNI_VERSION_1_2
&& version
!= JNI_VERSION_1_1
)
2084 return JNI_EVERSION
;
2087 *penv
= (void *) _Jv_GetCurrentJNIEnv ();
2092 JNI_GetDefaultJavaVMInitArgs (void *args
)
2094 jint version
= * (jint
*) args
;
2095 // Here we only support 1.2.
2096 if (version
!= JNI_VERSION_1_2
)
2097 return JNI_EVERSION
;
2099 JavaVMInitArgs
*ia
= reinterpret_cast<JavaVMInitArgs
*> (args
);
2100 ia
->version
= JNI_VERSION_1_2
;
2103 ia
->ignoreUnrecognized
= true;
2109 JNI_CreateJavaVM (JavaVM
**vm
, void **penv
, void *args
)
2111 JvAssert (! the_vm
);
2112 // FIXME: synchronize
2113 JavaVM
*nvm
= (JavaVM
*) _Jv_MallocUnchecked (sizeof (JavaVM
));
2116 nvm
->functions
= &_Jv_JNI_InvokeFunctions
;
2118 // Parse the arguments.
2121 jint version
= * (jint
*) args
;
2122 // We only support 1.2.
2123 if (version
!= JNI_VERSION_1_2
)
2124 return JNI_EVERSION
;
2125 JavaVMInitArgs
*ia
= reinterpret_cast<JavaVMInitArgs
*> (args
);
2126 for (int i
= 0; i
< ia
->nOptions
; ++i
)
2128 if (! strcmp (ia
->options
[i
].optionString
, "vfprintf")
2129 || ! strcmp (ia
->options
[i
].optionString
, "exit")
2130 || ! strcmp (ia
->options
[i
].optionString
, "abort"))
2132 // We are required to recognize these, but for now we
2133 // don't handle them in any way. FIXME.
2136 else if (! strncmp (ia
->options
[i
].optionString
,
2137 "-verbose", sizeof ("-verbose") - 1))
2139 // We don't do anything with this option either. We
2140 // might want to make sure the argument is valid, but we
2141 // don't really care all that much for now.
2144 else if (! strncmp (ia
->options
[i
].optionString
, "-D", 2))
2149 else if (ia
->ignoreUnrecognized
)
2151 if (ia
->options
[i
].optionString
[0] == '_'
2152 || ! strncmp (ia
->options
[i
].optionString
, "-X", 2))
2160 jint r
=_Jv_JNI_AttachCurrentThread (nvm
, penv
, NULL
);
2173 JNI_GetCreatedJavaVMs (JavaVM
**vm_buffer
, jsize buf_len
, jsize
*n_vms
)
2178 // We only support a single VM.
2181 vm_buffer
[0] = the_vm
;
2192 // FIXME: synchronize
2195 JavaVM
*nvm
= (JavaVM
*) _Jv_MallocUnchecked (sizeof (JavaVM
));
2197 nvm
->functions
= &_Jv_JNI_InvokeFunctions
;
2201 // If this is a Java thread, we want to make sure it has an
2202 // associated JNIEnv.
2203 if (_Jv_ThreadCurrent () != NULL
)
2206 _Jv_JNI_AttachCurrentThread (the_vm
, &ignore
, NULL
);
2213 _Jv_JNI_GetJavaVM (JNIEnv
*, JavaVM
**vm
)
2215 *vm
= _Jv_GetJavaVM ();
2216 return *vm
== NULL
? JNI_ERR
: JNI_OK
;
2221 #define NOT_IMPL NULL
2222 #define RESERVED NULL
2224 struct JNINativeInterface _Jv_JNIFunctions
=
2230 _Jv_JNI_GetVersion
, // GetVersion
2231 _Jv_JNI_DefineClass
, // DefineClass
2232 _Jv_JNI_FindClass
, // FindClass
2233 _Jv_JNI_FromReflectedMethod
, // FromReflectedMethod
2234 _Jv_JNI_FromReflectedField
, // FromReflectedField
2235 _Jv_JNI_ToReflectedMethod
, // ToReflectedMethod
2236 _Jv_JNI_GetSuperclass
, // GetSuperclass
2237 _Jv_JNI_IsAssignableFrom
, // IsAssignableFrom
2238 _Jv_JNI_ToReflectedField
, // ToReflectedField
2239 _Jv_JNI_Throw
, // Throw
2240 _Jv_JNI_ThrowNew
, // ThrowNew
2241 _Jv_JNI_ExceptionOccurred
, // ExceptionOccurred
2242 _Jv_JNI_ExceptionDescribe
, // ExceptionDescribe
2243 _Jv_JNI_ExceptionClear
, // ExceptionClear
2244 _Jv_JNI_FatalError
, // FatalError
2246 _Jv_JNI_PushLocalFrame
, // PushLocalFrame
2247 _Jv_JNI_PopLocalFrame
, // PopLocalFrame
2248 _Jv_JNI_NewGlobalRef
, // NewGlobalRef
2249 _Jv_JNI_DeleteGlobalRef
, // DeleteGlobalRef
2250 _Jv_JNI_DeleteLocalRef
, // DeleteLocalRef
2252 _Jv_JNI_IsSameObject
, // IsSameObject
2254 _Jv_JNI_NewLocalRef
, // NewLocalRef
2255 _Jv_JNI_EnsureLocalCapacity
, // EnsureLocalCapacity
2257 _Jv_JNI_AllocObject
, // AllocObject
2258 _Jv_JNI_NewObject
, // NewObject
2259 _Jv_JNI_NewObjectV
, // NewObjectV
2260 _Jv_JNI_NewObjectA
, // NewObjectA
2261 _Jv_JNI_GetObjectClass
, // GetObjectClass
2262 _Jv_JNI_IsInstanceOf
, // IsInstanceOf
2263 _Jv_JNI_GetAnyMethodID
<false>, // GetMethodID
2265 _Jv_JNI_CallMethod
<jobject
>, // CallObjectMethod
2266 _Jv_JNI_CallMethodV
<jobject
>, // CallObjectMethodV
2267 _Jv_JNI_CallMethodA
<jobject
>, // CallObjectMethodA
2268 _Jv_JNI_CallMethod
<jboolean
>, // CallBooleanMethod
2269 _Jv_JNI_CallMethodV
<jboolean
>, // CallBooleanMethodV
2270 _Jv_JNI_CallMethodA
<jboolean
>, // CallBooleanMethodA
2271 _Jv_JNI_CallMethod
<jbyte
>, // CallByteMethod
2272 _Jv_JNI_CallMethodV
<jbyte
>, // CallByteMethodV
2273 _Jv_JNI_CallMethodA
<jbyte
>, // CallByteMethodA
2274 _Jv_JNI_CallMethod
<jchar
>, // CallCharMethod
2275 _Jv_JNI_CallMethodV
<jchar
>, // CallCharMethodV
2276 _Jv_JNI_CallMethodA
<jchar
>, // CallCharMethodA
2277 _Jv_JNI_CallMethod
<jshort
>, // CallShortMethod
2278 _Jv_JNI_CallMethodV
<jshort
>, // CallShortMethodV
2279 _Jv_JNI_CallMethodA
<jshort
>, // CallShortMethodA
2280 _Jv_JNI_CallMethod
<jint
>, // CallIntMethod
2281 _Jv_JNI_CallMethodV
<jint
>, // CallIntMethodV
2282 _Jv_JNI_CallMethodA
<jint
>, // CallIntMethodA
2283 _Jv_JNI_CallMethod
<jlong
>, // CallLongMethod
2284 _Jv_JNI_CallMethodV
<jlong
>, // CallLongMethodV
2285 _Jv_JNI_CallMethodA
<jlong
>, // CallLongMethodA
2286 _Jv_JNI_CallMethod
<jfloat
>, // CallFloatMethod
2287 _Jv_JNI_CallMethodV
<jfloat
>, // CallFloatMethodV
2288 _Jv_JNI_CallMethodA
<jfloat
>, // CallFloatMethodA
2289 _Jv_JNI_CallMethod
<jdouble
>, // CallDoubleMethod
2290 _Jv_JNI_CallMethodV
<jdouble
>, // CallDoubleMethodV
2291 _Jv_JNI_CallMethodA
<jdouble
>, // CallDoubleMethodA
2292 _Jv_JNI_CallVoidMethod
, // CallVoidMethod
2293 _Jv_JNI_CallVoidMethodV
, // CallVoidMethodV
2294 _Jv_JNI_CallVoidMethodA
, // CallVoidMethodA
2296 // Nonvirtual method invocation functions follow.
2297 _Jv_JNI_CallAnyMethod
<jobject
, nonvirtual
>, // CallNonvirtualObjectMethod
2298 _Jv_JNI_CallAnyMethodV
<jobject
, nonvirtual
>, // CallNonvirtualObjectMethodV
2299 _Jv_JNI_CallAnyMethodA
<jobject
, nonvirtual
>, // CallNonvirtualObjectMethodA
2300 _Jv_JNI_CallAnyMethod
<jboolean
, nonvirtual
>, // CallNonvirtualBooleanMethod
2301 _Jv_JNI_CallAnyMethodV
<jboolean
, nonvirtual
>, // CallNonvirtualBooleanMethodV
2302 _Jv_JNI_CallAnyMethodA
<jboolean
, nonvirtual
>, // CallNonvirtualBooleanMethodA
2303 _Jv_JNI_CallAnyMethod
<jbyte
, nonvirtual
>, // CallNonvirtualByteMethod
2304 _Jv_JNI_CallAnyMethodV
<jbyte
, nonvirtual
>, // CallNonvirtualByteMethodV
2305 _Jv_JNI_CallAnyMethodA
<jbyte
, nonvirtual
>, // CallNonvirtualByteMethodA
2306 _Jv_JNI_CallAnyMethod
<jchar
, nonvirtual
>, // CallNonvirtualCharMethod
2307 _Jv_JNI_CallAnyMethodV
<jchar
, nonvirtual
>, // CallNonvirtualCharMethodV
2308 _Jv_JNI_CallAnyMethodA
<jchar
, nonvirtual
>, // CallNonvirtualCharMethodA
2309 _Jv_JNI_CallAnyMethod
<jshort
, nonvirtual
>, // CallNonvirtualShortMethod
2310 _Jv_JNI_CallAnyMethodV
<jshort
, nonvirtual
>, // CallNonvirtualShortMethodV
2311 _Jv_JNI_CallAnyMethodA
<jshort
, nonvirtual
>, // CallNonvirtualShortMethodA
2312 _Jv_JNI_CallAnyMethod
<jint
, nonvirtual
>, // CallNonvirtualIntMethod
2313 _Jv_JNI_CallAnyMethodV
<jint
, nonvirtual
>, // CallNonvirtualIntMethodV
2314 _Jv_JNI_CallAnyMethodA
<jint
, nonvirtual
>, // CallNonvirtualIntMethodA
2315 _Jv_JNI_CallAnyMethod
<jlong
, nonvirtual
>, // CallNonvirtualLongMethod
2316 _Jv_JNI_CallAnyMethodV
<jlong
, nonvirtual
>, // CallNonvirtualLongMethodV
2317 _Jv_JNI_CallAnyMethodA
<jlong
, nonvirtual
>, // CallNonvirtualLongMethodA
2318 _Jv_JNI_CallAnyMethod
<jfloat
, nonvirtual
>, // CallNonvirtualFloatMethod
2319 _Jv_JNI_CallAnyMethodV
<jfloat
, nonvirtual
>, // CallNonvirtualFloatMethodV
2320 _Jv_JNI_CallAnyMethodA
<jfloat
, nonvirtual
>, // CallNonvirtualFloatMethodA
2321 _Jv_JNI_CallAnyMethod
<jdouble
, nonvirtual
>, // CallNonvirtualDoubleMethod
2322 _Jv_JNI_CallAnyMethodV
<jdouble
, nonvirtual
>, // CallNonvirtualDoubleMethodV
2323 _Jv_JNI_CallAnyMethodA
<jdouble
, nonvirtual
>, // CallNonvirtualDoubleMethodA
2324 _Jv_JNI_CallAnyVoidMethod
<nonvirtual
>, // CallNonvirtualVoidMethod
2325 _Jv_JNI_CallAnyVoidMethodV
<nonvirtual
>, // CallNonvirtualVoidMethodV
2326 _Jv_JNI_CallAnyVoidMethodA
<nonvirtual
>, // CallNonvirtualVoidMethodA
2328 _Jv_JNI_GetAnyFieldID
<false>, // GetFieldID
2329 _Jv_JNI_GetField
<jobject
>, // GetObjectField
2330 _Jv_JNI_GetField
<jboolean
>, // GetBooleanField
2331 _Jv_JNI_GetField
<jbyte
>, // GetByteField
2332 _Jv_JNI_GetField
<jchar
>, // GetCharField
2333 _Jv_JNI_GetField
<jshort
>, // GetShortField
2334 _Jv_JNI_GetField
<jint
>, // GetIntField
2335 _Jv_JNI_GetField
<jlong
>, // GetLongField
2336 _Jv_JNI_GetField
<jfloat
>, // GetFloatField
2337 _Jv_JNI_GetField
<jdouble
>, // GetDoubleField
2338 _Jv_JNI_SetField
, // SetObjectField
2339 _Jv_JNI_SetField
, // SetBooleanField
2340 _Jv_JNI_SetField
, // SetByteField
2341 _Jv_JNI_SetField
, // SetCharField
2342 _Jv_JNI_SetField
, // SetShortField
2343 _Jv_JNI_SetField
, // SetIntField
2344 _Jv_JNI_SetField
, // SetLongField
2345 _Jv_JNI_SetField
, // SetFloatField
2346 _Jv_JNI_SetField
, // SetDoubleField
2347 _Jv_JNI_GetAnyMethodID
<true>, // GetStaticMethodID
2349 _Jv_JNI_CallStaticMethod
<jobject
>, // CallStaticObjectMethod
2350 _Jv_JNI_CallStaticMethodV
<jobject
>, // CallStaticObjectMethodV
2351 _Jv_JNI_CallStaticMethodA
<jobject
>, // CallStaticObjectMethodA
2352 _Jv_JNI_CallStaticMethod
<jboolean
>, // CallStaticBooleanMethod
2353 _Jv_JNI_CallStaticMethodV
<jboolean
>, // CallStaticBooleanMethodV
2354 _Jv_JNI_CallStaticMethodA
<jboolean
>, // CallStaticBooleanMethodA
2355 _Jv_JNI_CallStaticMethod
<jbyte
>, // CallStaticByteMethod
2356 _Jv_JNI_CallStaticMethodV
<jbyte
>, // CallStaticByteMethodV
2357 _Jv_JNI_CallStaticMethodA
<jbyte
>, // CallStaticByteMethodA
2358 _Jv_JNI_CallStaticMethod
<jchar
>, // CallStaticCharMethod
2359 _Jv_JNI_CallStaticMethodV
<jchar
>, // CallStaticCharMethodV
2360 _Jv_JNI_CallStaticMethodA
<jchar
>, // CallStaticCharMethodA
2361 _Jv_JNI_CallStaticMethod
<jshort
>, // CallStaticShortMethod
2362 _Jv_JNI_CallStaticMethodV
<jshort
>, // CallStaticShortMethodV
2363 _Jv_JNI_CallStaticMethodA
<jshort
>, // CallStaticShortMethodA
2364 _Jv_JNI_CallStaticMethod
<jint
>, // CallStaticIntMethod
2365 _Jv_JNI_CallStaticMethodV
<jint
>, // CallStaticIntMethodV
2366 _Jv_JNI_CallStaticMethodA
<jint
>, // CallStaticIntMethodA
2367 _Jv_JNI_CallStaticMethod
<jlong
>, // CallStaticLongMethod
2368 _Jv_JNI_CallStaticMethodV
<jlong
>, // CallStaticLongMethodV
2369 _Jv_JNI_CallStaticMethodA
<jlong
>, // CallStaticLongMethodA
2370 _Jv_JNI_CallStaticMethod
<jfloat
>, // CallStaticFloatMethod
2371 _Jv_JNI_CallStaticMethodV
<jfloat
>, // CallStaticFloatMethodV
2372 _Jv_JNI_CallStaticMethodA
<jfloat
>, // CallStaticFloatMethodA
2373 _Jv_JNI_CallStaticMethod
<jdouble
>, // CallStaticDoubleMethod
2374 _Jv_JNI_CallStaticMethodV
<jdouble
>, // CallStaticDoubleMethodV
2375 _Jv_JNI_CallStaticMethodA
<jdouble
>, // CallStaticDoubleMethodA
2376 _Jv_JNI_CallStaticVoidMethod
, // CallStaticVoidMethod
2377 _Jv_JNI_CallStaticVoidMethodV
, // CallStaticVoidMethodV
2378 _Jv_JNI_CallStaticVoidMethodA
, // CallStaticVoidMethodA
2380 _Jv_JNI_GetAnyFieldID
<true>, // GetStaticFieldID
2381 _Jv_JNI_GetStaticField
<jobject
>, // GetStaticObjectField
2382 _Jv_JNI_GetStaticField
<jboolean
>, // GetStaticBooleanField
2383 _Jv_JNI_GetStaticField
<jbyte
>, // GetStaticByteField
2384 _Jv_JNI_GetStaticField
<jchar
>, // GetStaticCharField
2385 _Jv_JNI_GetStaticField
<jshort
>, // GetStaticShortField
2386 _Jv_JNI_GetStaticField
<jint
>, // GetStaticIntField
2387 _Jv_JNI_GetStaticField
<jlong
>, // GetStaticLongField
2388 _Jv_JNI_GetStaticField
<jfloat
>, // GetStaticFloatField
2389 _Jv_JNI_GetStaticField
<jdouble
>, // GetStaticDoubleField
2390 _Jv_JNI_SetStaticField
, // SetStaticObjectField
2391 _Jv_JNI_SetStaticField
, // SetStaticBooleanField
2392 _Jv_JNI_SetStaticField
, // SetStaticByteField
2393 _Jv_JNI_SetStaticField
, // SetStaticCharField
2394 _Jv_JNI_SetStaticField
, // SetStaticShortField
2395 _Jv_JNI_SetStaticField
, // SetStaticIntField
2396 _Jv_JNI_SetStaticField
, // SetStaticLongField
2397 _Jv_JNI_SetStaticField
, // SetStaticFloatField
2398 _Jv_JNI_SetStaticField
, // SetStaticDoubleField
2399 _Jv_JNI_NewString
, // NewString
2400 _Jv_JNI_GetStringLength
, // GetStringLength
2401 _Jv_JNI_GetStringChars
, // GetStringChars
2402 _Jv_JNI_ReleaseStringChars
, // ReleaseStringChars
2403 _Jv_JNI_NewStringUTF
, // NewStringUTF
2404 _Jv_JNI_GetStringUTFLength
, // GetStringUTFLength
2405 _Jv_JNI_GetStringUTFChars
, // GetStringUTFLength
2406 _Jv_JNI_ReleaseStringUTFChars
, // ReleaseStringUTFChars
2407 _Jv_JNI_GetArrayLength
, // GetArrayLength
2408 _Jv_JNI_NewObjectArray
, // NewObjectArray
2409 _Jv_JNI_GetObjectArrayElement
, // GetObjectArrayElement
2410 _Jv_JNI_SetObjectArrayElement
, // SetObjectArrayElement
2411 _Jv_JNI_NewPrimitiveArray
<jboolean
, JvPrimClass (boolean
)>,
2413 _Jv_JNI_NewPrimitiveArray
<jbyte
, JvPrimClass (byte
)>, // NewByteArray
2414 _Jv_JNI_NewPrimitiveArray
<jchar
, JvPrimClass (char)>, // NewCharArray
2415 _Jv_JNI_NewPrimitiveArray
<jshort
, JvPrimClass (short)>, // NewShortArray
2416 _Jv_JNI_NewPrimitiveArray
<jint
, JvPrimClass (int)>, // NewIntArray
2417 _Jv_JNI_NewPrimitiveArray
<jlong
, JvPrimClass (long)>, // NewLongArray
2418 _Jv_JNI_NewPrimitiveArray
<jfloat
, JvPrimClass (float)>, // NewFloatArray
2419 _Jv_JNI_NewPrimitiveArray
<jdouble
, JvPrimClass (double)>, // NewDoubleArray
2420 _Jv_JNI_GetPrimitiveArrayElements
, // GetBooleanArrayElements
2421 _Jv_JNI_GetPrimitiveArrayElements
, // GetByteArrayElements
2422 _Jv_JNI_GetPrimitiveArrayElements
, // GetCharArrayElements
2423 _Jv_JNI_GetPrimitiveArrayElements
, // GetShortArrayElements
2424 _Jv_JNI_GetPrimitiveArrayElements
, // GetIntArrayElements
2425 _Jv_JNI_GetPrimitiveArrayElements
, // GetLongArrayElements
2426 _Jv_JNI_GetPrimitiveArrayElements
, // GetFloatArrayElements
2427 _Jv_JNI_GetPrimitiveArrayElements
, // GetDoubleArrayElements
2428 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseBooleanArrayElements
2429 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseByteArrayElements
2430 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseCharArrayElements
2431 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseShortArrayElements
2432 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseIntArrayElements
2433 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseLongArrayElements
2434 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseFloatArrayElements
2435 _Jv_JNI_ReleasePrimitiveArrayElements
, // ReleaseDoubleArrayElements
2436 _Jv_JNI_GetPrimitiveArrayRegion
, // GetBooleanArrayRegion
2437 _Jv_JNI_GetPrimitiveArrayRegion
, // GetByteArrayRegion
2438 _Jv_JNI_GetPrimitiveArrayRegion
, // GetCharArrayRegion
2439 _Jv_JNI_GetPrimitiveArrayRegion
, // GetShortArrayRegion
2440 _Jv_JNI_GetPrimitiveArrayRegion
, // GetIntArrayRegion
2441 _Jv_JNI_GetPrimitiveArrayRegion
, // GetLongArrayRegion
2442 _Jv_JNI_GetPrimitiveArrayRegion
, // GetFloatArrayRegion
2443 _Jv_JNI_GetPrimitiveArrayRegion
, // GetDoubleArrayRegion
2444 _Jv_JNI_SetPrimitiveArrayRegion
, // SetBooleanArrayRegion
2445 _Jv_JNI_SetPrimitiveArrayRegion
, // SetByteArrayRegion
2446 _Jv_JNI_SetPrimitiveArrayRegion
, // SetCharArrayRegion
2447 _Jv_JNI_SetPrimitiveArrayRegion
, // SetShortArrayRegion
2448 _Jv_JNI_SetPrimitiveArrayRegion
, // SetIntArrayRegion
2449 _Jv_JNI_SetPrimitiveArrayRegion
, // SetLongArrayRegion
2450 _Jv_JNI_SetPrimitiveArrayRegion
, // SetFloatArrayRegion
2451 _Jv_JNI_SetPrimitiveArrayRegion
, // SetDoubleArrayRegion
2452 _Jv_JNI_RegisterNatives
, // RegisterNatives
2453 _Jv_JNI_UnregisterNatives
, // UnregisterNatives
2454 _Jv_JNI_MonitorEnter
, // MonitorEnter
2455 _Jv_JNI_MonitorExit
, // MonitorExit
2456 _Jv_JNI_GetJavaVM
, // GetJavaVM
2458 _Jv_JNI_GetStringRegion
, // GetStringRegion
2459 _Jv_JNI_GetStringUTFRegion
, // GetStringUTFRegion
2460 _Jv_JNI_GetPrimitiveArrayCritical
, // GetPrimitiveArrayCritical
2461 _Jv_JNI_ReleasePrimitiveArrayCritical
, // ReleasePrimitiveArrayCritical
2462 _Jv_JNI_GetStringCritical
, // GetStringCritical
2463 _Jv_JNI_ReleaseStringCritical
, // ReleaseStringCritical
2465 NOT_IMPL
/* newweakglobalref */,
2466 NOT_IMPL
/* deleteweakglobalref */,
2468 _Jv_JNI_ExceptionCheck
2471 struct JNIInvokeInterface _Jv_JNI_InvokeFunctions
=
2477 _Jv_JNI_DestroyJavaVM
,
2478 _Jv_JNI_AttachCurrentThread
,
2479 _Jv_JNI_DetachCurrentThread
,