- Calling the class loader
- Running the main method
- $Id: main.c 1359 2004-07-28 10:48:36Z twisti $
+ $Id: main.c 1505 2004-11-14 14:15:58Z jowenn $
*/
printf(" u(tf) ......... show the utf - hash\n");
printf(" -i n ............. activate inlining\n");
printf(" v ............. inline virtual methods\n");
+ printf(" uses/turns rt option on\n");
printf(" e ............. inline methods with exceptions\n");
printf(" p ............. optimize argument renaming\n");
printf(" o ............. inline methods of foreign classes\n");
/************ Collect info from the environment ************************/
- classpath = MNEW(u1, 2);
+ /* set an initial, minimal classpath */
+ classpath = MNEW(char, 2);
strcpy(classpath, ".");
/* get classpath environment */
cp = getenv("CLASSPATH");
if (cp) {
classpath = MREALLOC(classpath,
- u1,
+ char,
strlen(classpath),
strlen(classpath) + 1 + strlen(cp) + 1);
strcat(classpath, ":");
- strncat(classpath, cp, strlen(cp));
+ strcat(classpath, cp);
}
/***************** Interpret the command line *****************/
case OPT_IGNORE: break;
case OPT_CLASSPATH:
- classpath = MREALLOC(classpath,
- u1,
- strlen(classpath),
- strlen(classpath) + 1 + strlen(opt_arg) + 1);
- strcat(classpath, ":");
- strncat(classpath, opt_arg, strlen(opt_arg));
+ /* forget old classpath and set the argument as new classpath */
+ MFREE(classpath, char, strlen(classpath));
+
+ classpath = MNEW(char, strlen(opt_arg) + 1);
+ strcpy(classpath, opt_arg);
break;
case OPT_D:
for (n = 0; n < l; n++) {
if (opt_arg[n] == '=') {
opt_arg[n] = '\0';
- attach_property(opt_arg, opt_arg + n + 1);
+ create_property(opt_arg, opt_arg + n + 1);
goto didit;
}
}
for (j = 0; j < strlen(opt_arg); j++) {
switch (opt_arg[j]) {
case 'n':
+ /* define in options.h; Used in main.c, jit.c & inline.c */
+ #ifdef INAFTERMAIN
+ useinliningm = true;
+ useinlining = false;
+ #else
useinlining = true;
+ #endif
break;
case 'v':
inlinevirtuals = true;
+ opt_rt = true;
break;
case 'e':
inlineexceptions = true;
exit(10);
}
}
-
-
+
if (opt_ind >= argc) {
print_usage();
exit(10);
cacao_initializing = true;
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(USE_THREADS)
+#if defined(NATIVE_THREADS)
initThreadsEarly();
#endif
+ initLocks();
+#endif
/* install architecture dependent signal handler used for exceptions */
init_exceptions();
jit_init();
/* initialize exceptions used in the system */
- init_system_exceptions();
+ if (!init_system_exceptions())
+ throw_main_exception_exit();
native_loadclasses();
if (!class_init(class_new(utf_new_char("java/lang/System"))))
throw_main_exception_exit();
+
+
+/* jni_init(); */
cacao_initializing = false;
/************************* Start worker routines ********************/
if (startit) {
methodinfo *mainmethod;
- java_objectarray *a;
+ java_objectarray *a;
+ s4 result=0;
/* create, load and link the main class */
mainclass = class_new(utf_new_char(mainstring));
asm_calljavafunction(mainmethod, a, NULL, NULL, NULL);
/* exception occurred? */
- if (*exceptionptr)
+ if (*exceptionptr) {
+ result=1;
throw_main_exception();
+ }
#if defined(USE_THREADS)
#if defined(NATIVE_THREADS)
/* now exit the JavaVM */
- cacao_exit(0);
+ cacao_exit(result);
}
/************* If requested, compile all methods ********************/
if (!m)
throw_main_exception_exit();
- asm_calljavafunction(m, rt, (void *) 0, NULL, NULL);
+ asm_calljavafunction(m, rt, (void *) status, NULL, NULL);
/* this should never happen */
void cacao_shutdown(s4 status)
{
- /**** RTAprint ***/
-
if (verbose || getcompilingtime || opt_stat) {
log_text("CACAO terminated by shutdown");
- if (opt_stat)
- print_stats();
- if (getcompilingtime)
- print_times();
- mem_usagelog(0);
- dolog("Exit status: %d\n", (int) status);
+ dolog("Exit status: %d\n", (s4) status);
}
exit(status);