#include "native/native.h"
#if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
# include "native/include/gnu_classpath_Pointer.h"
# if SIZEOF_VOID_P == 8
#include "native/include/java_lang_Throwable.h"
#if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_SUN)
+
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
# endif
# include "native/include/java_nio_Buffer.h"
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+# include "native/include/java_lang_reflect_VMConstructor.h"
+# include "native/include/java_lang_reflect_VMField.h"
+# include "native/include/java_lang_reflect_VMMethod.h"
+
# include "native/include/java_nio_DirectByteBufferImpl.h"
# endif
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+# include "native/include/java_lang_Class.h"
#endif
#if defined(ENABLE_JVMTI)
# include "native/jvmti/cacaodbg.h"
#endif
-#include "native/vm/java_lang_Class.h"
-
#if defined(ENABLE_JAVASE)
# include "native/vm/reflect.h"
#endif
#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/initialize.h"
-#include "vm/primitive.h"
+#include "vm/primitive.hpp"
#include "vm/resolve.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
/* debug **********************************************************************/
#if !defined(NDEBUG)
-# define TRACEJNICALLS(text) \
+
+# define TRACEJNICALLS(x) \
do { \
if (opt_TraceJNICalls) { \
- log_println text; \
+ log_println x; \
} \
} while (0)
+
+# define TRACEJNICALLSENTER(x) \
+ do { \
+ if (opt_TraceJNICalls) { \
+ log_start(); \
+ log_print x; \
+ } \
+ } while (0)
+
+# define TRACEJNICALLSEXIT(x) \
+ do { \
+ if (opt_TraceJNICalls) { \
+ log_print x; \
+ log_finish(); \
+ } \
+ } while (0)
+
#else
-# define TRACEJNICALLS(text)
+
+# define TRACEJNICALLS(x)
+# define TRACEJNICALLSENTER(x)
+# define TRACEJNICALLSEXIT(x)
+
#endif
#if defined(ENABLE_JAVASE)
static classinfo *class_java_nio_Buffer;
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
static classinfo *class_java_nio_DirectByteBufferImpl;
static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
static methodinfo *dbbirw_init;
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
static classinfo *class_sun_nio_ch_DirectBuffer;
static classinfo *class_java_nio_DirectByteBuffer;
/* some forward declarations **************************************************/
-jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref);
+jobject jni_NewLocalRef(JNIEnv *env, jobject ref);
/* jni_init ********************************************************************
!link_class(class_java_nio_Buffer))
return false;
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
if (!(class_java_nio_DirectByteBufferImpl =
load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
return false;
# endif
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
if (!(class_sun_nio_ch_DirectBuffer =
load_class_bootstrap(utf_new_char("sun/nio/ch/DirectBuffer"))))
}
-/* _Jv_jni_invokeNative ********************************************************
-
- Invoke a method on the given object with the given arguments.
-
- For instance methods OBJ must be != NULL and the method is looked up
- in the vftbl of the object.
-
- For static methods, OBJ is ignored.
-
-*******************************************************************************/
-
-java_handle_t *_Jv_jni_invokeNative(methodinfo *m, java_handle_t *o,
- java_handle_objectarray_t *params)
-{
- methodinfo *resm;
- java_handle_t *ro;
- s4 argcount;
- s4 paramcount;
-
- if (m == NULL) {
- exceptions_throw_nullpointerexception();
- return NULL;
- }
-
- argcount = m->parseddesc->paramcount;
- paramcount = argcount;
-
- /* if method is non-static, remove the `this' pointer */
-
- if (!(m->flags & ACC_STATIC))
- paramcount--;
-
- /* For instance methods the object has to be an instance of the
- class the method belongs to. For static methods the obj
- parameter is ignored. */
-
- if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
- exceptions_throw_illegalargumentexception();
- return NULL;
- }
-
- /* check if we got the right number of arguments */
-
- if (((params == NULL) && (paramcount != 0)) ||
- (params && (LLNI_array_size(params) != paramcount)))
- {
- exceptions_throw_illegalargumentexception();
- return NULL;
- }
-
- /* for instance methods we need an object */
-
- if (!(m->flags & ACC_STATIC) && (o == NULL)) {
- /* XXX not sure if that is the correct exception */
- exceptions_throw_nullpointerexception();
- return NULL;
- }
-
- /* for static methods, zero object to make subsequent code simpler */
- if (m->flags & ACC_STATIC)
- o = NULL;
-
- if (o != NULL) {
- /* for instance methods we must do a vftbl lookup */
- resm = method_vftbl_lookup(LLNI_vftbl_direct(o), m);
- }
- else {
- /* for static methods, just for convenience */
- resm = m;
- }
-
- ro = vm_call_method_objectarray(resm, o, params);
-
- return ro;
-}
-
-
/* GetVersion ******************************************************************
Returns the major version number in the higher 16 bits and the
{
#if defined(ENABLE_JAVASE)
utf *u;
- classloader *cl;
+ classloader_t *cl;
classinfo *c;
java_lang_Class *co;
co = LLNI_classinfo_wrap(c);
- return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) co);
#else
vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration");
*******************************************************************************/
-jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
+jclass jni_FindClass(JNIEnv *env, const char *name)
{
#if defined(ENABLE_JAVASE)
classinfo *c;
java_lang_Class *co;
- TRACEJNICALLS(("_Jv_JNI_FindClass(env=%p, name=%s)", env, name));
+ TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name));
+
+ /* FIXME If name is NULL we have a problem here. */
u = utf_new_char_classname((char *) name);
+ if ((u == NULL) /*|| (int)strlen(name) > symbolOopDesc::max_length() */) {
+ exceptions_throw_noclassdeffounderror(u);
+ return NULL;
+ }
+
/* Check stacktrace for classloader, if one found use it,
otherwise use the system classloader. */
else
c = load_class_from_classloader(u, cc->classloader);
- if (c == NULL)
+ if (c == NULL) {
+ resolve_handle_pending_exception(true);
return NULL;
+ }
if (!link_class(c))
return NULL;
co = LLNI_classinfo_wrap(c);
- return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) co);
#elif defined(ENABLE_JAVAME_CLDC1_1)
utf *u;
classinfo *c;
- TRACEJNICALLS(("_Jv_JNI_FindClass(env=%p, name=%s)", env, name));
+ TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name));
u = utf_new_char_classname((char *) name);
c = load_class_bootstrap(u);
- if (c == NULL)
+ if (c == NULL) {
+ resolve_handle_pending_exception(true);
return NULL;
+ }
if (!link_class(c))
return NULL;
- return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
+ return (jclass) jni_NewLocalRef(env, (jobject) c);
#else
- vm_abort("_Jv_JNI_FindClass: not implemented in this configuration");
+ vm_abort("jni_FindClass: not implemented in this configuration");
/* keep compiler happy */
co = LLNI_classinfo_wrap(super);
- return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) co);
}
jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
{
- java_lang_Class *csup;
- java_lang_Class *csub;
+ classinfo *to;
+ classinfo *from;
- csup = (java_lang_Class *) sup;
- csub = (java_lang_Class *) sub;
+ TRACEJNICALLS(("_Jv_JNI_IsAssignableFrom(env=%p, sub=%p, sup=%p)", env, sub, sup));
- STATISTICS(jniinvokation());
+ to = (classinfo *) sup;
+ from = (classinfo *) sub;
- return _Jv_java_lang_Class_isAssignableFrom(csup, csub);
+ return class_is_assignable_from(to, from);
}
o = exceptions_get_exception();
- return _Jv_JNI_NewLocalRef(env, (jthrowable) o);
+ return jni_NewLocalRef(env, (jthrowable) o);
}
*******************************************************************************/
-void _Jv_JNI_ExceptionDescribe(JNIEnv *env)
+void jni_ExceptionDescribe(JNIEnv *env)
{
- java_handle_t *o;
- classinfo *c;
- methodinfo *m;
+ TRACEJNICALLS(("jni_ExceptionDescribe(env=%p)", env));
- TRACEJNICALLS(("_Jv_JNI_ExceptionDescribe(env=%p)", env));
-
- /* Clear exception, because we are probably calling Java code
- again. */
-
- o = exceptions_get_and_clear_exception();
-
- if (o != NULL) {
- /* get printStackTrace method from exception class */
-
- LLNI_class_get(o, c);
-
- m = class_resolveclassmethod(c,
- utf_printStackTrace,
- utf_void__void,
- NULL,
- true);
-
- if (m == NULL)
- vm_abort("_Jv_JNI_ExceptionDescribe: could not find printStackTrace");
-
- /* Print the stacktrace. */
-
- (void) vm_call_method(m, o);
- }
+ exceptions_print_stacktrace();
}
*******************************************************************************/
-void _Jv_JNI_ExceptionClear(JNIEnv *env)
+void jni_ExceptionClear(JNIEnv *env)
{
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_ExceptionClear(env=%p)", env));
exceptions_clear_exception();
}
*******************************************************************************/
-jint _Jv_JNI_PushLocalFrame(JNIEnv* env, jint capacity)
+jint jni_PushLocalFrame(JNIEnv* env, jint capacity)
{
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_PushLocalFrame(env=%p, capacity=%d)", env, capacity));
if (capacity <= 0)
return -1;
*******************************************************************************/
-jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result)
+jobject jni_PopLocalFrame(JNIEnv* env, jobject result)
{
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_PopLocalFrame(env=%p, result=%p)", env, result));
/* release all current local frames */
/* add local reference and return the value */
- return _Jv_JNI_NewLocalRef(env, result);
+ return jni_NewLocalRef(env, result);
}
*******************************************************************************/
-void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef)
+void jni_DeleteLocalRef(JNIEnv *env, jobject localRef)
{
java_handle_t *o;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_DeleteLocalRef(env=%p, ref=%p)", env, localRef));
o = (java_handle_t *) localRef;
*******************************************************************************/
-jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref)
+jobject jni_NewLocalRef(JNIEnv *env, jobject ref)
{
java_handle_t *o;
java_handle_t *localref;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_NewLocalRef(env=%p, ref=%p)", env, ref));
o = (java_handle_t *) ref;
*******************************************************************************/
-jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity)
+jint jni_EnsureLocalCapacity(JNIEnv* env, jint capacity)
{
localref_table *lrt;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_EnsureLocalCapacity(env=%p, capacity=%d)", env, capacity));
/* get local reference table (thread specific) */
/* check if capacity elements are available in the local references table */
if ((lrt->used + capacity) > lrt->capacity)
- return _Jv_JNI_PushLocalFrame(env, capacity);
+ return jni_PushLocalFrame(env, capacity);
return 0;
}
o = builtin_new(c);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
*******************************************************************************/
-jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jobject jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
java_handle_t *o;
classinfo *c;
methodinfo *m;
va_list ap;
- STATISTICS(jniinvokation());
+ TRACEJNICALLSENTER(("jni_NewObject(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID));
c = LLNI_classinfo_unwrap(clazz);
m = (methodinfo *) methodID;
_Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap);
va_end(ap);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ TRACEJNICALLSEXIT(("->%p", o));
+
+ return jni_NewLocalRef(env, (jobject) o);
}
_Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
_Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
co = LLNI_classinfo_wrap(c);
- return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) co);
}
jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
{
- java_lang_Class *c;
- java_lang_Object *o;
+ classinfo *c;
+ java_handle_t *h;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("_Jv_JNI_IsInstanceOf(env=%p, obj=%p, clazz=%p)", env, obj, clazz));
- c = (java_lang_Class *) clazz;
- o = (java_lang_Object *) obj;
+ /* XXX Is this correct? */
+ c = LLNI_classinfo_unwrap(clazz);
+ h = (java_handle_t *) obj;
- return _Jv_java_lang_Class_isInstance(c, o);
+ return class_is_instance(c, h);
}
*******************************************************************************/
-jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
+jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
{
#if defined(ENABLE_JAVASE)
- java_handle_t *o;
- classinfo *c;
- methodinfo *m;
- s4 slot;
+ java_handle_t *o;
+ java_lang_reflect_Method *rm;
+ java_lang_reflect_Constructor *rc;
+ classinfo *c;
+ methodinfo *m;
+ int32_t slot;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+ java_lang_reflect_VMMethod *rvmm;
+ java_lang_reflect_VMConstructor *rvmc;
+#endif
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_FromReflectedMethod(env=%p, method=%p)", env, method));
o = (java_handle_t *) method;
if (o == NULL)
return NULL;
-
- if (builtin_instanceof(o, class_java_lang_reflect_Method)) {
- java_lang_reflect_Method *rm;
- rm = (java_lang_reflect_Method *) method;
- LLNI_field_get_cls(rm, clazz, c);
- LLNI_field_get_val(rm, slot , slot);
- }
- else if (builtin_instanceof(o, class_java_lang_reflect_Constructor)) {
- java_lang_reflect_Constructor *rc;
+ if (o->vftbl->clazz == class_java_lang_reflect_Constructor) {
+ rc = (java_lang_reflect_Constructor *) method;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+ LLNI_field_get_ref(rc, cons , rvmc);
+ LLNI_field_get_cls(rvmc, clazz, c);
+ LLNI_field_get_val(rvmc, slot , slot);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- rc = (java_lang_reflect_Constructor *) method;
LLNI_field_get_cls(rc, clazz, c);
LLNI_field_get_val(rc, slot , slot);
+
+#else
+# error unknown configuration
+#endif
+ }
+ else {
+ assert(o->vftbl->clazz == class_java_lang_reflect_Method);
+
+ rm = (java_lang_reflect_Method *) method;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+ LLNI_field_get_ref(rm, m , rvmm);
+ LLNI_field_get_cls(rvmm, clazz, c);
+ LLNI_field_get_val(rvmm, slot , slot);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+ LLNI_field_get_cls(rm, clazz, c);
+ LLNI_field_get_val(rm, slot , slot);
+
+#else
+# error unknown configuration
+#endif
}
- else
- return NULL;
m = &(c->methods[slot]);
return (jmethodID) m;
#else
- vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
+ vm_abort("jni_FromReflectedMethod: Not implemented in this configuration.");
- /* keep compiler happy */
+ /* Keep compiler happy. */
return NULL;
#endif
*******************************************************************************/
-jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
+jfieldID jni_FromReflectedField(JNIEnv* env, jobject field)
{
#if defined(ENABLE_JAVASE)
- java_lang_reflect_Field *rf;
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
+ java_lang_reflect_Field *rf;
+ classinfo *c;
+ fieldinfo *f;
+ int32_t slot;
- STATISTICS(jniinvokation());
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+ java_lang_reflect_VMField *rvmf;
+#endif
+
+ TRACEJNICALLS(("jni_FromReflectedField(env=%p, field=%p)", env, field));
rf = (java_lang_reflect_Field *) field;
if (rf == NULL)
return NULL;
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+ LLNI_field_get_ref(rf, f, rvmf);
+ LLNI_field_get_cls(rvmf, clazz, c);
+ LLNI_field_get_val(rvmf, slot , slot);
+
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
LLNI_field_get_cls(rf, clazz, c);
LLNI_field_get_val(rf, slot , slot);
+
+#else
+# error unknown configuration
+#endif
+
f = &(c->fields[slot]);
return (jfieldID) f;
#else
- vm_abort("_Jv_JNI_FromReflectedField: not implemented in this configuration");
+ vm_abort("jni_FromReflectedField: Not implemented in this configuration.");
- /* keep compiler happy */
+ /* Keep compiler happy. */
return NULL;
#endif
ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, ap);
va_end(ap);
- return _Jv_JNI_NewLocalRef(env, (jobject) ret);
+ return jni_NewLocalRef(env, (jobject) ret);
}
ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, args);
- return _Jv_JNI_NewLocalRef(env, (jobject) ret);
+ return jni_NewLocalRef(env, (jobject) ret);
}
ret = _Jv_jni_CallObjectMethodA(o, LLNI_vftbl_direct(o), m, args);
- return _Jv_JNI_NewLocalRef(env, (jobject) ret);
+ return jni_NewLocalRef(env, (jobject) ret);
}
r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
va_end(ap);
- return _Jv_JNI_NewLocalRef(env, (jobject) r);
+ return jni_NewLocalRef(env, (jobject) r);
}
r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
- return _Jv_JNI_NewLocalRef(env, (jobject) r);
+ return jni_NewLocalRef(env, (jobject) r);
}
{
log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
- return _Jv_JNI_NewLocalRef(env, NULL);
+ return jni_NewLocalRef(env, NULL);
}
LLNI_CRITICAL_END;
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
va_end(ap);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
h = LLNI_WRAP(f->value->a);
- return _Jv_JNI_NewLocalRef(env, (jobject) h);
+ return jni_NewLocalRef(env, (jobject) h);
}
LLNI_field_set_val(s, offset, 0);
LLNI_field_set_val(s, count , len);
- return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
+ return (jstring) jni_NewLocalRef(env, (jobject) s);
}
s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
- return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
+ return (jstring) jni_NewLocalRef(env, (jobject) s);
}
for (i = 0; i < length; i++)
array_objectarray_element_set(oa, i, o);
- return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa);
+ return (jobjectArray) jni_NewLocalRef(env, (jobject) oa);
}
o = array_objectarray_element_get(oa, index);
- return _Jv_JNI_NewLocalRef(env, (jobject) o);
+ return jni_NewLocalRef(env, (jobject) o);
}
\
a = builtin_newarray_##intern(len); \
\
- return (type) _Jv_JNI_NewLocalRef(env, (jobject) a); \
+ return (type) jni_NewLocalRef(env, (jobject) a); \
}
JNI_NEW_ARRAY(Boolean, jbooleanArray, boolean)
JNI_NEW_ARRAY(Byte, jbyteArray, byte)
JNI_NEW_ARRAY(Char, jcharArray, char)
-JNI_NEW_ARRAY(Short, jshortArray, byte)
+JNI_NEW_ARRAY(Short, jshortArray, short)
JNI_NEW_ARRAY(Int, jintArray, int)
JNI_NEW_ARRAY(Long, jlongArray, long)
JNI_NEW_ARRAY(Float, jfloatArray, float)
Obtain a direct pointer to array elements.
+ ATTENTION: Critical section keeps open when this function returns!
+ See ReleasePrimitiveArrayCritical.
+
*******************************************************************************/
-void *_Jv_JNI_GetPrimitiveArrayCritical(JNIEnv *env, jarray array,
- jboolean *isCopy)
+void* jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)
{
- java_handle_bytearray_t *ba;
- jbyte *bp;
+ java_handle_t* h;
+ java_array_t* a;
+ arraydescriptor* ad;
+ void* data;
- ba = (java_handle_bytearray_t *) array;
+ TRACEJNICALLS(("jni_GetPrimitiveArrayCritical(env=%p, array=%p, isCopy=%d)", env, array, isCopy));
- /* do the same as Kaffe does */
+ if (isCopy != NULL) {
+ *isCopy = JNI_FALSE;
+ }
- bp = _Jv_JNI_GetByteArrayElements(env, (jbyteArray) ba, isCopy);
+ LLNI_CRITICAL_START;
- return (void *) bp;
+ h = (java_handle_t*) array;
+ a = (java_array_t*) LLNI_UNWRAP(h);
+ ad = a->objheader.vftbl->arraydesc;
+
+ /* Sanity check. */
+
+ assert(ad != NULL);
+
+ data = (void*) (((intptr_t) a) + ad->dataoffset);
+
+ return data;
}
No specific documentation.
+ ATTENTION: This function closes the critical section opened in
+ GetPrimitiveArrayCritical!
+
*******************************************************************************/
-void _Jv_JNI_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array,
- void *carray, jint mode)
+void jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)
{
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_ReleasePrimitiveArrayCritical(env=%p, array=%p, carray=%p, mode=%d)", env, array, carray, mode));
- /* do the same as Kaffe does */
-
- _Jv_JNI_ReleaseByteArrayElements(env, (jbyteArray) array, (jbyte *) carray,
- mode);
+ LLNI_CRITICAL_END;
}
*******************************************************************************/
-jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
+jobject jni_NewGlobalRef(JNIEnv* env, jobject obj)
{
hashtable_global_ref_entry *gre;
u4 key; /* hashkey */
u4 slot; /* slot in hashtable */
java_handle_t *o;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_NewGlobalRef(env=%p, obj=%p)", env, obj));
o = (java_handle_t *) obj;
/* global ref not found, create a new one */
if (gre == NULL) {
- gre = NEW(hashtable_global_ref_entry);
+ gre = GCNEW_UNCOLLECTABLE(hashtable_global_ref_entry, 1);
#if defined(ENABLE_GC_CACAO)
/* register global ref with the GC */
*******************************************************************************/
-void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
+void jni_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
{
hashtable_global_ref_entry *gre;
hashtable_global_ref_entry *prevgre;
u4 slot; /* slot in hashtable */
java_handle_t *o;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_DeleteGlobalRef(env=%p, globalRef=%p)", env, globalRef));
o = (java_handle_t *) globalRef;
gc_reference_unregister(&(gre->o));
#endif
- FREE(gre, hashtable_global_ref_entry);
+ GCFREE(gre);
}
LLNI_CRITICAL_END;
gre = gre->hashlink; /* next element in external chain */
}
- log_println("JNI-DeleteGlobalRef: global reference not found");
+ log_println("jni_DeleteGlobalRef: Global reference not found.");
LLNI_CRITICAL_END;
*******************************************************************************/
-jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
+jobject jni_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
{
#if defined(ENABLE_JAVASE)
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
java_handle_t *nbuf;
# if SIZEOF_VOID_P == 8
gnu_classpath_Pointer32 *paddress;
# endif
- TRACEJNICALLS(("_Jv_JNI_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld", env, address, capacity));
+ TRACEJNICALLSENTER(("jni_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld)", env, address, capacity));
/* alocate a gnu.classpath.Pointer{32,64} object */
/* add local reference and return the value */
- return _Jv_JNI_NewLocalRef(env, nbuf);
+ TRACEJNICALLSEXIT(("->%p", nbuf));
+
+ return jni_NewLocalRef(env, nbuf);
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
jobject o;
int64_t addr;
int32_t cap;
- TRACEJNICALLS(("_Jv_JNI_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld", env, address, capacity));
+ TRACEJNICALLSENTER(("jni_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld)", env, address, capacity));
/* Be paranoid about address sign-extension. */
/* Add local reference and return the value. */
- return _Jv_JNI_NewLocalRef(env, o);
+ TRACEJNICALLSEXIT(("->%p", o));
+
+ return jni_NewLocalRef(env, o);
# else
# error unknown classpath configuration
# endif
#else
- vm_abort("_Jv_JNI_NewDirectByteBuffer: not implemented in this configuration");
+ vm_abort("jni_NewDirectByteBuffer: Not implemented in this configuration.");
/* keep compiler happy */
#if defined(ENABLE_JAVASE)
java_handle_t *h;
-# if defined(WITH_CLASSPATH_GNU)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
java_nio_DirectByteBufferImpl *nbuf;
gnu_classpath_Pointer *po;
return p;
-# elif defined(WITH_CLASSPATH_SUN)
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
java_nio_Buffer *o;
int64_t address;
jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
{
-#if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
+#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
java_handle_t *o;
java_nio_Buffer *nbuf;
jlong capacity;
return JNI_EVERSION;
}
- if (!threads_attach_current_thread(vm_aargs, false))
+ if (!thread_attach_current_external_thread(vm_aargs, false))
return JNI_ERR;
if (!localref_table_init())
}
-jint _Jv_JNI_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args)
+jint jni_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args)
{
int result;
- TRACEJNICALLS(("_Jv_JNI_AttachCurrentThread(vm=%p, p_env=%p, thr_args=%p)", vm, p_env, thr_args));
+ TRACEJNICALLS(("jni_AttachCurrentThread(vm=%p, p_env=%p, thr_args=%p)", vm, p_env, thr_args));
if (vm_created == false)
return JNI_ERR;
*******************************************************************************/
-jint _Jv_JNI_DetachCurrentThread(JavaVM *vm)
+jint jni_DetachCurrentThread(JavaVM *vm)
{
#if defined(ENABLE_THREADS)
- threadobject *t;
- bool result;
-
- TRACEJNICALLS(("_Jv_JNI_DetachCurrentThread(vm=%p)", vm));
+ bool result;
- t = thread_get_current();
+ TRACEJNICALLS(("jni_DetachCurrentThread(vm=%p)", vm));
- /* Sanity check. */
-
- assert(t != NULL);
-
- /* If the given thread has already been detached, this operation
+ /* If the current thread has already been detached, this operation
is a no-op. */
- result = thread_is_attached(t);
+ result = thread_current_is_attached();
if (result == false)
return true;
if (!localref_table_destroy())
return JNI_ERR;
- if (!threads_detach_thread(t))
+ if (!thread_detach_current_external_thread())
return JNI_ERR;
#endif
*******************************************************************************/
-jint _Jv_JNI_GetEnv(JavaVM *vm, void **env, jint version)
+jint jni_GetEnv(JavaVM *vm, void **env, jint version)
{
- TRACEJNICALLS(("_Jv_JNI_GetEnv(vm=%p, env=%p, %d=version)", vm, env, version));
+ TRACEJNICALLS(("jni_GetEnv(vm=%p, env=%p, version=%d)", vm, env, version));
if (vm_created == false) {
*env = NULL;
*******************************************************************************/
-jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
+jint jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
{
int result;
- TRACEJNICALLS(("_Jv_JNI_AttachCurrentThreadAsDaemon(vm=%p, penv=%p, args=%p)", vm, penv, args));
+ TRACEJNICALLS(("jni_AttachCurrentThreadAsDaemon(vm=%p, penv=%p, args=%p)", vm, penv, args));
if (vm_created == false)
return JNI_ERR;
NULL,
_Jv_JNI_DestroyJavaVM,
- _Jv_JNI_AttachCurrentThread,
- _Jv_JNI_DetachCurrentThread,
- _Jv_JNI_GetEnv,
- _Jv_JNI_AttachCurrentThreadAsDaemon
+ jni_AttachCurrentThread,
+ jni_DetachCurrentThread,
+ jni_GetEnv,
+ jni_AttachCurrentThreadAsDaemon
};
_Jv_JNI_GetVersion,
_Jv_JNI_DefineClass,
- _Jv_JNI_FindClass,
- _Jv_JNI_FromReflectedMethod,
- _Jv_JNI_FromReflectedField,
+ jni_FindClass,
+ jni_FromReflectedMethod,
+ jni_FromReflectedField,
_Jv_JNI_ToReflectedMethod,
_Jv_JNI_GetSuperclass,
_Jv_JNI_IsAssignableFrom,
_Jv_JNI_Throw,
_Jv_JNI_ThrowNew,
_Jv_JNI_ExceptionOccurred,
- _Jv_JNI_ExceptionDescribe,
- _Jv_JNI_ExceptionClear,
+ jni_ExceptionDescribe,
+ jni_ExceptionClear,
_Jv_JNI_FatalError,
- _Jv_JNI_PushLocalFrame,
- _Jv_JNI_PopLocalFrame,
+ jni_PushLocalFrame,
+ jni_PopLocalFrame,
- _Jv_JNI_NewGlobalRef,
- _Jv_JNI_DeleteGlobalRef,
- _Jv_JNI_DeleteLocalRef,
+ jni_NewGlobalRef,
+ jni_DeleteGlobalRef,
+ jni_DeleteLocalRef,
_Jv_JNI_IsSameObject,
- _Jv_JNI_NewLocalRef,
- _Jv_JNI_EnsureLocalCapacity,
+ jni_NewLocalRef,
+ jni_EnsureLocalCapacity,
_Jv_JNI_AllocObject,
- _Jv_JNI_NewObject,
+ jni_NewObject,
_Jv_JNI_NewObjectV,
_Jv_JNI_NewObjectA,
_Jv_JNI_GetStringRegion,
_Jv_JNI_GetStringUTFRegion,
- _Jv_JNI_GetPrimitiveArrayCritical,
- _Jv_JNI_ReleasePrimitiveArrayCritical,
+ jni_GetPrimitiveArrayCritical,
+ jni_ReleasePrimitiveArrayCritical,
_Jv_JNI_GetStringCritical,
_Jv_JNI_ReleaseStringCritical,
/* New JNI 1.4 functions. */
- _Jv_JNI_NewDirectByteBuffer,
+ jni_NewDirectByteBuffer,
_Jv_JNI_GetDirectBufferAddress,
_Jv_JNI_GetDirectBufferCapacity,