1 /* src/cacao/cacao.c - contains main() of cacao
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
34 This module does the following tasks:
35 - Command line option handling
36 - Calling initialization routines
37 - Calling the class loader
38 - Running the main method
40 $Id: cacao.c 2798 2005-06-23 09:52:06Z twisti $
50 #include "cacao/cacao.h"
52 #include "mm/memory.h"
53 #include "native/jni.h"
54 #include "native/native.h"
55 #include "toolbox/logging.h"
56 #include "vm/exceptions.h"
57 #include "vm/global.h"
58 #include "vm/initialize.h"
59 #include "vm/loader.h"
60 #include "vm/options.h"
61 #include "vm/signallocal.h"
62 #include "vm/statistics.h"
63 #include "vm/stringlocal.h"
64 #include "vm/tables.h"
65 #include "vm/classcache.h"
66 #include "vm/jit/asmpart.h"
67 #include "vm/jit/jit.h"
69 #ifdef TYPEINFO_DEBUG_TEST
70 #include "vm/jit/verify/typeinfo.h"
74 /* define heap sizes **********************************************************/
76 #define HEAP_MAXSIZE 64 * 1024 * 1024; /* default 64MB */
77 #define HEAP_STARTSIZE 2 * 1024 * 1024; /* default 2MB */
80 /* Invocation API variables ***************************************************/
82 JavaVM *jvm; /* denotes a Java VM */
83 JNIEnv *env; /* pointer to native method interface */
85 JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization arguments */
88 bool cacao_initializing;
90 char *bootclasspath; /* contains the boot classpath */
91 char *classpath; /* contains the classpath */
94 static classinfo *mainclass;
96 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
97 void **stackbottom = 0;
101 /* define command line options ************************************************/
103 #define OPT_CLASSPATH 2
107 #define OPT_VERBOSE1 6
108 #define OPT_VERBOSE 7
109 #define OPT_VERBOSEGC 8
110 #define OPT_VERBOSECALL 9
111 #define OPT_NOIEEE 10
112 #define OPT_SOFTNULL 11
115 #if defined(STATISTICS)
117 #endif /* defined(STATISTICS) */
122 #define OPT_METHOD 17
123 #define OPT_SIGNATURE 18
127 #define OPT_INLINING 25
129 #define STATIC_ANALYSIS
130 #if defined(STATIC_ANALYSIS)
134 #endif /* defined(STATIC_ANALYSIS) */
136 #define OPT_VERBOSETC 29
137 #define OPT_NOVERIFY 30
138 #define OPT_LIBERALUTF 31
139 #define OPT_VERBOSEEXCEPTION 32
144 #endif /* defined(LSRA) */
147 #define OPT_BOOTCLASSPATH 36
148 #define OPT_BOOTCLASSPATH_A 37
149 #define OPT_BOOTCLASSPATH_P 38
150 #define OPT_VERSION 39
153 opt_struct opts[] = {
154 { "classpath", true, OPT_CLASSPATH },
155 { "cp", true, OPT_CLASSPATH },
156 { "D", true, OPT_D },
157 { "Xms", true, OPT_MS },
158 { "Xmx", true, OPT_MX },
159 { "ms", true, OPT_MS },
160 { "mx", true, OPT_MX },
161 { "noasyncgc", false, OPT_IGNORE },
162 { "noverify", false, OPT_NOVERIFY },
163 { "liberalutf", false, OPT_LIBERALUTF },
164 { "oss", true, OPT_IGNORE },
165 { "ss", true, OPT_IGNORE },
166 { "v", false, OPT_VERBOSE1 },
167 { "verbose", false, OPT_VERBOSE },
168 { "verbosegc", false, OPT_VERBOSEGC },
169 { "verbosecall", false, OPT_VERBOSECALL },
170 { "verboseexception", false, OPT_VERBOSEEXCEPTION },
171 #ifdef TYPECHECK_VERBOSE
172 { "verbosetc", false, OPT_VERBOSETC },
174 #if defined(__ALPHA__)
175 { "noieee", false, OPT_NOIEEE },
177 { "softnull", false, OPT_SOFTNULL },
178 { "time", false, OPT_TIME },
179 #if defined(STATISTICS)
180 { "stat", false, OPT_STAT },
182 { "log", true, OPT_LOG },
183 { "c", true, OPT_CHECK },
184 { "l", false, OPT_LOAD },
185 { "eager", false, OPT_EAGER },
186 { "m", true, OPT_METHOD },
187 { "sig", true, OPT_SIGNATURE },
188 { "s", true, OPT_SHOW },
189 { "all", false, OPT_ALL },
190 { "oloop", false, OPT_OLOOP },
191 { "i", true, OPT_INLINING },
192 #ifdef STATIC_ANALYSIS
193 { "rt", false, OPT_RT },
194 { "xta", false, OPT_XTA },
195 { "vta", false, OPT_VTA },
198 { "lsra", false, OPT_LSRA },
200 { "jar", false, OPT_JAR },
201 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
202 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
203 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
204 { "version", false, OPT_VERSION },
209 /******************** interne Function: print_usage ************************
211 Prints the correct usage syntax to stdout.
213 ***************************************************************************/
217 printf("Usage: cacao [options] classname [program arguments]\n\n");
219 printf("Options:\n");
220 printf(" -cp <path> specify a path to look for classes\n");
221 printf(" -classpath <path> specify a path to look for classes\n");
222 printf(" -jar jarfile execute a jar file\n");
223 printf(" -D<name>=<value> add an entry to the property list\n");
224 printf(" -Xmx<size>[kK|mM] specify the size for the heap\n");
225 printf(" -Xms<size>[kK|mM] specify the initial size for the heap\n");
226 printf(" -mx<size>[kK|mM] specify the size for the heap\n");
227 printf(" -ms<size>[kK|mM] specify the initial size for the heap\n");
228 printf(" -Xbootclasspath:<path> set search path for bootstrap classes and resources\n");
229 printf(" -Xbootclasspath/a:<path> append to end of bootstrap class path\n");
230 printf(" -Xbootclasspath/p:<path> prepend in front of bootstrap class path\n");
231 printf(" -v ................... write state-information\n");
232 printf(" -verbose ............. write more information\n");
233 printf(" -verbosegc ........... write message for each GC\n");
234 printf(" -verbosecall ......... write message for each call\n");
235 printf(" -verboseexception .... write message for each step of stack unwinding\n");
236 #ifdef TYPECHECK_VERBOSE
237 printf(" -verbosetc ........... write debug messages while typechecking\n");
239 printf(" -version print product version and exit\n");
240 #if defined(__ALPHA__)
241 printf(" -noieee .............. don't use ieee compliant arithmetic\n");
243 printf(" -noverify ............ don't verify classfiles\n");
244 printf(" -liberalutf........... don't warn about overlong UTF-8 sequences\n");
245 printf(" -softnull ............ use software nullpointer check\n");
246 printf(" -time ................ measure the runtime\n");
247 #if defined(STATISTICS)
248 printf(" -stat ................ detailed compiler statistics\n");
250 printf(" -log logfile ......... specify a name for the logfile\n");
251 printf(" -c(heck)b(ounds) ..... don't check array bounds\n");
252 printf(" s(ync) ....... don't check for synchronization\n");
253 printf(" -oloop ............... optimize array accesses in loops\n");
254 printf(" -l ................... don't start the class after loading\n");
255 printf(" -eager ............... perform eager class loading and linking\n");
256 printf(" -all ................. compile all methods, no execution\n");
257 printf(" -m ................... compile only a specific method\n");
258 printf(" -sig ................. specify signature for a specific method\n");
259 printf(" -s(how)a(ssembler) ... show disassembled listing\n");
260 printf(" c(onstants) ... show the constant pool\n");
261 printf(" d(atasegment).. show data segment listing\n");
262 printf(" i(ntermediate). show intermediate representation\n");
263 printf(" m(ethods)...... show class fields and methods\n");
264 printf(" n(ative)....... show disassembled native stubs\n");
265 printf(" u(tf) ......... show the utf - hash\n");
266 printf(" -i n ............. activate inlining\n");
267 printf(" v ............. inline virtual methods\n");
268 printf(" uses/turns rt option on\n");
269 printf(" e ............. inline methods with exceptions\n");
270 printf(" p ............. optimize argument renaming\n");
271 printf(" o ............. inline methods of foreign classes\n");
272 #ifdef STATIC_ANALYSIS
273 printf(" -rt .................. use rapid type analysis\n");
274 printf(" -xta ................. use x type analysis\n");
275 printf(" -vta ................. use variable type analysis\n");
278 printf(" -lsra ................ use linear scan register allocation\n");
281 /* exit with error code */
287 /* version *********************************************************************
289 Only prints cacao version information and exits.
291 *******************************************************************************/
293 static void version()
295 printf("cacao "VERSION"\n");
300 #ifdef TYPECHECK_STATISTICS
301 void typecheck_print_statistics(FILE *file);
306 /* getmainclassfromjar ************************************************************
308 gets the name of the main class form a jar's manifest file
310 **********************************************************************************/
312 char *getmainclassnamefromjar(JNIEnv *env, char *mainstring)
318 class = (*env)->FindClass(env, "java/util/jar/JarFile");
320 log_text("unable to find java.util.jar.JarFile");
321 throw_main_exception_exit();
324 mid = (*env)->GetMethodID(NULL, class, "<init>","(Ljava/lang/String;)V");
326 log_text("unable to find constructor in java.util.jar.JarFile");
331 obj = (*env)->NewObject(NULL,class,mid,((*env)->NewStringUTF(NULL,(char*)mainstring)));
332 if ((*env)->ExceptionOccurred(NULL) != NULL) {
333 (*env)->ExceptionDescribe(NULL);
337 mid = (*env)->GetMethodID(NULL, class, "getManifest","()Ljava/util/jar/Manifest;");
339 log_text("unable to find getMainfest method");
343 /* get manifest object */
344 obj = (*env)->CallObjectMethod(NULL,obj,mid);
345 if ((*env)->ExceptionOccurred(NULL) != NULL) {
346 (*env)->ExceptionDescribe(NULL);
350 mid = (*env)->GetMethodID(NULL, (jclass)((java_objectheader*) obj)->vftbl->class, "getMainAttributes","()Ljava/util/jar/Attributes;");
352 log_text("unable to find getMainAttributes method");
356 /* get Main Attributes */
357 obj = (*env)->CallObjectMethod(NULL,obj,mid);
358 if ((*env)->ExceptionOccurred(NULL) != NULL) {
359 (*env)->ExceptionDescribe(NULL);
364 mid = (*env)->GetMethodID(NULL, (jclass)((java_objectheader*) obj)->vftbl->class, "getValue","(Ljava/lang/String;)Ljava/lang/String;");
366 log_text("unable to find getValue method");
370 /* get property Main-Class */
371 obj = (*env)->CallObjectMethod(NULL,obj,mid,(*env)->NewStringUTF(NULL,"Main-Class"));
372 if ((*env)->ExceptionOccurred(NULL) != NULL) {
373 (*env)->ExceptionDescribe(NULL);
377 return javastring_tochar((java_objectheader *) obj);
382 * void exit_handler(void)
383 * -----------------------
384 * The exit_handler function is called upon program termination to shutdown
385 * the various subsystems and release the resources allocated to the VM.
387 void exit_handler(void)
389 /********************* Print debug tables ************************/
391 if (showmethods) class_showmethods(mainclass);
392 if (showconstantpool) class_showconstantpool(mainclass);
393 if (showutf) utf_show();
395 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
396 clear_thread_flags(); /* restores standard file descriptor
400 /************************ Free all resources *******************/
405 MFREE(classpath, u1, strlen(classpath));
407 if (opt_verbose || getcompilingtime || opt_stat) {
408 log_text("CACAO terminated");
410 #if defined(STATISTICS)
413 #ifdef TYPECHECK_STATISTICS
414 typecheck_print_statistics(get_logfile());
418 if (getcompilingtime)
426 /************************** Function: main *******************************
430 **************************************************************************/
432 int main(int argc, char **argv)
437 /********** interne (nur fuer main relevante Optionen) **************/
439 char logfilename[200] = "";
445 char *specificmethodname = NULL;
446 char *specificsignature = NULL;
449 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
450 stackbottom = &dummy;
453 if (atexit(exit_handler))
454 throw_cacao_exception_exit(string_java_lang_InternalError,
455 "Unable to register exit_handler");
458 /************ Collect info from the environment ************************/
460 /* set the bootclasspath */
462 cp = getenv("BOOTCLASSPATH");
464 bootclasspath = MNEW(char, strlen(cp) + 1);
465 strcpy(bootclasspath, cp);
468 #if !defined(WITH_EXTERNAL_CLASSPATH)
469 cplen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_RT_JAR_PATH);
471 bootclasspath = MNEW(char, cplen + 1);
472 strcpy(bootclasspath, CACAO_INSTALL_PREFIX);
473 strcat(bootclasspath, CACAO_RT_JAR_PATH);
475 cplen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_VM_ZIP_PATH) +
476 strlen(EXTERNAL_CLASSPATH_PREFIX) + strlen(CLASSPATH_GLIBJ_ZIP_PATH);
478 bootclasspath = MNEW(char, cplen + 1 + 1);
479 strcpy(bootclasspath, CACAO_INSTALL_PREFIX);
480 strcat(bootclasspath, CACAO_VM_ZIP_PATH);
481 strcat(bootclasspath, ":");
482 strcat(bootclasspath, EXTERNAL_CLASSPATH_PREFIX);
483 strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP_PATH);
488 /* set the classpath */
490 cp = getenv("CLASSPATH");
492 classpath = MNEW(char, strlen(cp) + 1);
493 strcat(classpath, cp);
496 classpath = MNEW(char, 2);
497 strcpy(classpath, ".");
501 /***************** Interpret the command line *****************/
506 heapmaxsize = HEAP_MAXSIZE;
507 heapstartsize = HEAP_STARTSIZE;
510 while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
515 case OPT_BOOTCLASSPATH:
516 /* Forget default bootclasspath and set the argument as new boot */
518 MFREE(bootclasspath, char, strlen(bootclasspath));
520 bootclasspath = MNEW(char, strlen(opt_arg) + 1);
521 strcpy(bootclasspath, opt_arg);
524 case OPT_BOOTCLASSPATH_A:
525 /* append to end of bootclasspath */
526 cplen = strlen(bootclasspath);
528 bootclasspath = MREALLOC(bootclasspath,
531 cplen + 1 + strlen(opt_arg) + 1);
533 strcat(bootclasspath, ":");
534 strcat(bootclasspath, opt_arg);
537 case OPT_BOOTCLASSPATH_P:
538 /* prepend in front of bootclasspath */
542 bootclasspath = MNEW(char, strlen(opt_arg) + 1 + cplen + 1);
544 strcpy(bootclasspath, opt_arg);
545 strcat(bootclasspath, ":");
546 strcat(bootclasspath, cp);
548 MFREE(cp, char, cplen);
552 /* forget old classpath and set the argument as new classpath */
553 MFREE(classpath, char, strlen(classpath));
555 classpath = MNEW(char, strlen(opt_arg) + 1);
556 strcpy(classpath, opt_arg);
565 for (j = 0; j < strlen(opt_arg); j++) {
566 if (opt_arg[j] == '=') {
568 create_property(opt_arg, opt_arg + j + 1);
573 /* if no '=' is given, just create an empty property */
574 create_property(opt_arg, "");
584 c = opt_arg[strlen(opt_arg) - 1];
586 if (c == 'k' || c == 'K') {
587 j = 1024 * atoi(opt_arg);
589 } else if (c == 'm' || c == 'M') {
590 j = 1024 * 1024 * atoi(opt_arg);
592 } else j = atoi(opt_arg);
594 if (i == OPT_MX) heapmaxsize = j;
595 else heapstartsize = j;
608 compileverbose = true;
611 case OPT_VERBOSEEXCEPTION:
612 verboseexception = true;
616 collectverbose = true;
619 #ifdef TYPECHECK_VERBOSE
621 typecheckverbose = true;
625 case OPT_VERBOSECALL:
642 opt_liberalutf = true;
650 getcompilingtime = true;
651 getloadingtime = true;
654 #if defined(STATISTICS)
661 strcpy(logfilename, opt_arg);
665 for (j = 0; j < strlen(opt_arg); j++) {
666 switch (opt_arg[j]) {
681 makeinitializations = false;
690 specificmethodname = opt_arg;
691 makeinitializations = false;
695 specificsignature = opt_arg;
701 makeinitializations = false;
704 case OPT_SHOW: /* Display options */
705 for (j = 0; j < strlen(opt_arg); j++) {
706 switch (opt_arg[j]) {
708 showdisassemble = true;
709 compileverbose = true;
712 showconstantpool = true;
715 showddatasegment = true;
718 showintermediate = true;
719 compileverbose = true;
725 opt_shownativestub = true;
741 for (j = 0; j < strlen(opt_arg); j++) {
742 switch (opt_arg[j]) {
744 /* define in options.h; Used in main.c, jit.c & inline.c */
753 inlinevirtuals = true;
757 inlineexceptions = true;
760 inlineparamopt = true;
763 inlineoutsiders = true;
771 #ifdef STATIC_ANALYSIS
773 opt_rt = true; /* default for inlining */
777 opt_xta = true; /* in test currently */
781 printf("\nVTA is not yet available\n");
783 /***opt_vta = true; not yet **/
794 printf("Unknown option: %s\n", argv[opt_ind]);
803 /* transform dots into slashes in the class name */
805 mainstring = argv[opt_ind++];
807 /* do not mangle jar filename */
808 for (i = strlen(mainstring) - 1; i >= 0; i--) {
809 if (mainstring[i] == '.') mainstring[i] = '/';
813 /* put jarfile in classpath */
815 classpath = MNEW(char, strlen(mainstring) + 1 + strlen(classpath) + 1);
816 strcpy(classpath, mainstring);
817 strcat(classpath, ":");
818 strcat(classpath, cp);
820 MFREE(cp, char, strlen(cp));
823 /**************************** Program start *****************************/
825 log_init(logfilename);
828 log_text("CACAO started -------------------------------------------------------");
830 /* initialize JavaVM */
832 vm_args.version = 0x00010001; /* New in 1.1.2: VM version */
834 /* Get the default initialization arguments and set the class path */
836 JNI_GetDefaultJavaVMInitArgs(&vm_args);
838 vm_args.minHeapSize = heapstartsize;
839 vm_args.maxHeapSize = heapmaxsize;
841 vm_args.classpath = classpath;
843 /* load and initialize a Java VM, return a JNI interface pointer in env */
845 JNI_CreateJavaVM(&jvm, &env, &vm_args);
848 /* initialize the garbage collector */
850 gc_init(heapmaxsize, heapstartsize);
854 /* initialize the loader with bootclasspath */
856 suck_init(bootclasspath);
858 cacao_initializing = true;
860 #if defined(USE_THREADS)
861 #if defined(NATIVE_THREADS)
867 /* install architecture dependent signal handler used for exceptions */
871 /* initialize the codegen sub systems */
875 /* initializes jit compiler */
879 /* initialize some cacao subsystems */
883 if (!loader_init((u1 *) &dummy))
884 throw_main_exception_exit();
887 throw_main_exception_exit();
890 throw_main_exception_exit();
892 if (!exceptions_init())
893 throw_main_exception_exit();
896 throw_main_exception_exit();
898 #if defined(USE_THREADS)
899 initThreads((u1 *) &dummy);
902 *threadrootmethod = NULL;
904 /*That's important, otherwise we get into trouble, if the Runtime static
905 initializer is called before (circular dependency. This is with
906 classpath 0.09. Another important thing is, that this has to happen
907 after initThreads!!! */
909 if (!initialize_class(class_java_lang_System))
910 throw_main_exception_exit();
912 cacao_initializing = false;
915 /* start worker routines **************************************************/
918 classinfo *mainclass; /* java/lang/Class */
923 /* set return value to OK */
928 /* open jar file with java.util.jar.JarFile */
929 mainstring = getmainclassnamefromjar((JNIEnv *) &env, mainstring);
932 /* load the main class */
934 if (!(mainclass = load_class_from_sysloader(utf_new_char(mainstring))))
935 throw_main_exception_exit();
937 /* error loading class, clear exceptionptr for new exception */
939 if (*exceptionptr || !mainclass) {
940 /* *exceptionptr = NULL; */
942 /* *exceptionptr = */
943 /* new_exception_message(string_java_lang_NoClassDefFoundError, */
945 throw_main_exception_exit();
948 /* find the `main' method of the main class */
950 m = class_resolveclassmethod(mainclass,
951 utf_new_char("main"),
952 utf_new_char("([Ljava/lang/String;)V"),
953 class_java_lang_Object,
957 throw_main_exception_exit();
960 /* there is no main method or it isn't static */
962 if (!m || !(m->flags & ACC_STATIC)) {
963 *exceptionptr = NULL;
966 new_exception_message(string_java_lang_NoSuchMethodError,
968 throw_main_exception_exit();
971 /* build argument array */
973 a = builtin_anewarray(argc - opt_ind, class_java_lang_String);
974 for (i = opt_ind; i < argc; i++) {
975 a->data[i - opt_ind] =
976 (java_objectheader *) javastring_new(utf_new_char(argv[i]));
979 #ifdef TYPEINFO_DEBUG_TEST
980 /* test the typeinfo system */
983 /*class_showmethods(currentThread->group->header.vftbl->class); */
985 *threadrootmethod = m;
989 asm_calljavafunction(m, a, NULL, NULL, NULL);
991 /* exception occurred? */
993 throw_main_exception();
997 #if defined(USE_THREADS)
998 #if defined(NATIVE_THREADS)
1001 killThread(currentThread);
1005 /* now exit the JavaVM */
1007 /* (*jvm)->DestroyJavaVM(jvm); */
1012 /************* If requested, compile all methods ********************/
1019 classcache_name_entry *nmen;
1020 classcache_class_entry *clsen;
1022 /* create all classes found in the classpath */
1023 /* XXX currently only works with zip/jar's */
1025 loader_load_all_classes();
1027 /* link all classes */
1029 for (slot = 0; slot < classcache_hash.size; slot++) {
1030 nmen = (classcache_name_entry *) classcache_hash.ptr[slot];
1032 for (; nmen; nmen = nmen->hashlink) {
1033 /* iterate over all class entries */
1035 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1036 c = clsen->classobj;
1043 /*utf_fprint_classname(stderr,c->name);fprintf(stderr,"\n");*/
1047 throw_main_exception_exit();
1049 /* compile all class methods */
1050 for (i = 0; i < c->methodscount; i++) {
1051 m = &(c->methods[i]);
1053 /*fprintf(stderr," compiling:");utf_fprint(stderr,m->name);fprintf(stderr,"\n");*/
1054 (void) jit_compile(m);
1063 /******** If requested, compile a specific method ***************/
1065 if (specificmethodname) {
1068 /* create, load and link the main class */
1070 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
1071 throw_main_exception_exit();
1073 if (!link_class(mainclass))
1074 throw_main_exception_exit();
1076 if (specificsignature) {
1077 m = class_resolveclassmethod(mainclass,
1078 utf_new_char(specificmethodname),
1079 utf_new_char(specificsignature),
1083 m = class_resolveclassmethod(mainclass,
1084 utf_new_char(specificmethodname),
1091 char message[MAXLOGTEXT];
1092 sprintf(message, "%s%s", specificmethodname,
1093 specificsignature ? specificsignature : "");
1096 new_exception_message(string_java_lang_NoSuchMethodException,
1099 throw_main_exception_exit();
1107 /* keep compiler happy */
1113 /* cacao_exit ******************************************************************
1115 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1117 *******************************************************************************/
1119 void cacao_exit(s4 status)
1124 assert(class_java_lang_System);
1125 assert(class_java_lang_System->loaded);
1127 if (!link_class(class_java_lang_System))
1128 throw_main_exception_exit();
1130 /* call java.lang.System.exit(I)V */
1132 m = class_resolveclassmethod(class_java_lang_System,
1133 utf_new_char("exit"),
1135 class_java_lang_Object,
1139 throw_main_exception_exit();
1141 /* call the exit function with passed exit status */
1143 /* both inlinevirtual and outsiders not allowed on exit */
1144 /* not sure if permanant or temp restriction */
1145 if (inlinevirtuals) inlineoutsiders = false;
1147 asm_calljavafunction(m, (void *) (ptrint) status, NULL, NULL, NULL);
1149 /* this should never happen */
1152 throw_exception_exit();
1154 throw_cacao_exception_exit(string_java_lang_InternalError,
1155 "System.exit(I)V returned without exception");
1159 /*************************** Shutdown function *********************************
1161 Terminates the system immediately without freeing memory explicitly (to be
1162 used only for abnormal termination)
1164 *******************************************************************************/
1166 void cacao_shutdown(s4 status)
1168 if (opt_verbose || getcompilingtime || opt_stat) {
1169 log_text("CACAO terminated by shutdown");
1170 dolog("Exit status: %d\n", (s4) status);
1178 * These are local overrides for various environment variables in Emacs.
1179 * Please do not remove this and leave it at the end of the file, where
1180 * Emacs will automagically detect them.
1181 * ---------------------------------------------------------------------
1184 * indent-tabs-mode: t