#include "vm/resolve.h"
#include "vm/signallocal.h"
#include "vm/stringlocal.h"
-#include "vm/system.h"
#include "vm/vm.h"
#include "vm/jit/stacktrace.h"
#include "vmcore/classcache.h"
#include "vmcore/options.h"
+#include "vmcore/system.h"
/* debugging macros ***********************************************************/
#if !defined(NDEBUG)
-# define TRACEJVMCALLS(...) \
- do { \
- if (opt_TraceJVMCalls) { \
- log_println(__VA_ARGS__); \
- } \
+# define TRACEJVMCALLS(...) \
+ do { \
+ if (opt_TraceJVMCalls) { \
+ log_println(__VA_ARGS__); \
+ } \
} while (0)
# define PRINTJVMWARNINGS(...)
jobject JVM_InitProperties(JNIEnv *env, jobject properties)
{
-#if PRINTJVM
- log_println("JVM_InitProperties: properties=%d", properties);
-#endif
- properties_system_add_all((java_handle_t *) properties);
+ java_handle_t *h;
+
+ TRACEJVMCALLS("JVM_InitProperties(env=%p, properties=%p)", env, properties);
+
+ h = (java_handle_t *) properties;
+
+ properties_system_add_all(h);
+
+ return properties;
}
void JVM_FillInStackTrace(JNIEnv *env, jobject receiver)
{
- java_lang_Throwable *o;
- stacktracecontainer *stc;
+ java_lang_Throwable *o;
+ java_handle_bytearray_t *ba;
#if PRINTJVM
log_println("JVM_FillInStackTrace: receiver=%p", receiver);
o = (java_lang_Throwable *) receiver;
- stc = stacktrace_fillInStackTrace();
+ ba = stacktrace_fillInStackTrace();
- if (stc == NULL)
+ if (ba == NULL)
return;
- o->backtrace = (java_lang_Object *) stc;
+ o->backtrace = (java_lang_Object *) ba;
}
jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
{
- java_lang_Throwable *o;
- stacktracecontainer *stc;
- stacktracebuffer *stb;
+ java_lang_Throwable *o;
+ java_handle_bytearray_t *ba;
+ stacktracebuffer *stb;
-#if PRINTJVM
- log_println("JVM_GetStackTraceDepth: throwable=%p", throwable);
-#endif
+ TRACEJVMCALLS("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable);
+
+ if (throwable == NULL) {
+ exceptions_throw_nullpointerexception();
+ return 0;
+ }
o = (java_lang_Throwable *) throwable;
- stc = (stacktracecontainer *) o->backtrace;
- stb = &(stc->stb);
+ ba = (java_handle_bytearray_t *) o->backtrace;
+
+ if (ba == NULL)
+ return 0;
+
+ stb = (stacktracebuffer *) LLNI_array_data(ba);
return stb->used;
}
jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
{
java_lang_Throwable *t;
- stacktracecontainer *stc;
- stacktracebuffer *stb;
- stacktrace_entry *ste;
+ java_handle_bytearray_t *ba;
+ stacktracebuffer *stb;
+ stacktrace_entry *ste;
java_lang_StackTraceElement *o;
java_lang_String *declaringclass;
java_lang_String *filename;
#endif
t = (java_lang_Throwable *) throwable;
- stc = (stacktracecontainer *) t->backtrace;
- stb = &(stc->stb);
+ ba = (java_handle_bytearray_t *) t->backtrace;
+ stb = (stacktracebuffer *) LLNI_array_data(ba);
if ((index < 0) || (index >= stb->used)) {
/* XXX This should be an IndexOutOfBoundsException (check this
#if defined(ENABLE_THREADS)
o = (java_handle_t *) handle;
- LLNI_CRITICAL_START;
- lock_wait_for_object(LLNI_DIRECT(o), ms, 0);
- LLNI_CRITICAL_END;
+ lock_wait_for_object(o, ms, 0);
#endif
}
#if defined(ENABLE_THREADS)
o = (java_handle_t *) handle;
- LLNI_CRITICAL_START;
- lock_notify_object(LLNI_DIRECT(o));
- LLNI_CRITICAL_END;
+ lock_notify_object(o);
#endif
}
#if defined(ENABLE_THREADS)
o = (java_handle_t *) handle;
- LLNI_CRITICAL_START;
- lock_notify_all_object(LLNI_DIRECT(o));
- LLNI_CRITICAL_END;
+ lock_notify_all_object(o);
#endif
}
TRACEJVMCALLS("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source);
- u = utf_new_char(name);
+ if (name != NULL)
+ u = utf_new_char(name);
+ else
+ u = NULL;
+
cl = loader_hashtable_classloader_add((java_handle_t *) loader);
/* XXX do something with source */
jlong JVM_Lseek(jint fd, jlong offset, jint whence)
{
-#if PRINTJVM
- log_println("JVM_Lseek: fd=%d, offset=%ld, whence=%d", fd, offset, whence);
-#endif
+ TRACEJVMCALLS("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence);
+
return (jlong) lseek(fd, (off_t) offset, whence);
}
jint JVM_SetLength(jint fd, jlong length)
{
- log_println("JVM_SetLength: IMPLEMENT ME!");
+ TRACEJVMCALLS("JVM_SetLength(fd=%d, length=%ld)", length);
+
+ return ftruncate(fd, length);
}