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 2780 2005-06-22 10:51:03Z 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/statistics.h"
62 #include "vm/stringlocal.h"
63 #include "vm/tables.h"
64 #include "vm/classcache.h"
65 #include "vm/jit/asmpart.h"
66 #include "vm/jit/jit.h"
68 #ifdef TYPEINFO_DEBUG_TEST
69 #include "vm/jit/verify/typeinfo.h"
73 /* define heap sizes **********************************************************/
75 #define HEAP_MAXSIZE 64 * 1024 * 1024; /* default 64MB */
76 #define HEAP_STARTSIZE 2 * 1024 * 1024; /* default 2MB */
79 /* Invocation API variables ***************************************************/
81 JavaVM *jvm; /* denotes a Java VM */
82 JNIEnv *env; /* pointer to native method interface */
84 JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization arguments */
87 bool cacao_initializing;
89 char *bootclasspath; /* contains the boot classpath */
90 char *classpath; /* contains the classpath */
93 static classinfo *mainclass;
95 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
96 void **stackbottom = 0;
100 /* define command line options ************************************************/
102 #define OPT_CLASSPATH 2
106 #define OPT_VERBOSE1 6
107 #define OPT_VERBOSE 7
108 #define OPT_VERBOSEGC 8
109 #define OPT_VERBOSECALL 9
110 #define OPT_NOIEEE 10
111 #define OPT_SOFTNULL 11
114 #if defined(STATISTICS)
116 #endif /* defined(STATISTICS) */
121 #define OPT_METHOD 17
122 #define OPT_SIGNATURE 18
126 #define OPT_INLINING 25
128 #define STATIC_ANALYSIS
129 #if defined(STATIC_ANALYSIS)
133 #endif /* defined(STATIC_ANALYSIS) */
135 #define OPT_VERBOSETC 29
136 #define OPT_NOVERIFY 30
137 #define OPT_LIBERALUTF 31
138 #define OPT_VERBOSEEXCEPTION 32
143 #endif /* defined(LSRA) */
146 #define OPT_BOOTCLASSPATH 36
147 #define OPT_BOOTCLASSPATH_A 37
148 #define OPT_BOOTCLASSPATH_P 38
149 #define OPT_VERSION 39
152 opt_struct opts[] = {
153 { "classpath", true, OPT_CLASSPATH },
154 { "cp", true, OPT_CLASSPATH },
155 { "D", true, OPT_D },
156 { "Xms", true, OPT_MS },
157 { "Xmx", true, OPT_MX },
158 { "ms", true, OPT_MS },
159 { "mx", true, OPT_MX },
160 { "noasyncgc", false, OPT_IGNORE },
161 { "noverify", false, OPT_NOVERIFY },
162 { "liberalutf", false, OPT_LIBERALUTF },
163 { "oss", true, OPT_IGNORE },
164 { "ss", true, OPT_IGNORE },
165 { "v", false, OPT_VERBOSE1 },
166 { "verbose", false, OPT_VERBOSE },
167 { "verbosegc", false, OPT_VERBOSEGC },
168 { "verbosecall", false, OPT_VERBOSECALL },
169 { "verboseexception", false, OPT_VERBOSEEXCEPTION },
170 #ifdef TYPECHECK_VERBOSE
171 { "verbosetc", false, OPT_VERBOSETC },
173 #if defined(__ALPHA__)
174 { "noieee", false, OPT_NOIEEE },
176 { "softnull", false, OPT_SOFTNULL },
177 { "time", false, OPT_TIME },
178 #if defined(STATISTICS)
179 { "stat", false, OPT_STAT },
181 { "log", true, OPT_LOG },
182 { "c", true, OPT_CHECK },
183 { "l", false, OPT_LOAD },
184 { "eager", false, OPT_EAGER },
185 { "m", true, OPT_METHOD },
186 { "sig", true, OPT_SIGNATURE },
187 { "s", true, OPT_SHOW },
188 { "all", false, OPT_ALL },
189 { "oloop", false, OPT_OLOOP },
190 { "i", true, OPT_INLINING },
191 #ifdef STATIC_ANALYSIS
192 { "rt", false, OPT_RT },
193 { "xta", false, OPT_XTA },
194 { "vta", false, OPT_VTA },
197 { "lsra", false, OPT_LSRA },
199 { "jar", false, OPT_JAR },
200 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
201 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
202 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
203 { "version", false, OPT_VERSION },
208 /******************** interne Function: print_usage ************************
210 Prints the correct usage syntax to stdout.
212 ***************************************************************************/
216 printf("Usage: cacao [options] classname [program arguments]\n\n");
218 printf("Options:\n");
219 printf(" -cp <path> specify a path to look for classes\n");
220 printf(" -classpath <path> specify a path to look for classes\n");
221 printf(" -jar jarfile execute a jar file\n");
222 printf(" -D<name>=<value> add an entry to the property list\n");
223 printf(" -Xmx<size>[kK|mM] specify the size for the heap\n");
224 printf(" -Xms<size>[kK|mM] specify the initial size for the heap\n");
225 printf(" -mx<size>[kK|mM] specify the size for the heap\n");
226 printf(" -ms<size>[kK|mM] specify the initial size for the heap\n");
227 printf(" -Xbootclasspath:<path> set search path for bootstrap classes and resources\n");
228 printf(" -Xbootclasspath/a:<path> append to end of bootstrap class path\n");
229 printf(" -Xbootclasspath/p:<path> prepend in front of bootstrap class path\n");
230 printf(" -v ................... write state-information\n");
231 printf(" -verbose ............. write more information\n");
232 printf(" -verbosegc ........... write message for each GC\n");
233 printf(" -verbosecall ......... write message for each call\n");
234 printf(" -verboseexception .... write message for each step of stack unwinding\n");
235 #ifdef TYPECHECK_VERBOSE
236 printf(" -verbosetc ........... write debug messages while typechecking\n");
238 printf(" -version print product version and exit\n");
239 #if defined(__ALPHA__)
240 printf(" -noieee .............. don't use ieee compliant arithmetic\n");
242 printf(" -noverify ............ don't verify classfiles\n");
243 printf(" -liberalutf........... don't warn about overlong UTF-8 sequences\n");
244 printf(" -softnull ............ use software nullpointer check\n");
245 printf(" -time ................ measure the runtime\n");
246 #if defined(STATISTICS)
247 printf(" -stat ................ detailed compiler statistics\n");
249 printf(" -log logfile ......... specify a name for the logfile\n");
250 printf(" -c(heck)b(ounds) ..... don't check array bounds\n");
251 printf(" s(ync) ....... don't check for synchronization\n");
252 printf(" -oloop ............... optimize array accesses in loops\n");
253 printf(" -l ................... don't start the class after loading\n");
254 printf(" -eager ............... perform eager class loading and linking\n");
255 printf(" -all ................. compile all methods, no execution\n");
256 printf(" -m ................... compile only a specific method\n");
257 printf(" -sig ................. specify signature for a specific method\n");
258 printf(" -s(how)a(ssembler) ... show disassembled listing\n");
259 printf(" c(onstants) ... show the constant pool\n");
260 printf(" d(atasegment).. show data segment listing\n");
261 printf(" i(ntermediate). show intermediate representation\n");
262 printf(" m(ethods)...... show class fields and methods\n");
263 printf(" n(ative)....... show disassembled native stubs\n");
264 printf(" u(tf) ......... show the utf - hash\n");
265 printf(" -i n ............. activate inlining\n");
266 printf(" v ............. inline virtual methods\n");
267 printf(" uses/turns rt option on\n");
268 printf(" e ............. inline methods with exceptions\n");
269 printf(" p ............. optimize argument renaming\n");
270 printf(" o ............. inline methods of foreign classes\n");
271 #ifdef STATIC_ANALYSIS
272 printf(" -rt .................. use rapid type analysis\n");
273 printf(" -xta ................. use x type analysis\n");
274 printf(" -vta ................. use variable type analysis\n");
277 printf(" -lsra ................ use linear scan register allocation\n");
280 /* exit with error code */
286 /* version *********************************************************************
288 Only prints cacao version information and exits.
290 *******************************************************************************/
292 static void version()
294 printf("cacao "VERSION"\n");
299 #ifdef TYPECHECK_STATISTICS
300 void typecheck_print_statistics(FILE *file);
305 /* getmainclassfromjar ************************************************************
307 gets the name of the main class form a jar's manifest file
309 **********************************************************************************/
311 char *getmainclassnamefromjar(JNIEnv *env, char *mainstring)
317 class = (*env)->FindClass(env, "java/util/jar/JarFile");
319 log_text("unable to find java.util.jar.JarFile");
320 throw_main_exception_exit();
323 mid = (*env)->GetMethodID(NULL, class, "<init>","(Ljava/lang/String;)V");
325 log_text("unable to find constructor in java.util.jar.JarFile");
330 obj = (*env)->NewObject(NULL,class,mid,((*env)->NewStringUTF(NULL,(char*)mainstring)));
331 if ((*env)->ExceptionOccurred(NULL) != NULL) {
332 (*env)->ExceptionDescribe(NULL);
336 mid = (*env)->GetMethodID(NULL, class, "getManifest","()Ljava/util/jar/Manifest;");
338 log_text("unable to find getMainfest method");
342 /* get manifest object */
343 obj = (*env)->CallObjectMethod(NULL,obj,mid);
344 if ((*env)->ExceptionOccurred(NULL) != NULL) {
345 (*env)->ExceptionDescribe(NULL);
349 mid = (*env)->GetMethodID(NULL, (jclass)((java_objectheader*) obj)->vftbl->class, "getMainAttributes","()Ljava/util/jar/Attributes;");
351 log_text("unable to find getMainAttributes method");
355 /* get Main Attributes */
356 obj = (*env)->CallObjectMethod(NULL,obj,mid);
357 if ((*env)->ExceptionOccurred(NULL) != NULL) {
358 (*env)->ExceptionDescribe(NULL);
363 mid = (*env)->GetMethodID(NULL, (jclass)((java_objectheader*) obj)->vftbl->class, "getValue","(Ljava/lang/String;)Ljava/lang/String;");
365 log_text("unable to find getValue method");
369 /* get property Main-Class */
370 obj = (*env)->CallObjectMethod(NULL,obj,mid,(*env)->NewStringUTF(NULL,"Main-Class"));
371 if ((*env)->ExceptionOccurred(NULL) != NULL) {
372 (*env)->ExceptionDescribe(NULL);
376 return javastring_tochar((java_objectheader *) obj);
381 * void exit_handler(void)
382 * -----------------------
383 * The exit_handler function is called upon program termination to shutdown
384 * the various subsystems and release the resources allocated to the VM.
386 void exit_handler(void)
388 /********************* Print debug tables ************************/
390 if (showmethods) class_showmethods(mainclass);
391 if (showconstantpool) class_showconstantpool(mainclass);
392 if (showutf) utf_show();
394 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
395 clear_thread_flags(); /* restores standard file descriptor
399 /************************ Free all resources *******************/
404 MFREE(classpath, u1, strlen(classpath));
406 if (opt_verbose || getcompilingtime || opt_stat) {
407 log_text("CACAO terminated");
409 #if defined(STATISTICS)
412 #ifdef TYPECHECK_STATISTICS
413 typecheck_print_statistics(get_logfile());
417 if (getcompilingtime)
425 /************************** Function: main *******************************
429 **************************************************************************/
431 int main(int argc, char **argv)
436 /********** interne (nur fuer main relevante Optionen) **************/
438 char logfilename[200] = "";
444 char *specificmethodname = NULL;
445 char *specificsignature = NULL;
448 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
449 stackbottom = &dummy;
452 if (atexit(exit_handler))
453 throw_cacao_exception_exit(string_java_lang_InternalError,
454 "Unable to register exit_handler");
457 /************ Collect info from the environment ************************/
459 /* set the bootclasspath */
461 cp = getenv("BOOTCLASSPATH");
463 bootclasspath = MNEW(char, strlen(cp) + 1);
464 strcpy(bootclasspath, cp);
467 #if !defined(WITH_EXTERNAL_CLASSPATH)
468 cplen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_RT_JAR_PATH);
470 bootclasspath = MNEW(char, cplen + 1);
471 strcpy(bootclasspath, CACAO_INSTALL_PREFIX);
472 strcat(bootclasspath, CACAO_RT_JAR_PATH);
474 cplen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_VM_ZIP_PATH) +
475 strlen(EXTERNAL_CLASSPATH_PREFIX) + strlen(CLASSPATH_GLIBJ_ZIP_PATH);
477 bootclasspath = MNEW(char, cplen + 1 + 1);
478 strcpy(bootclasspath, CACAO_INSTALL_PREFIX);
479 strcat(bootclasspath, CACAO_VM_ZIP_PATH);
480 strcat(bootclasspath, ":");
481 strcat(bootclasspath, EXTERNAL_CLASSPATH_PREFIX);
482 strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP_PATH);
487 /* set the classpath */
489 cp = getenv("CLASSPATH");
491 classpath = MNEW(char, strlen(cp) + 1);
492 strcat(classpath, cp);
495 classpath = MNEW(char, 2);
496 strcpy(classpath, ".");
500 /***************** Interpret the command line *****************/
505 heapmaxsize = HEAP_MAXSIZE;
506 heapstartsize = HEAP_STARTSIZE;
509 while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
514 case OPT_BOOTCLASSPATH:
515 /* Forget default bootclasspath and set the argument as new boot */
517 MFREE(bootclasspath, char, strlen(bootclasspath));
519 bootclasspath = MNEW(char, strlen(opt_arg) + 1);
520 strcpy(bootclasspath, opt_arg);
523 case OPT_BOOTCLASSPATH_A:
524 /* append to end of bootclasspath */
525 cplen = strlen(bootclasspath);
527 bootclasspath = MREALLOC(bootclasspath,
530 cplen + 1 + strlen(opt_arg) + 1);
532 strcat(bootclasspath, ":");
533 strcat(bootclasspath, opt_arg);
536 case OPT_BOOTCLASSPATH_P:
537 /* prepend in front of bootclasspath */
541 bootclasspath = MNEW(char, strlen(opt_arg) + 1 + cplen + 1);
543 strcpy(bootclasspath, opt_arg);
544 strcat(bootclasspath, ":");
545 strcat(bootclasspath, cp);
547 MFREE(cp, char, cplen);
551 /* forget old classpath and set the argument as new classpath */
552 MFREE(classpath, char, strlen(classpath));
554 classpath = MNEW(char, strlen(opt_arg) + 1);
555 strcpy(classpath, opt_arg);
564 for (j = 0; j < strlen(opt_arg); j++) {
565 if (opt_arg[j] == '=') {
567 create_property(opt_arg, opt_arg + j + 1);
572 /* if no '=' is given, just create an empty property */
573 create_property(opt_arg, "");
583 c = opt_arg[strlen(opt_arg) - 1];
585 if (c == 'k' || c == 'K') {
586 j = 1024 * atoi(opt_arg);
588 } else if (c == 'm' || c == 'M') {
589 j = 1024 * 1024 * atoi(opt_arg);
591 } else j = atoi(opt_arg);
593 if (i == OPT_MX) heapmaxsize = j;
594 else heapstartsize = j;
607 compileverbose = true;
610 case OPT_VERBOSEEXCEPTION:
611 verboseexception = true;
615 collectverbose = true;
618 #ifdef TYPECHECK_VERBOSE
620 typecheckverbose = true;
624 case OPT_VERBOSECALL:
641 opt_liberalutf = true;
649 getcompilingtime = true;
650 getloadingtime = true;
653 #if defined(STATISTICS)
660 strcpy(logfilename, opt_arg);
664 for (j = 0; j < strlen(opt_arg); j++) {
665 switch (opt_arg[j]) {
680 makeinitializations = false;
689 specificmethodname = opt_arg;
690 makeinitializations = false;
694 specificsignature = opt_arg;
700 makeinitializations = false;
703 case OPT_SHOW: /* Display options */
704 for (j = 0; j < strlen(opt_arg); j++) {
705 switch (opt_arg[j]) {
707 showdisassemble = true;
708 compileverbose = true;
711 showconstantpool = true;
714 showddatasegment = true;
717 showintermediate = true;
718 compileverbose = true;
724 opt_shownativestub = true;
740 for (j = 0; j < strlen(opt_arg); j++) {
741 switch (opt_arg[j]) {
743 /* define in options.h; Used in main.c, jit.c & inline.c */
752 inlinevirtuals = true;
756 inlineexceptions = true;
759 inlineparamopt = true;
762 inlineoutsiders = true;
770 #ifdef STATIC_ANALYSIS
772 opt_rt = true; /* default for inlining */
776 opt_xta = true; /* in test currently */
780 printf("\nVTA is not yet available\n");
782 /***opt_vta = true; not yet **/
793 printf("Unknown option: %s\n", argv[opt_ind]);
802 /* transform dots into slashes in the class name */
804 mainstring = argv[opt_ind++];
806 /* do not mangle jar filename */
807 for (i = strlen(mainstring) - 1; i >= 0; i--) {
808 if (mainstring[i] == '.') mainstring[i] = '/';
812 /* put jarfile in classpath */
814 classpath = MNEW(char, strlen(mainstring) + 1 + strlen(classpath) + 1);
815 strcpy(classpath, mainstring);
816 strcat(classpath, ":");
817 strcat(classpath, cp);
819 MFREE(cp, char, strlen(cp));
822 /**************************** Program start *****************************/
824 log_init(logfilename);
827 log_text("CACAO started -------------------------------------------------------");
829 /* initialize JavaVM */
831 vm_args.version = 0x00010001; /* New in 1.1.2: VM version */
833 /* Get the default initialization arguments and set the class path */
835 JNI_GetDefaultJavaVMInitArgs(&vm_args);
837 vm_args.minHeapSize = heapstartsize;
838 vm_args.maxHeapSize = heapmaxsize;
840 vm_args.classpath = classpath;
842 /* load and initialize a Java VM, return a JNI interface pointer in env */
844 JNI_CreateJavaVM(&jvm, &env, &vm_args);
847 /* initialize the garbage collector */
849 gc_init(heapmaxsize, heapstartsize);
853 /* initialize the loader with bootclasspath */
855 suck_init(bootclasspath);
857 cacao_initializing = true;
859 #if defined(USE_THREADS)
860 #if defined(NATIVE_THREADS)
866 /* install architecture dependent signal handler used for exceptions */
870 /* initialize the codegen sub systems */
874 /* initializes jit compiler */
878 /* initialize some cacao subsystems */
882 if (!loader_init((u1 *) &dummy))
883 throw_main_exception_exit();
886 throw_main_exception_exit();
889 throw_main_exception_exit();
891 if (!exceptions_init())
892 throw_main_exception_exit();
895 throw_main_exception_exit();
897 #if defined(USE_THREADS)
898 initThreads((u1 *) &dummy);
901 *threadrootmethod = NULL;
903 /*That's important, otherwise we get into trouble, if the Runtime static
904 initializer is called before (circular dependency. This is with
905 classpath 0.09. Another important thing is, that this has to happen
906 after initThreads!!! */
908 if (!initialize_class(class_java_lang_System))
909 throw_main_exception_exit();
911 cacao_initializing = false;
914 /* start worker routines **************************************************/
917 classinfo *mainclass; /* java/lang/Class */
922 /* set return value to OK */
927 /* open jar file with java.util.jar.JarFile */
928 mainstring = getmainclassnamefromjar((JNIEnv *) &env, mainstring);
931 /* load the main class */
933 if (!(mainclass = load_class_from_sysloader(utf_new_char(mainstring))))
934 throw_main_exception_exit();
936 /* error loading class, clear exceptionptr for new exception */
938 if (*exceptionptr || !mainclass) {
939 /* *exceptionptr = NULL; */
941 /* *exceptionptr = */
942 /* new_exception_message(string_java_lang_NoClassDefFoundError, */
944 throw_main_exception_exit();
947 /* find the `main' method of the main class */
949 m = class_resolveclassmethod(mainclass,
950 utf_new_char("main"),
951 utf_new_char("([Ljava/lang/String;)V"),
952 class_java_lang_Object,
956 throw_main_exception_exit();
959 /* there is no main method or it isn't static */
961 if (!m || !(m->flags & ACC_STATIC)) {
962 *exceptionptr = NULL;
965 new_exception_message(string_java_lang_NoSuchMethodError,
967 throw_main_exception_exit();
970 /* build argument array */
972 a = builtin_anewarray(argc - opt_ind, class_java_lang_String);
973 for (i = opt_ind; i < argc; i++) {
974 a->data[i - opt_ind] =
975 (java_objectheader *) javastring_new(utf_new_char(argv[i]));
978 #ifdef TYPEINFO_DEBUG_TEST
979 /* test the typeinfo system */
982 /*class_showmethods(currentThread->group->header.vftbl->class); */
984 *threadrootmethod = m;
988 asm_calljavafunction(m, a, NULL, NULL, NULL);
990 /* exception occurred? */
992 throw_main_exception();
996 #if defined(USE_THREADS)
997 #if defined(NATIVE_THREADS)
1000 killThread(currentThread);
1004 /* now exit the JavaVM */
1006 /* (*jvm)->DestroyJavaVM(jvm); */
1011 /************* If requested, compile all methods ********************/
1018 classcache_name_entry *nmen;
1019 classcache_class_entry *clsen;
1021 /* create all classes found in the classpath */
1022 /* XXX currently only works with zip/jar's */
1024 loader_load_all_classes();
1026 /* link all classes */
1028 for (slot = 0; slot < classcache_hash.size; slot++) {
1029 nmen = (classcache_name_entry *) classcache_hash.ptr[slot];
1031 for (; nmen; nmen = nmen->hashlink) {
1032 /* iterate over all class entries */
1034 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1035 c = clsen->classobj;
1042 /*utf_fprint_classname(stderr,c->name);fprintf(stderr,"\n");*/
1046 throw_main_exception_exit();
1048 /* compile all class methods */
1049 for (i = 0; i < c->methodscount; i++) {
1050 m = &(c->methods[i]);
1052 /*fprintf(stderr," compiling:");utf_fprint(stderr,m->name);fprintf(stderr,"\n");*/
1053 (void) jit_compile(m);
1062 /******** If requested, compile a specific method ***************/
1064 if (specificmethodname) {
1067 /* create, load and link the main class */
1069 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
1070 throw_main_exception_exit();
1072 if (!link_class(mainclass))
1073 throw_main_exception_exit();
1075 if (specificsignature) {
1076 m = class_resolveclassmethod(mainclass,
1077 utf_new_char(specificmethodname),
1078 utf_new_char(specificsignature),
1082 m = class_resolveclassmethod(mainclass,
1083 utf_new_char(specificmethodname),
1090 char message[MAXLOGTEXT];
1091 sprintf(message, "%s%s", specificmethodname,
1092 specificsignature ? specificsignature : "");
1095 new_exception_message(string_java_lang_NoSuchMethodException,
1098 throw_main_exception_exit();
1106 /* keep compiler happy */
1112 /* cacao_exit ******************************************************************
1114 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1116 *******************************************************************************/
1118 void cacao_exit(s4 status)
1123 assert(class_java_lang_System);
1124 assert(class_java_lang_System->loaded);
1126 if (!link_class(class_java_lang_System))
1127 throw_main_exception_exit();
1129 /* call java.lang.System.exit(I)V */
1131 m = class_resolveclassmethod(class_java_lang_System,
1132 utf_new_char("exit"),
1134 class_java_lang_Object,
1138 throw_main_exception_exit();
1140 /* call the exit function with passed exit status */
1142 /* both inlinevirtual and outsiders not allowed on exit */
1143 /* not sure if permanant or temp restriction */
1144 if (inlinevirtuals) inlineoutsiders = false;
1146 asm_calljavafunction(m, (void *) (ptrint) status, NULL, NULL, NULL);
1148 /* this should never happen */
1151 throw_exception_exit();
1153 throw_cacao_exception_exit(string_java_lang_InternalError,
1154 "System.exit(I)V returned without exception");
1158 /*************************** Shutdown function *********************************
1160 Terminates the system immediately without freeing memory explicitly (to be
1161 used only for abnormal termination)
1163 *******************************************************************************/
1165 void cacao_shutdown(s4 status)
1167 if (opt_verbose || getcompilingtime || opt_stat) {
1168 log_text("CACAO terminated by shutdown");
1169 dolog("Exit status: %d\n", (s4) status);
1177 * These are local overrides for various environment variables in Emacs.
1178 * Please do not remove this and leave it at the end of the file, where
1179 * Emacs will automagically detect them.
1180 * ---------------------------------------------------------------------
1183 * indent-tabs-mode: t