* src/vm/vm.c (vm_create): Moved localref_table_init from vm_createjvm.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Mon, 8 Oct 2007 14:57:26 +0000 (16:57 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Mon, 8 Oct 2007 14:57:26 +0000 (16:57 +0200)
src/vm/vm.c

index c289e6798e7df83c9279769955f338d53072001b..279d4daf04f5a766210997ac57ba522412475fd4 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "native/jni.h"
 #include "native/llni.h"
+#include "native/localref.h"
 #include "native/native.h"
 
 #include "native/include/java_lang_Object.h"             /* required by j.l.C */
@@ -742,16 +743,6 @@ bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args)
        if (!vm_create(_vm_args))
                goto error;
 
-#if defined(ENABLE_JNI)
-       /* setup the local ref table (must be created after vm_create) */
-
-       /* XXX this one will never get freed for the main thread;
-          call localref_table_destroy() if you want to do it! */
-
-       if (!localref_table_init())
-               goto error;
-#endif
-
        /* now return the values */
 
        *p_vm  = (JavaVM *) vm;
@@ -1561,6 +1552,14 @@ bool vm_create(JavaVMInitArgs *vm_args)
                vm_abort("vm_create: jni_init failed");
 #endif
 
+#if defined(ENABLE_JNI) || defined(ENABLE_HANDLES)
+       /* Initialize the local reference table for the main thread. */
+       /* BEFORE: threads_init */
+
+       if (!localref_table_init())
+               vm_abort("vm_create: localref_table_init failed");
+#endif
+
 #if defined(ENABLE_THREADS)
        if (!threads_init())
                vm_abort("vm_create: threads_init failed");