1 // jni.cc - JNI implementation, including the jump table.
3 /* Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
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>
24 #include <java/lang/Class.h>
25 #include <java/lang/ClassLoader.h>
26 #include <java/lang/Throwable.h>
27 #include <java/lang/ArrayIndexOutOfBoundsException.h>
28 #include <java/lang/StringIndexOutOfBoundsException.h>
29 #include <java/lang/AbstractMethodError.h>
30 #include <java/lang/InstantiationException.h>
31 #include <java/lang/NoSuchFieldError.h>
32 #include <java/lang/NoSuchMethodError.h>
33 #include <java/lang/reflect/Constructor.h>
34 #include <java/lang/reflect/Method.h>
35 #include <java/lang/reflect/Modifier.h>
36 #include <java/lang/OutOfMemoryError.h>
37 #include <java/util/Hashtable.h>
38 #include <java/lang/Integer.h>
39 #include <gnu/gcj/jni/NativeThread.h>
41 #include <gcj/method.h>
42 #include <gcj/field.h>
44 #include <java-interp.h>
46 #define ClassClass _CL_Q34java4lang5Class
47 extern java::lang::Class ClassClass;
48 #define ObjectClass _CL_Q34java4lang6Object
49 extern java::lang::Class ObjectClass;
51 #define ThrowableClass _CL_Q34java4lang9Throwable
52 extern java::lang::Class ThrowableClass;
53 #define MethodClass _CL_Q44java4lang7reflect6Method
54 extern java::lang::Class MethodClass;
55 #define ThreadGroupClass _CL_Q34java4lang11ThreadGroup
56 extern java::lang::Class ThreadGroupClass;
57 #define NativeThreadClass _CL_Q43gnu3gcj3jni12NativeThread
58 extern java::lang::Class ThreadGroupClass;
60 // This enum is used to select different template instantiations in
61 // the invocation code.
70 // Forward declarations.
71 extern struct JNINativeInterface _Jv_JNIFunctions;
72 extern struct JNIInvokeInterface _Jv_JNI_InvokeFunctions;
74 // Number of slots in the default frame. The VM must allow at least
78 // This structure is used to keep track of local references.
79 struct _Jv_JNI_LocalFrame
81 // This is true if this frame object represents a pushed frame (eg
82 // from PushLocalFrame).
85 // Number of elements in frame.
88 // Next frame in chain.
89 _Jv_JNI_LocalFrame *next;
91 // The elements. These are allocated using the C "struct hack".
95 // This holds a reference count for all local and global references.
96 static java::util::Hashtable *ref_table;
99 static JavaVM *the_vm;
106 ref_table = new java::util::Hashtable;
109 // Tell the GC that a certain pointer is live.
111 mark_for_gc (jobject obj)
113 JvSynchronize sync (ref_table);
115 using namespace java::lang;
116 Integer *refcount = (Integer *) ref_table->get (obj);
117 jint val = (refcount == NULL) ? 0 : refcount->intValue ();
118 ref_table->put (obj, new Integer (val + 1));
123 unmark_for_gc (jobject obj)
125 JvSynchronize sync (ref_table);
127 using namespace java::lang;
128 Integer *refcount = (Integer *) ref_table->get (obj);
130 jint val = refcount->intValue () - 1;
132 ref_table->remove (obj);
134 ref_table->put (obj, new Integer (val));
140 _Jv_JNI_NewGlobalRef (JNIEnv *, jobject obj)
147 _Jv_JNI_DeleteGlobalRef (JNIEnv *, jobject obj)
153 _Jv_JNI_DeleteLocalRef (JNIEnv *env, jobject obj)
155 _Jv_JNI_LocalFrame *frame;
157 for (frame = env->locals; frame != NULL; frame = frame->next)
159 for (int i = 0; i < FRAME_SIZE; ++i)
161 if (frame->vec[i] == obj)
163 frame->vec[i] = NULL;
169 // Don't go past a marked frame.
170 JvAssert (! frame->marker);
177 _Jv_JNI_EnsureLocalCapacity (JNIEnv *env, jint size)
179 // It is easier to just always allocate a new frame of the requested
180 // size. This isn't the most efficient thing, but for now we don't
181 // care. Note that _Jv_JNI_PushLocalFrame relies on this right now.
183 _Jv_JNI_LocalFrame *frame
184 = (_Jv_JNI_LocalFrame *) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame)
185 + size * sizeof (jobject));
188 // FIXME: exception processing.
189 env->ex = new java::lang::OutOfMemoryError;
193 frame->marker = true;
195 memset (&frame->vec[0], 0, size * sizeof (jobject));
196 frame->next = env->locals;
203 _Jv_JNI_PushLocalFrame (JNIEnv *env, jint size)
205 jint r = _Jv_JNI_EnsureLocalCapacity (env, size);
209 // The new frame is on top.
210 env->locals->marker = true;
216 _Jv_JNI_NewLocalRef (JNIEnv *env, jobject obj)
218 // Try to find an open slot somewhere in the topmost frame.
219 _Jv_JNI_LocalFrame *frame = env->locals;
220 bool done = false, set = false;
221 while (frame != NULL && ! done)
223 for (int i = 0; i < frame->size; ++i)
224 if (frame->vec[i] == NULL)
235 // No slots, so we allocate a new frame. According to the spec
236 // we could just die here. FIXME: return value.
237 _Jv_JNI_EnsureLocalCapacity (env, 16);
238 // We know the first element of the new frame will be ok.
239 env->locals->vec[0] = obj;
247 _Jv_JNI_PopLocalFrame (JNIEnv *env, jobject result)
249 _Jv_JNI_LocalFrame *rf = env->locals;
252 while (rf != NULL && ! done)
254 for (int i = 0; i < rf->size; ++i)
255 if (rf->vec[i] != NULL)
256 unmark_for_gc (rf->vec[i]);
258 // If the frame we just freed is the marker frame, we are done.
261 _Jv_JNI_LocalFrame *n = rf->next;
262 // When N==NULL, we've reached the stack-allocated frame, and we
263 // must not free it. However, we must be sure to clear all its
264 // elements, since we might conceivably reuse it.
267 memset (&rf->vec[0], 0, rf->size * sizeof (jobject));
275 return result == NULL ? NULL : _Jv_JNI_NewLocalRef (env, result);
278 // This function is used from other template functions. It wraps the
279 // return value appropriately; we specialize it so that object returns
280 // are turned into local references.
283 wrap_value (JNIEnv *, T value)
290 wrap_value (JNIEnv *env, jobject value)
292 return value == NULL ? value : _Jv_JNI_NewLocalRef (env, value);
298 _Jv_JNI_GetVersion (JNIEnv *)
300 return JNI_VERSION_1_2;
304 _Jv_JNI_DefineClass (JNIEnv *env, jobject loader,
305 const jbyte *buf, jsize bufLen)
307 jbyteArray bytes = JvNewByteArray (bufLen);
308 jbyte *elts = elements (bytes);
309 memcpy (elts, buf, bufLen * sizeof (jbyte));
311 java::lang::ClassLoader *l
312 = reinterpret_cast<java::lang::ClassLoader *> (loader);
314 // FIXME: exception processing.
315 jclass result = l->defineClass (bytes, 0, bufLen);
316 return (jclass) wrap_value (env, result);
320 _Jv_JNI_FindClass (JNIEnv *env, const char *name)
322 // FIXME: assume that NAME isn't too long.
323 int len = strlen (name);
325 for (int i = 0; i <= len; ++i)
326 s[i] = (name[i] == '/') ? '.' : name[i];
327 jstring n = JvNewStringUTF (s);
329 java::lang::ClassLoader *loader;
330 if (env->klass == NULL)
332 // FIXME: should use getBaseClassLoader, but we don't have that
334 loader = java::lang::ClassLoader::getSystemClassLoader ();
337 loader = env->klass->getClassLoader ();
339 // FIXME: exception processing.
340 jclass r = loader->loadClass (n);
342 return (jclass) wrap_value (env, r);
346 _Jv_JNI_GetSuperclass (JNIEnv *env, jclass clazz)
348 return (jclass) wrap_value (env, clazz->getSuperclass ());
352 _Jv_JNI_IsAssignableFrom(JNIEnv *, jclass clazz1, jclass clazz2)
354 return clazz1->isAssignableFrom (clazz2);
358 _Jv_JNI_Throw (JNIEnv *env, jthrowable obj)
360 // We check in case the user did some funky cast.
361 JvAssert (obj != NULL && (&ThrowableClass)->isInstance (obj));
367 _Jv_JNI_ThrowNew (JNIEnv *env, jclass clazz, const char *message)
369 using namespace java::lang::reflect;
371 JvAssert ((&ThrowableClass)->isAssignableFrom (clazz));
373 JArray<jclass> *argtypes
374 = (JArray<jclass> *) JvNewObjectArray (1, &ClassClass, NULL);
376 jclass *elts = elements (argtypes);
377 elts[0] = &StringClass;
379 // FIXME: exception processing.
380 Constructor *cons = clazz->getConstructor (argtypes);
382 jobjectArray values = JvNewObjectArray (1, &StringClass, NULL);
383 jobject *velts = elements (values);
384 velts[0] = JvNewStringUTF (message);
386 // FIXME: exception processing.
387 jobject obj = cons->newInstance (values);
389 env->ex = reinterpret_cast<jthrowable> (obj);
394 _Jv_JNI_ExceptionOccurred (JNIEnv *env)
396 return (jthrowable) wrap_value (env, env->ex);
400 _Jv_JNI_ExceptionDescribe (JNIEnv *env)
403 env->ex->printStackTrace();
407 _Jv_JNI_ExceptionClear (JNIEnv *env)
413 _Jv_JNI_ExceptionCheck (JNIEnv *env)
415 return env->ex != NULL;
419 _Jv_JNI_FatalError (JNIEnv *, const char *message)
427 _Jv_JNI_IsSameObject (JNIEnv *, jobject obj1, jobject obj2)
433 _Jv_JNI_AllocObject (JNIEnv *env, jclass clazz)
436 using namespace java::lang::reflect;
438 JvAssert (clazz && ! clazz->isArray ());
439 if (clazz->isInterface() || Modifier::isAbstract(clazz->getModifiers()))
440 env->ex = new java::lang::InstantiationException ();
443 // FIXME: exception processing.
444 // FIXME: will this work for String?
445 obj = JvAllocObject (clazz);
448 return wrap_value (env, obj);
452 _Jv_JNI_GetObjectClass (JNIEnv *env, jobject obj)
455 return (jclass) wrap_value (env, obj->getClass());
459 _Jv_JNI_IsInstanceOf (JNIEnv *, jobject obj, jclass clazz)
461 return clazz->isInstance(obj);
467 // This section concerns method invocation.
470 template<jboolean is_static>
472 _Jv_JNI_GetAnyMethodID (JNIEnv *env, jclass clazz,
473 const char *name, const char *sig)
475 // FIXME: exception processing.
476 _Jv_InitClass (clazz);
478 _Jv_Utf8Const *name_u = _Jv_makeUtf8Const ((char *) name, -1);
479 _Jv_Utf8Const *sig_u = _Jv_makeUtf8Const ((char *) sig, -1);
481 JvAssert (! clazz->isPrimitive());
483 using namespace java::lang::reflect;
485 while (clazz != NULL)
487 jint count = JvNumMethods (clazz);
488 jmethodID meth = JvGetFirstMethod (clazz);
490 for (jint i = 0; i < count; ++i)
492 if (((is_static && Modifier::isStatic (meth->accflags))
493 || (! is_static && ! Modifier::isStatic (meth->accflags)))
494 && _Jv_equalUtf8Consts (meth->name, name_u)
495 && _Jv_equalUtf8Consts (meth->signature, sig_u))
498 meth = meth->getNextMethod();
501 clazz = clazz->getSuperclass ();
504 env->ex = new java::lang::NoSuchMethodError ();
508 // This is a helper function which turns a va_list into an array of
509 // `jvalue's. It needs signature information in order to do its work.
510 // The array of values must already be allocated.
512 array_from_valist (jvalue *values, JArray<jclass> *arg_types, va_list vargs)
514 jclass *arg_elts = elements (arg_types);
515 for (int i = 0; i < arg_types->length; ++i)
517 if (arg_elts[i] == JvPrimClass (byte))
518 values[i].b = va_arg (vargs, jbyte);
519 else if (arg_elts[i] == JvPrimClass (short))
520 values[i].s = va_arg (vargs, jshort);
521 else if (arg_elts[i] == JvPrimClass (int))
522 values[i].i = va_arg (vargs, jint);
523 else if (arg_elts[i] == JvPrimClass (long))
524 values[i].j = va_arg (vargs, jlong);
525 else if (arg_elts[i] == JvPrimClass (float))
526 values[i].f = va_arg (vargs, jfloat);
527 else if (arg_elts[i] == JvPrimClass (double))
528 values[i].d = va_arg (vargs, jdouble);
529 else if (arg_elts[i] == JvPrimClass (boolean))
530 values[i].z = va_arg (vargs, jboolean);
531 else if (arg_elts[i] == JvPrimClass (char))
532 values[i].c = va_arg (vargs, jchar);
536 values[i].l = va_arg (vargs, jobject);
541 // This can call any sort of method: virtual, "nonvirtual", static, or
543 template<typename T, invocation_type style>
545 _Jv_JNI_CallAnyMethodV (JNIEnv *env, jobject obj, jclass klass,
546 jmethodID id, va_list vargs)
549 id = _Jv_LookupDeclaredMethod (obj->getClass (), id->name, id->signature);
551 jclass decl_class = klass ? klass : obj->getClass ();
552 JvAssert (decl_class != NULL);
555 JArray<jclass> *arg_types;
556 // FIXME: exception processing.
557 _Jv_GetTypesFromSignature (id, decl_class,
558 &arg_types, &return_type);
560 jvalue args[arg_types->length];
561 array_from_valist (args, arg_types, vargs);
563 // For constructors we need to pass the Class we are instantiating.
564 if (style == constructor)
568 jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
569 style == constructor,
570 arg_types, args, &result);
575 // We cheat a little here. FIXME.
576 return wrap_value (env, * (T *) &result);
579 template<typename T, invocation_type style>
581 _Jv_JNI_CallAnyMethod (JNIEnv *env, jobject obj, jclass klass,
582 jmethodID method, ...)
587 va_start (args, method);
588 result = _Jv_JNI_CallAnyMethodV<T, style> (env, obj, klass, method, args);
594 template<typename T, invocation_type style>
596 _Jv_JNI_CallAnyMethodA (JNIEnv *env, jobject obj, jclass klass,
597 jmethodID id, jvalue *args)
600 id = _Jv_LookupDeclaredMethod (obj->getClass (), id->name, id->signature);
602 jclass decl_class = klass ? klass : obj->getClass ();
603 JvAssert (decl_class != NULL);
606 JArray<jclass> *arg_types;
607 // FIXME: exception processing.
608 _Jv_GetTypesFromSignature (id, decl_class,
609 &arg_types, &return_type);
611 // For constructors we need to pass the Class we are instantiating.
612 if (style == constructor)
616 jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
617 style == constructor,
618 arg_types, args, &result);
623 // We cheat a little here. FIXME.
624 return wrap_value (env, * (T *) &result);
627 template<invocation_type style>
629 _Jv_JNI_CallAnyVoidMethodV (JNIEnv *env, jobject obj, jclass klass,
630 jmethodID id, va_list vargs)
633 id = _Jv_LookupDeclaredMethod (obj->getClass (), id->name, id->signature);
635 jclass decl_class = klass ? klass : obj->getClass ();
636 JvAssert (decl_class != NULL);
639 JArray<jclass> *arg_types;
640 // FIXME: exception processing.
641 _Jv_GetTypesFromSignature (id, decl_class,
642 &arg_types, &return_type);
644 jvalue args[arg_types->length];
645 array_from_valist (args, arg_types, vargs);
647 // For constructors we need to pass the Class we are instantiating.
648 if (style == constructor)
651 jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
652 style == constructor,
653 arg_types, args, NULL);
659 template<invocation_type style>
661 _Jv_JNI_CallAnyVoidMethod (JNIEnv *env, jobject obj, jclass klass,
662 jmethodID method, ...)
666 va_start (args, method);
667 _Jv_JNI_CallAnyVoidMethodV<style> (env, obj, klass, method, args);
671 template<invocation_type style>
673 _Jv_JNI_CallAnyVoidMethodA (JNIEnv *env, jobject obj, jclass klass,
674 jmethodID id, jvalue *args)
677 id = _Jv_LookupDeclaredMethod (obj->getClass (), id->name, id->signature);
679 jclass decl_class = klass ? klass : obj->getClass ();
680 JvAssert (decl_class != NULL);
683 JArray<jclass> *arg_types;
684 // FIXME: exception processing.
685 _Jv_GetTypesFromSignature (id, decl_class,
686 &arg_types, &return_type);
688 jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
689 style == constructor,
690 arg_types, args, NULL);
696 // Functions with this signature are used to implement functions in
697 // the CallMethod family.
700 _Jv_JNI_CallMethodV (JNIEnv *env, jobject obj, jmethodID id, va_list args)
702 return _Jv_JNI_CallAnyMethodV<T, normal> (env, obj, NULL, id, args);
705 // Functions with this signature are used to implement functions in
706 // the CallMethod family.
709 _Jv_JNI_CallMethod (JNIEnv *env, jobject obj, jmethodID id, ...)
715 result = _Jv_JNI_CallAnyMethodV<T, normal> (env, obj, NULL, id, args);
721 // Functions with this signature are used to implement functions in
722 // the CallMethod family.
725 _Jv_JNI_CallMethodA (JNIEnv *env, jobject obj, jmethodID id, jvalue *args)
727 return _Jv_JNI_CallAnyMethodA<T, normal> (env, obj, NULL, id, args);
731 _Jv_JNI_CallVoidMethodV (JNIEnv *env, jobject obj, jmethodID id, va_list args)
733 _Jv_JNI_CallAnyVoidMethodV<normal> (env, obj, NULL, id, args);
737 _Jv_JNI_CallVoidMethod (JNIEnv *env, jobject obj, jmethodID id, ...)
742 _Jv_JNI_CallAnyVoidMethodV<normal> (env, obj, NULL, id, args);
747 _Jv_JNI_CallVoidMethodA (JNIEnv *env, jobject obj, jmethodID id, jvalue *args)
749 _Jv_JNI_CallAnyVoidMethodA<normal> (env, obj, NULL, id, args);
752 // Functions with this signature are used to implement functions in
753 // the CallStaticMethod family.
756 _Jv_JNI_CallStaticMethodV (JNIEnv *env, jclass klass,
757 jmethodID id, va_list args)
759 return _Jv_JNI_CallAnyMethodV<T, static_type> (env, NULL, klass, id, args);
762 // Functions with this signature are used to implement functions in
763 // the CallStaticMethod family.
766 _Jv_JNI_CallStaticMethod (JNIEnv *env, jclass klass, jmethodID id, ...)
772 result = _Jv_JNI_CallAnyMethodV<T, static_type> (env, NULL, klass,
779 // Functions with this signature are used to implement functions in
780 // the CallStaticMethod family.
783 _Jv_JNI_CallStaticMethodA (JNIEnv *env, jclass klass, jmethodID id,
786 return _Jv_JNI_CallAnyMethodA<T, static_type> (env, NULL, klass, id, args);
790 _Jv_JNI_CallStaticVoidMethodV (JNIEnv *env, jclass klass, jmethodID id,
793 _Jv_JNI_CallAnyVoidMethodV<static_type> (env, NULL, klass, id, args);
797 _Jv_JNI_CallStaticVoidMethod (JNIEnv *env, jclass klass, jmethodID id, ...)
802 _Jv_JNI_CallAnyVoidMethodV<static_type> (env, NULL, klass, id, args);
807 _Jv_JNI_CallStaticVoidMethodA (JNIEnv *env, jclass klass, jmethodID id,
810 _Jv_JNI_CallAnyVoidMethodA<static_type> (env, NULL, klass, id, args);
814 _Jv_JNI_NewObjectV (JNIEnv *env, jclass klass,
815 jmethodID id, va_list args)
817 JvAssert (klass && ! klass->isArray ());
818 JvAssert (! strcmp (id->name->data, "<init>")
819 && id->signature->length > 2
820 && id->signature->data[0] == '('
821 && ! strcmp (&id->signature->data[id->signature->length - 2],
824 return _Jv_JNI_CallAnyMethodV<jobject, constructor> (env, NULL, klass,
829 _Jv_JNI_NewObject (JNIEnv *env, jclass klass, jmethodID id, ...)
831 JvAssert (klass && ! klass->isArray ());
832 JvAssert (! strcmp (id->name->data, "<init>")
833 && id->signature->length > 2
834 && id->signature->data[0] == '('
835 && ! strcmp (&id->signature->data[id->signature->length - 2],
842 result = _Jv_JNI_CallAnyMethodV<jobject, constructor> (env, NULL, klass,
850 _Jv_JNI_NewObjectA (JNIEnv *env, jclass klass, jmethodID id,
853 JvAssert (klass && ! klass->isArray ());
854 JvAssert (! strcmp (id->name->data, "<init>")
855 && id->signature->length > 2
856 && id->signature->data[0] == '('
857 && ! strcmp (&id->signature->data[id->signature->length - 2],
860 return _Jv_JNI_CallAnyMethodA<jobject, constructor> (env, NULL, klass,
868 _Jv_JNI_GetField (JNIEnv *env, jobject obj, jfieldID field)
871 T *ptr = (T *) ((char *) obj + field->getOffset ());
872 return wrap_value (env, *ptr);
877 _Jv_JNI_SetField (JNIEnv *, jobject obj, jfieldID field, T value)
880 T *ptr = (T *) ((char *) obj + field->getOffset ());
884 template<jboolean is_static>
886 _Jv_JNI_GetAnyFieldID (JNIEnv *env, jclass clazz,
887 const char *name, const char *sig)
889 // FIXME: exception processing.
890 _Jv_InitClass (clazz);
892 _Jv_Utf8Const *a_name = _Jv_makeUtf8Const ((char *) name, -1);
894 jclass field_class = NULL;
896 field_class = _Jv_FindClassFromSignature ((char *) sig, NULL);
899 _Jv_Utf8Const *sig_u = _Jv_makeUtf8Const ((char *) sig, -1);
900 field_class = _Jv_FindClass (sig_u, NULL);
903 // FIXME: what if field_class == NULL?
905 while (clazz != NULL)
907 jint count = (is_static
908 ? JvNumStaticFields (clazz)
909 : JvNumInstanceFields (clazz));
910 jfieldID field = (is_static
911 ? JvGetFirstStaticField (clazz)
912 : JvGetFirstInstanceField (clazz));
913 for (jint i = 0; i < count; ++i)
915 // The field is resolved as a side effect of class
917 JvAssert (field->isResolved ());
919 _Jv_Utf8Const *f_name = field->getNameUtf8Const(clazz);
921 if (_Jv_equalUtf8Consts (f_name, a_name)
922 && field->getClass() == field_class)
925 field = field->getNextField ();
928 clazz = clazz->getSuperclass ();
931 env->ex = new java::lang::NoSuchFieldError ();
937 _Jv_JNI_GetStaticField (JNIEnv *env, jclass, jfieldID field)
939 T *ptr = (T *) field->u.addr;
940 return wrap_value (env, *ptr);
945 _Jv_JNI_SetStaticField (JNIEnv *, jclass, jfieldID field, T value)
947 T *ptr = (T *) field->u.addr;
952 _Jv_JNI_NewString (JNIEnv *env, const jchar *unichars, jsize len)
954 // FIXME: exception processing.
955 jstring r = _Jv_NewString (unichars, len);
956 return (jstring) wrap_value (env, r);
960 _Jv_JNI_GetStringLength (JNIEnv *, jstring string)
962 return string->length();
966 _Jv_JNI_GetStringChars (JNIEnv *, jstring string, jboolean *isCopy)
968 jchar *result = _Jv_GetStringChars (string);
969 mark_for_gc (string);
972 return (const jchar *) result;
976 _Jv_JNI_ReleaseStringChars (JNIEnv *, jstring string, const jchar *)
978 unmark_for_gc (string);
982 _Jv_JNI_NewStringUTF (JNIEnv *env, const char *bytes)
984 // FIXME: exception processing.
985 jstring result = JvNewStringUTF (bytes);
986 return (jstring) wrap_value (env, result);
990 _Jv_JNI_GetStringUTFLength (JNIEnv *, jstring string)
992 return JvGetStringUTFLength (string);
996 _Jv_JNI_GetStringUTFChars (JNIEnv *, jstring string, jboolean *isCopy)
998 jsize len = JvGetStringUTFLength (string);
999 // FIXME: exception processing.
1000 char *r = (char *) _Jv_Malloc (len + 1);
1001 JvGetStringUTFRegion (string, 0, len, r);
1007 return (const char *) r;
1011 _Jv_JNI_ReleaseStringUTFChars (JNIEnv *, jstring, const char *utf)
1013 _Jv_Free ((void *) utf);
1017 _Jv_JNI_GetStringRegion (JNIEnv *env, jstring string, jsize start, jsize len,
1020 jchar *result = _Jv_GetStringChars (string);
1021 if (start < 0 || start > string->length ()
1022 || len < 0 || start + len > string->length ())
1023 env->ex = new java::lang::StringIndexOutOfBoundsException ();
1025 memcpy (buf, &result[start], len * sizeof (jchar));
1029 _Jv_JNI_GetStringUTFRegion (JNIEnv *env, jstring str, jsize start,
1030 jsize len, char *buf)
1032 if (start < 0 || start > str->length ()
1033 || len < 0 || start + len > str->length ())
1034 env->ex = new java::lang::StringIndexOutOfBoundsException ();
1036 _Jv_GetStringUTFRegion (str, start, len, buf);
1039 static const jchar *
1040 _Jv_JNI_GetStringCritical (JNIEnv *, jstring str, jboolean *isCopy)
1042 jchar *result = _Jv_GetStringChars (str);
1049 _Jv_JNI_ReleaseStringCritical (JNIEnv *, jstring, const jchar *)
1055 _Jv_JNI_GetArrayLength (JNIEnv *, jarray array)
1057 return array->length;
1061 _Jv_JNI_NewObjectArray (JNIEnv *env, jsize length, jclass elementClass,
1064 // FIXME: exception processing.
1065 jarray result = JvNewObjectArray (length, elementClass, init);
1066 return (jarray) wrap_value (env, result);
1070 _Jv_JNI_GetObjectArrayElement (JNIEnv *env, jobjectArray array, jsize index)
1072 jobject *elts = elements (array);
1073 return wrap_value (env, elts[index]);
1077 _Jv_JNI_SetObjectArrayElement (JNIEnv *, jobjectArray array, jsize index,
1080 // FIXME: exception processing.
1081 _Jv_CheckArrayStore (array, value);
1082 jobject *elts = elements (array);
1083 elts[index] = value;
1086 template<typename T, jclass K>
1088 _Jv_JNI_NewPrimitiveArray (JNIEnv *env, jsize length)
1090 // FIXME: exception processing.
1091 return (JArray<T> *) wrap_value (env, _Jv_NewPrimArray (K, length));
1094 template<typename T>
1096 _Jv_JNI_GetPrimitiveArrayElements (JNIEnv *, JArray<T> *array,
1099 T *elts = elements (array);
1102 // We elect never to copy.
1105 mark_for_gc (array);
1109 template<typename T>
1111 _Jv_JNI_ReleasePrimitiveArrayElements (JNIEnv *, JArray<T> *array,
1112 T *, jint /* mode */)
1114 // Note that we ignore MODE. We can do this because we never copy
1115 // the array elements. My reading of the JNI documentation is that
1116 // this is an option for the implementor.
1117 unmark_for_gc (array);
1120 template<typename T>
1122 _Jv_JNI_GetPrimitiveArrayRegion (JNIEnv *env, JArray<T> *array,
1123 jsize start, jsize len,
1126 if (start < 0 || len >= array->length || start + len >= array->length)
1129 env->ex = new java::lang::ArrayIndexOutOfBoundsException ();
1133 T *elts = elements (array) + start;
1134 memcpy (buf, elts, len * sizeof (T));
1138 template<typename T>
1140 _Jv_JNI_SetPrimitiveArrayRegion (JNIEnv *env, JArray<T> *array,
1141 jsize start, jsize len, T *buf)
1143 if (start < 0 || len >= array->length || start + len >= array->length)
1146 env->ex = new java::lang::ArrayIndexOutOfBoundsException ();
1150 T *elts = elements (array) + start;
1151 memcpy (elts, buf, len * sizeof (T));
1156 _Jv_JNI_GetPrimitiveArrayCritical (JNIEnv *, jarray array,
1159 // FIXME: does this work?
1160 jclass klass = array->getClass()->getComponentType();
1161 JvAssert (klass->isPrimitive ());
1162 char *r = _Jv_GetArrayElementFromElementType (array, klass);
1169 _Jv_JNI_ReleasePrimitiveArrayCritical (JNIEnv *, jarray, void *, jint)
1175 _Jv_JNI_MonitorEnter (JNIEnv *, jobject obj)
1177 // FIXME: exception processing.
1178 jint r = _Jv_MonitorEnter (obj);
1183 _Jv_JNI_MonitorExit (JNIEnv *, jobject obj)
1185 // FIXME: exception processing.
1186 jint r = _Jv_MonitorExit (obj);
1192 _Jv_JNI_ToReflectedField (JNIEnv *env, jclass cls, jfieldID fieldID,
1195 // FIXME: exception processing.
1196 java::lang::reflect::Field *field = new java::lang::reflect::Field();
1197 field->declaringClass = cls;
1198 field->offset = (char*) fieldID - (char *) cls->fields;
1199 field->name = _Jv_NewStringUtf8Const (fieldID->getNameUtf8Const (cls));
1200 return wrap_value (env, field);
1205 _Jv_JNI_FromReflectedField (JNIEnv *, jobject f)
1207 using namespace java::lang::reflect;
1209 Field *field = reinterpret_cast<Field *> (f);
1210 return _Jv_FromReflectedField (field);
1214 _Jv_JNI_ToReflectedMethod (JNIEnv *env, jclass klass, jmethodID id,
1217 using namespace java::lang::reflect;
1220 static _Jv_Utf8Const *init_name = _Jv_makeUtf8Const ("<init>", 6);
1223 if (_Jv_equalUtf8Consts (id->name, init_name))
1226 Constructor *cons = new Constructor ();
1227 cons->offset = (char *) id - (char *) &klass->methods;
1228 cons->declaringClass = klass;
1233 Method *meth = new Method ();
1234 meth->offset = (char *) id - (char *) &klass->methods;
1235 meth->declaringClass = klass;
1239 return wrap_value (env, result);
1243 _Jv_JNI_FromReflectedMethod (JNIEnv *, jobject method)
1245 using namespace java::lang::reflect;
1246 if ((&MethodClass)->isInstance (method))
1247 return _Jv_FromReflectedMethod (reinterpret_cast<Method *> (method));
1249 _Jv_FromReflectedConstructor (reinterpret_cast<Constructor *> (method));
1256 // Add a character to the buffer, encoding properly.
1258 add_char (char *buf, jchar c, int *here)
1262 buf[(*here)++] = '_';
1263 buf[(*here)++] = '1';
1267 buf[(*here)++] = '_';
1268 buf[(*here)++] = '2';
1272 buf[(*here)++] = '_';
1273 buf[(*here)++] = '3';
1276 buf[(*here)++] = '_';
1277 else if ((c >= '0' && c <= '9')
1278 || (c >= 'a' && c <= 'z')
1279 || (c >= 'A' && c <= 'Z'))
1280 buf[(*here)++] = (char) c;
1283 // "Unicode" character.
1284 buf[(*here)++] = '_';
1285 buf[(*here)++] = '0';
1286 for (int i = 0; i < 4; ++i)
1289 buf[(*here) + 4 - i] = (val > 10) ? ('a' + val - 10) : ('0' + val);
1296 // Compute a mangled name for a native function. This computes the
1297 // long name, and also returns an index which indicates where a NUL
1298 // can be placed to create the short name. This function assumes that
1299 // the buffer is large enough for its results.
1301 mangled_name (jclass klass, _Jv_Utf8Const *func_name,
1302 _Jv_Utf8Const *signature, char *buf, int *long_start)
1304 strcpy (buf, "Java_");
1307 // Add fully qualified class name.
1308 jchar *chars = _Jv_GetStringChars (klass->getName ());
1309 jint len = klass->getName ()->length ();
1310 for (int i = 0; i < len; ++i)
1311 add_char (buf, chars[i], &here);
1313 // Don't use add_char because we need a literal `_'.
1316 const unsigned char *fn = (const unsigned char *) func_name->data;
1317 const unsigned char *limit = fn + func_name->length;
1318 for (int i = 0; ; ++i)
1320 int ch = UTF8_GET (fn, limit);
1323 add_char (buf, ch, &here);
1326 // This is where the long signature begins.
1331 const unsigned char *sig = (const unsigned char *) signature->data;
1332 limit = sig + signature->length;
1333 JvAssert (signature[0] == '(');
1337 int ch = UTF8_GET (sig, limit);
1338 if (ch == ')' || ch < 0)
1340 add_char (buf, ch, &here);
1346 // This function is the stub which is used to turn an ordinary (CNI)
1347 // method call into a JNI call.
1349 _Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this)
1351 _Jv_JNIMethod* _this = (_Jv_JNIMethod *) __this;
1354 _Jv_JNI_LocalFrame *frame
1355 = (_Jv_JNI_LocalFrame *) alloca (sizeof (_Jv_JNI_LocalFrame)
1356 + FRAME_SIZE * sizeof (jobject));
1358 env.p = &_Jv_JNIFunctions;
1360 env.klass = _this->defining_class;
1363 frame->marker = true;
1365 frame->size = FRAME_SIZE;
1366 for (int i = 0; i < frame->size; ++i)
1367 frame->vec[i] = NULL;
1369 // FIXME: we should mark every reference parameter as a local. For
1370 // now we assume a conservative GC, and we assume that the
1371 // references are on the stack somewhere.
1373 // We cache the value that we find, of course, but if we don't find
1374 // a value we don't cache that fact -- we might subsequently load a
1375 // library which finds the function in question.
1376 if (_this->function == NULL)
1378 char buf[10 + 6 * (_this->self->name->length
1379 + _this->self->signature->length)];
1381 mangled_name (_this->defining_class, _this->self->name,
1382 _this->self->signature, buf, &long_start);
1383 char c = buf[long_start];
1384 buf[long_start] = '\0';
1385 _this->function = _Jv_FindSymbolInExecutable (buf);
1386 if (_this->function == NULL)
1388 buf[long_start] = c;
1389 _this->function = _Jv_FindSymbolInExecutable (buf);
1390 if (_this->function == NULL)
1392 jstring str = JvNewStringUTF (_this->self->name->data);
1393 JvThrow (new java::lang::AbstractMethodError (str));
1398 JvAssert (_this->args_raw_size % sizeof (ffi_raw) == 0);
1399 ffi_raw real_args[2 + _this->args_raw_size / sizeof (ffi_raw)];
1402 // First argument is always the environment pointer.
1403 real_args[offset++].ptr = &env;
1405 // For a static method, we pass in the Class. For non-static
1406 // methods, the `this' argument is already handled.
1407 if ((_this->self->accflags & java::lang::reflect::Modifier::STATIC))
1408 real_args[offset++].ptr = _this->defining_class;
1410 // Copy over passed-in arguments.
1411 memcpy (&real_args[offset], args, _this->args_raw_size);
1413 // The actual call to the JNI function.
1414 ffi_raw_call (&_this->jni_cif, (void (*) (...)) _this->function,
1419 _Jv_JNI_PopLocalFrame (&env, NULL);
1421 while (env.locals != frame);
1427 #endif /* INTERPRETER */
1435 // An internal helper function.
1437 _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
1439 JavaVMAttachArgs *attach = reinterpret_cast<JavaVMAttachArgs *> (args);
1440 java::lang::ThreadGroup *group = NULL;
1444 // FIXME: do we really want to support 1.1?
1445 if (attach->version != JNI_VERSION_1_2
1446 && attach->version != JNI_VERSION_1_1)
1447 return JNI_EVERSION;
1449 JvAssert ((&ThreadGroupClass)->isInstance (attach->group));
1450 group = reinterpret_cast<java::lang::ThreadGroup *> (attach->group);
1453 // Attaching an already-attached thread is a no-op.
1454 if (_Jv_ThreadCurrent () != NULL)
1457 JNIEnv *env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv));
1460 env->p = &_Jv_JNIFunctions;
1464 = (_Jv_JNI_LocalFrame *) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame)
1466 * sizeof (jobject)));
1467 if (env->locals == NULL)
1472 *penv = reinterpret_cast<void *> (env);
1474 java::lang::Thread *t = new gnu::gcj::jni::NativeThread (group, name);
1475 t = t; // Avoid compiler warning. Eww.
1476 _Jv_SetCurrentJNIEnv (env);
1481 // This is the one actually used by JNI.
1483 _Jv_JNI_AttachCurrentThread (JavaVM *vm, void **penv, void *args)
1485 return _Jv_JNI_AttachCurrentThread (vm, NULL, penv, args);
1489 _Jv_JNI_DestroyJavaVM (JavaVM *vm)
1491 JvAssert (the_vm && vm == the_vm);
1494 if (_Jv_ThreadCurrent () != NULL)
1496 jint r = _Jv_JNI_AttachCurrentThread (vm,
1497 JvNewStringLatin1 ("main"),
1498 reinterpret_cast<void **> (&env),
1504 env = _Jv_GetCurrentJNIEnv ();
1508 // Docs say that this always returns an error code.
1513 _Jv_JNI_DetachCurrentThread (JavaVM *)
1515 java::lang::Thread *t = _Jv_ThreadCurrent ();
1517 return JNI_EDETACHED;
1519 // FIXME: we only allow threads attached via AttachCurrentThread to
1520 // be detached. I have no idea how we could implement detaching
1521 // other threads, given the requirement that we must release all the
1522 // monitors. That just seems evil.
1523 JvAssert ((&NativeThreadClass)->isInstance (t));
1525 // FIXME: release the monitors. We'll take this to mean all
1526 // monitors acquired via the JNI interface. This means we have to
1527 // keep track of them.
1529 gnu::gcj::jni::NativeThread *nt
1530 = reinterpret_cast<gnu::gcj::jni::NativeThread *> (t);
1537 _Jv_JNI_GetEnv (JavaVM *, void **penv, jint version)
1539 if (_Jv_ThreadCurrent () == NULL)
1542 return JNI_EDETACHED;
1545 // FIXME: do we really want to support 1.1?
1546 if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_1)
1549 return JNI_EVERSION;
1552 *penv = (void *) _Jv_GetCurrentJNIEnv ();
1557 JNI_GetDefaultJavaVMInitArgs (void *args)
1559 jint version = * (jint *) args;
1560 // Here we only support 1.2.
1561 if (version != JNI_VERSION_1_2)
1562 return JNI_EVERSION;
1564 JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args);
1565 ia->version = JNI_VERSION_1_2;
1568 ia->ignoreUnrecognized = true;
1574 JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args)
1576 JvAssert (! the_vm);
1577 // FIXME: synchronize
1578 JavaVM *nvm = (JavaVM *) _Jv_MallocUnchecked (sizeof (JavaVM));
1581 nvm->functions = &_Jv_JNI_InvokeFunctions;
1583 // Parse the arguments.
1586 jint version = * (jint *) args;
1587 // We only support 1.2.
1588 if (version != JNI_VERSION_1_2)
1589 return JNI_EVERSION;
1590 JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args);
1591 for (int i = 0; i < ia->nOptions; ++i)
1593 if (! strcmp (ia->options[i].optionString, "vfprintf")
1594 || ! strcmp (ia->options[i].optionString, "exit")
1595 || ! strcmp (ia->options[i].optionString, "abort"))
1597 // We are required to recognize these, but for now we
1598 // don't handle them in any way. FIXME.
1601 else if (! strncmp (ia->options[i].optionString,
1602 "-verbose", sizeof ("-verbose") - 1))
1604 // We don't do anything with this option either. We
1605 // might want to make sure the argument is valid, but we
1606 // don't really care all that much for now.
1609 else if (! strncmp (ia->options[i].optionString, "-D", 2))
1614 else if (ia->ignoreUnrecognized)
1616 if (ia->options[i].optionString[0] == '_'
1617 || ! strncmp (ia->options[i].optionString, "-X", 2))
1625 jint r =_Jv_JNI_AttachCurrentThread (nvm, penv, NULL);
1635 JNI_GetCreatedJavaVMs (JavaVM **vm_buffer, jsize buf_len, jsize *n_vms)
1637 JvAssert (buf_len > 0);
1638 // We only support a single VM.
1641 vm_buffer[0] = the_vm;
1650 _Jv_JNI_GetJavaVM (JNIEnv *, JavaVM **vm)
1652 // FIXME: synchronize
1655 JavaVM *nvm = (JavaVM *) _Jv_MallocUnchecked (sizeof (JavaVM));
1658 nvm->functions = &_Jv_JNI_InvokeFunctions;
1668 #define NOT_IMPL NULL
1669 #define RESERVED NULL
1671 struct JNINativeInterface _Jv_JNIFunctions =
1678 _Jv_JNI_DefineClass,
1680 _Jv_JNI_FromReflectedMethod,
1681 _Jv_JNI_FromReflectedField,
1682 _Jv_JNI_ToReflectedMethod,
1683 _Jv_JNI_GetSuperclass,
1684 _Jv_JNI_IsAssignableFrom,
1685 _Jv_JNI_ToReflectedField,
1688 _Jv_JNI_ExceptionOccurred,
1689 _Jv_JNI_ExceptionDescribe,
1690 _Jv_JNI_ExceptionClear,
1693 _Jv_JNI_PushLocalFrame,
1694 _Jv_JNI_PopLocalFrame,
1695 _Jv_JNI_NewGlobalRef,
1696 _Jv_JNI_DeleteGlobalRef,
1697 _Jv_JNI_DeleteLocalRef,
1699 _Jv_JNI_IsSameObject,
1701 _Jv_JNI_NewLocalRef,
1702 _Jv_JNI_EnsureLocalCapacity,
1704 _Jv_JNI_AllocObject,
1708 _Jv_JNI_GetObjectClass,
1709 _Jv_JNI_IsInstanceOf,
1710 _Jv_JNI_GetAnyMethodID<false>,
1712 _Jv_JNI_CallMethod<jobject>,
1713 _Jv_JNI_CallMethodV<jobject>,
1714 _Jv_JNI_CallMethodA<jobject>,
1715 _Jv_JNI_CallMethod<jboolean>,
1716 _Jv_JNI_CallMethodV<jboolean>,
1717 _Jv_JNI_CallMethodA<jboolean>,
1718 _Jv_JNI_CallMethod<jbyte>,
1719 _Jv_JNI_CallMethodV<jbyte>,
1720 _Jv_JNI_CallMethodA<jbyte>,
1721 _Jv_JNI_CallMethod<jchar>,
1722 _Jv_JNI_CallMethodV<jchar>,
1723 _Jv_JNI_CallMethodA<jchar>,
1724 _Jv_JNI_CallMethod<jshort>,
1725 _Jv_JNI_CallMethodV<jshort>,
1726 _Jv_JNI_CallMethodA<jshort>,
1727 _Jv_JNI_CallMethod<jint>,
1728 _Jv_JNI_CallMethodV<jint>,
1729 _Jv_JNI_CallMethodA<jint>,
1730 _Jv_JNI_CallMethod<jlong>,
1731 _Jv_JNI_CallMethodV<jlong>,
1732 _Jv_JNI_CallMethodA<jlong>,
1733 _Jv_JNI_CallMethod<jfloat>,
1734 _Jv_JNI_CallMethodV<jfloat>,
1735 _Jv_JNI_CallMethodA<jfloat>,
1736 _Jv_JNI_CallMethod<jdouble>,
1737 _Jv_JNI_CallMethodV<jdouble>,
1738 _Jv_JNI_CallMethodA<jdouble>,
1739 _Jv_JNI_CallVoidMethod,
1740 _Jv_JNI_CallVoidMethodV,
1741 _Jv_JNI_CallVoidMethodA,
1743 // Nonvirtual method invocation functions follow.
1744 _Jv_JNI_CallAnyMethod<jobject, nonvirtual>,
1745 _Jv_JNI_CallAnyMethodV<jobject, nonvirtual>,
1746 _Jv_JNI_CallAnyMethodA<jobject, nonvirtual>,
1747 _Jv_JNI_CallAnyMethod<jboolean, nonvirtual>,
1748 _Jv_JNI_CallAnyMethodV<jboolean, nonvirtual>,
1749 _Jv_JNI_CallAnyMethodA<jboolean, nonvirtual>,
1750 _Jv_JNI_CallAnyMethod<jbyte, nonvirtual>,
1751 _Jv_JNI_CallAnyMethodV<jbyte, nonvirtual>,
1752 _Jv_JNI_CallAnyMethodA<jbyte, nonvirtual>,
1753 _Jv_JNI_CallAnyMethod<jchar, nonvirtual>,
1754 _Jv_JNI_CallAnyMethodV<jchar, nonvirtual>,
1755 _Jv_JNI_CallAnyMethodA<jchar, nonvirtual>,
1756 _Jv_JNI_CallAnyMethod<jshort, nonvirtual>,
1757 _Jv_JNI_CallAnyMethodV<jshort, nonvirtual>,
1758 _Jv_JNI_CallAnyMethodA<jshort, nonvirtual>,
1759 _Jv_JNI_CallAnyMethod<jint, nonvirtual>,
1760 _Jv_JNI_CallAnyMethodV<jint, nonvirtual>,
1761 _Jv_JNI_CallAnyMethodA<jint, nonvirtual>,
1762 _Jv_JNI_CallAnyMethod<jlong, nonvirtual>,
1763 _Jv_JNI_CallAnyMethodV<jlong, nonvirtual>,
1764 _Jv_JNI_CallAnyMethodA<jlong, nonvirtual>,
1765 _Jv_JNI_CallAnyMethod<jfloat, nonvirtual>,
1766 _Jv_JNI_CallAnyMethodV<jfloat, nonvirtual>,
1767 _Jv_JNI_CallAnyMethodA<jfloat, nonvirtual>,
1768 _Jv_JNI_CallAnyMethod<jdouble, nonvirtual>,
1769 _Jv_JNI_CallAnyMethodV<jdouble, nonvirtual>,
1770 _Jv_JNI_CallAnyMethodA<jdouble, nonvirtual>,
1771 _Jv_JNI_CallAnyVoidMethod<nonvirtual>,
1772 _Jv_JNI_CallAnyVoidMethodV<nonvirtual>,
1773 _Jv_JNI_CallAnyVoidMethodA<nonvirtual>,
1775 _Jv_JNI_GetAnyFieldID<false>,
1776 _Jv_JNI_GetField<jobject>,
1777 _Jv_JNI_GetField<jboolean>,
1778 _Jv_JNI_GetField<jbyte>,
1779 _Jv_JNI_GetField<jchar>,
1780 _Jv_JNI_GetField<jshort>,
1781 _Jv_JNI_GetField<jint>,
1782 _Jv_JNI_GetField<jlong>,
1783 _Jv_JNI_GetField<jfloat>,
1784 _Jv_JNI_GetField<jdouble>,
1794 _Jv_JNI_GetAnyMethodID<true>,
1796 _Jv_JNI_CallStaticMethod<jobject>,
1797 _Jv_JNI_CallStaticMethodV<jobject>,
1798 _Jv_JNI_CallStaticMethodA<jobject>,
1799 _Jv_JNI_CallStaticMethod<jboolean>,
1800 _Jv_JNI_CallStaticMethodV<jboolean>,
1801 _Jv_JNI_CallStaticMethodA<jboolean>,
1802 _Jv_JNI_CallStaticMethod<jbyte>,
1803 _Jv_JNI_CallStaticMethodV<jbyte>,
1804 _Jv_JNI_CallStaticMethodA<jbyte>,
1805 _Jv_JNI_CallStaticMethod<jchar>,
1806 _Jv_JNI_CallStaticMethodV<jchar>,
1807 _Jv_JNI_CallStaticMethodA<jchar>,
1808 _Jv_JNI_CallStaticMethod<jshort>,
1809 _Jv_JNI_CallStaticMethodV<jshort>,
1810 _Jv_JNI_CallStaticMethodA<jshort>,
1811 _Jv_JNI_CallStaticMethod<jint>,
1812 _Jv_JNI_CallStaticMethodV<jint>,
1813 _Jv_JNI_CallStaticMethodA<jint>,
1814 _Jv_JNI_CallStaticMethod<jlong>,
1815 _Jv_JNI_CallStaticMethodV<jlong>,
1816 _Jv_JNI_CallStaticMethodA<jlong>,
1817 _Jv_JNI_CallStaticMethod<jfloat>,
1818 _Jv_JNI_CallStaticMethodV<jfloat>,
1819 _Jv_JNI_CallStaticMethodA<jfloat>,
1820 _Jv_JNI_CallStaticMethod<jdouble>,
1821 _Jv_JNI_CallStaticMethodV<jdouble>,
1822 _Jv_JNI_CallStaticMethodA<jdouble>,
1823 _Jv_JNI_CallStaticVoidMethod,
1824 _Jv_JNI_CallStaticVoidMethodV,
1825 _Jv_JNI_CallStaticVoidMethodA,
1827 _Jv_JNI_GetAnyFieldID<true>,
1828 _Jv_JNI_GetStaticField<jobject>,
1829 _Jv_JNI_GetStaticField<jboolean>,
1830 _Jv_JNI_GetStaticField<jbyte>,
1831 _Jv_JNI_GetStaticField<jchar>,
1832 _Jv_JNI_GetStaticField<jshort>,
1833 _Jv_JNI_GetStaticField<jint>,
1834 _Jv_JNI_GetStaticField<jlong>,
1835 _Jv_JNI_GetStaticField<jfloat>,
1836 _Jv_JNI_GetStaticField<jdouble>,
1837 _Jv_JNI_SetStaticField,
1838 _Jv_JNI_SetStaticField,
1839 _Jv_JNI_SetStaticField,
1840 _Jv_JNI_SetStaticField,
1841 _Jv_JNI_SetStaticField,
1842 _Jv_JNI_SetStaticField,
1843 _Jv_JNI_SetStaticField,
1844 _Jv_JNI_SetStaticField,
1845 _Jv_JNI_SetStaticField,
1847 _Jv_JNI_GetStringLength,
1848 _Jv_JNI_GetStringChars,
1849 _Jv_JNI_ReleaseStringChars,
1850 _Jv_JNI_NewStringUTF,
1851 _Jv_JNI_GetStringUTFLength,
1852 _Jv_JNI_GetStringUTFChars,
1853 _Jv_JNI_ReleaseStringUTFChars,
1854 _Jv_JNI_GetArrayLength,
1855 _Jv_JNI_NewObjectArray,
1856 _Jv_JNI_GetObjectArrayElement,
1857 _Jv_JNI_SetObjectArrayElement,
1858 _Jv_JNI_NewPrimitiveArray<jboolean, JvPrimClass (boolean)>,
1859 _Jv_JNI_NewPrimitiveArray<jbyte, JvPrimClass (byte)>,
1860 _Jv_JNI_NewPrimitiveArray<jchar, JvPrimClass (char)>,
1861 _Jv_JNI_NewPrimitiveArray<jshort, JvPrimClass (short)>,
1862 _Jv_JNI_NewPrimitiveArray<jint, JvPrimClass (int)>,
1863 _Jv_JNI_NewPrimitiveArray<jlong, JvPrimClass (long)>,
1864 _Jv_JNI_NewPrimitiveArray<jfloat, JvPrimClass (float)>,
1865 _Jv_JNI_NewPrimitiveArray<jdouble, JvPrimClass (double)>,
1866 _Jv_JNI_GetPrimitiveArrayElements,
1867 _Jv_JNI_GetPrimitiveArrayElements,
1868 _Jv_JNI_GetPrimitiveArrayElements,
1869 _Jv_JNI_GetPrimitiveArrayElements,
1870 _Jv_JNI_GetPrimitiveArrayElements,
1871 _Jv_JNI_GetPrimitiveArrayElements,
1872 _Jv_JNI_GetPrimitiveArrayElements,
1873 _Jv_JNI_GetPrimitiveArrayElements,
1874 _Jv_JNI_ReleasePrimitiveArrayElements,
1875 _Jv_JNI_ReleasePrimitiveArrayElements,
1876 _Jv_JNI_ReleasePrimitiveArrayElements,
1877 _Jv_JNI_ReleasePrimitiveArrayElements,
1878 _Jv_JNI_ReleasePrimitiveArrayElements,
1879 _Jv_JNI_ReleasePrimitiveArrayElements,
1880 _Jv_JNI_ReleasePrimitiveArrayElements,
1881 _Jv_JNI_ReleasePrimitiveArrayElements,
1882 _Jv_JNI_GetPrimitiveArrayRegion,
1883 _Jv_JNI_GetPrimitiveArrayRegion,
1884 _Jv_JNI_GetPrimitiveArrayRegion,
1885 _Jv_JNI_GetPrimitiveArrayRegion,
1886 _Jv_JNI_GetPrimitiveArrayRegion,
1887 _Jv_JNI_GetPrimitiveArrayRegion,
1888 _Jv_JNI_GetPrimitiveArrayRegion,
1889 _Jv_JNI_GetPrimitiveArrayRegion,
1890 _Jv_JNI_SetPrimitiveArrayRegion,
1891 _Jv_JNI_SetPrimitiveArrayRegion,
1892 _Jv_JNI_SetPrimitiveArrayRegion,
1893 _Jv_JNI_SetPrimitiveArrayRegion,
1894 _Jv_JNI_SetPrimitiveArrayRegion,
1895 _Jv_JNI_SetPrimitiveArrayRegion,
1896 _Jv_JNI_SetPrimitiveArrayRegion,
1897 _Jv_JNI_SetPrimitiveArrayRegion,
1898 NOT_IMPL /* RegisterNatives */,
1899 NOT_IMPL /* UnregisterNatives */,
1900 _Jv_JNI_MonitorEnter,
1901 _Jv_JNI_MonitorExit,
1904 _Jv_JNI_GetStringRegion,
1905 _Jv_JNI_GetStringUTFRegion,
1906 _Jv_JNI_GetPrimitiveArrayCritical,
1907 _Jv_JNI_ReleasePrimitiveArrayCritical,
1908 _Jv_JNI_GetStringCritical,
1909 _Jv_JNI_ReleaseStringCritical,
1911 NOT_IMPL /* newweakglobalref */,
1912 NOT_IMPL /* deleteweakglobalref */,
1914 _Jv_JNI_ExceptionCheck
1917 struct JNIInvokeInterface _Jv_JNI_InvokeFunctions =
1923 _Jv_JNI_DestroyJavaVM,
1924 _Jv_JNI_AttachCurrentThread,
1925 _Jv_JNI_DetachCurrentThread,