OPT_VERBOSE1,
OPT_NOIEEE,
- OPT_SOFTNULL,
#if defined(ENABLE_STATISTICS)
OPT_TIME,
#if defined(__ALPHA__)
{ "noieee", false, OPT_NOIEEE },
#endif
- { "softnull", false, OPT_SOFTNULL },
#if defined(ENABLE_STATISTICS)
{ "time", false, OPT_TIME },
{ "stat", false, OPT_STAT },
#if defined(ENABLE_VERIFIER)
puts(" -noverify don't verify classfiles");
#endif
- puts(" -softnull use software nullpointer check");
#if defined(ENABLE_STATISTICS)
puts(" -time measure the runtime");
puts(" -stat detailed compiler statistics");
env = NEW(_Jv_JNIEnv);
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JNI)
env->env = &_Jv_JNINativeInterface;
#endif
vm = NEW(_Jv_JavaVM);
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JNI)
vm->functions = &_Jv_JNIInvokeInterface;
#endif
if (!vm_create(_vm_args))
goto error;
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JNI)
/* setup the local ref table (must be created after vm_create) */
if (!jni_init_localref_table())
opt_version = false;
opt_exit = false;
- checknull = false;
opt_noieee = false;
opt_heapmaxsize = HEAP_MAXSIZE;
else if (strcmp("memory", opt_arg) == 0) {
opt_verbosememory = true;
+# if defined(ENABLE_STATISTICS)
/* we also need statistics */
opt_stat = true;
+# endif
}
#endif
break;
break;
#endif
- case OPT_SOFTNULL:
- checknull = true;
- break;
-
#if defined(ENABLE_STATISTICS)
case OPT_TIME:
opt_getcompilingtime = true;
}
#endif
- /* Now re-set some of the properties that may have changed. This
- must be done after _all_ environment variables have been
- processes (e.g. -jar handling). */
-
- if (!properties_postinit())
- vm_abort("properties_postinit failed");
-
- /* Now we have all options handled and we can print the version
- information. */
-
- if (opt_version)
- version(opt_exit);
-
/* initialize this JVM ****************************************************/
vm_initializing = true;
}
#endif
- /* initialize the string hashtable stuff: lock (must be done
- _after_ threads_preinit) */
+ /* AFTER: threads_preinit */
if (!string_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: string_init failed");
- /* initialize the utf8 hashtable stuff: lock, often used utf8
- strings (must be done _after_ threads_preinit) */
+ /* AFTER: threads_preinit */
if (!utf8_init())
- throw_main_exception_exit();
-
- /* initialize the classcache hashtable stuff: lock, hashtable
- (must be done _after_ threads_preinit) */
-
- if (!classcache_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: utf8_init failed");
- /* initialize the loader with bootclasspath (must be done _after_
- thread_preinit) */
+ /* AFTER: thread_preinit */
if (!suck_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: suck_init failed");
suck_add_from_property("java.endorsed.dirs");
+
+ /* Now we have all options handled and we can print the version
+ information.
+
+ AFTER: suck_add_from_property("java.endorsed.dirs"); */
+
+ if (opt_version)
+ version(opt_exit);
+
+ /* AFTER: utf8_init */
+
suck_add(_Jv_bootclasspath);
+ /* Now re-set some of the properties that may have changed. This
+ must be done after _all_ environment variables have been
+ processes (e.g. -jar handling).
+
+ AFTER: suck_add_from_property, since it may change the
+ _Jv_bootclasspath pointer. */
+
+ if (!properties_postinit())
+ vm_abort("vm_create: properties_postinit failed");
+
+ /* initialize the classcache hashtable stuff: lock, hashtable
+ (must be done _after_ threads_preinit) */
+
+ if (!classcache_init())
+ vm_abort("vm_create: classcache_init failed");
+
/* initialize the memory subsystem (must be done _after_
threads_preinit) */
if (!memory_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: memory_init failed");
/* initialize the finalizer stuff (must be done _after_
threads_preinit) */
if (!finalizer_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: finalizer_init failed");
/* install architecture dependent signal handlers */
classcache_init) */
if (!loader_init())
- vm_abort("loader_init failed");
+ vm_abort("vm_create: loader_init failed");
if (!linker_init())
- vm_abort("linker_init failed");
+ vm_abort("vm_create: linker_init failed");
if (!native_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: native_init failed");
if (!exceptions_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: exceptions_init failed");
if (!builtin_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: builtin_init failed");
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JNI)
/* Initialize the JNI subsystem (must be done _before_
threads_init, as threads_init can call JNI methods
(e.g. NewGlobalRef). */
if (!jni_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: jni_init failed");
#endif
#if defined(ENABLE_THREADS)
if (!threads_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: threads_init failed");
#endif
#if defined(ENABLE_PROFILING)
/* initialize profiling */
if (!profile_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: profile_init failed");
#endif
#if defined(ENABLE_THREADS)
/* initialize recompilation */
if (!recompile_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: recompile_init failed");
/* start the signal handler thread */
-/* if (!signal_start_thread()) */
-/* throw_main_exception_exit(); */
+ if (!signal_start_thread())
+ vm_abort("vm_create: signal_start_thread failed");
/* finally, start the finalizer thread */
if (!finalizer_start_thread())
- throw_main_exception_exit();
+ vm_abort("vm_create: finalizer_start_thread failed");
# if !defined(NDEBUG)
/* start the memory profiling thread */
if (opt_verbosememory)
if (!memory_start_thread())
- throw_main_exception_exit();
+ vm_abort("vm_create: memory_start_thread failed");
# endif
/* start the recompilation thread (must be done before the
profiling thread) */
if (!recompile_start_thread())
- throw_main_exception_exit();
+ vm_abort("vm_create: recompile_start_thread failed");
# if defined(ENABLE_PROFILING)
/* start the profile sampling thread */
/* if (opt_prof) */
/* if (!profile_start_thread()) */
-/* throw_main_exception_exit(); */
+/* exceptions_print_stacktrace(); */
# endif
#endif
#if defined(ENABLE_JVMTI)
+# if defined(ENABLE_GC_CACAO)
+ /* XXX this will not work with the new indirection cells for classloaders!!! */
+ assert(0);
+# endif
if (jvmti) {
/* add agent library to native library hashtable */
native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
status = 0;
- if (opt_jar == true)
+ if (opt_jar == true) {
/* open jar file with java.util.jar.JarFile */
+
mainstring = vm_get_mainclass_from_jar(mainstring);
+ if (mainstring == NULL)
+ vm_exit(1);
+ }
+
/* load the main class */
mainutf = utf_new_char(mainstring);
/* error loading class */
- if ((exceptions_get_exception() != NULL) || (mainclass == NULL))
- throw_main_exception_exit();
+ if ((exceptions_get_exception() != NULL) || (mainclass == NULL)) {
+ exceptions_print_stacktrace();
+ vm_exit(1);
+ }
- if (!link_class(mainclass))
- throw_main_exception_exit();
+ if (!link_class(mainclass)) {
+ exceptions_print_stacktrace();
+ vm_exit(1);
+ }
/* find the `main' method of the main class */
class_java_lang_Object,
false);
- if (*exceptionptr) {
- throw_main_exception_exit();
+ if (exceptions_get_exception()) {
+ exceptions_print_stacktrace();
+ vm_exit(1);
}
/* there is no main method or it isn't static */
utf_new_char("main"),
utf_new_char("([Ljava/lang/String;)V"));
- throw_main_exception_exit();
+ exceptions_print_stacktrace();
+ vm_exit(1);
}
/* build argument array */
/* exception occurred? */
- if (*exceptionptr) {
- throw_main_exception();
+ if (exceptions_get_exception()) {
+ exceptions_print_stacktrace();
status = 1;
}
/* unload the JavaVM */
- vm_destroy(vm);
+ (void) vm_destroy(vm);
/* and exit */
}
#endif
- if (!link_class(class_java_lang_System))
- throw_main_exception_exit();
+ if (!link_class(class_java_lang_System)) {
+ exceptions_print_stacktrace();
+ exit(1);
+ }
/* call java.lang.System.exit(I)V */
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ exit(1);
+ }
/* call the exit function with passed exit status */
c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
- if (c == NULL)
- throw_main_exception_exit();
-
+ if (c == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
+
/* create JarFile object */
o = builtin_new(c);
- if (o == NULL)
- throw_main_exception_exit();
-
+ if (o == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
m = class_resolveclassmethod(c,
utf_init,
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
s = javastring_new_from_ascii(mainstring);
(void) vm_call_method(m, o, s);
- if (*exceptionptr)
- throw_main_exception_exit();
+ if (exceptions_get_exception()) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
/* get manifest object */
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
o = vm_call_method(m, o);
if (o == NULL) {
fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
- vm_exit(1);
+ return NULL;
}
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
o = vm_call_method(m, o);
if (o == NULL) {
fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
- vm_exit(1);
+ return NULL;
}
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
s = javastring_new_from_ascii("Main-Class");
o = vm_call_method(m, o, s);
- if (o == NULL)
- throw_main_exception_exit();
+ if (o == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
return javastring_tochar(o);
}
/* create, load and link the main class */
- if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
- throw_main_exception_exit();
+ mainclass = load_class_bootstrap(utf_new_char(mainstring));
+
+ if (mainclass == NULL)
+ exceptions_print_stacktrace();
if (!link_class(mainclass))
- throw_main_exception_exit();
+ exceptions_print_stacktrace();
if (opt_signature != NULL) {
m = class_resolveclassmethod(mainclass,
{
java_objectheader *o;
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE;
+#endif
+
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
if (opt_intrp)
o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
#endif
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE;
+#endif
+
return o;
}
{
s4 i;
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE;
+#endif
+
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
if (opt_intrp)
i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
#endif
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE;
+#endif
+
return i;
}
{
s8 l;
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE;
+#endif
+
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
if (opt_intrp)
l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
#endif
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE;
+#endif
+
return l;
}
{
float f;
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE;
+#endif
+
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
if (opt_intrp)
f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
#endif
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE;
+#endif
+
return f;
}
{
double d;
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE;
+#endif
+
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
if (opt_intrp)
d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
#endif
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+ THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE;
+#endif
+
return d;
}