/* src/native/vm/sun/jvm.c - HotSpot JVM interface functions
- Copyright (C) 2007, 2008 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
+ Copyright (C) 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "native/include/sun_reflect_ConstantPool.h"
#endif
-#include "native/vm/java_lang_Class.h"
-#include "native/vm/java_lang_ClassLoader.h"
-#include "native/vm/java_lang_Runtime.h"
-#include "native/vm/java_lang_Thread.h"
-#include "native/vm/java_lang_reflect_Constructor.h"
-#include "native/vm/java_lang_reflect_Method.h"
#include "native/vm/reflect.h"
+#include "native/vm/sun/hpi.h"
+
#include "threads/lock-common.h"
-#include "threads/threads-common.h"
+#include "threads/thread.h"
#include "toolbox/logging.h"
#include "toolbox/list.h"
#if !defined(NDEBUG)
-# define TRACEJVMCALLS(...) \
- do { \
- if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \
- log_println(__VA_ARGS__); \
- } \
+# define TRACEJVMCALLS(x) \
+ do { \
+ if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \
+ log_println x; \
+ } \
+ } while (0)
+
+# define TRACEJVMCALLSENTER(x) \
+ do { \
+ if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \
+ log_start(); \
+ log_print x; \
+ } \
+ } while (0)
+
+# define TRACEJVMCALLSEXIT(x) \
+ do { \
+ if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \
+ log_print x; \
+ log_finish(); \
+ } \
} while (0)
# define TRACEJVMCALLSVERBOSE(x) \
} \
} while (0)
-# define PRINTJVMWARNINGS(...)
+# define PRINTJVMWARNINGS(x)
/* do { \ */
/* if (opt_PrintJVMWarnings) { \ */
-/* log_println(__VA_ARGS__); \ */
+/* log_println x; \ */
/* } \ */
/* } while (0) */
#else
-# define TRACEJVMCALLS(...)
+# define TRACEJVMCALLS(x)
+# define TRACEJVMCALLSENTER(x)
+# define TRACEJVMCALLSEXIT(x)
# define TRACEJVMCALLSVERBOSE(x)
-# define PRINTJVMWARNINGS(...)
+# define PRINTJVMWARNINGS(x)
#endif
jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored)
{
- TRACEJVMCALLS("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored);
+ TRACEJVMCALLS(("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored));
return (jlong) builtin_currenttimemillis();
}
jlong JVM_NanoTime(JNIEnv *env, jclass ignored)
{
- TRACEJVMCALLS("JVM_NanoTime(env=%p, ignored=%p)", env, ignored);
+ TRACEJVMCALLS(("JVM_NanoTime(env=%p, ignored=%p)", env, ignored));
return (jlong) builtin_nanotime();
}
jobject JVM_InitProperties(JNIEnv *env, jobject properties)
{
java_handle_t *h;
+ char buf[256];
- TRACEJVMCALLS("JVM_InitProperties(env=%p, properties=%p)", env, properties);
+ TRACEJVMCALLS(("JVM_InitProperties(env=%p, properties=%p)", env, properties));
h = (java_handle_t *) properties;
+ /* Convert the -XX:MaxDirectMemorySize= command line flag to the
+ sun.nio.MaxDirectMemorySize property. Do this after setting
+ user properties to prevent people from setting the value with a
+ -D option, as requested. */
+
+ jio_snprintf(buf, sizeof(buf), PRINTF_FORMAT_INT64_T, opt_MaxDirectMemorySize);
+ properties_add("sun.nio.MaxDirectMemorySize", buf);
+
+ /* Add all properties. */
+
properties_system_add_all(h);
return properties;
void JVM_Halt(jint code)
{
- TRACEJVMCALLS("JVM_Halt(code=%d)", code);
+ TRACEJVMCALLS(("JVM_Halt(code=%d)", code));
/* vm_exit(code); */
vm_shutdown(code);
void JVM_GC(void)
{
- TRACEJVMCALLS("JVM_GC()");
+ TRACEJVMCALLS(("JVM_GC()"));
gc_call();
}
jlong JVM_TotalMemory(void)
{
- TRACEJVMCALLS("JVM_TotalMemory()");
+ TRACEJVMCALLS(("JVM_TotalMemory()"));
return gc_get_heap_size();
}
jlong JVM_FreeMemory(void)
{
- TRACEJVMCALLS("JVM_FreeMemory()");
+ TRACEJVMCALLS(("JVM_FreeMemory()"));
return gc_get_free_bytes();
}
jlong JVM_MaxMemory(void)
{
- TRACEJVMCALLS("JVM_MaxMemory()");
+ TRACEJVMCALLS(("JVM_MaxMemory()"));
return gc_get_max_heap_size();
}
jint JVM_ActiveProcessorCount(void)
{
- TRACEJVMCALLS("JVM_ActiveProcessorCount()");
+ TRACEJVMCALLS(("JVM_ActiveProcessorCount()"));
return system_processors_online();
}
java_lang_Throwable *o;
java_handle_bytearray_t *ba;
- TRACEJVMCALLS("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver);
+ TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver));
o = (java_lang_Throwable *) receiver;
- ba = stacktrace_get();
+ ba = stacktrace_get_current();
if (ba == NULL)
return;
- LLNI_field_set_ref(o, backtrace, ba);
+ LLNI_field_set_ref(o, backtrace, (java_lang_Object *) ba);
}
jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
{
- java_lang_Throwable *t;
+ java_lang_Throwable *to;
+ java_lang_Object *o;
java_handle_bytearray_t *ba;
stacktrace_t *st;
int32_t depth;
- TRACEJVMCALLS("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable);
+ TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable));
if (throwable == NULL) {
exceptions_throw_nullpointerexception();
return 0;
}
- t = (java_lang_Throwable *) throwable;
+ to = (java_lang_Throwable *) throwable;
- LLNI_field_get_ref(t, backtrace, ba);
+ LLNI_field_get_ref(to, backtrace, o);
+
+ ba = (java_handle_bytearray_t *) o;
if (ba == NULL)
return 0;
jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
{
- java_lang_Throwable *t;
+ java_lang_Throwable *to;
+ java_lang_Object *o;
java_handle_bytearray_t *ba;
stacktrace_t *st;
stacktrace_entry_t *ste;
codeinfo *code;
methodinfo *m;
classinfo *c;
- java_lang_StackTraceElement *o;
- java_lang_String *declaringclass;
+ java_lang_StackTraceElement *steo;
+ java_handle_t* declaringclass;
java_lang_String *filename;
int32_t linenumber;
- TRACEJVMCALLS("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index);
+ TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index));
+
+ to = (java_lang_Throwable *) throwable;
- t = (java_lang_Throwable *) throwable;
+ LLNI_field_get_ref(to, backtrace, o);
- LLNI_field_get_ref(t, backtrace, ba);
+ ba = (java_handle_bytearray_t *) o;
/* FIXME critical section */
code = ste->code;
m = code->m;
- c = m->class;
+ c = m->clazz;
/* allocate a new StackTraceElement */
- o = (java_lang_StackTraceElement *)
+ steo = (java_lang_StackTraceElement *)
builtin_new(class_java_lang_StackTraceElement);
- if (o == NULL)
+ if (steo == NULL)
return NULL;
/* get filename */
/* get declaring class name */
- declaringclass = _Jv_java_lang_Class_getName(LLNI_classinfo_wrap(c));
+ declaringclass = class_get_classname(c);
/* fill the java.lang.StackTraceElement element */
/* FIXME critical section */
- o->declaringClass = declaringclass;
- o->methodName = (java_lang_String *) javastring_new(m->name);
- o->fileName = filename;
- o->lineNumber = linenumber;
+ steo->declaringClass = (java_lang_String*) declaringclass;
+ steo->methodName = (java_lang_String*) javastring_new(m->name);
+ steo->fileName = filename;
+ steo->lineNumber = linenumber;
- return (jobject) o;
+ return (jobject) steo;
}
jint JVM_IHashCode(JNIEnv* env, jobject handle)
{
- TRACEJVMCALLS("JVM_IHashCode(env=%p, jobject=%p)", env, handle);
+ TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle));
return (jint) ((ptrint) handle);
}
java_handle_t *o;
#endif
- TRACEJVMCALLS("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms);
+ TRACEJVMCALLS(("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms));
if (ms < 0) {
/* exceptions_throw_illegalargumentexception("argument out of range"); */
exceptions_throw_illegalargumentexception();
java_handle_t *o;
#endif
- TRACEJVMCALLS("JVM_MonitorNotify(env=%p, handle=%p)", env, handle);
+ TRACEJVMCALLS(("JVM_MonitorNotify(env=%p, handle=%p)", env, handle));
#if defined(ENABLE_THREADS)
o = (java_handle_t *) handle;
java_handle_t *o;
#endif
- TRACEJVMCALLS("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle);
+ TRACEJVMCALLS(("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle));
#if defined(ENABLE_THREADS)
o = (java_handle_t *) handle;
jobject JVM_Clone(JNIEnv* env, jobject handle)
{
- TRACEJVMCALLS("JVM_Clone(env=%p, handle=%p)", env, handle);
+ TRACEJVMCALLS(("JVM_Clone(env=%p, handle=%p)", env, handle));
return (jobject) builtin_clone(env, (java_handle_t *) handle);
}
void JVM_EnableCompiler(JNIEnv *env, jclass compCls)
{
- TRACEJVMCALLS("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls);
- PRINTJVMWARNINGS("JVM_EnableCompiler not supported");
+ TRACEJVMCALLS(("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls));
+ PRINTJVMWARNINGS(("JVM_EnableCompiler not supported"));
}
void JVM_DisableCompiler(JNIEnv *env, jclass compCls)
{
- TRACEJVMCALLS("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls);
- PRINTJVMWARNINGS("JVM_DisableCompiler not supported");
+ TRACEJVMCALLS(("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls));
+ PRINTJVMWARNINGS(("JVM_DisableCompiler not supported"));
}
jint JVM_GetLastErrorString(char *buf, int len)
{
- const char *s;
- int n;
-
- if (errno == 0) {
- return 0;
- }
- else {
- s = strerror(errno);
- n = strlen(s);
-
- if (n >= len)
- n = len - 1;
-
- strncpy(buf, s, n);
-
- buf[n] = '\0';
+ TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len));
- return n;
- }
+ return hpi_system->GetLastErrorString(buf, len);
}
char *JVM_NativePath(char *path)
{
- TRACEJVMCALLS("JVM_NativePath(path=%s)", path);
+ TRACEJVMCALLS(("JVM_NativePath(path=%s)", path));
- /* XXX is this correct? */
-
- return path;
+ return hpi_file->NativePath(path);
}
jclass JVM_GetCallerClass(JNIEnv* env, int depth)
{
- java_handle_objectarray_t *oa;
-
- TRACEJVMCALLS("JVM_GetCallerClass(env=%p, depth=%d)", env, depth);
-
- oa = stacktrace_getClassContext();
-
- if (oa == NULL)
- return NULL;
+ classinfo *c;
- if (oa->header.size < depth)
- return NULL;
+ TRACEJVMCALLS(("JVM_GetCallerClass(env=%p, depth=%d)", env, depth));
- return (jclass) oa->data[depth - 1];
+ c = stacktrace_get_caller_class(depth);
+ return (jclass) c;
}
classinfo *c;
utf *u;
- TRACEJVMCALLS("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s);
+ TRACEJVMCALLS(("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s));
u = utf_new_char(s);
c = primitive_class_get_by_name(u);
void JVM_ResolveClass(JNIEnv* env, jclass cls)
{
- TRACEJVMCALLS("JVM_ResolveClass(env=%p, cls=%p)", env, cls);
- PRINTJVMWARNINGS("JVM_ResolveClass not implemented");
+ TRACEJVMCALLS(("JVM_ResolveClass(env=%p, cls=%p)", env, cls));
+ PRINTJVMWARNINGS(("JVM_ResolveClass not implemented"));
}
jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError)
{
- classinfo *c;
- utf *u;
- classloader *cl;
+ classinfo *c;
+ utf *u;
+ classloader_t *cl;
+
+ TRACEJVMCALLS(("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError));
+
+ /* As of now, OpenJDK does not call this function with throwError
+ is true. */
- TRACEJVMCALLS("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError);
+ assert(throwError == false);
u = utf_new_char(name);
cl = loader_hashtable_classloader_add((java_handle_t *) loader);
jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)
{
- classinfo *c;
- utf *u;
- classloader *cl;
+ classinfo *c;
+ utf *u;
+ classloader_t *cl;
- TRACEJVMCALLS("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source);
+ TRACEJVMCALLS(("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source));
if (name != NULL)
u = utf_new_char(name);
/* XXX do something with source */
- c = class_define(u, cl, len, (const uint8_t *) buf, (java_handle_t *) pd);
+ c = class_define(u, cl, len, (uint8_t *) buf, (java_handle_t *) pd);
return (jclass) LLNI_classinfo_wrap(c);
}
jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
{
- classloader *cl;
- utf *u;
- classinfo *c;
+ classloader_t *cl;
+ utf *u;
+ classinfo *c;
- TRACEJVMCALLS("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name);
+ TRACEJVMCALLS(("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name));
cl = loader_hashtable_classloader_add((java_handle_t *) loader);
jstring JVM_GetClassName(JNIEnv *env, jclass cls)
{
- TRACEJVMCALLS("JVM_GetClassName(env=%p, cls=%p)", env, cls);
+ classinfo* c;
+
+ TRACEJVMCALLS(("JVM_GetClassName(env=%p, cls=%p)", env, cls));
+
+ c = LLNI_classinfo_unwrap(cls);
- return (jstring) _Jv_java_lang_Class_getName((java_lang_Class *) cls);
+ return (jstring) class_get_classname(c);
}
classinfo *c;
java_handle_objectarray_t *oa;
- TRACEJVMCALLS("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
jobject JVM_GetClassLoader(JNIEnv *env, jclass cls)
{
- classinfo *c;
- classloader *cl;
+ classinfo *c;
+ classloader_t *cl;
- TRACEJVMCALLS("JVM_GetClassLoader(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLSENTER(("JVM_GetClassLoader(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
cl = class_get_classloader(c);
+ TRACEJVMCALLSEXIT(("->%p", cl));
+
return (jobject) cl;
}
{
classinfo *c;
- TRACEJVMCALLS("JVM_IsInterface(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_IsInterface(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
classinfo *c;
java_handle_objectarray_t *hoa;
- TRACEJVMCALLS("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers);
+ TRACEJVMCALLS(("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers));
c = LLNI_classinfo_unwrap(cls);
{
classinfo *c;
- TRACEJVMCALLS("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException)
{
- java_handle_t *o;
+ java_handle_t *h;
classinfo *c;
methodinfo *m;
java_handle_t *result;
java_handle_t *e;
- TRACEJVMCALLS("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException);
+ TRACEJVMCALLS(("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException));
- o = (java_handle_t *) action;
- c = o->vftbl->class;
+ h = (java_handle_t *) action;
+ LLNI_class_get(h, c);
if (action == NULL) {
exceptions_throw_nullpointerexception();
/* XXX It seems something with a privileged stack needs to be done
here. */
- result = vm_call_method(m, o);
+ result = vm_call_method(m, h);
- e = exceptions_get_and_clear_exception();
+ e = exceptions_get_exception();
if (e != NULL) {
- exceptions_throw_privilegedactionexception(e);
+ if ( builtin_instanceof(e, class_java_lang_Exception) &&
+ !builtin_instanceof(e, class_java_lang_RuntimeException)) {
+ exceptions_clear_exception();
+ exceptions_throw_privilegedactionexception(e);
+ }
+
return NULL;
}
jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)
{
- TRACEJVMCALLS("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls);
+ TRACEJVMCALLS(("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls));
/* XXX All stuff I tested so far works without that function. At
some point we have to implement it, but I disable the output
{
classinfo *c;
- TRACEJVMCALLS("JVM_IsArrayClass(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_IsArrayClass(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
{
classinfo *c;
- TRACEJVMCALLS("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
classinfo *component;
classinfo *c;
- TRACEJVMCALLS("JVM_GetComponentType(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_GetComponentType(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
classinfo *c;
int32_t flags;
- TRACEJVMCALLS("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
classinfo *c;
java_handle_objectarray_t *oa;
- TRACEJVMCALLS("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass);
+ TRACEJVMCALLS(("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass));
c = LLNI_classinfo_unwrap(ofClass);
classinfo *c;
classinfo *dc;
- TRACEJVMCALLS("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass);
+ TRACEJVMCALLS(("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass));
c = LLNI_classinfo_unwrap(ofClass);
utf *u;
java_handle_t *s;
- TRACEJVMCALLS("JVM_GetClassSignature(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_GetClassSignature(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
classinfo *c = NULL; /* classinfo for 'cls' */
java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
- TRACEJVMCALLS("JVM_GetClassAnnotations: cls=%p", cls);
+ TRACEJVMCALLS(("JVM_GetClassAnnotations: cls=%p", cls));
if (cls == NULL) {
exceptions_throw_nullpointerexception();
java_lang_reflect_Field *rf = NULL; /* java.lang.reflect.Field for 'field' */
java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
- TRACEJVMCALLS("JVM_GetFieldAnnotations: field=%p", field);
+ TRACEJVMCALLS(("JVM_GetFieldAnnotations: field=%p", field));
if (field == NULL) {
exceptions_throw_nullpointerexception();
java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
- TRACEJVMCALLS("JVM_GetMethodAnnotations: method=%p", method);
+ TRACEJVMCALLS(("JVM_GetMethodAnnotations: method=%p", method));
if (method == NULL) {
exceptions_throw_nullpointerexception();
java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
java_handle_bytearray_t *ba = NULL; /* unparsed annotation default value */
- TRACEJVMCALLS("JVM_GetMethodDefaultAnnotationValue: method=%p", method);
+ TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue: method=%p", method));
if (method == NULL) {
exceptions_throw_nullpointerexception();
java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
java_handle_bytearray_t *ba = NULL; /* unparsed parameter annotations */
- TRACEJVMCALLS("JVM_GetMethodParameterAnnotations: method=%p", method);
+ TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations: method=%p", method));
if (method == NULL) {
exceptions_throw_nullpointerexception();
jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)
{
- TRACEJVMCALLS("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly);
+ classinfo *c;
+ java_handle_objectarray_t *oa;
+
+ TRACEJVMCALLS(("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+ c = LLNI_classinfo_unwrap(ofClass);
+
+ oa = class_get_declaredfields(c, publicOnly);
- return (jobjectArray) _Jv_java_lang_Class_getDeclaredFields((java_lang_Class *) ofClass, publicOnly);
+ return (jobjectArray) oa;
}
jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
{
- TRACEJVMCALLS("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly);
+ classinfo *c;
+ java_handle_objectarray_t *oa;
- return (jobjectArray) _Jv_java_lang_Class_getDeclaredMethods((java_lang_Class *) ofClass, publicOnly);
+ TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+ c = LLNI_classinfo_unwrap(ofClass);
+
+ oa = class_get_declaredmethods(c, publicOnly);
+
+ return (jobjectArray) oa;
}
jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly)
{
- TRACEJVMCALLS("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly);
+ classinfo *c;
+ java_handle_objectarray_t *oa;
+
+ TRACEJVMCALLS(("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
+
+ c = LLNI_classinfo_unwrap(ofClass);
- return (jobjectArray) _Jv_java_lang_Class_getDeclaredConstructors((java_lang_Class *) ofClass, publicOnly);
+ oa = class_get_declaredconstructors(c, publicOnly);
+
+ return (jobjectArray) oa;
}
{
classinfo *c;
- TRACEJVMCALLS("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls));
c = LLNI_classinfo_unwrap(cls);
java_lang_Object *constantPoolOop = (java_lang_Object*)cls;
/* constantPoolOop field of the constant pool object */
- TRACEJVMCALLS("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls);
+ TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls));
constantPool =
(sun_reflect_ConstantPool*)native_new_and_init(
{
classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool));
c = LLNI_classinfo_unwrap(jcpool);
classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
classinfo *result; /* classinfo of the class at constant pool index 'index' */
- TRACEJVMCALLS("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index));
c = LLNI_classinfo_unwrap(jcpool);
classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
classinfo *result; /* classinfo of the class at constant pool index 'index' */
- TRACEJVMCALLS("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index));
c = LLNI_classinfo_unwrap(jcpool);
constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
classinfo *c = NULL; /* resolved declaring class of the method */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
classinfo *c; /* resolved declaring class for the field */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
constant_integer *ref; /* reference to the int value in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer);
constant_long *ref; /* reference to the long value in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long);
constant_float *ref; /* reference to the float value in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float);
constant_double *ref; /* reference to the double value in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double);
utf *ref; /* utf object for the string in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */
classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
- TRACEJVMCALLS("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index);
+ TRACEJVMCALLS(("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index));
cls = LLNI_classinfo_unwrap(jcpool);
ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
jboolean status;
utf *name;
- TRACEJVMCALLS("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls);
+ TRACEJVMCALLS(("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls));
c = LLNI_classinfo_unwrap(cls);
s4 i, j;
#endif
- TRACEJVMCALLS("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused);
+ TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused));
c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
/* JVM_Open */
+/* Taken from: hotspot/src/share/vm/prims/jvm.h */
+
+/*
+ * JVM I/O error codes
+ */
+#define JVM_EEXIST -100
+
jint JVM_Open(const char *fname, jint flags, jint mode)
{
int result;
- TRACEJVMCALLS("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode);
+ TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode));
- result = system_open(fname, flags, mode);
+ result = hpi_file->Open(fname, flags, mode);
if (result >= 0) {
return result;
}
else {
- switch(errno) {
+ switch (errno) {
case EEXIST:
- /* XXX don't know what to do here */
-/* return JVM_EEXIST; */
- return -1;
+ return JVM_EEXIST;
default:
return -1;
}
jint JVM_Close(jint fd)
{
- TRACEJVMCALLS("JVM_Close(fd=%d)", fd);
+ TRACEJVMCALLS(("JVM_Close(fd=%d)", fd));
- return system_close(fd);
+ return hpi_file->Close(fd);
}
jint JVM_Read(jint fd, char *buf, jint nbytes)
{
- TRACEJVMCALLS("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes);
+ TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes));
- return system_read(fd, buf, nbytes);
+ return (jint) hpi_file->Read(fd, buf, nbytes);
}
jint JVM_Write(jint fd, char *buf, jint nbytes)
{
- TRACEJVMCALLS("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes);
+ TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes));
- return system_write(fd, buf, nbytes);
+ return (jint) hpi_file->Write(fd, buf, nbytes);
}
jint JVM_Available(jint fd, jlong *pbytes)
{
-#if defined(FIONREAD)
- int bytes;
- int result;
-
- TRACEJVMCALLS("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes);
-
- *pbytes = 0;
-
- result = ioctl(fd, FIONREAD, &bytes);
-
- if (result < 0)
- return 0;
-
- *pbytes = bytes;
+ TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes));
- return 1;
-#else
-# error FIONREAD not defined
-#endif
+ return hpi_file->Available(fd, pbytes);
}
jlong JVM_Lseek(jint fd, jlong offset, jint whence)
{
- TRACEJVMCALLS("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence);
+ TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence));
- return (jlong) system_lseek(fd, (off_t) offset, whence);
+ return hpi_file->Seek(fd, (off_t) offset, whence);
}
jint JVM_SetLength(jint fd, jlong length)
{
- TRACEJVMCALLS("JVM_SetLength(fd=%d, length=%ld)", length);
+ TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length));
- return system_ftruncate(fd, length);
+ return hpi_file->SetLength(fd, length);
}
jint JVM_Sync(jint fd)
{
- TRACEJVMCALLS("JVM_Sync(fd=%d)", fd);
+ TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd));
- return system_fsync(fd);
+ return hpi_file->Sync(fd);
}
void JVM_StartThread(JNIEnv* env, jobject jthread)
{
- TRACEJVMCALLS("JVM_StartThread(env=%p, jthread=%p)", env, jthread);
+ TRACEJVMCALLS(("JVM_StartThread(env=%p, jthread=%p)", env, jthread));
- _Jv_java_lang_Thread_start((java_lang_Thread *) jthread, 0);
+ threads_thread_start((java_handle_t *) jthread);
}
jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread)
{
- threadobject *t;
- bool equal;
- bool result;
-
- TRACEJVMCALLS("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread);
-
- /* XXX this is just a quick hack */
+ java_handle_t *h;
+ threadobject *t;
+ bool result;
- for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
- LLNI_equals(t->object, jthread, equal);
+ TRACEJVMCALLS(("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread));
- if (equal == true)
- break;
- }
+ h = (java_handle_t *) jthread;
+ t = thread_get_thread(h);
/* The threadobject is null when a thread is created in Java. The
priority is set later during startup. */
void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)
{
- TRACEJVMCALLS("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio);
+ java_handle_t *h;
+ threadobject *t;
+
+ TRACEJVMCALLS(("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio));
+
+ h = (java_handle_t *) jthread;
+ t = thread_get_thread(h);
+
+ /* The threadobject is null when a thread is created in Java. The
+ priority is set later during startup. */
- _Jv_java_lang_Thread_setPriority((java_lang_Thread *) jthread, prio);
+ if (t == NULL)
+ return;
+
+ threads_set_thread_priority(t->tid, prio);
}
void JVM_Yield(JNIEnv *env, jclass threadClass)
{
- TRACEJVMCALLS("JVM_Yield(env=%p, threadClass=%p)", env, threadClass);
+ TRACEJVMCALLS(("JVM_Yield(env=%p, threadClass=%p)", env, threadClass));
threads_yield();
}
void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)
{
- TRACEJVMCALLS("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis);
+ TRACEJVMCALLS(("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis));
- _Jv_java_lang_Thread_sleep(millis);
+ threads_sleep(millis, 0);
}
jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass)
{
+ java_object_t *o;
+
TRACEJVMCALLSVERBOSE(("JVM_CurrentThread(env=%p, threadClass=%p)", env, threadClass));
- return (jobject) _Jv_java_lang_Thread_currentThread();
+ o = thread_get_current_object();
+
+ return (jobject) o;
}
void JVM_Interrupt(JNIEnv* env, jobject jthread)
{
- log_println("JVM_Interrupt: IMPLEMENT ME!");
+ java_handle_t *h;
+ threadobject *t;
+
+ TRACEJVMCALLS(("JVM_Interrupt(env=%p, jthread=%p)", env, jthread));
+
+ h = (java_handle_t *) jthread;
+ t = thread_get_thread(h);
+
+ if (t == NULL)
+ return;
+
+ threads_thread_interrupt(t);
}
jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)
{
- TRACEJVMCALLS("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted);
+ java_handle_t *h;
+ threadobject *t;
+ jboolean interrupted;
+
+ TRACEJVMCALLS(("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted));
+
+ h = (java_handle_t *) jthread;
+ t = thread_get_thread(h);
- /* XXX do something with clear_interrupted */
+ interrupted = thread_is_interrupted(t);
- return _Jv_java_lang_Thread_isInterrupted((java_lang_Thread *) jthread);
+ if (interrupted && clear_interrupted)
+ thread_set_interrupted(t, false);
+
+ return interrupted;
}
java_handle_t *h;
bool result;
- TRACEJVMCALLS("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj);
+ TRACEJVMCALLS(("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj));
h = (java_handle_t *) obj;
jobjectArray JVM_GetClassContext(JNIEnv *env)
{
- TRACEJVMCALLS("JVM_GetClassContext(env=%p)", env);
+ TRACEJVMCALLS(("JVM_GetClassContext(env=%p)", env));
return (jobjectArray) stacktrace_getClassContext();
}
utf *u;
utf *result;
- TRACEJVMCALLS("JVM_GetSystemPackage(env=%p, name=%p)", env, name);
+ TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name));
/* s = package_find(name); */
- u = javastring_toutf(name, false);
+ u = javastring_toutf((java_handle_t *) name, false);
+
result = package_find(u);
+
if (result != NULL)
s = javastring_new(result);
else
jobject JVM_LatestUserDefinedLoader(JNIEnv *env)
{
- classloader *cl;
+ classloader_t *cl;
- TRACEJVMCALLS("JVM_LatestUserDefinedLoader(env=%p)", env);
+ TRACEJVMCALLS(("JVM_LatestUserDefinedLoader(env=%p)", env));
cl = stacktrace_first_nonnull_classloader();
{
java_handle_t *a;
- TRACEJVMCALLS("JVM_GetArrayLength(arr=%p)", arr);
+ TRACEJVMCALLS(("JVM_GetArrayLength(arr=%p)", arr));
a = (java_handle_t *) arr;
java_handle_t *a;
java_handle_t *o;
- TRACEJVMCALLS("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index);
+ TRACEJVMCALLS(("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index));
a = (java_handle_t *) arr;
java_handle_t *a;
java_handle_t *value;
- TRACEJVMCALLS("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val);
+ TRACEJVMCALLS(("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val));
a = (java_handle_t *) arr;
value = (java_handle_t *) val;
java_handle_t *a;
java_handle_objectarray_t *oa;
- TRACEJVMCALLS("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length);
+ TRACEJVMCALLS(("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length));
if (eltClass == NULL) {
exceptions_throw_nullpointerexception();
c = LLNI_classinfo_unwrap(eltClass);
- /* create primitive or object array */
+ /* Create primitive or object array. */
if (class_is_primitive(c)) {
pc = primitive_arrayclass_get_by_name(c->name);
+
+ /* void arrays are not allowed. */
+
+ if (pc == NULL) {
+ exceptions_throw_illegalargumentexception();
+ return NULL;
+ }
+
a = builtin_newarray(length, pc);
return (jobject) a;
classinfo *ac;
java_handle_objectarray_t *a;
- TRACEJVMCALLS("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim);
+ TRACEJVMCALLS(("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim));
if (eltClass == NULL) {
exceptions_throw_nullpointerexception();
c = LLNI_classinfo_unwrap(eltClass);
- /* XXX This is just a quick hack to get it working. */
-
ia = (java_handle_intarray_t *) dim;
- length = array_length_get(ia);
+ length = array_length_get((java_handle_t *) ia);
+
+ /* We check here for exceptions thrown in array_length_get,
+ otherwise these exceptions get overwritten by the following
+ IllegalArgumentException. */
+
+ if (length < 0)
+ return NULL;
+
+ if ((length <= 0) || (length > /* MAX_DIM */ 255)) {
+ exceptions_throw_illegalargumentexception();
+ return NULL;
+ }
+
+ /* XXX This is just a quick hack to get it working. */
dims = MNEW(long, length);
if (ac == NULL)
return NULL;
- a = builtin_multianewarray(length, ac, dims);
+ a = builtin_multianewarray(length, (java_handle_t *) ac, dims);
return (jobject) a;
}
jint JVM_InitializeSocketLibrary()
{
- log_println("JVM_InitializeSocketLibrary: IMPLEMENT ME!");
+ TRACEJVMCALLS(("JVM_InitializeSocketLibrary()"));
- return 0;
+ return hpi_initialize_socket_library();
}
jint JVM_Socket(jint domain, jint type, jint protocol)
{
- TRACEJVMCALLS("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol);
+ TRACEJVMCALLS(("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol));
return system_socket(domain, type, protocol);
}
jint JVM_SocketClose(jint fd)
{
- TRACEJVMCALLS("JVM_SocketClose(fd=%d)", fd);
+ TRACEJVMCALLS(("JVM_SocketClose(fd=%d)", fd));
return system_close(fd);
}
jint JVM_SocketShutdown(jint fd, jint howto)
{
- TRACEJVMCALLS("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto);
+ TRACEJVMCALLS(("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto));
return system_shutdown(fd, howto);
}
jint JVM_Listen(jint fd, jint count)
{
- TRACEJVMCALLS("JVM_Listen(fd=%d, count=%d)", fd, count);
+ TRACEJVMCALLS(("JVM_Listen(fd=%d, count=%d)", fd, count));
return system_listen(fd, count);
}
jint JVM_Connect(jint fd, struct sockaddr *him, jint len)
{
- TRACEJVMCALLS("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len);
+ TRACEJVMCALLS(("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len));
return system_connect(fd, him, len);
}
jint JVM_Accept(jint fd, struct sockaddr *him, jint *len)
{
- TRACEJVMCALLS("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len);
+ TRACEJVMCALLS(("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len));
return system_accept(fd, him, (socklen_t *) len);
}
jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len)
{
- TRACEJVMCALLS("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len);
+ TRACEJVMCALLS(("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len));
return system_getsockname(fd, him, (socklen_t *) len);
}
int bytes;
int result;
- TRACEJVMCALLS("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes);
+ TRACEJVMCALLS(("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes));
*pbytes = 0;
jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)
{
- TRACEJVMCALLS("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen);
+ TRACEJVMCALLS(("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen));
return system_getsockopt(fd, level, optname, optval, (socklen_t *) optlen);
}
jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)
{
- TRACEJVMCALLS("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen);
+ TRACEJVMCALLS(("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen));
return system_setsockopt(fd, level, optname, optval, optlen);
}
int JVM_GetHostName(char *name, int namelen)
{
- TRACEJVMCALLS("JVM_GetHostName(name=%s, namelen=%d)", name, namelen);
+ int result;
+
+ TRACEJVMCALLSENTER(("JVM_GetHostName(name=%s, namelen=%d)", name, namelen));
- return system_gethostname(name, namelen);
+ result = system_gethostname(name, namelen);
+
+ TRACEJVMCALLSEXIT(("->%d (name=%s)", result, name));
+
+ return result;
}
void *JVM_LoadLibrary(const char *name)
{
- utf *u;
+ utf* u;
+ void* handle;
- TRACEJVMCALLS("JVM_LoadLibrary(name=%s)", name);
+ TRACEJVMCALLSENTER(("JVM_LoadLibrary(name=%s)", name));
u = utf_new_char(name);
- return native_library_open(u);
+ handle = native_library_open(u);
+
+ TRACEJVMCALLSEXIT(("->%p", handle));
+
+ return handle;
}
void JVM_UnloadLibrary(void* handle)
{
- TRACEJVMCALLS("JVM_UnloadLibrary(handle=%p)", handle);
+ TRACEJVMCALLS(("JVM_UnloadLibrary(handle=%p)", handle));
native_library_close(handle);
}
{
lt_ptr symbol;
- TRACEJVMCALLS("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name);
+ TRACEJVMCALLSENTER(("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name));
symbol = lt_dlsym(handle, name);
+ TRACEJVMCALLSEXIT(("->%p", symbol));
+
return symbol;
}
jboolean JVM_IsSupportedJNIVersion(jint version)
{
- TRACEJVMCALLS("JVM_IsSupportedJNIVersion(version=%d)", version);
+ TRACEJVMCALLS(("JVM_IsSupportedJNIVersion(version=%d)", version));
return jni_version_check(version);
}
jstring JVM_InternString(JNIEnv *env, jstring str)
{
- TRACEJVMCALLS("JVM_InternString(env=%p, str=%p)", env, str);
+ TRACEJVMCALLS(("JVM_InternString(env=%p, str=%p)", env, str));
return (jstring) javastring_intern((java_handle_t *) str);
}
{
java_object_t *o;
- TRACEJVMCALLS("JVM_RawMonitorCreate()");
+ TRACEJVMCALLS(("JVM_RawMonitorCreate()"));
o = NEW(java_object_t);
JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon)
{
- TRACEJVMCALLS("JVM_RawMonitorDestroy(mon=%p)", mon);
+ TRACEJVMCALLS(("JVM_RawMonitorDestroy(mon=%p)", mon));
FREE(mon, java_object_t);
}
JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon)
{
- TRACEJVMCALLS("JVM_RawMonitorEnter(mon=%p)", mon);
+ TRACEJVMCALLS(("JVM_RawMonitorEnter(mon=%p)", mon));
(void) lock_monitor_enter((java_object_t *) mon);
JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon)
{
- TRACEJVMCALLS("JVM_RawMonitorExit(mon=%p)", mon);
+ TRACEJVMCALLS(("JVM_RawMonitorExit(mon=%p)", mon));
(void) lock_monitor_exit((java_object_t *) mon);
}
jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
{
- TRACEJVMCALLS("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0);
+ java_lang_reflect_Method *rm;
+ classinfo *c;
+ int32_t slot;
+ int32_t override;
+ methodinfo *m;
+ java_handle_t *ro;
+
+ TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0));
- return (jobject) _Jv_java_lang_reflect_Method_invoke((java_lang_reflect_Method *) method, (java_lang_Object *) obj, (java_handle_objectarray_t *) args0);
+ rm = (java_lang_reflect_Method *) method;
+
+ LLNI_field_get_cls(rm, clazz, c);
+ LLNI_field_get_val(rm, slot, slot);
+ LLNI_field_get_val(rm, override, override);
+
+ m = &(c->methods[slot]);
+
+ ro = reflect_method_invoke(m, (java_handle_t *) obj, (java_handle_objectarray_t *) args0, override);
+
+ return (jobject) ro;
}
/* JVM_NewInstanceFromConstructor */
-jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0)
+jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0)
{
- TRACEJVMCALLS("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, c, args0);
+ java_lang_reflect_Constructor *rc;
+ classinfo *c;
+ int32_t slot;
+ int32_t override;
+ methodinfo *m;
+ java_handle_t *o;
+
+ TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0));
- return (jobject) _Jv_java_lang_reflect_Constructor_newInstance(env, (java_lang_reflect_Constructor *) c, (java_handle_objectarray_t *) args0);
+ rc = (java_lang_reflect_Constructor *) con;
+
+ LLNI_field_get_cls(rc, clazz, c);
+ LLNI_field_get_val(rc, slot, slot);
+ LLNI_field_get_val(rc, override, override);
+
+ m = &(c->methods[slot]);
+
+ o = reflect_constructor_newinstance(m, (java_handle_objectarray_t *) args0, override);
+
+ return (jobject) o;
}
jboolean JVM_SupportsCX8()
{
- TRACEJVMCALLS("JVM_SupportsCX8()");
+ TRACEJVMCALLS(("JVM_SupportsCX8()"));
/* IMPLEMENT ME */
void *JVM_GetManagement(jint version)
{
- TRACEJVMCALLS("JVM_GetManagement(version=%d)", version);
+ TRACEJVMCALLS(("JVM_GetManagement(version=%d)", version));
/* TODO We current don't support the management interface. */
methodinfo *m;
java_handle_objectarray_t *oa;
- TRACEJVMCALLS("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass);
+ TRACEJVMCALLS(("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass));
c = LLNI_classinfo_unwrap(ofClass);
if ((c == NULL) || class_is_primitive(c))
return NULL;
- m = class_get_enclosingmethod(c);
+ m = class_get_enclosingmethod_raw(c);
if (m == NULL)
return NULL;
if (oa == NULL)
return NULL;
- array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->class));
+ array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->clazz));
array_objectarray_element_set(oa, 1, javastring_new(m->name));
array_objectarray_element_set(oa, 2, javastring_new(m->descriptor));
{
java_handle_intarray_t *ia;
- TRACEJVMCALLS("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)",
- env, javaThreadState);
+ TRACEJVMCALLS(("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)",
+ env, javaThreadState));
/* If new thread states are added in future JDK and VM versions,
this should check if the JDK version is compatible with thread
java_handle_objectarray_t *oa;
java_object_t *s;
- TRACEJVMCALLS("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)",
- env, javaThreadState, values);
+ TRACEJVMCALLS(("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)",
+ env, javaThreadState, values));
ia = (java_handle_intarray_t *) values;
{
functionptr newHandler;
- TRACEJVMCALLS("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler);
+ TRACEJVMCALLS(("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler));
if (handler == (void *) 2)
newHandler = (functionptr) signal_thread_handler;
jint JVM_FindSignal(const char *name)
{
- TRACEJVMCALLS("JVM_FindSignal(name=%s)", name);
+ TRACEJVMCALLS(("JVM_FindSignal(name=%s)", name));
#if defined(__LINUX__)
if (strcmp(name, "HUP") == 0)