Exceptions work now with nested builtin_news correctly (set the exception pointer...
[cacao.git] / headers.c
1 /* headers.c - main for header generation (cacaoh)
2
3    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4    R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5    M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6    P. Tomsich, J. Wenninger
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Reinhard Grafl
28
29    Changes: Mark Probst
30             Philipp Tomsich
31
32    $Id: headers.c 1112 2004-05-31 15:47:20Z jowenn $
33
34 */
35
36
37 #include <stdlib.h>
38 #include <string.h>
39 #include <ctype.h>
40 #include "config.h"
41 #include "global.h"
42 #include "tables.h"
43 #include "loader.h"
44 #include "builtin.h"
45 #include "mm/boehm.h"
46 #include "toolbox/chain.h"
47 #include "toolbox/memory.h"
48 #include "toolbox/logging.h"
49 #include "nat/java_lang_String.h"
50
51
52 /* replace command line options */
53
54 bool verbose =  false;
55 bool verboseexception =  false;
56 bool compileall = false;
57 bool runverbose = false;
58 bool collectverbose = false;
59
60 bool loadverbose = false;
61 bool linkverbose = false;
62 bool initverbose = false;
63
64 bool opt_rt = false;            /* true if RTA parse should be used     RT-CO */
65 bool opt_xta = false;           /* true if XTA parse should be used    XTA-CO */
66 bool opt_vta = false;           /* true if VTA parse should be used    VTA-CO */
67 bool opt_verify = true;        /* true if classfiles should be verified      */
68 bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences       */
69
70 bool opt_stat = false;
71 bool opt_eager = false;
72
73 bool showmethods = false;
74 bool showconstantpool = false;
75 bool showutf = false;
76
77 bool makeinitializations = true;
78
79 bool getloadingtime = false;
80 s8 loadingtime = 0;
81
82
83 /******* replace some external functions  *********/
84  
85 functionptr native_findfunction(utf *cname, utf *mname, utf *desc, bool isstatic)
86 { return NULL; }
87
88 java_objectheader *javastring_new(utf *text)
89 { return NULL; }
90
91 utf *javastring_toutf(java_lang_String *string, bool isclassname)
92 { return NULL; }
93
94
95 /* some exception stuff */
96
97 char *string_java_lang_IllegalMonitorStateException =
98     "java/lang/IllegalMonitorStateException";
99
100 char *string_java_lang_NegativeArraySizeException =
101     "java/lang/NegativeArraySizeException";
102
103
104 char *string_java_lang_AbstractMethodError =
105     "java/lang/AbstractMethodError";
106
107 char *string_java_lang_ClassCircularityError =
108     "java/lang/ClassCircularityError";
109
110 char *string_java_lang_ClassFormatError =
111     "java/lang/ClassFormatError";
112
113 char *string_java_lang_ExceptionInInitializerError =
114     "java/lang/ExceptionInInitializerError";
115
116 char *string_java_lang_IncompatibleClassChangeError =
117     "java/lang/IncompatibleClassChangeError";
118
119 char *string_java_lang_InternalError =
120     "java/lang/InternalError";
121
122 char *string_java_lang_LinkageError =
123     "java/lang/LinkageError";
124
125 char *string_java_lang_NoClassDefFoundError =
126     "java/lang/NoClassDefFoundError";
127
128 char *string_java_lang_NoSuchFieldError =
129     "java/lang/NoSuchFieldError";
130
131 char *string_java_lang_NoSuchMethodError =
132         "java/lang/NoSuchMethodError";
133
134 char *string_java_lang_OutOfMemoryError =
135     "java/lang/OutOfMemoryError";
136
137
138 void throw_exception_exit() {}
139
140 void throw_cacao_exception_exit(char *exception, char *message)
141 {
142         fprintf(stderr,
143                         "Exception in thread \"main\" %s: %s\n", exception, message);
144         fflush(stderr);
145
146         /* good bye! */
147         exit(1);
148 }
149
150
151 void new_exception(char *classname) {}
152 void new_exception_message(char *classname, char *message) {}
153 void new_exception_throwable(char *classname, java_objectheader *t) {}
154 void new_exception_utfmessage(char *classname, utf *message)
155 {
156         printf("%s: ", classname);
157         utf_display(message);
158         printf("\n");
159         exit(1);
160 }
161
162 java_objectheader *literalstring_new(utf *u) { return NULL; }  
163
164
165 void literalstring_free(java_objectheader *o) { }
166 void stringtable_update() { }
167 void synchronize_caches() { }
168 void asm_call_jit_compiler() { }
169 void asm_calljavafunction() { }
170 s4 asm_builtin_checkcast(java_objectheader *obj, classinfo *class) { return 0; }
171
172 s4 asm_builtin_idiv(s4 a, s4 b) {return 0;}
173 s4 asm_builtin_irem(s4 a, s4 b) {return 0;}
174 s8 asm_builtin_ldiv(s8 a, s8 b) {return 0;}
175 s8 asm_builtin_lrem(s8 a, s8 b) {return 0;}
176
177 s4 asm_builtin_f2i(float a) { return 0; }
178 s8 asm_builtin_f2l(float a) { return 0; }
179 s4 asm_builtin_d2i(double a) { return 0; }
180 s8 asm_builtin_d2l(double a) { return 0; }
181
182 void asm_builtin_monitorenter(java_objectheader *o) {}
183 void asm_builtin_monitorexit(java_objectheader *o) {}
184
185 s4 asm_builtin_checkarraycast(java_objectheader *obj, vftbl *target) {return 0;}
186
187
188 #if defined(__I386__)
189 s4 asm_builtin_arrayinstanceof(java_objectheader *obj, classinfo *class) { return 0; }
190 void asm_builtin_newarray(s4 size, vftbl *arrayvftbl) {}
191 #endif
192
193 void asm_builtin_aastore(java_objectarray *a, s4 index, java_objectheader *o) {}
194
195 u1 *createcompilerstub(methodinfo *m) {return NULL;}
196 u1 *createnativestub(functionptr f, methodinfo *m) {return NULL;}
197 u1 *oldcreatenativestub(functionptr f, methodinfo *m) {return NULL;}
198
199 void removecompilerstub(u1 *stub) {}
200 void removenativestub(u1 *stub) {}
201
202 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop) {}
203 u1* asm_initialize_thread_stack(void *func, u1 *stack) { return NULL; }
204 void thread_restartcriticalsection() {}
205 void asm_switchstackandcall() {}
206 void asm_handle_builtin_exception(classinfo *c) {}
207 void asm_getclassvalues_atomic() {}
208
209 #if defined(__DARWIN__)
210 int cacao_catch_Handler() {}
211 #endif
212
213 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
214 threadcritnode asm_criticalsections;
215 #endif
216
217 java_objectheader *native_new_and_init(void *p) { return NULL; }
218
219
220 /************************ global variables **********************/
221
222 THREADSPECIFIC java_objectheader *_exceptionptr;
223
224 static chain *nativemethod_chain;    /* chain with native methods     */
225 static chain *nativeclass_chain;                               /* chain with processed classes  */      
226 static chain *ident_chain;        /* chain with method and field names in current class */
227 static FILE *file = NULL;
228 static u4 outputsize;
229 static bool dopadding;
230
231
232 static void printIDpart(int c) 
233 {
234         if ((c >= 'a' && c <= 'z')
235                 || (c >= 'A' && c <= 'Z')
236                 || (c >= '0' && c <= '9')
237                 || (c == '_'))
238                 putc(c, file);
239         else
240                 putc('_', file);
241 }
242
243
244 static void printID(utf *u)
245 {
246         char *utf_ptr = u->text;
247         int i;
248
249         for (i = 0; i < utf_strlen(u); i++) 
250                 printIDpart(utf_nextu2(&utf_ptr));
251 }
252
253
254 static void addoutputsize (int len)
255 {
256         u4 newsize,i;
257         if (!dopadding) return;
258
259         newsize = ALIGN(outputsize, len);
260         
261         for (i = outputsize; i < newsize; i++) fprintf(file, "   u1 pad%d\n", (int) i);
262         outputsize = newsize;
263 }
264
265
266 static char *printtype(char *utf_ptr)
267 {
268         u2 c;
269
270         switch (utf_nextu2(&utf_ptr)) {
271         case 'V': fprintf (file, "void");
272                 break;
273         case 'I':
274         case 'S':
275         case 'B':
276         case 'C':
277         case 'Z': addoutputsize (4);
278                 fprintf (file, "s4");
279                 break;
280         case 'J': addoutputsize (8);
281                 fprintf (file, "s8");
282                 break;
283         case 'F': addoutputsize (4);
284                 fprintf (file, "float");
285                 break;
286         case 'D': addoutputsize (8);
287                 fprintf (file, "double");
288                 break;
289         case '[':
290                 addoutputsize ( sizeof(java_arrayheader*) ); 
291                 switch (utf_nextu2(&utf_ptr)) {
292                 case 'I':  fprintf (file, "java_intarray*"); break;
293                 case 'J':  fprintf (file, "java_longarray*"); break;
294                 case 'Z':  fprintf (file, "java_booleanarray*"); break;
295                 case 'B':  fprintf (file, "java_bytearray*"); break;
296                 case 'S':  fprintf (file, "java_shortarray*"); break;
297                 case 'C':  fprintf (file, "java_chararray*"); break;
298                 case 'F':  fprintf (file, "java_floatarray*"); break;
299                 case 'D':  fprintf (file, "java_doublearray*"); break;
300                                 
301                 case '[':  fprintf (file, "java_objectarray*");                                        
302                         while ((c = utf_nextu2(&utf_ptr)) == '[') ;
303                         if (c=='L') 
304                                 while (utf_nextu2(&utf_ptr) != ';');
305                         break;
306                            
307                 case 'L':  fprintf (file, "java_objectarray*");
308                         while ( utf_nextu2(&utf_ptr) != ';');
309                         break;
310                 default: panic ("invalid type descriptor");
311                 }
312                 break;
313                 
314         case 'L': 
315                 addoutputsize ( sizeof(java_objectheader*));
316                 fprintf (file, "struct ");
317                 while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c);     
318                 fprintf (file, "*");
319                 break;
320                                         
321         default:  panic ("Unknown type in field descriptor");
322         }
323         
324         return utf_ptr;
325 }
326
327
328 /***** determine the number of entries of a utf string in the ident chain *****/
329
330 static int searchidentchain_utf(utf *ident) 
331 {
332         utf *u = chain_first(ident_chain);     /* first element of list */
333         int count = 0;
334
335         while (u) {
336                 if (u==ident) count++;         /* string found */
337                 u = chain_next(ident_chain);   /* next element in list */ 
338         }
339
340         return count;
341 }
342
343
344 /************** print structure for direct access to objects ******************/
345
346 static void printfields(classinfo *c)
347 {
348         u4 i;
349         fieldinfo *f;
350         int ident_count;
351         
352         if (!c) {
353                 addoutputsize(sizeof(java_objectheader));
354                 fprintf(file, "   java_objectheader header;\n");
355                 return;
356         }
357                 
358         printfields(c->super);
359         
360         for (i = 0; i < c->fieldscount; i++) {
361                 f = &(c->fields[i]);
362                 
363                 if (!(f->flags & ACC_STATIC)) {
364                         fprintf(file, "   ");
365                         printtype(f->descriptor->text);
366                         fprintf(file, " ");
367                         utf_fprint(file, f->name);
368
369                         /* rename multiple fieldnames */
370                         if ((ident_count = searchidentchain_utf(f->name)))
371                                 fprintf(file, "%d", ident_count - 1);
372                         chain_addlast(ident_chain, f->name);    
373
374                         fprintf(file, ";\n");
375                 }
376         }
377 }
378
379
380 /***************** store prototype for native method in file ******************/
381
382 static void printmethod(methodinfo *m)
383 {
384         char *utf_ptr;
385         u2 paramnum = 1;
386         u2 ident_count;
387
388         /* search for return-type in descriptor */      
389         utf_ptr = m->descriptor->text;
390         while (utf_nextu2(&utf_ptr) != ')');
391
392         /* create remarks */
393         fprintf(file, "\n/*\n * Class:     ");
394         utf_fprint(file, m->class->name);
395         fprintf(file, "\n * Method:    ");
396         utf_fprint(file, m->name);
397         fprintf(file, "\n * Signature: ");
398         utf_fprint(file, m->descriptor);
399         fprintf(file, "\n */\n");       
400
401         /* create prototype */                  
402         fprintf(file, "JNIEXPORT ");                            
403         printtype(utf_ptr);
404         fprintf(file, " JNICALL Java_");
405         printID(m->class->name);           
406
407         /* rename overloaded method */
408         if ((ident_count = searchidentchain_utf(m->name)))
409                 fprintf(file, "%d", ident_count - 1);           
410         chain_addlast(ident_chain, m->name);    
411
412         fprintf(file, "_");
413         printID(m->name);
414         fprintf(file, "(JNIEnv *env");
415         
416         utf_ptr = m->descriptor->text + 1;
417                         
418         if (!(m->flags & ACC_STATIC)) {
419                 fprintf(file, ", struct ");
420                 printID(m->class->name);
421                 fprintf(file, "* this");
422
423         } else {
424                 fprintf(file, ", jclass clazz");
425         }
426
427         if ((*utf_ptr) != ')') fprintf(file, ", ");
428                         
429         while ((*utf_ptr) != ')') {
430                 utf_ptr = printtype(utf_ptr);
431                 fprintf(file, " par%d", paramnum++);
432                 if ((*utf_ptr)!=')') fprintf(file, ", ");
433         }
434                         
435         fprintf(file, ");\n\n");
436 }
437
438
439 /******* remove package-name in fully-qualified classname *********************/
440
441 static void gen_header_filename(char *buffer, utf *u)
442 {
443         int i;
444   
445         for (i = 0;i < utf_strlen(u); i++) {
446                 if ((u->text[i] == '/') || (u->text[i] == '$')) buffer[i] = '_';  /* convert '$' and '/' to '_' */
447                 else buffer[i] = u->text[i];
448         }
449         buffer[utf_strlen(u)] = '\0';
450 }
451
452
453 /* create headerfile for classes and store native methods in chain ************/
454
455 static void headerfile_generate(classinfo *c)
456 {
457         char header_filename[1024] = "";
458         char classname[1024]; 
459         char uclassname[1024];
460         u2 i;
461         methodinfo *m;                  
462                       
463         /* store class in chain */                    
464         chain_addlast(nativeclass_chain, c);
465                                 
466         /* open headerfile for class */
467         gen_header_filename(classname, c->name);
468
469         /* create chain for renaming fields */
470         ident_chain = chain_new();
471         
472         sprintf(header_filename, "nat/%s.h", classname);
473         file = fopen(header_filename, "w");
474         if (!file) panic("Can not open file to store header information");
475
476         fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n");
477
478         /* convert to uppercase */
479         for (i = 0; classname[i]; i++) {
480                 uclassname[i] = toupper(classname[i]);
481         }
482         uclassname[i] = '\0';
483
484         fprintf(file, "#ifndef _%s_H\n#define _%s_H\n\n", uclassname, uclassname);
485
486         /* create structure for direct access to objects */     
487         fprintf(file, "/* Structure information for class: ");
488         utf_fprint(file, c->name);
489         fprintf(file, " */\n\n");
490         fprintf(file, "typedef struct ");
491         printID(c->name);                                                       
492         fprintf(file, " {\n");
493         outputsize = 0;
494         dopadding = true;
495
496         printfields(c);
497
498         fprintf(file, "} ");
499         printID(c->name);
500         fprintf(file, ";\n\n");
501
502         /* create chain for renaming overloaded methods */
503         chain_free(ident_chain);
504         ident_chain = chain_new();
505
506         /* create method-prototypes */
507                                 
508         for (i = 0; i < c->methodscount; i++) {
509
510                 m = &(c->methods[i]);
511
512                 if (m->flags & ACC_NATIVE) {
513                         chain_addlast(nativemethod_chain, m);
514                         printmethod(m);
515                 }
516         }
517
518         chain_free(ident_chain);
519
520         fprintf(file, "#endif\n\n");
521
522         fclose(file);
523 }
524
525
526 /******** print classname, '$' used to seperate inner-class name ***********/
527
528 void print_classname(classinfo *clazz)
529 {
530         utf *u = clazz->name;
531     char *endpos  = u->text + u->blength;
532     char *utf_ptr = u->text; 
533         u2 c;
534
535     while (utf_ptr < endpos) {
536                 if ((c = utf_nextu2(&utf_ptr)) == '_') {
537                         putc('$', file);
538
539                 } else {
540                         putc(c, file);
541                 }
542         }
543
544
545
546 /*************** create table for locating native functions ****************/
547
548 static void printnativetableentry(methodinfo *m)
549 {
550         fprintf(file, "   { \"");
551         print_classname(m->class);
552         fprintf(file, "\",\n     \"");
553         utf_fprint(file, m->name);
554         fprintf(file, "\",\n     \"");
555         utf_fprint(file, m->descriptor);
556         fprintf(file, "\",\n     ");
557
558         if ((m->flags & ACC_STATIC) != 0)
559                 fprintf(file, "true");
560         else
561                 fprintf(file, "false");
562
563         fprintf(file, ",\n     ");
564         fprintf(file, "(functionptr) Java_");
565         printID(m->class->name);
566         fprintf(file,"_");
567         printID(m->name);
568         fprintf(file,"\n   },\n");
569 }
570
571
572 /***************************************************************************
573
574         create the nativetypes-headerfile which includes 
575         the headerfiles of the classes stored in the classes-chain 
576
577 ****************************************************************************/
578
579 static void headers_finish()
580 {
581         methodinfo *m;
582         classinfo *c;
583         char classname[1024];
584         
585         file = fopen("nativetypes.hh", "w");
586
587         if (!file)
588                 panic("Can not open file 'native.h' to store header information");
589         
590         fprintf(file, "/* Headerfile for native methods: nativetypes.hh */\n");
591         fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n");      
592         fprintf(file, "\n/* include native-Headerfiles */\n\n");
593                         
594         c = chain_first(nativeclass_chain);
595         while (c) {
596                 dopadding = false;
597                 gen_header_filename(classname, c->name);                                                                                                                                                                                        
598                 fprintf(file, "#include \"nat/%s.h\"\n", classname);            
599                 c = chain_next(nativeclass_chain);              
600         }
601
602     fclose(file);
603         chain_free(nativeclass_chain);
604         
605         /* create table of native-methods */
606
607         file = fopen("nativetable.hh", "w");
608
609         if (!file)
610                 panic("Can not open file 'nativetable' to store native-link-table");
611
612         fprintf(file, "/* Table of native methods: nativetables.hh */\n");
613         fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n"); 
614
615         while ((m = chain_first(nativemethod_chain)) != NULL) {
616                 chain_remove(nativemethod_chain);               
617                 printnativetableentry(m);
618         }
619                 
620         chain_free(nativemethod_chain);
621         fclose(file);
622 }
623
624
625 /******************** internal function: print_usage ************************
626
627 Prints usage information for the JAVA header generator to stdout.
628
629 ***************************************************************************/
630
631 static void print_usage()
632 {
633         printf("Usage: cacaoh class [class..]\n");
634 }   
635
636
637
638 /************************** Function: main *******************************
639
640    Main program.
641    
642 **************************************************************************/
643
644 int main(int argc, char **argv)
645 {
646         s4 i,a;
647         char *cp;
648         classinfo *topclass;
649                 
650
651         /********** internal (only used by main) *****************************/
652    
653         char classpath[500] = "";
654         char offsets_filename[1024] = ""; /* phil */
655         u4 heapmaxsize = 1000000;
656         u4 heapstartsize = 100000;
657
658         /*********** options so only headers are generated *******************/
659    
660         makeinitializations = false;
661    
662
663         /************ Collect some info from the environment *****************/
664
665         cp = getenv("CLASSPATH");
666         if (cp) {
667                 strcpy(classpath + strlen(classpath), ":");
668                 strcpy(classpath + strlen(classpath), cp);
669         }
670
671         if (argc < 2) {
672                 print_usage();
673                 exit(10);
674         }
675
676
677         /**************************** Program start **************************/
678
679         log_init(NULL);
680         log_text("Java - header-generator started"); 
681         
682         sprintf(offsets_filename, "jit/%s/offsets.h", ARCH_DIR);
683         file = fopen(offsets_filename, "w");
684         if (file == NULL) {
685                 fprintf(stderr, "Can not open file '%s' for write", offsets_filename);
686                 exit(-1);
687         }
688         
689         fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n"); 
690
691         fprintf(file, "#define offobjvftbl    %3d\n", (int) OFFSET(java_objectheader, vftbl));
692         fprintf(file, "#define offarraysize   %3d\n", (int) OFFSET(java_arrayheader, size));
693         fprintf(file, "#define offobjarrdata  %3d\n\n", (int) OFFSET(java_objectarray, data[0]));
694         fprintf(file, "#define offbaseval     %3d\n", (int) OFFSET(vftbl, baseval));
695         fprintf(file, "#define offdiffval     %3d\n\n", (int) OFFSET(vftbl, diffval));
696         fprintf(file, "#define offclass     %3d\n\n", (int) OFFSET(vftbl, class));
697
698         fprintf(file, "#define offclassvftbl  %3d\n", (int) OFFSET(classinfo, vftbl));
699         fprintf(file, "#define offclassinit   %3d\n", (int) OFFSET(classinfo, initialized));
700         fprintf(file, "#define offclassloaded %3d\n", (int) OFFSET(classinfo, loaded));
701         fprintf(file, "#define offclasslinked %3d\n\n", (int) OFFSET(classinfo, linked));
702
703         fprintf(file, "#define offjniitemtype %3d\n", (int) OFFSET(jni_callblock, itemtype));
704         fprintf(file, "#define offjniitem     %3d\n", (int) OFFSET(jni_callblock, item));
705         fprintf(file, "#define sizejniblock   %3d\n\n", (int) sizeof(jni_callblock));
706
707         fprintf(file, "#define offclassmethodinfo   %3d\n\n", (int) OFFSET(methodinfo,class));
708
709         fprintf(file, "#define offmethodnative %3d\n", (int) OFFSET(native_stackframeinfo,method));
710 /*      fprintf(file, "#define offreturnfromnative %3d\n", (int) OFFSET(native_stackframeinfo,returnFromNative));
711         fprintf(file, "#define offaddrreturnfromnative %3d\n", (int) OFFSET(native_stackframeinfo,addrReturnFromNative));
712         fprintf(file, "#define offprevnative %3d\n", (int) OFFSET(native_stackframeinfo,prev));
713         fprintf(file, "#define offnextnative %3d\n", (int) OFFSET(native_stackframeinfo,next));*/
714
715         fprintf(file, "\n");
716         fprintf(file, "#define offcast_super_baseval  %3d\n", (int) OFFSET(castinfo, super_baseval));
717         fprintf(file, "#define offcast_super_diffval  %3d\n", (int) OFFSET(castinfo, super_diffval));
718         fprintf(file, "#define offcast_sub_baseval    %3d\n", (int) OFFSET(castinfo, sub_baseval));
719
720         fclose(file);
721
722         /* initialize the garbage collector */
723         gc_init(heapmaxsize, heapstartsize);
724
725         suck_init(classpath);
726    
727         tables_init();
728
729 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
730         initThreadsEarly();
731 #endif
732         loader_init();
733
734
735         /*********************** Load JAVA classes  **************************/
736         
737         nativemethod_chain = chain_new();
738         nativeclass_chain = chain_new();
739         
740         for (a = 1; a < argc; a++) {
741                 cp = argv[a];
742
743                 /* convert classname */
744                 for (i = strlen(cp) - 1; i >= 0; i--) {
745                         switch (cp[i]) {
746                         case '.': cp[i]='/';
747                                 break;
748                         case '_': cp[i]='$';    
749                         }
750                 }
751         
752 /*              topclass = loader_load(utf_new_char(cp)); */
753                 topclass = class_load(class_new(utf_new_char(cp)));
754                 class_link(topclass);
755
756         headerfile_generate(topclass);
757         }
758
759         headers_finish();
760
761         /************************ Release all resources **********************/
762
763         loader_close();
764         tables_close(literalstring_free);
765
766         /* Print "finished" message */
767
768         log_text("Java - header-generator stopped");
769         log_cputime();
770         mem_usagelog(1);
771         
772         return 0;
773 }
774
775
776 void setVMClassField(classinfo *c)
777 {
778 }
779
780
781 void *Java_java_lang_VMObject_clone(void *env, void *clazz, void * this) {
782         return 0;
783 }
784
785
786 /*
787  * These are local overrides for various environment variables in Emacs.
788  * Please do not remove this and leave it at the end of the file, where
789  * Emacs will automagically detect them.
790  * ---------------------------------------------------------------------
791  * Local variables:
792  * mode: c
793  * indent-tabs-mode: t
794  * c-basic-offset: 4
795  * tab-width: 4
796  * End:
797  */