* src/vm/method.h (methodinfo): Removed isleafmethod, frequency,
[cacao.git] / src / cacaoh / headers.c
1 /* src/cacaoh/headers.c - functions for header generation
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
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., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28
29    Changes: Mark Probst
30             Philipp Tomsich
31             Christian Thalinger
32                         Edwin Steiner
33
34    $Id: headers.c 5079 2006-07-06 11:36:01Z twisti $
35
36 */
37
38
39 #include "config.h"
40
41 #include <assert.h>
42 #include <ctype.h>
43 #include <stdarg.h>
44 #include <stdlib.h>
45 #include <string.h>
46
47 #include "vm/types.h"
48
49 #if defined(ENABLE_THREADS)
50 # if defined(__DARWIN__)
51 #  include <signal.h>
52 # endif
53 # include <ucontext.h>
54 #endif
55
56 #include "mm/boehm.h"
57 #include "mm/memory.h"
58 #include "native/include/java_lang_String.h"
59 #include "native/include/java_lang_Throwable.h"
60 #include "toolbox/chain.h"
61 #include "toolbox/logging.h"
62 #include "vm/builtin.h"
63 #include "vm/class.h"
64 #include "vm/global.h"
65 #include "vm/method.h"
66 #include "vm/loader.h"
67 #include "vm/options.h"
68 #include "vm/stringlocal.h"
69 #include "vm/jit/asmpart.h"
70
71
72 #if defined(ENABLE_INTRP)
73 /* dummy interpreter stack to keep the compiler happy */
74
75 u1 *intrp_main_stack;
76 #endif
77
78
79 /* for raising exceptions from native methods *********************************/
80
81 #if !defined(ENABLE_THREADS)
82 java_objectheader *_no_threads_exceptionptr = NULL;
83 #endif
84
85
86 /* replace some non-vmcore functions ******************************************/
87
88 functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
89                                                                 bool isstatic)
90 {
91         /* return something different than NULL, otherwise we get an exception */
92
93         return (functionptr) 1;
94 }
95
96 java_objectheader *native_new_and_init(classinfo *c) { return NULL; }
97 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s) { return NULL; }
98 java_objectheader *native_new_and_init_int(classinfo *c, s4 i) { return NULL; }
99 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t) { return NULL; }
100
101
102 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
103 { return NULL; }
104
105 void vm_abort(const char *text, ...)
106 {
107         abort();
108 }
109
110 /* code patching functions */
111 void patcher_builtin_arraycheckcast(u1 *sp) {}
112
113 #if defined(__MIPS__)
114 long compare_and_swap(long *p, long oldval, long newval)
115 {
116         if (*p == oldval) {
117                 *p = newval;
118                 return oldval;
119         } else
120                 return *p;
121 }
122 #endif
123
124
125 u1 *createcompilerstub(methodinfo *m) { return NULL; }
126 #if defined(ENABLE_INTRP)
127 u1 *intrp_createcompilerstub(methodinfo *m) { return NULL; }
128 #endif
129
130 codeinfo *codegen_createnativestub(functionptr f, methodinfo *m) { return NULL; }
131
132 void removecompilerstub(u1 *stub) {}
133 void removenativestub(u1 *stub) {}
134
135 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop) {}
136 u1* asm_initialize_thread_stack(void *func, u1 *stack) { return NULL; }
137
138 void *asm_switchstackandcall(void *stack, void *func, void **stacktopsave, void * p) { return NULL; }
139
140 void asm_handle_builtin_exception(classinfo *c) {}
141 void asm_abstractmethoderror(void) {}
142
143 #if defined(ENABLE_JIT)
144 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out) {}
145 #endif
146
147 #if defined(ENABLE_INTRP)
148 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out) {}
149 #endif
150
151 u8 asm_get_cycle_count(void)
152 {
153         return 0;
154 }
155
156
157 void *Java_java_lang_VMObject_clone(void *env, void *clazz, void * this)
158 {
159         return NULL;
160 }
161
162 typecheck_result typeinfo_is_assignable_to_class(typeinfo *value,classref_or_classinfo dest)
163 {
164         return typecheck_TRUE;
165 }
166
167 void typeinfo_init_classinfo(typeinfo *info,classinfo *c)
168 {
169 }
170
171 bool typeinfo_init_class(typeinfo *info,classref_or_classinfo c)
172 {
173         return true;
174 }
175
176 void typeinfo_print(FILE *file,typeinfo *info,int indent) {}
177
178 void exceptions_print_exception(java_objectheader *xptr) {}
179 void stacktrace_print_trace(java_objectheader *xptr) {}
180
181 void code_free_code_of_method(methodinfo *m) {}
182
183
184 /* exception functions ********************************************************/
185
186 /* these should not be called */
187
188 void throw_main_exception_exit(void) { assert(0); }
189 void throw_exception(void) { assert(0); }
190 void throw_exception_exit(void) { assert(0); }
191
192 java_objectheader *new_verifyerror(methodinfo *m, const char *message)
193 {
194         assert(0);
195
196         /* keep compiler happy */
197
198         return NULL;
199 }
200
201 java_objectheader *new_exception_throwable(const char *classname, java_lang_Throwable *throwable)
202 {
203         assert(0);
204
205         /* keep compiler happy */
206
207         return NULL;
208 }
209
210
211 void throw_cacao_exception_exit(const char *exception, const char *message, ...)
212 {
213         va_list ap;
214
215         fprintf(stderr, "%s: ", exception);
216
217         va_start(ap, message);
218         vfprintf(stderr, message, ap);
219         va_end(ap);
220
221         fputc('\n', stderr);
222
223         exit(1);
224 }
225
226
227 void exceptions_throw_outofmemory_exit(void)
228 {
229         fprintf(stderr, "java.lang.InternalError: Out of memory\n");
230         exit(1);
231 }
232
233
234 java_objectheader *new_exception(const char *classname)
235 {
236         fprintf(stderr, "%s\n", classname);
237         exit(1);
238
239         /* keep compiler happy */
240
241         return NULL;
242 }
243
244
245 java_objectheader *new_exception_message(const char *classname, const char *message)
246 {
247         fprintf(stderr, "%s: %s\n", classname, message);
248         exit(1);
249
250         /* keep compiler happy */
251
252         return NULL;
253 }
254
255
256 java_objectheader *new_exception_utfmessage(const char *classname, utf *message)
257 {
258         fprintf(stderr, "%s: ", classname);
259         utf_display_printable_ascii(message);
260         fputc('\n', stderr);
261
262         exit(1);
263
264         /* keep compiler happy */
265
266         return NULL;
267 }
268
269
270 java_objectheader *new_exception_javastring(const char *classname,
271                                                                                         java_lang_String *message)
272 {
273         fprintf(stderr, "%s: ", classname);
274         /* TODO print message */
275         fputc('\n', stderr);
276
277         exit(1);
278
279         /* keep compiler happy */
280
281         return NULL;
282 }
283
284
285 void exceptions_throw_abstractmethoderror(void)
286 {
287         fprintf(stderr, "java.lang.AbstractMethodError\n");
288
289         exit(1);
290 }
291
292
293 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...)
294 {
295         va_list ap;
296
297         utf_display_printable_ascii(c->name);
298         fprintf(stderr, ": ");
299
300         va_start(ap, message);
301         vfprintf(stderr, message, ap);
302         va_end(ap);
303
304         fputc('\n', stderr);
305
306         exit(1);
307
308         /* keep compiler happy */
309
310         return NULL;
311 }
312
313
314 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
315 {
316         va_list ap;
317
318         va_start(ap, message);
319         (void) new_classformaterror(c, message, ap);
320         va_end(ap);
321 }
322
323
324 java_objectheader *new_classnotfoundexception(utf *name)
325 {
326         fprintf(stderr, "java.lang.ClassNotFoundException: ");
327         utf_fprint_printable_ascii(stderr, name);
328         fputc('\n', stderr);
329
330         exit(1);
331
332         /* keep compiler happy */
333
334         return NULL;
335 }
336
337
338 java_objectheader *new_noclassdeffounderror(utf *name)
339 {
340         fprintf(stderr, "java.lang.NoClassDefFoundError: ");
341         utf_fprint_printable_ascii(stderr, name);
342         fputc('\n', stderr);
343
344         exit(1);
345
346         /* keep compiler happy */
347
348         return NULL;
349 }
350
351
352 java_objectheader *exceptions_new_linkageerror(const char *message,
353                                                                                            classinfo *c)
354 {
355         fprintf(stderr, "java.lang.LinkageError: %s",message);
356         if (c) {
357                 utf_fprint_printable_ascii_classname(stderr, c->name);
358         }
359         fputc('\n', stderr);
360
361         exit(1);
362
363         /* keep compiler happy */
364
365         return NULL;
366 }
367
368 java_objectheader *exceptions_new_nosuchmethoderror(classinfo *c,
369                                                                                                         utf *name, utf *desc)
370 {
371         fprintf(stderr, "java.lang.NoSuchMethodError: ");
372         utf_fprint_printable_ascii(stderr, c->name);
373         fprintf(stderr, ".");
374         utf_fprint_printable_ascii(stderr, name);
375         utf_fprint_printable_ascii(stderr, desc);
376         fputc('\n', stderr);
377
378         exit(1);
379
380         /* keep compiler happy */
381
382         return NULL;
383 }
384
385
386 void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
387 {
388         (void) exceptions_new_nosuchmethoderror(c, name, desc);
389 }
390
391
392 java_objectheader *new_internalerror(const char *message, ...)
393 {
394         va_list ap;
395
396         fprintf(stderr, "%s: ", string_java_lang_InternalError);
397
398         va_start(ap, message);
399         vfprintf(stderr, message, ap);
400         va_end(ap);
401
402         exit(1);
403
404         /* keep compiler happy */
405
406         return NULL;
407 }
408
409
410 java_objectheader *new_unsupportedclassversionerror(classinfo *c, const char *message, ...)
411 {
412         va_list ap;
413
414         fprintf(stderr, "%s: ", string_java_lang_UnsupportedClassVersionError);
415
416         utf_display_printable_ascii(c->name);
417         fprintf(stderr, ": ");
418
419         va_start(ap, message);
420         vfprintf(stderr, message, ap);
421         va_end(ap);
422
423         exit(1);
424
425         /* keep compiler happy */
426
427         return NULL;
428 }
429
430
431 java_objectheader *new_illegalmonitorstateexception(void)
432 {
433         fprintf(stderr, "%s", string_java_lang_IllegalMonitorStateException);
434         exit(1);
435
436         /* keep compiler happy */
437
438         return NULL;
439 }
440
441
442 java_objectheader *new_negativearraysizeexception(void)
443 {
444         fprintf(stderr, "%s", string_java_lang_NegativeArraySizeException);
445         exit(1);
446
447         /* keep compiler happy */
448
449         return NULL;
450 }
451
452
453 void exceptions_throw_negativearraysizeexception(void)
454 {
455         (void) new_negativearraysizeexception();
456 }
457
458
459 java_objectheader *new_nullpointerexception(void)
460 {
461         fprintf(stderr, "%s", string_java_lang_NullPointerException);
462         exit(1);
463
464         /* keep compiler happy */
465
466         return NULL;
467 }
468
469
470 void exceptions_throw_nullpointerexception(void)
471 {
472         (void) new_nullpointerexception();
473 }
474
475
476 void classnotfoundexception_to_noclassdeffounderror(void)
477 {
478 }
479
480 /* machine dependent stuff ****************************************************/
481
482 #if defined(ENABLE_THREADS)
483 critical_section_node_t asm_criticalsections;
484 void thread_restartcriticalsection(ucontext_t *uc) {}
485 #endif
486
487 void md_param_alloc(methoddesc *md) {}
488
489
490 #if defined(ENABLE_INTRP)
491 void print_dynamic_super_statistics(void) {}
492 #endif
493
494
495 /************************ global variables **********************/
496
497 chain *ident_chain;     /* chain with method and field names in current class */
498 FILE *file = NULL;
499 static u4 outputsize;
500 static bool dopadding;
501
502
503 static void printIDpart(int c)
504 {
505         if ((c >= 'a' && c <= 'z') ||
506                 (c >= 'A' && c <= 'Z') ||
507                 (c >= '0' && c <= '9') ||
508                 (c == '_'))
509                 putc(c, file);
510         else
511                 putc('_', file);
512 }
513
514
515 void printID(utf *u)
516 {
517         char *utf_ptr = u->text;
518         int i;
519
520         for (i = 0; i < utf_get_number_of_u2s(u); i++) 
521                 printIDpart(utf_nextu2(&utf_ptr));
522 }
523
524
525 static void addoutputsize (int len)
526 {
527         u4 newsize,i;
528         if (!dopadding) return;
529
530         newsize = ALIGN(outputsize, len);
531         
532         for (i = outputsize; i < newsize; i++) fprintf(file, "   u1 pad%d\n", (int) i);
533         outputsize = newsize;
534 }
535
536
537 void printOverloadPart(utf *desc)
538 {
539         char *utf_ptr=desc->text;
540         u2 c;
541
542         fprintf(file, "__");
543
544         while ((c = utf_nextu2(&utf_ptr)) != ')') {
545                 switch (c) {
546                 case 'I':
547                 case 'S':
548                 case 'B':
549                 case 'C':
550                 case 'Z':
551                 case 'J':
552                 case 'F':
553                 case 'D': 
554                         fprintf(file, "%c", (char) c);
555                         break;
556                 case '[':
557                         fprintf(file, "_3");
558                         break;
559                 case 'L':
560                         putc('L', file);
561                         while ((c = utf_nextu2(&utf_ptr)) != ';')
562                                 printIDpart(c);
563                         fprintf(file, "_2");
564                         break;
565                 case '(':
566                         break;
567                 default: 
568                         log_text("invalid method descriptor");
569                         assert(0);
570                 }
571         }
572 }
573
574 static char *printtype(char *utf_ptr)
575 {
576         u2 c;
577
578         switch (utf_nextu2(&utf_ptr)) {
579         case 'V': fprintf (file, "void");
580                 break;
581         case 'I':
582         case 'S':
583         case 'B':
584         case 'C':
585         case 'Z': addoutputsize (4);
586                 fprintf (file, "s4");
587                 break;
588         case 'J': addoutputsize (8);
589                 fprintf (file, "s8");
590                 break;
591         case 'F': addoutputsize (4);
592                 fprintf (file, "float");
593                 break;
594         case 'D': addoutputsize (8);
595                 fprintf (file, "double");
596                 break;
597         case '[':
598                 addoutputsize ( sizeof(java_arrayheader*) ); 
599                 switch (utf_nextu2(&utf_ptr)) {
600                 case 'I':  fprintf (file, "java_intarray*"); break;
601                 case 'J':  fprintf (file, "java_longarray*"); break;
602                 case 'Z':  fprintf (file, "java_booleanarray*"); break;
603                 case 'B':  fprintf (file, "java_bytearray*"); break;
604                 case 'S':  fprintf (file, "java_shortarray*"); break;
605                 case 'C':  fprintf (file, "java_chararray*"); break;
606                 case 'F':  fprintf (file, "java_floatarray*"); break;
607                 case 'D':  fprintf (file, "java_doublearray*"); break;
608                                 
609                 case '[': fprintf(file, "java_objectarray*");
610                         while ((c = utf_nextu2(&utf_ptr)) == '[');
611                         if (c == 'L')
612                                 while (utf_nextu2(&utf_ptr) != ';');
613                         break;
614                            
615                 case 'L':  fprintf(file, "java_objectarray*");
616                         while (utf_nextu2(&utf_ptr) != ';');
617                         break;
618                 default:
619                         log_text("invalid type descriptor");
620                         assert(0);
621                 }
622                 break;
623                 
624         case 'L': 
625                 addoutputsize ( sizeof(java_objectheader*));
626                 fprintf (file, "struct ");
627                 while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c);     
628                 fprintf (file, "*");
629                 break;
630                                         
631         default:
632                 log_text("Unknown type in field descriptor");
633                 assert(0);
634         }
635         
636         return utf_ptr;
637 }
638
639
640 /***** determine the number of entries of a utf string in the ident chain *****/
641
642 static int searchidentchain_utf(utf *ident) 
643 {
644         utf *u = chain_first(ident_chain);     /* first element of list */
645         int count = 0;
646
647         while (u) {
648                 if (u==ident) count++;         /* string found */
649                 u = chain_next(ident_chain);   /* next element in list */ 
650         }
651
652         return count;
653 }
654
655
656 /************** print structure for direct access to objects ******************/
657
658 static void printfields(classinfo *c)
659 {
660         u4 i;
661         fieldinfo *f;
662         int ident_count;
663         
664         if (!c) {
665                 addoutputsize(sizeof(java_objectheader));
666                 fprintf(file, "   java_objectheader header;\n");
667                 return;
668         }
669                 
670         printfields(c->super.cls);
671         
672         for (i = 0; i < c->fieldscount; i++) {
673                 f = &(c->fields[i]);
674                 
675                 if (!(f->flags & ACC_STATIC)) {
676                         fprintf(file, "   ");
677                         printtype(f->descriptor->text);
678                         fprintf(file, " ");
679                         utf_fprint_printable_ascii(file, f->name);
680
681                         /* rename multiple fieldnames */
682                         if ((ident_count = searchidentchain_utf(f->name)))
683                                 fprintf(file, "%d", ident_count - 1);
684                         chain_addlast(ident_chain, f->name);    
685
686                         fprintf(file, ";\n");
687                 }
688         }
689 }
690
691
692 /***************** store prototype for native method in file ******************/
693
694 void printmethod(methodinfo *m)
695 {
696         char *utf_ptr;
697         u2 paramnum = 1;
698
699         /* search for return-type in descriptor */      
700         utf_ptr = m->descriptor->text;
701         while (utf_nextu2(&utf_ptr) != ')');
702
703         /* create remarks */
704         fprintf(file, "\n/*\n * Class:     ");
705         utf_fprint_printable_ascii(file, m->class->name);
706         fprintf(file, "\n * Method:    ");
707         utf_fprint_printable_ascii(file, m->name);
708         fprintf(file, "\n * Signature: ");
709         utf_fprint_printable_ascii(file, m->descriptor);
710         fprintf(file, "\n */\n");
711
712         /* create prototype */                  
713         fprintf(file, "JNIEXPORT ");
714         printtype(utf_ptr);
715         fprintf(file, " JNICALL Java_");
716         printID(m->class->name);
717
718         chain_addlast(ident_chain, m->name);
719
720         fprintf(file, "_");
721         printID(m->name);
722
723         /* ATTENTION: We use the methodinfo's stackcount variable as
724            nativelyoverloaded, so we can save some space during
725            runtime. */
726
727         if (m->stackcount)
728                 printOverloadPart(m->descriptor);
729
730         fprintf(file, "(JNIEnv *env");
731         
732         utf_ptr = m->descriptor->text + 1;
733                         
734         if (!(m->flags & ACC_STATIC)) {
735                 fprintf(file, ", struct ");
736                 printID(m->class->name);
737                 fprintf(file, "* this");
738
739         } else {
740                 fprintf(file, ", jclass clazz");
741         }
742
743         if ((*utf_ptr) != ')') fprintf(file, ", ");
744                         
745         while ((*utf_ptr) != ')') {
746                 utf_ptr = printtype(utf_ptr);
747                 fprintf(file, " par%d", paramnum++);
748                 if ((*utf_ptr)!=')') fprintf(file, ", ");
749         }
750                         
751         fprintf(file, ");\n\n");
752 }
753
754
755 /******* remove package-name in fully-qualified classname *********************/
756
757 void gen_header_filename(char *buffer, utf *u)
758 {
759         s4 i;
760   
761         for (i = 0; i < utf_get_number_of_u2s(u); i++) {
762                 if ((u->text[i] == '/') || (u->text[i] == '$')) {
763                         buffer[i] = '_';  /* convert '$' and '/' to '_' */
764
765                 } else {
766                         buffer[i] = u->text[i];
767                 }
768         }
769         buffer[utf_get_number_of_u2s(u)] = '\0';
770 }
771
772
773 /* create headerfile for classes and store native methods in chain ************/
774
775 void headerfile_generate(classinfo *c, char *opt_directory)
776 {
777         char header_filename[1024] = "";
778         char classname[1024]; 
779         char uclassname[1024];
780         u2 i;
781         methodinfo *m;                  
782         u2 j;
783         methodinfo *m2;
784         bool nativelyoverloaded;
785
786         /* prevent compiler warnings */
787
788         nativelyoverloaded = false;
789
790         /* open headerfile for class */
791         gen_header_filename(classname, c->name);
792
793         /* create chain for renaming fields */
794         ident_chain = chain_new();
795         
796         if (opt_directory) {
797                 sprintf(header_filename, "%s/%s.h", opt_directory, classname);
798
799         } else {
800                 sprintf(header_filename, "%s.h", classname);
801         }
802
803         file = fopen(header_filename, "w");
804         if (!file) {
805                 log_text("Can not open file to store header information");
806                 assert(0);
807         }
808
809         fprintf(file, "/* This file is machine generated, don't edit it! */\n\n");
810
811         /* convert to uppercase */
812         for (i = 0; classname[i]; i++) {
813                 uclassname[i] = toupper(classname[i]);
814         }
815         uclassname[i] = '\0';
816
817         fprintf(file, "#ifndef _%s_H\n#define _%s_H\n\n", uclassname, uclassname);
818
819         /* create structure for direct access to objects */     
820         fprintf(file, "/* Structure information for class: ");
821         utf_fprint_printable_ascii(file, c->name);
822         fprintf(file, " */\n\n");
823         fprintf(file, "typedef struct ");
824         printID(c->name);                                                       
825         fprintf(file, " {\n");
826         outputsize = 0;
827         dopadding = true;
828
829         printfields(c);
830
831         fprintf(file, "} ");
832         printID(c->name);
833         fprintf(file, ";\n\n");
834
835         /* create chain for renaming overloaded methods */
836         chain_free(ident_chain);
837         ident_chain = chain_new();
838
839         /* create method-prototypes */
840                                 
841         /* find overloaded methods */
842
843         for (i = 0; i < c->methodscount; i++) {
844                 m = &(c->methods[i]);
845
846                 if (!(m->flags & ACC_NATIVE))
847                         continue;
848
849                 /* We use the methodinfo's stackcount variable as
850                    nativelyoverloaded, so we can save some space during
851                    runtime. */
852
853                 if (!m->stackcount) {
854                         nativelyoverloaded = false;
855
856                         for (j = i + 1; j < c->methodscount; j++) {
857                                 m2 = &(c->methods[j]);
858
859                                 if (!(m2->flags & ACC_NATIVE))
860                                         continue;
861
862                                 if (m->name == m2->name) {
863                                         m2->stackcount     = true;
864                                         nativelyoverloaded = true;
865                                 }
866                         }
867                 }
868
869                 m->stackcount = nativelyoverloaded;
870         }
871
872         for (i = 0; i < c->methodscount; i++) {
873                 m = &(c->methods[i]);
874
875                 if (m->flags & ACC_NATIVE)
876                         printmethod(m);
877         }
878
879         chain_free(ident_chain);
880
881         fprintf(file, "#endif\n\n");
882
883         fclose(file);
884 }
885
886
887 /******** print classname, '$' used to seperate inner-class name ***********/
888
889 void print_classname(classinfo *clazz)
890 {
891         utf *u = clazz->name;
892     char *endpos  = u->text + u->blength;
893     char *utf_ptr = u->text; 
894         u2 c;
895
896     while (utf_ptr < endpos) {
897                 if ((c = utf_nextu2(&utf_ptr)) == '_')
898                         putc('$', file);
899                 else
900                         putc(c, file);
901         }
902
903
904 /* jvmti releated functions ************************************************/
905
906 #if defined(ENABLE_JVMTI)
907 void jvmti_ThreadStartEnd(int ev) {;}
908 void jvmti_ClassLoadPrepare(bool prepared, classinfo *c) {;}
909 void jvmti_MonitorContendedEntering(bool entered, jobject obj) {;}
910 #endif
911
912
913
914 /*
915  * These are local overrides for various environment variables in Emacs.
916  * Please do not remove this and leave it at the end of the file, where
917  * Emacs will automagically detect them.
918  * ---------------------------------------------------------------------
919  * Local variables:
920  * mode: c
921  * indent-tabs-mode: t
922  * c-basic-offset: 4
923  * tab-width: 4
924  * End:
925  * vim:noexpandtab:sw=4:ts=4:
926  */