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 2131 2005-03-29 22:34:19Z twisti $
49 #include "cacao/cacao.h"
51 #include "mm/memory.h"
52 #include "native/jni.h"
53 #include "native/native.h"
54 #include "toolbox/logging.h"
55 #include "vm/exceptions.h"
56 #include "vm/global.h"
57 #include "vm/loader.h"
58 #include "vm/options.h"
59 #include "vm/statistics.h"
60 #include "vm/stringlocal.h"
61 #include "vm/tables.h"
62 #include "vm/jit/asmpart.h"
63 #include "vm/jit/jit.h"
65 #ifdef TYPEINFO_DEBUG_TEST
66 #include "vm/jit/verify/typeinfo.h"
70 /* define heap sizes **********************************************************/
72 #define HEAP_MAXSIZE 64 * 1024 * 1024; /* default 64MB */
73 #define HEAP_STARTSIZE 2 * 1024 * 1024; /* default 2MB */
76 /* Invocation API variables ***************************************************/
78 JavaVM *jvm; /* denotes a Java VM */
79 JNIEnv *env; /* pointer to native method interface */
81 JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization arguments */
84 bool cacao_initializing;
86 char *bootclasspath; /* contains the boot classpath */
87 char *classpath; /* contains the classpath */
90 static classinfo *mainclass;
92 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
93 void **stackbottom = 0;
97 /* define command line options ************************************************/
99 #define OPT_CLASSPATH 2
103 #define OPT_VERBOSE1 6
104 #define OPT_VERBOSE 7
105 #define OPT_VERBOSEGC 8
106 #define OPT_VERBOSECALL 9
107 #define OPT_NOIEEE 10
108 #define OPT_SOFTNULL 11
111 #if defined(STATISTICS)
113 #endif /* defined(STATISTICS) */
118 #define OPT_METHOD 17
119 #define OPT_SIGNATURE 18
123 #define OPT_INLINING 25
125 #define STATIC_ANALYSIS
126 #if defined(STATIC_ANALYSIS)
130 #endif /* defined(STATIC_ANALYSIS) */
132 #define OPT_VERBOSETC 29
133 #define OPT_NOVERIFY 30
134 #define OPT_LIBERALUTF 31
135 #define OPT_VERBOSEEXCEPTION 32
140 #endif /* defined(LSRA) */
143 #define OPT_BOOTCLASSPATH 36
144 #define OPT_BOOTCLASSPATH_A 37
145 #define OPT_BOOTCLASSPATH_P 38
146 #define OPT_VERSION 39
149 opt_struct opts[] = {
150 { "classpath", true, OPT_CLASSPATH },
151 { "cp", true, OPT_CLASSPATH },
152 { "D", true, OPT_D },
153 { "Xms", true, OPT_MS },
154 { "Xmx", true, OPT_MX },
155 { "ms", true, OPT_MS },
156 { "mx", true, OPT_MX },
157 { "noasyncgc", false, OPT_IGNORE },
158 { "noverify", false, OPT_NOVERIFY },
159 { "liberalutf", false, OPT_LIBERALUTF },
160 { "oss", true, OPT_IGNORE },
161 { "ss", true, OPT_IGNORE },
162 { "v", false, OPT_VERBOSE1 },
163 { "verbose", false, OPT_VERBOSE },
164 { "verbosegc", false, OPT_VERBOSEGC },
165 { "verbosecall", false, OPT_VERBOSECALL },
166 { "verboseexception", false, OPT_VERBOSEEXCEPTION },
167 #ifdef TYPECHECK_VERBOSE
168 { "verbosetc", false, OPT_VERBOSETC },
170 #if defined(__ALPHA__)
171 { "noieee", false, OPT_NOIEEE },
173 { "softnull", false, OPT_SOFTNULL },
174 { "time", false, OPT_TIME },
175 #if defined(STATISTICS)
176 { "stat", false, OPT_STAT },
178 { "log", true, OPT_LOG },
179 { "c", true, OPT_CHECK },
180 { "l", false, OPT_LOAD },
181 { "eager", false, OPT_EAGER },
182 { "m", true, OPT_METHOD },
183 { "sig", true, OPT_SIGNATURE },
184 { "s", true, OPT_SHOW },
185 { "all", false, OPT_ALL },
186 { "oloop", false, OPT_OLOOP },
187 { "i", true, OPT_INLINING },
188 #ifdef STATIC_ANALYSIS
189 { "rt", false, OPT_RT },
190 { "xta", false, OPT_XTA },
191 { "vta", false, OPT_VTA },
194 { "lsra", false, OPT_LSRA },
196 { "jar", false, OPT_JAR },
197 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
198 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
199 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
200 { "version", false, OPT_VERSION },
205 /******************** interne Function: print_usage ************************
207 Prints the correct usage syntax to stdout.
209 ***************************************************************************/
213 printf("Usage: cacao [options] classname [program arguments]\n\n");
215 printf("Options:\n");
216 printf(" -cp <path> specify a path to look for classes\n");
217 printf(" -classpath <path> specify a path to look for classes\n");
218 printf(" -jar jarfile execute a jar file\n");
219 printf(" -D<name>=<value> add an entry to the property list\n");
220 printf(" -Xmx<size>[kK|mM] specify the size for the heap\n");
221 printf(" -Xms<size>[kK|mM] specify the initial size for the heap\n");
222 printf(" -mx<size>[kK|mM] specify the size for the heap\n");
223 printf(" -ms<size>[kK|mM] specify the initial size for the heap\n");
224 printf(" -Xbootclasspath:<path> set search path for bootstrap classes and resources\n");
225 printf(" -Xbootclasspath/a:<path> append to end of bootstrap class path\n");
226 printf(" -Xbootclasspath/p:<path> prepend in front of bootstrap class path\n");
227 printf(" -v ................... write state-information\n");
228 printf(" -verbose ............. write more information\n");
229 printf(" -verbosegc ........... write message for each GC\n");
230 printf(" -verbosecall ......... write message for each call\n");
231 printf(" -verboseexception .... write message for each step of stack unwinding\n");
232 #ifdef TYPECHECK_VERBOSE
233 printf(" -verbosetc ........... write debug messages while typechecking\n");
235 printf(" -version print product version and exit\n");
236 #if defined(__ALPHA__)
237 printf(" -noieee .............. don't use ieee compliant arithmetic\n");
239 printf(" -noverify ............ don't verify classfiles\n");
240 printf(" -liberalutf........... don't warn about overlong UTF-8 sequences\n");
241 printf(" -softnull ............ use software nullpointer check\n");
242 printf(" -time ................ measure the runtime\n");
243 #if defined(STATISTICS)
244 printf(" -stat ................ detailed compiler statistics\n");
246 printf(" -log logfile ......... specify a name for the logfile\n");
247 printf(" -c(heck)b(ounds) ..... don't check array bounds\n");
248 printf(" s(ync) ....... don't check for synchronization\n");
249 printf(" -oloop ............... optimize array accesses in loops\n");
250 printf(" -l ................... don't start the class after loading\n");
251 printf(" -eager ............... perform eager class loading and linking\n");
252 printf(" -all ................. compile all methods, no execution\n");
253 printf(" -m ................... compile only a specific method\n");
254 printf(" -sig ................. specify signature for a specific method\n");
255 printf(" -s(how)a(ssembler) ... show disassembled listing\n");
256 printf(" c(onstants) ... show the constant pool\n");
257 printf(" d(atasegment).. show data segment listing\n");
258 printf(" i(ntermediate). show intermediate representation\n");
259 printf(" m(ethods)...... show class fields and methods\n");
260 printf(" u(tf) ......... show the utf - hash\n");
261 printf(" -i n ............. activate inlining\n");
262 printf(" v ............. inline virtual methods\n");
263 printf(" uses/turns rt option on\n");
264 printf(" e ............. inline methods with exceptions\n");
265 printf(" p ............. optimize argument renaming\n");
266 printf(" o ............. inline methods of foreign classes\n");
267 #ifdef STATIC_ANALYSIS
268 printf(" -rt .................. use rapid type analysis\n");
269 printf(" -xta ................. use x type analysis\n");
270 printf(" -vta ................. use variable type analysis\n");
273 printf(" -lsra ................ use linear scan register allocation\n");
276 /* exit with error code */
282 /* version *********************************************************************
284 Only prints cacao version information and exits.
286 *******************************************************************************/
288 static void version()
290 printf("cacao "VERSION"\n");
295 #ifdef TYPECHECK_STATISTICS
296 void typecheck_print_statistics(FILE *file);
301 /* getmainclassfromjar ************************************************************
303 gets the name of the main class form a jar's manifest file
305 **********************************************************************************/
307 char *getmainclassnamefromjar(JNIEnv *env, char *mainstring)
313 class = (*env)->FindClass(env, "java/util/jar/JarFile");
315 log_text("unable to find java.util.jar.JarFile");
316 throw_main_exception_exit();
319 mid = (*env)->GetMethodID(NULL, class, "<init>","(Ljava/lang/String;)V");
321 log_text("unable to find constructor in java.util.jar.JarFile");
326 obj = (*env)->NewObject(NULL,class,mid,((*env)->NewStringUTF(NULL,(char*)mainstring)));
327 if ((*env)->ExceptionOccurred(NULL) != NULL) {
328 (*env)->ExceptionDescribe(NULL);
332 mid = (*env)->GetMethodID(NULL, class, "getManifest","()Ljava/util/jar/Manifest;");
334 log_text("unable to find getMainfest method");
338 /* get manifest object */
339 obj = (*env)->CallObjectMethod(NULL,obj,mid);
340 if ((*env)->ExceptionOccurred(NULL) != NULL) {
341 (*env)->ExceptionDescribe(NULL);
345 mid = (*env)->GetMethodID(NULL, (jclass)((java_objectheader*) obj)->vftbl->class, "getMainAttributes","()Ljava/util/jar/Attributes;");
347 log_text("unable to find getMainAttributes method");
351 /* get Main Attributes */
352 obj = (*env)->CallObjectMethod(NULL,obj,mid);
353 if ((*env)->ExceptionOccurred(NULL) != NULL) {
354 (*env)->ExceptionDescribe(NULL);
359 mid = (*env)->GetMethodID(NULL, (jclass)((java_objectheader*) obj)->vftbl->class, "getValue","(Ljava/lang/String;)Ljava/lang/String;");
361 log_text("unable to find getValue method");
365 /* get property Main-Class */
366 obj = (*env)->CallObjectMethod(NULL,obj,mid,(*env)->NewStringUTF(NULL,"Main-Class"));
367 if ((*env)->ExceptionOccurred(NULL) != NULL) {
368 (*env)->ExceptionDescribe(NULL);
372 return javastring_tochar((java_objectheader *) obj);
377 * void exit_handler(void)
378 * -----------------------
379 * The exit_handler function is called upon program termination to shutdown
380 * the various subsystems and release the resources allocated to the VM.
382 void exit_handler(void)
384 /********************* Print debug tables ************************/
386 if (showmethods) class_showmethods(mainclass);
387 if (showconstantpool) class_showconstantpool(mainclass);
388 if (showutf) utf_show();
390 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
391 clear_thread_flags(); /* restores standard file descriptor
395 /************************ Free all resources *******************/
400 MFREE(classpath, u1, strlen(classpath));
402 if (opt_verbose || getcompilingtime || opt_stat) {
403 log_text("CACAO terminated");
405 #if defined(STATISTICS)
408 #ifdef TYPECHECK_STATISTICS
409 typecheck_print_statistics(get_logfile());
413 if (getcompilingtime)
421 /************************** Function: main *******************************
425 **************************************************************************/
427 int main(int argc, char **argv)
432 /********** interne (nur fuer main relevante Optionen) **************/
434 char logfilename[200] = "";
440 char *specificmethodname = NULL;
441 char *specificsignature = NULL;
444 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
445 stackbottom = &dummy;
448 if (atexit(exit_handler))
449 throw_cacao_exception_exit(string_java_lang_InternalError,
450 "Unable to register exit_handler");
453 /************ Collect info from the environment ************************/
455 /* set the bootclasspath */
457 cp = getenv("BOOTCLASSPATH");
459 bootclasspath = MNEW(char, strlen(cp) + 1);
460 strcpy(bootclasspath, cp);
463 #if !defined(WITH_EXTERNAL_CLASSPATH)
464 cplen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_RT_JAR_PATH);
466 bootclasspath = MNEW(char, cplen + 1);
467 strcpy(bootclasspath, CACAO_INSTALL_PREFIX);
468 strcat(bootclasspath, CACAO_RT_JAR_PATH);
470 cplen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_VM_ZIP_PATH) +
471 strlen(EXTERNAL_CLASSPATH_PREFIX) + strlen(CLASSPATH_GLIBJ_ZIP_PATH);
473 bootclasspath = MNEW(char, cplen + 1 + 1);
474 strcpy(bootclasspath, CACAO_INSTALL_PREFIX);
475 strcat(bootclasspath, CACAO_VM_ZIP_PATH);
476 strcat(bootclasspath, ":");
477 strcat(bootclasspath, EXTERNAL_CLASSPATH_PREFIX);
478 strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP_PATH);
483 /* set the classpath */
485 cp = getenv("CLASSPATH");
487 classpath = MNEW(char, strlen(cp) + 1);
488 strcat(classpath, cp);
491 classpath = MNEW(char, 2);
492 strcpy(classpath, ".");
496 /***************** Interpret the command line *****************/
501 heapmaxsize = HEAP_MAXSIZE;
502 heapstartsize = HEAP_STARTSIZE;
505 while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
510 case OPT_BOOTCLASSPATH:
511 /* Forget default bootclasspath and set the argument as new boot */
513 MFREE(bootclasspath, char, strlen(bootclasspath));
515 bootclasspath = MNEW(char, strlen(opt_arg) + 1);
516 strcpy(bootclasspath, opt_arg);
519 case OPT_BOOTCLASSPATH_A:
520 /* append to end of bootclasspath */
521 cplen = strlen(bootclasspath);
523 bootclasspath = MREALLOC(bootclasspath,
526 cplen + 1 + strlen(opt_arg) + 1);
528 strcat(bootclasspath, ":");
529 strcat(bootclasspath, opt_arg);
532 case OPT_BOOTCLASSPATH_P:
533 /* prepend in front of bootclasspath */
537 bootclasspath = MNEW(char, strlen(opt_arg) + 1 + cplen + 1);
539 strcpy(bootclasspath, opt_arg);
540 strcat(bootclasspath, ":");
541 strcat(bootclasspath, cp);
543 MFREE(cp, char, cplen);
547 /* forget old classpath and set the argument as new classpath */
548 MFREE(classpath, char, strlen(classpath));
550 classpath = MNEW(char, strlen(opt_arg) + 1);
551 strcpy(classpath, opt_arg);
560 for (j = 0; j < strlen(opt_arg); j++) {
561 if (opt_arg[j] == '=') {
563 create_property(opt_arg, opt_arg + j + 1);
568 /* if no '=' is given, just create an empty property */
569 create_property(opt_arg, "");
579 c = opt_arg[strlen(opt_arg) - 1];
581 if (c == 'k' || c == 'K') {
582 j = 1024 * atoi(opt_arg);
584 } else if (c == 'm' || c == 'M') {
585 j = 1024 * 1024 * atoi(opt_arg);
587 } else j = atoi(opt_arg);
589 if (i == OPT_MX) heapmaxsize = j;
590 else heapstartsize = j;
603 compileverbose = true;
606 case OPT_VERBOSEEXCEPTION:
607 verboseexception = true;
611 collectverbose = true;
614 #ifdef TYPECHECK_VERBOSE
616 typecheckverbose = true;
620 case OPT_VERBOSECALL:
637 opt_liberalutf = true;
645 getcompilingtime = true;
646 getloadingtime = true;
649 #if defined(STATISTICS)
656 strcpy(logfilename, opt_arg);
660 for (j = 0; j < strlen(opt_arg); j++) {
661 switch (opt_arg[j]) {
676 makeinitializations = false;
685 specificmethodname = opt_arg;
686 makeinitializations = false;
690 specificsignature = opt_arg;
696 makeinitializations = false;
699 case OPT_SHOW: /* Display options */
700 for (j = 0; j < strlen(opt_arg); j++) {
701 switch (opt_arg[j]) {
703 showdisassemble = true;
704 compileverbose = true;
707 showconstantpool = true;
710 showddatasegment = true;
713 showintermediate = true;
714 compileverbose = true;
733 for (j = 0; j < strlen(opt_arg); j++) {
734 switch (opt_arg[j]) {
736 /* define in options.h; Used in main.c, jit.c & inline.c */
745 inlinevirtuals = true;
749 inlineexceptions = true;
752 inlineparamopt = true;
755 inlineoutsiders = true;
763 #ifdef STATIC_ANALYSIS
765 opt_rt = true; /* default for inlining */
769 opt_xta = true; /* in test currently */
773 printf("\nVTA is not yet available\n");
775 /***opt_vta = true; not yet **/
781 #if defined(__I386__) || defined(__ALPHA__) || defined (__X86_64__) || defined(__POWERPC__)
784 printf("LSRA not available for this architecture\n");
791 printf("Unknown option: %s\n", argv[opt_ind]);
800 /* transform dots into slashes in the class name */
802 mainstring = argv[opt_ind++];
804 /* do not mangle jar filename */
805 for (i = strlen(mainstring) - 1; i >= 0; i--) {
806 if (mainstring[i] == '.') mainstring[i] = '/';
810 /* put jarfile in classpath */
812 classpath = MNEW(char, strlen(mainstring) + 1 + strlen(classpath) + 1);
813 strcpy(classpath, mainstring);
814 strcat(classpath, ":");
815 strcat(classpath, cp);
817 MFREE(cp, char, strlen(cp));
820 /**************************** Program start *****************************/
822 log_init(logfilename);
825 log_text("CACAO started -------------------------------------------------------");
827 /* initialize JavaVM */
829 vm_args.version = 0x00010001; /* New in 1.1.2: VM version */
831 /* Get the default initialization arguments and set the class path */
833 JNI_GetDefaultJavaVMInitArgs(&vm_args);
835 vm_args.minHeapSize = heapstartsize;
836 vm_args.maxHeapSize = heapmaxsize;
838 vm_args.classpath = classpath;
840 /* load and initialize a Java VM, return a JNI interface pointer in env */
842 JNI_CreateJavaVM(&jvm, &env, &vm_args);
845 /* initialize the garbage collector */
847 gc_init(heapmaxsize, heapstartsize);
851 /* initialize the loader with bootclasspath */
853 suck_init(bootclasspath);
855 cacao_initializing = true;
857 #if defined(USE_THREADS)
858 #if defined(NATIVE_THREADS)
864 /* install architecture dependent signal handler used for exceptions */
867 /* initializes jit compiler and codegen stuff */
870 /* initialize some cacao subsystems */
875 if (!loader_init((u1 *) &dummy))
876 throw_main_exception_exit();
879 throw_main_exception_exit();
882 throw_main_exception_exit();
884 if (!exceptions_init())
885 throw_main_exception_exit();
887 #if defined(USE_THREADS)
888 initThreads((u1 *) &dummy);
891 *threadrootmethod = NULL;
893 /*That's important, otherwise we get into trouble, if the Runtime static
894 initializer is called before (circular dependency. This is with
895 classpath 0.09. Another important thing is, that this has to happen
896 after initThreads!!! */
898 if (!class_init(class_java_lang_System))
899 throw_main_exception_exit();
901 cacao_initializing = false;
904 /* start worker routines **************************************************/
907 classinfo *cl; /* java/lang/ClassLoader */
908 classinfo *mainclass; /* java/lang/Class */
913 /* set return value to OK */
918 /* open jar file with java.util.jar.JarFile */
919 mainstring = getmainclassnamefromjar((JNIEnv *) &env, mainstring);
922 /* get system classloader */
924 m = class_resolveclassmethod(class_java_lang_ClassLoader,
925 utf_new_char("getSystemClassLoader"),
926 utf_new_char("()Ljava/lang/ClassLoader;"),
927 class_java_lang_Object,
930 cl = (classinfo *) asm_calljavafunction(m, NULL, NULL, NULL, NULL);
932 /* get `loadClass' method */
934 m = class_resolveclassmethod(cl->header.vftbl->class,
936 utf_java_lang_String__java_lang_Class,
937 class_java_lang_Object,
940 /* load the main class */
943 (classinfo *) asm_calljavafunction(m,
945 javastring_new_char(mainstring),
949 /* error loading class, clear exceptionptr for new exception */
951 if (*exceptionptr || !mainclass) {
952 /* *exceptionptr = NULL; */
954 /* *exceptionptr = */
955 /* new_exception_message(string_java_lang_NoClassDefFoundError, */
957 throw_main_exception_exit();
960 /* find the `main' method of the main class */
962 m = class_resolveclassmethod(mainclass,
963 utf_new_char("main"),
964 utf_new_char("([Ljava/lang/String;)V"),
965 class_java_lang_Object,
968 /* there is no main method or it isn't static */
970 if (*exceptionptr || !m || !(m->flags & ACC_STATIC)) {
971 *exceptionptr = NULL;
974 new_exception_message(string_java_lang_NoSuchMethodError,
976 throw_main_exception_exit();
979 /* build argument array */
981 a = builtin_anewarray(argc - opt_ind, class_java_lang_String);
982 for (i = opt_ind; i < argc; i++) {
983 a->data[i - opt_ind] =
984 (java_objectheader *) javastring_new(utf_new_char(argv[i]));
987 #ifdef TYPEINFO_DEBUG_TEST
988 /* test the typeinfo system */
991 /*class_showmethods(currentThread->group->header.vftbl->class); */
993 *threadrootmethod = m;
997 asm_calljavafunction(m, a, NULL, NULL, NULL);
999 /* exception occurred? */
1000 if (*exceptionptr) {
1001 throw_main_exception();
1005 #if defined(USE_THREADS)
1006 #if defined(NATIVE_THREADS)
1009 killThread(currentThread);
1013 /* now exit the JavaVM */
1015 /* (*jvm)->DestroyJavaVM(jvm); */
1020 /************* If requested, compile all methods ********************/
1028 /* create all classes found in the classpath */
1029 /* XXX currently only works with zip/jar's */
1030 create_all_classes();
1032 /* load and link all classes */
1033 for (slot = 0; slot < class_hash.size; slot++) {
1034 c = class_hash.ptr[slot];
1039 throw_main_exception_exit();
1043 throw_main_exception_exit();
1045 /* compile all class methods */
1046 for (i = 0; i < c->methodscount; i++) {
1047 m = &(c->methods[i]);
1049 (void) jit_compile(m);
1059 /******** If requested, compile a specific method ***************/
1061 if (specificmethodname) {
1064 /* create, load and link the main class */
1065 mainclass = class_new(utf_new_char(mainstring));
1067 if (!class_load(mainclass))
1068 throw_main_exception_exit();
1070 if (!class_link(mainclass))
1071 throw_main_exception_exit();
1073 if (specificsignature) {
1074 m = class_resolveclassmethod(mainclass,
1075 utf_new_char(specificmethodname),
1076 utf_new_char(specificsignature),
1080 m = class_resolveclassmethod(mainclass,
1081 utf_new_char(specificmethodname),
1088 char message[MAXLOGTEXT];
1089 sprintf(message, "%s%s", specificmethodname,
1090 specificsignature ? specificsignature : "");
1093 new_exception_message(string_java_lang_NoSuchMethodException,
1096 throw_main_exception_exit();
1104 /* keep compiler happy */
1110 /* cacao_exit ******************************************************************
1112 Calls java.lang.Runtime.exit(I)V to exit the JavaVM correctly.
1114 *******************************************************************************/
1116 void cacao_exit(s4 status)
1121 /* class should already be loaded, but who knows... */
1123 c = class_new(utf_new_char("java/lang/System"));
1126 throw_main_exception_exit();
1129 throw_main_exception_exit();
1131 /* call System.exit(I)V */
1133 m = class_resolveclassmethod(c,
1134 utf_new_char("exit"),
1135 utf_new_char("(I)V"),
1136 class_java_lang_Object,
1140 throw_main_exception_exit();
1142 /* call the exit function with passed exit status */
1144 /* both inlinevirtual and outsiders not allowed on exit */
1145 /* not sure if permanant or temp restriction */
1146 if (inlinevirtuals) inlineoutsiders = false;
1148 asm_calljavafunction(m, (void *) (ptrint) status, NULL, NULL, NULL);
1150 /* this should never happen */
1153 throw_exception_exit();
1155 throw_cacao_exception_exit(string_java_lang_InternalError,
1156 "System.exit(I)V returned without exception");
1160 /*************************** Shutdown function *********************************
1162 Terminates the system immediately without freeing memory explicitly (to be
1163 used only for abnormal termination)
1165 *******************************************************************************/
1167 void cacao_shutdown(s4 status)
1169 if (opt_verbose || getcompilingtime || opt_stat) {
1170 log_text("CACAO terminated by shutdown");
1171 dolog("Exit status: %d\n", (s4) status);
1179 * These are local overrides for various environment variables in Emacs.
1180 * Please do not remove this and leave it at the end of the file, where
1181 * Emacs will automagically detect them.
1182 * ---------------------------------------------------------------------
1185 * indent-tabs-mode: t