Removed GC_DEBUG for x86_64
[cacao.git] / native.c
1 /* native.c - table of native functions
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             Roman Obermaisser
29             Andreas Krall
30
31    The .hh files created with the header file generator are all
32    included here as are the C functions implementing these methods.
33
34    $Id: native.c 912 2004-02-05 21:20:33Z twisti $
35
36 */
37
38
39 #include <stdlib.h>
40 #include <unistd.h>
41 #include <time.h>
42 #include <math.h>
43 #include <string.h>
44 #include <assert.h>
45 #include <sys/time.h>
46 #include <utime.h>
47
48 #include "config.h"
49 #include "global.h"
50 #include "jni.h"
51 #include "native.h"
52 #include "nativetypes.hh"
53 #include "builtin.h"
54 #include "asmpart.h"
55 #include "tables.h"
56 #include "loader.h"
57 #include "jni.h"
58 #include "toolbox/loging.h"
59 #include "toolbox/memory.h"
60 #include "threads/thread.h"
61 #include "threads/threadio.h"
62 #include "threads/locks.h"
63
64 /* Include files for IO functions */
65
66 #include <fcntl.h>
67 #include <dirent.h>
68 #include <sys/types.h>
69 #ifdef _OSF_SOURCE 
70 #include <sys/mode.h>
71 #endif
72 #include <sys/stat.h>
73
74 #include "threads/threadio.h"
75
76 /* searchpath for classfiles */
77 char *classpath;
78
79 /* for java-string to char conversion */
80 #define MAXSTRINGSIZE 1000                          
81
82 /******************** systemclasses required for native methods ***************/
83
84 classinfo *class_java_lang_Class;
85 classinfo *class_java_lang_VMClass;
86 methodinfo *method_vmclass_init;
87 /* static classinfo *class_java_lang_Cloneable=0; */ /* now in global.h */
88 classinfo *class_java_lang_CloneNotSupportedException;
89 classinfo *class_java_lang_System;
90 classinfo *class_java_lang_ClassLoader;
91 classinfo *class_java_lang_NoClassDefFoundError;
92 classinfo *class_java_lang_ClassNotFoundException;
93 classinfo *class_java_lang_LinkageError;
94 classinfo *class_java_lang_InstantiationException;
95 classinfo *class_java_lang_NoSuchMethodError;   
96 classinfo *class_java_lang_NoSuchFieldError;
97 classinfo *class_java_lang_ClassFormatError;
98 classinfo *class_java_lang_IllegalArgumentException;
99 classinfo *class_java_lang_ArrayIndexOutOfBoundsException;
100 classinfo *class_java_lang_NoSuchFieldException;
101 classinfo *class_java_io_SyncFailedException;
102 classinfo *class_java_io_IOException;
103 classinfo *class_java_io_FileNotFoundException;
104 classinfo *class_java_io_UnixFileSystem;
105 classinfo *class_java_security_PrivilegedActionException;
106 classinfo *class_java_net_UnknownHostException;
107 classinfo *class_java_net_SocketException;
108 classinfo *class_java_lang_NoSuchMethodException;
109 classinfo *class_java_lang_Double;
110 classinfo *class_java_lang_Float;
111 classinfo *class_java_lang_Long;
112 classinfo *class_java_lang_Byte;
113 classinfo *class_java_lang_Short;
114 classinfo *class_java_lang_Boolean;
115 classinfo *class_java_lang_Void;
116 classinfo *class_java_lang_Character;
117 classinfo *class_java_lang_Integer;
118
119 /* the system classloader object */
120 struct java_lang_ClassLoader *SystemClassLoader = NULL;
121
122 /* for raising exceptions from native methods */
123 THREADSPECIFIC java_objectheader* _exceptionptr = NULL;
124
125 /************* use classinfo structure as java.lang.Class object **************/
126
127 void use_class_as_object(classinfo *c) 
128 {
129         vftbl *vt;
130 /*      vftbl *newtbl; */
131
132         if (!class_java_lang_Class)
133                 class_java_lang_Class = class_new(utf_new_char ("java/lang/Class"));
134
135         vt = class_java_lang_Class->vftbl;
136
137
138         if (!c->classvftbl) {
139                 c->classvftbl = true;
140
141                 /*                copy_vftbl(&newtbl, vt);
142                                                   newtbl->class = c->header.vftbl->class;
143                                                   newtbl->baseval = c->header.vftbl->baseval;
144                                                   newtbl->diffval = c->header.vftbl->diffval;
145                                                   c->header.vftbl = newtbl;*/
146                 
147                 c->header.vftbl = class_java_lang_Class->vftbl;
148         
149                 if (!class_java_lang_VMClass) {
150                         loader_load_sysclass(&class_java_lang_VMClass,
151                                                                  utf_new_char("java/lang/VMClass"));
152
153                         method_vmclass_init =
154                                 class_findmethod(class_java_lang_VMClass,
155                                                                  utf_new_char("<init>"),
156                                                                  utf_new_char("(Lgnu/classpath/RawData;)V"));
157
158                         if (method_vmclass_init == 0) {
159                                 class_showmethods(class_java_lang_VMClass);
160                                 panic("Needed class initializer for VMClass could not be found");
161                         }
162                 }
163                 {     
164                         java_objectheader *vmo = builtin_new(class_java_lang_VMClass);
165
166                         if (!vmo) panic("Error while creating instance of java/lang/VMClass");
167                         asm_calljavafunction(method_vmclass_init, vmo, c, NULL, NULL);
168                         c->vmClass = (java_lang_VMClass *) vmo;
169                         /*log_text("VMCLASS has been attached");*/
170                 }
171         }
172 }
173
174
175 /*************************** include native methods ***************************/ 
176
177 #ifdef USE_GTK 
178 #include "nat/GdkGraphics.c"
179 #include "nat/GtkComponentPeer.c"
180 #include "nat/GdkPixbufDecoder.c"
181 #include "nat/GtkScrollPanePeer.c"
182 #include "nat/GtkFileDialogPeer.c"
183 #include "nat/GtkLabelPeer.c"
184 #endif
185
186
187 /************************** tables for methods ********************************/
188
189 #undef JOWENN_DEBUG
190 #undef JOWENN_DEBUG1
191
192 /* table for locating native methods */
193 static struct nativeref {
194         char *classname;
195         char *methodname;
196         char *descriptor;
197         bool isstatic;
198         functionptr func;
199 } nativetable [] = {
200
201 #include "nativetable.hh"
202
203 };
204
205
206 #define NATIVETABLESIZE  (sizeof(nativetable)/sizeof(struct nativeref))
207
208 /* table for fast string comparison */
209 static struct nativecompref {
210         utf *classname;
211         utf *methodname;
212         utf *descriptor;
213         bool isstatic;
214         functionptr func;
215 } nativecomptable [NATIVETABLESIZE];
216
217 /* string comparsion table initialized */
218 static bool nativecompdone = false;
219
220
221 /******************************************************************************/
222 /******************************************************************************/
223 #include "natcalls.h"
224
225 /* string call comparison table initialized */
226
227 /******************************************************************************/
228 /******************************************************************************/
229
230 /*--------------- native method calls & classes used -------------------------*/
231
232
233
234 /* throw some loader exceptions */
235
236 void throw_noclassdeffounderror_message(utf* classname)
237 {
238         if (!class_java_lang_NoClassDefFoundError) {
239                 panic("java.lang.NoClassDefFoundError not found. Maybe wrong classpath?");
240         }
241
242         /* throws a NoClassDefFoundError with message */
243         *exceptionptr = native_new_and_init_string(class_java_lang_NoClassDefFoundError,
244                                                                                           javastring_new(classname));
245 }
246
247
248 void throw_linkageerror_message(utf* classname)
249 {
250         if (!class_java_lang_LinkageError) {
251                 panic("java.lang.LinkageError not found. Maybe wrong classpath?");
252         }
253
254         /* throws a LinkageError with message */
255         *exceptionptr = native_new_and_init_string(class_java_lang_LinkageError,
256                                                                                           javastring_new(classname));
257 }
258
259
260 void throw_exception_message(char *classname, char *message)
261 {
262         classinfo *c = class_new(utf_new_char(classname));
263
264         if (!c->linked)
265                 panic("...");
266
267         *exceptionptr = native_new_and_init_string(c,
268                                                                                            javastring_new_char(message));
269 }
270
271
272 /*********************** function: native_loadclasses **************************
273
274         load classes required for native methods        
275
276 *******************************************************************************/
277
278 void native_loadclasses()
279 {
280         static int classesLoaded=0; /*temporary hack JoWenn*/
281         if (classesLoaded) return;
282         classesLoaded = 1;
283 /*      log_text("loadclasses entered");*/
284
285
286         /*class_java_lang_System =*/
287         (void) class_new(utf_new_char("java/lang/VMClass"));/*JoWenn*/
288         (void) class_new(utf_new_char("java/lang/Class"));/*JoWenn*/
289
290         /* class_new adds the class to the list of classes to be loaded */
291         if (!class_java_lang_Cloneable)
292                 class_java_lang_Cloneable = 
293                         class_new(utf_new_char("java/lang/Cloneable"));
294 /*      log_text("loadclasses: class_java_lang_Cloneable has been initialized");*/
295         class_java_lang_CloneNotSupportedException = 
296                 class_new(utf_new_char("java/lang/CloneNotSupportedException"));
297         if (!class_java_lang_Class)
298                 class_java_lang_Class =
299                         class_new(utf_new_char("java/lang/Class"));
300         class_java_io_IOException = 
301                 class_new(utf_new_char("java/io/IOException"));
302         class_java_io_FileNotFoundException = 
303                 class_new(utf_new_char("java/io/FileNotFoundException"));
304         class_java_lang_NoClassDefFoundError =
305                 class_new(utf_new_char("java/lang/NoClassDefFoundError"));
306         class_java_lang_ClassNotFoundException =
307                 class_new(utf_new_char("java/lang/ClassNotFoundException"));
308         class_java_lang_LinkageError =
309                 class_new(utf_new_char("java/lang/LinkageError"));
310         class_java_lang_InstantiationException =
311                 class_new(utf_new_char("java/lang/InstantiationException"));
312         class_java_lang_NoSuchMethodError =
313                 class_new(utf_new_char("java/lang/NoSuchMethodError"));
314         class_java_lang_NoSuchFieldError =
315                 class_new(utf_new_char("java/lang/NoSuchFieldError"));  
316         class_java_lang_ClassFormatError =
317                 class_new(utf_new_char("java/lang/ClassFormatError"));  
318         class_java_io_SyncFailedException =
319                 class_new(utf_new_char("java/io/SyncFailedException"));
320                 
321 /*      log_text("native_loadclasses: class_new(\"java/lang/ClassLoader\")");           */
322         class_java_lang_ClassLoader =
323                 class_new(utf_new_char("java/lang/ClassLoader"));       
324 /*      log_text("native_loadclasses: class_new(\"java/security/PrivilegedActionException\")");         */
325         class_java_security_PrivilegedActionException =
326                 class_new(utf_new_char("java/security/PrivilegedActionException"));
327
328         loader_load_sysclass(&class_java_net_UnknownHostException,
329                                                  utf_new_char("java/net/UnknownHostException"));
330         loader_load_sysclass(&class_java_net_SocketException,
331                                                  utf_new_char("java/net/SocketException"));
332
333         class_java_lang_IllegalArgumentException =
334                 class_new(utf_new_char("java/lang/IllegalArgumentException"));
335         class_java_lang_ArrayIndexOutOfBoundsException =
336                 class_new(utf_new_char("java/lang/ArrayIndexOutOfBoundsException"));
337         class_java_lang_NoSuchFieldException =
338                 class_new(utf_new_char("java/lang/NoSuchFieldException"));
339         class_java_lang_NoSuchMethodException = 
340                 class_new(utf_new_char("java/lang/NoSuchMethodException"));
341
342         /* load classes for wrapping primitive types */
343         class_java_lang_Double    = class_new(utf_new_char("java/lang/Double"));
344         class_init(class_java_lang_Double);
345
346         class_java_lang_Float     = class_new(utf_new_char("java/lang/Float"));
347         class_java_lang_Character =     class_new(utf_new_char("java/lang/Character"));
348         class_java_lang_Integer   = class_new(utf_new_char("java/lang/Integer"));
349         class_java_lang_Long      = class_new(utf_new_char("java/lang/Long"));
350         class_java_lang_Byte      = class_new(utf_new_char("java/lang/Byte"));
351         class_java_lang_Short     = class_new(utf_new_char("java/lang/Short"));
352         class_java_lang_Boolean   = class_new(utf_new_char("java/lang/Boolean"));
353         class_java_lang_Void      = class_new(utf_new_char("java/lang/Void"));
354
355         classesLoaded = 1;
356 }
357
358
359 /*************** adds a class to the vector of loaded classes ****************/
360
361 void systemclassloader_addclass(classinfo *c)
362 {
363         methodinfo *m;
364
365         /* find method addClass of java.lang.ClassLoader */
366         m = class_resolvemethod(class_java_lang_ClassLoader,
367                                                         utf_new_char("addClass"),
368                                                         utf_new_char("(Ljava/lang/Class;)")
369                                                         );
370         
371         if (!m)
372                 panic("warning: cannot initialize classloader");
373
374         /* prepare class to be passed as argument */
375         use_class_as_object (c);
376
377         /* call 'addClass' */
378         asm_calljavafunction(m,
379                                                  (java_objectheader*) SystemClassLoader, 
380                                                  (java_objectheader*) c,
381                                                  NULL,  
382                                                  NULL
383                                                  );
384 }
385
386
387 /*************** adds a library to the vector of loaded libraries *************/
388
389 void systemclassloader_addlibrary(java_objectheader *o)
390 {
391         log_text("systemclassloader_addlibrary");
392 }
393
394
395 /*****************************************************************************
396
397         create systemclassloader object and initialize instance fields  
398
399 ******************************************************************************/
400
401 void init_systemclassloader() 
402 {
403         if (!SystemClassLoader) {
404                 native_loadclasses();
405                 log_text("Initializing new system class loader");
406                 /* create object and call initializer */
407                 SystemClassLoader = (java_lang_ClassLoader*) native_new_and_init(class_java_lang_ClassLoader);  
408
409                 /* systemclassloader has no parent */
410                 SystemClassLoader->parent      = NULL;
411                 SystemClassLoader->initialized = true;
412         }
413         log_text("leaving system class loader");
414 }
415
416
417 /********************* add loaded library name  *******************************/
418
419 void systemclassloader_addlibname(java_objectheader *o)
420 {
421         methodinfo *m;
422         jfieldID id;
423
424         m = class_resolvemethod(loader_load_sysclass(NULL, utf_new_char ("java/util/Vector")),
425                                                         utf_new_char("addElement"),
426                                                         utf_new_char("(Ljava/lang/Object;)V"));
427
428         if (!m) panic("cannot initialize classloader");
429
430         id = envTable.GetStaticFieldID(&env,
431                                                                    class_java_lang_ClassLoader,
432                                                                    "loadedLibraryNames",
433                                                                    "Ljava/util/Vector;");
434
435         if (!id) panic("can not access ClassLoader");
436
437         asm_calljavafunction(m,
438                                                  envTable.GetStaticObjectField(&env, class_java_lang_ClassLoader, id),
439                                                  o,
440                                                  NULL,  
441                                                  NULL);
442 }
443
444
445 /********************* function: native_setclasspath **************************/
446  
447 void native_setclasspath(char *path)
448 {
449         /* set searchpath for classfiles */
450         classpath = path;
451 }
452
453
454 /*********************** Function: native_findfunction *************************
455
456         Looks up a method (must have the same class name, method name, descriptor
457         and 'static'ness) and returns a function pointer to it.
458         Returns: function pointer or NULL (if there is no such method)
459
460         Remark: For faster operation, the names/descriptors are converted from C
461                 strings to Unicode the first time this function is called.
462
463 *******************************************************************************/
464
465 functionptr native_findfunction(utf *cname, utf *mname, 
466                                                                 utf *desc, bool isstatic)
467 {
468         int i;
469         /* entry of table for fast string comparison */
470         struct nativecompref *n;
471         /* for warning message if no function is found */
472         char *buffer;                   
473         int buffer_len;
474
475         isstatic = isstatic ? true : false;
476         
477         if (!nativecompdone) {
478                 for (i = 0; i < NATIVETABLESIZE; i++) {
479                         nativecomptable[i].classname  = 
480                                 utf_new_char(nativetable[i].classname);
481                         nativecomptable[i].methodname = 
482                                 utf_new_char(nativetable[i].methodname);
483                         nativecomptable[i].descriptor = 
484                                 utf_new_char(nativetable[i].descriptor);
485                         nativecomptable[i].isstatic   = 
486                                 nativetable[i].isstatic;
487                         nativecomptable[i].func       = 
488                                 nativetable[i].func;
489                 }
490                 nativecompdone = true;
491         }
492
493 #ifdef JOWENN_DEBUG
494         buffer_len = 
495                 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
496         
497         buffer = MNEW(char, buffer_len);
498
499         strcpy(buffer, "searching matching function in native table:");
500         utf_sprint(buffer+strlen(buffer), mname);
501         strcpy(buffer+strlen(buffer), ": ");
502         utf_sprint(buffer+strlen(buffer), desc);
503         strcpy(buffer+strlen(buffer), " for class ");
504         utf_sprint(buffer+strlen(buffer), cname);
505
506         log_text(buffer);       
507
508         MFREE(buffer, char, buffer_len);
509 #endif
510                 
511         for (i = 0; i < NATIVETABLESIZE; i++) {
512                 n = &(nativecomptable[i]);
513
514                 if (cname == n->classname && mname == n->methodname &&
515                     desc == n->descriptor && isstatic == n->isstatic)
516                         return n->func;
517 #ifdef JOWENN_DEBUG
518                         else {
519                                 if (cname == n->classname && mname == n->methodname )  log_text("static and descriptor mismatch");
520                         
521                                 else {
522                                         buffer_len = 
523                                           utf_strlen(n->classname) + utf_strlen(n->methodname) + utf_strlen(n->descriptor) + 64;
524         
525                                         buffer = MNEW(char, buffer_len);
526
527                                         strcpy(buffer, "comparing with:");
528                                         utf_sprint(buffer+strlen(buffer), n->methodname);
529                                         strcpy (buffer+strlen(buffer), ": ");
530                                         utf_sprint(buffer+strlen(buffer), n->descriptor);
531                                         strcpy(buffer+strlen(buffer), " for class ");
532                                         utf_sprint(buffer+strlen(buffer), n->classname);
533
534                                         log_text(buffer);       
535
536                                         MFREE(buffer, char, buffer_len);
537                                 }
538                         } 
539 #endif
540         }
541
542                 
543         /* no function was found, display warning */
544
545         buffer_len = 
546                 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
547
548         buffer = MNEW(char, buffer_len);
549
550         strcpy(buffer, "warning: native function ");
551         utf_sprint(buffer + strlen(buffer), mname);
552         strcpy(buffer + strlen(buffer), ": ");
553         utf_sprint(buffer + strlen(buffer), desc);
554         strcpy(buffer + strlen(buffer), " not found in class ");
555         utf_sprint(buffer + strlen(buffer), cname);
556
557         log_text(buffer);       
558
559         MFREE(buffer, char, buffer_len);
560
561         exit(1);
562
563         /* keep compiler happy */
564         return NULL;
565 }
566
567
568 /********************** function: javastring_new *******************************
569
570         creates a new object of type java/lang/String with the text of 
571         the specified utf8-string
572
573         return: pointer to the string or NULL if memory is exhausted.   
574
575 *******************************************************************************/
576
577 /*  java_objectheader *javastring_new(utf *u) */
578 java_lang_String *javastring_new(utf *u)
579 {
580         char *utf_ptr = u->text;        /* current utf character in utf string    */
581         int utflength = utf_strlen(u);  /* length of utf-string if uncompressed   */
582         java_lang_String *s;                /* result-string                          */
583         java_chararray *a;
584         s4 i;
585         
586 /*      log_text("javastring_new");*/
587         
588         s = (java_lang_String*) builtin_new(class_java_lang_String);
589         a = builtin_newarray_char(utflength);
590
591         /* javastring or character-array could not be created */
592         if ((!a) || (!s))
593                 return NULL;
594
595         /* decompress utf-string */
596         for (i = 0; i < utflength; i++)
597                 a->data[i] = utf_nextu2(&utf_ptr);
598         
599         /* set fields of the javastring-object */
600         s->value  = a;
601         s->offset = 0;
602         s->count  = utflength;
603
604 /*      return (java_objectheader*) s; */
605         return s;
606 }
607
608
609 /********************** function: javastring_new_char **************************
610
611         creates a new java/lang/String object which contains the convertet
612         C-string passed via text.
613
614         return: the object pointer or NULL if memory is exhausted.
615
616 *******************************************************************************/
617
618 /*  java_objectheader *javastring_new_char (char *text) */
619 java_lang_String *javastring_new_char (char *text)
620 {
621         s4 i;
622         s4 len = strlen(text); /* length of the string */
623         java_lang_String *s;   /* result-string */
624         java_chararray *a;
625         
626         /*log_text("javastring_new_char");*/
627         s = (java_lang_String*) builtin_new(class_java_lang_String);
628         a = builtin_newarray_char(len);
629
630         /* javastring or character-array could not be created */
631         if ((!a) || (!s))
632                 return NULL;
633
634         /* copy text */
635         for (i = 0; i < len; i++)
636                 a->data[i] = text[i];
637         
638         /* set fields of the javastring-object */
639         s->value  = a;
640         s->offset = 0;
641         s->count  = len;
642
643 /*      return (java_objectheader*) s; */
644         return s;
645 }
646
647
648 /************************* function javastring_tochar **************************
649
650         converts a Java string into a C string.
651         
652         return: pointer to C string
653         
654         Caution: every call of this function overwrites the previous string !!!
655         
656 *******************************************************************************/
657
658 static char stringbuffer[MAXSTRINGSIZE];
659
660 char *javastring_tochar(java_objectheader *so) 
661 {
662         java_lang_String *s = (java_lang_String *) so;
663         java_chararray *a;
664         s4 i;
665         
666         if (!s)
667                 return "";
668
669         a = s->value;
670
671         if (!a)
672                 return "";
673
674         if (s->count > MAXSTRINGSIZE)
675                 return "";
676
677         for (i = 0; i < s->count; i++)
678                 stringbuffer[i] = a->data[s->offset + i];
679
680         stringbuffer[i] = '\0';
681
682         return stringbuffer;
683 }
684
685
686 /****************** function class_findfield_approx ****************************
687         
688         searches in 'classinfo'-structure for a field with the
689         specified name
690
691 *******************************************************************************/
692  
693 fieldinfo *class_findfield_approx(classinfo *c, utf *name)
694 {
695         s4 i;
696         for (i = 0; i < c->fieldscount; i++) {
697                 /* compare field names */
698                 if ((c->fields[i].name == name))
699                         return &(c->fields[i]);
700         }
701
702         /* field was not found, raise exception */      
703         *exceptionptr = native_new_and_init(class_java_lang_NoSuchFieldException);
704
705         return NULL;
706 }
707
708 s4 class_findfield_index_approx (classinfo *c, utf *name)
709 {
710         s4 i;
711         for (i = 0; i < c->fieldscount; i++) {
712                 /* compare field names */
713                 if ((c->fields[i].name == name))
714                         return i;
715                 }
716
717         /* field was not found, raise exception */      
718         *exceptionptr = native_new_and_init(class_java_lang_NoSuchFieldException);
719         return -1;
720 }
721
722
723 /********************** function: native_new_and_init *************************
724
725         Creates a new object on the heap and calls the initializer.
726         Returns the object pointer or NULL if memory is exhausted.
727                         
728 *******************************************************************************/
729
730 java_objectheader *native_new_and_init(classinfo *c)
731 {
732         methodinfo *m;
733         java_objectheader *o;
734
735         /* if c==NULL it is probebly because loader_load failed */
736         if (!c) return *exceptionptr;
737
738         o = builtin_new(c);          /* create object          */
739         
740         /*
741         printf("native_new_and_init ");
742         utf_display(c->name);
743         printf("\n");
744         */
745         if (!o) return NULL;
746         /* printf("o!=NULL\n"); */
747         /* find initializer */
748
749         m = class_findmethod(c, utf_new_char("<init>"), utf_new_char("()V"));
750                                                       
751         if (!m) {                                       /* initializer not found  */
752                 if (verbose) {
753                         char logtext[MAXLOGTEXT];
754                         sprintf(logtext, "Warning: class has no instance-initializer: ");
755                         utf_sprint(logtext + strlen(logtext), c->name);
756                         log_text(logtext);
757                 }
758                 return o;
759         }
760
761         /* call initializer */
762
763         asm_calljavafunction(m, o, NULL, NULL, NULL);
764
765         return o;
766 }
767
768
769 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s)
770 {
771         methodinfo *m;
772         java_objectheader *o;
773
774         /* if c==NULL it is probebly because loader_load failed */
775         if (!c) return *exceptionptr;
776
777         o = builtin_new(c);          /* create object          */
778         
779         if (!o) return NULL;
780
781         /* find initializer */
782
783         m = class_findmethod(c,
784                                                  utf_new_char("<init>"),
785                                                  utf_new_char("(Ljava/lang/String;)V"));
786                                                       
787         if (!m) {                                       /* initializer not found  */
788                 if (verbose) {
789                         char logtext[MAXLOGTEXT];
790                         sprintf(logtext, "Warning: class has no instance-initializer: ");
791                         utf_sprint(logtext + strlen(logtext), c->name);
792                         log_text(logtext);
793                 }
794                 return o;
795         }
796
797         /* call initializer */
798
799         asm_calljavafunction(m, o, s, NULL, NULL);
800
801         return o;
802 }
803
804
805 /******************** function: stringtable_update ****************************
806
807         traverses the javastring hashtable and sets the vftbl-entries of
808         javastrings which were temporarily set to NULL, because 
809         java.lang.Object was not yet loaded
810
811 *******************************************************************************/
812  
813 void stringtable_update ()
814 {
815         java_lang_String *js;   
816         java_chararray *a;
817         literalstring *s;       /* hashtable entry */
818         int i;
819
820         for (i = 0; i < string_hash.size; i++) {
821                 s = string_hash.ptr[i];
822                 if (s) {
823                         while (s) {
824                                                                 
825                                 js = (java_lang_String *) s->string;
826                                 
827                                 if (!js || !js->value) 
828                                         /* error in hashtable found */
829                                         panic("invalid literalstring in hashtable");
830
831                                 a = js->value;
832
833                                 if (!js->header.vftbl) 
834                                         /* vftbl of javastring is NULL */ 
835                                         js->header.vftbl = class_java_lang_String -> vftbl;
836
837                                 if (!a->header.objheader.vftbl) 
838                                         /* vftbl of character-array is NULL */ 
839                                         a->header.objheader.vftbl = primitivetype_table[ARRAYTYPE_CHAR].arrayvftbl;
840
841                                 /* follow link in external hash chain */
842                                 s = s->hashlink;
843                         }       
844                 }               
845         }
846 }
847
848
849 /************************* function: u2_utflength ***************************
850
851         returns the utf length in bytes of a u2 array 
852
853 *****************************************************************************/
854
855 u4 u2_utflength(u2 *text, u4 u2_length)
856 {
857         u4 result_len =  0;  /* utf length in bytes  */
858         u2 ch;               /* current unicode character */
859         u4 len;
860         
861         for (len = 0; len < u2_length; len++) {
862                 /* next unicode character */
863                 ch = *text++;
864           
865                 /* determine bytes required to store unicode character as utf */
866                 if (ch && (ch < 0x80)) 
867                         result_len++;
868                 else if (ch < 0x800)
869                         result_len += 2;        
870                 else 
871                         result_len += 3;        
872         }
873
874     return result_len;
875 }
876
877
878 /********************* function: utf_new_u2 ***********************************
879
880         make utf symbol from u2 array, 
881         if isclassname is true '.' is replaced by '/'
882
883 *******************************************************************************/
884
885 utf *utf_new_u2(u2 *unicode_pos, u4 unicode_length, bool isclassname)
886 {
887         char *buffer; /* memory buffer for  unicode characters */
888         char *pos;    /* pointer to current position in buffer */
889         u4 left;      /* unicode characters left */
890         u4 buflength; /* utf length in bytes of the u2 array  */
891         utf *result;  /* resulting utf-string */
892         int i;          
893
894         /* determine utf length in bytes and allocate memory */
895         /* printf("utf_new_u2: unicode_length=%d\n",unicode_length);            */
896         buflength = u2_utflength(unicode_pos, unicode_length); 
897         buffer    = MNEW(char, buflength);
898  
899         /* memory allocation failed */
900         if (!buffer) {
901                 printf("length: %d\n",buflength);
902                 log_text("utf_new_u2:buffer==NULL");
903         }
904
905         left = buflength;
906         pos  = buffer;
907
908         for (i = 0; i++ < unicode_length; unicode_pos++) {
909                 /* next unicode character */
910                 u2 c = *unicode_pos;
911                 
912                 if ((c != 0) && (c < 0x80)) {
913                         /* 1 character */       
914                         left--;
915                 if ((int) left < 0) break;
916                         /* convert classname */
917                         if (isclassname && c == '.')
918                                 *pos++ = '/';
919                         else
920                                 *pos++ = (char) c;
921
922                 } else if (c < 0x800) {             
923                         /* 2 characters */                              
924                 unsigned char high = c >> 6;
925                 unsigned char low  = c & 0x3F;
926                         left = left - 2;
927                 if ((int) left < 0) break;
928                 *pos++ = high | 0xC0; 
929                 *pos++ = low  | 0x80;     
930
931                 } else {         
932                 /* 3 characters */                              
933                 char low  = c & 0x3f;
934                 char mid  = (c >> 6) & 0x3F;
935                 char high = c >> 12;
936                         left = left - 3;
937                 if ((int) left < 0) break;
938                 *pos++ = high | 0xE0; 
939                 *pos++ = mid  | 0x80;  
940                 *pos++ = low  | 0x80;   
941                 }
942         }
943         
944         /* insert utf-string into symbol-table */
945         result = utf_new(buffer,buflength);
946
947         MFREE(buffer, char, buflength);
948
949         return result;
950 }
951
952
953 /********************* function: javastring_toutf *****************************
954
955         make utf symbol from javastring
956
957 *******************************************************************************/
958
959 utf *javastring_toutf(java_lang_String *string, bool isclassname)
960 {
961         java_lang_String *str = (java_lang_String *) string;
962
963 /*      printf("javastring_toutf offset: %d, len %d\n",str->offset, str->count); */
964 /*      fflush(stdout); */
965
966         return utf_new_u2(str->value->data + str->offset, str->count, isclassname);
967 }
968
969
970 /********************* function: literalstring_u2 *****************************
971
972     searches for the javastring with the specified u2-array in 
973     the string hashtable, if there is no such string a new one is 
974     created 
975
976     if copymode is true a copy of the u2-array is made
977
978 *******************************************************************************/
979
980 java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset,
981                                                                         bool copymode)
982 {
983     literalstring *s;                /* hashtable element */
984     java_lang_String *js;            /* u2-array wrapped in javastring */
985     java_chararray *stringdata;      /* copy of u2-array */      
986     u4 key;   
987     u4 slot;  
988     u2 i;
989
990 //#define DEBUG_LITERALSTRING_U2
991 #ifdef DEBUG_LITERALSTRING_U2
992     printf("literalstring_u2: length=%d, offset=%d\n", length, offset);
993         fflush(stdout);
994 #endif
995     
996     /* find location in hashtable */
997     key  = unicode_hashkey(a->data + offset, length);
998     slot = key & (string_hash.size - 1);
999     s    = string_hash.ptr[slot];
1000
1001     while (s) {
1002                 js = (java_lang_String *) s->string;
1003
1004                 if (length == js->count) {
1005                         /* compare text */
1006                         for (i = 0; i < length; i++) {
1007                                 if (a->data[offset + i] != js->value->data[i])
1008                                         goto nomatch;
1009                         }
1010
1011                         /* string already in hashtable, free memory */
1012                         if (!copymode)
1013                                 lit_mem_free(a, sizeof(java_chararray) + sizeof(u2) * (length - 1) + 10);
1014
1015 #ifdef DEBUG_LITERALSTRING_U2
1016                         printf("literalstring_u2: foundentry at %p\n", js);
1017                         utf_display(javastring_toutf(js, 0));
1018                         printf("\n\n");
1019                         fflush(stdout);
1020 #endif
1021                         return (java_objectheader *) js;
1022                 }
1023
1024         nomatch:
1025                 /* follow link in external hash chain */
1026                 s = s->hashlink;
1027     }
1028
1029     if (copymode) {
1030                 /* create copy of u2-array for new javastring */
1031                 u4 arraysize = sizeof(java_chararray) + sizeof(u2) * (length - 1) + 10;
1032                 stringdata = lit_mem_alloc(arraysize);
1033 /*              memcpy(stringdata, a, arraysize); */
1034                 memcpy(&(stringdata->header), &(a->header), sizeof(java_arrayheader));
1035                 memcpy(&(stringdata->data), &(a->data) + offset, sizeof(u2) * (length - 1) + 10);
1036
1037     } else {
1038                 stringdata = a;
1039         }
1040
1041     /* location in hashtable found, complete arrayheader */
1042     stringdata->header.objheader.vftbl = primitivetype_table[ARRAYTYPE_CHAR].arrayvftbl;
1043     stringdata->header.size = length;
1044
1045     /* create new javastring */
1046     js = LNEW(java_lang_String);
1047     js->header.vftbl = class_java_lang_String->vftbl;
1048     js->value  = stringdata;
1049     js->offset = 0;
1050     js->count  = length;
1051
1052     /* create new literalstring */
1053     s = NEW(literalstring);
1054     s->hashlink = string_hash.ptr[slot];
1055     s->string   = (java_objectheader *) js;
1056     string_hash.ptr[slot] = s;
1057
1058     /* update numbe of hashtable entries */
1059     string_hash.entries++;
1060
1061     /* reorganization of hashtable */       
1062     if (string_hash.entries > (string_hash.size * 2)) {
1063                 /* reorganization of hashtable, average length of 
1064          the external chains is approx. 2                */  
1065
1066                 u4 i;
1067                 literalstring *s;     
1068                 hashtable newhash; /* the new hashtable */
1069       
1070                 /* create new hashtable, double the size */
1071                 init_hashtable(&newhash, string_hash.size * 2);
1072                 newhash.entries = string_hash.entries;
1073       
1074                 /* transfer elements to new hashtable */
1075                 for (i = 0; i < string_hash.size; i++) {
1076                         s = string_hash.ptr[i];
1077                         while (s) {
1078                                 literalstring *nexts = s->hashlink;
1079                                 js   = (java_lang_String *) s->string;
1080                                 slot = unicode_hashkey(js->value->data, js->count) & (newhash.size - 1);
1081           
1082                                 s->hashlink = newhash.ptr[slot];
1083                                 newhash.ptr[slot] = s;
1084         
1085                                 /* follow link in external hash chain */  
1086                                 s = nexts;
1087                         }
1088                 }
1089         
1090                 /* dispose old table */ 
1091                 MFREE(string_hash.ptr, void*, string_hash.size);
1092                 string_hash = newhash;
1093     }
1094
1095 #ifdef DEBUG_LITERALSTRING_U2
1096         printf("literalstring_u2: newly created at %p\n", js);
1097         utf_display(javastring_toutf(js, 0));
1098         printf("\n\n");
1099         fflush(stdout);
1100 #endif
1101                         
1102     return (java_objectheader *) js;
1103 }
1104
1105
1106 /******************** Function: literalstring_new *****************************
1107
1108     creates a new javastring with the text of the utf-symbol
1109     and inserts it into the string hashtable
1110
1111 *******************************************************************************/
1112
1113 java_objectheader *literalstring_new(utf *u)
1114 {
1115     char *utf_ptr = u->text;         /* pointer to current unicode character in utf string */
1116     u4 utflength  = utf_strlen(u);   /* length of utf-string if uncompressed */
1117     java_chararray *a;               /* u2-array constructed from utf string */
1118     u4 i;
1119 /*    log_text("literalstring_new"); */
1120 /*    utf_display(u);*/
1121     /*if (utflength==0) while (1) sleep(60);*/
1122 /*    log_text("------------------");    */
1123     /* allocate memory */ 
1124     a = lit_mem_alloc(sizeof(java_chararray) + sizeof(u2) * (utflength - 1) + 10);
1125
1126     /* convert utf-string to u2-array */
1127     for (i = 0; i < utflength; i++)
1128                 a->data[i] = utf_nextu2(&utf_ptr);
1129
1130     return literalstring_u2(a, utflength, 0, false);
1131 }
1132
1133
1134 /********************** function: literalstring_free **************************
1135
1136         removes a javastring from memory                       
1137
1138 ******************************************************************************/
1139
1140 void literalstring_free(java_objectheader* sobj)
1141 {
1142         java_lang_String *s = (java_lang_String *) sobj;
1143         java_chararray *a = s->value;
1144
1145         log_text("literalstring_free called");
1146         
1147         /* dispose memory of java.lang.String object */
1148         LFREE(s, java_lang_String);
1149
1150         /* dispose memory of java-characterarray */
1151         LFREE(a, sizeof(java_chararray) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */
1152 }
1153
1154
1155 void copy_vftbl(vftbl **dest, vftbl *src)
1156 {
1157     *dest = src;
1158 #if 0
1159     /* XXX this kind of copying does not work (in the general
1160      * case). The interface tables would have to be copied, too. I
1161      * don't see why we should make a copy anyway. -Edwin
1162      */
1163         *dest = mem_alloc(sizeof(vftbl) + sizeof(methodptr)*(src->vftbllength-1));
1164         memcpy(*dest, src, sizeof(vftbl) - sizeof(methodptr));
1165         memcpy(&(*dest)->table, &src->table, src->vftbllength * sizeof(methodptr));
1166 #endif
1167 }
1168
1169
1170 /******************************************************************************************                                                                                                             
1171
1172         creates method signature (excluding return type) from array of 
1173         class-objects representing the parameters of the method 
1174
1175 *******************************************************************************************/
1176
1177
1178 utf *create_methodsig(java_objectarray* types, char *retType)
1179 {
1180     char *buffer;       /* buffer for building the desciptor */
1181     char *pos;          /* current position in buffer */
1182     utf *result;        /* the method signature */
1183     u4 buffer_size = 3; /* minimal size=3: room for parenthesis and returntype */
1184     u4 i, j;
1185  
1186     if (!types) return NULL;
1187
1188     /* determine required buffer-size */    
1189     for (i = 0; i < types->header.size; i++) {
1190                 classinfo *c = (classinfo *) types->data[i];
1191                 buffer_size  = buffer_size + c->name->blength + 2;
1192     }
1193
1194     if (retType) buffer_size += strlen(retType);
1195
1196     /* allocate buffer */
1197     buffer = MNEW(u1, buffer_size);
1198     pos    = buffer;
1199     
1200     /* method-desciptor starts with parenthesis */
1201     *pos++ = '(';
1202
1203     for (i = 0; i < types->header.size; i++) {
1204                 char ch;           
1205
1206                 /* current argument */
1207             classinfo *c = (classinfo *) types->data[i];
1208
1209             /* current position in utf-text */
1210             char *utf_ptr = c->name->text; 
1211             
1212             /* determine type of argument */
1213             if ((ch = utf_nextu2(&utf_ptr)) == '[') {
1214                 /* arrayclass */
1215                 for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
1216                                 *pos++ = *utf_ptr; /* copy text */
1217                         }
1218
1219             } else {            
1220                         /* check for primitive types */
1221                         for (j = 0; j < PRIMITIVETYPE_COUNT; j++) {
1222                                 char *utf_pos   = utf_ptr - 1;
1223                                 char *primitive = primitivetype_table[j].wrapname;
1224
1225                                 /* compare text */
1226                                 while (utf_pos < utf_end(c->name)) {
1227                                         if (*utf_pos++ != *primitive++) goto nomatch;
1228                                 }
1229
1230                                 /* primitive type found */
1231                                 *pos++ = primitivetype_table[j].typesig;
1232                                 goto next_type;
1233
1234                         nomatch:
1235                         }
1236
1237                         /* no primitive type and no arrayclass, so must be object */
1238                         *pos++ = 'L';
1239
1240                         /* copy text */
1241                         for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
1242                                 *pos++ = *utf_ptr;
1243                         }
1244
1245                         *pos++ = ';';
1246
1247                 next_type:
1248                 }  
1249     }       
1250
1251     *pos++ = ')';
1252
1253     if (retType) {
1254                 for (i = 0; i < strlen(retType); i++) {
1255                         *pos++ = retType[i];
1256                 }
1257     }
1258
1259     /* create utf-string */
1260     result = utf_new(buffer, (pos - buffer));
1261     MFREE(buffer, u1, buffer_size);
1262
1263     return result;
1264 }
1265
1266
1267 /******************************************************************************************
1268
1269         retrieve the next argument or returntype from a descriptor
1270         and return the corresponding class 
1271
1272 *******************************************************************************************/
1273
1274 classinfo *get_type(char **utf_ptr,char *desc_end, bool skip)
1275 {
1276     classinfo *c = class_from_descriptor(*utf_ptr,desc_end,utf_ptr,
1277                                          (skip) ? CLASSLOAD_SKIP : CLASSLOAD_LOAD);
1278     if (!c)
1279         /* unknown type */
1280         panic("illegal descriptor");
1281
1282     if (skip) return NULL;
1283
1284     use_class_as_object(c);
1285     return c;
1286 }
1287
1288
1289 /******************************************************************************************
1290
1291         use the descriptor of a method to generate a java/lang/Class array
1292         which contains the classes of the parametertypes of the method
1293
1294 *******************************************************************************************/
1295
1296 java_objectarray* get_parametertypes(methodinfo *m) 
1297 {
1298     utf  *descr    =  m->descriptor;    /* method-descriptor */ 
1299     char *utf_ptr  =  descr->text;      /* current position in utf-text */
1300     char *desc_end =  utf_end(descr);   /* points behind utf string     */
1301     java_objectarray* result;
1302     int parametercount = 0;
1303     int i;
1304
1305     /* skip '(' */
1306     utf_nextu2(&utf_ptr);
1307   
1308     /* determine number of parameters */
1309     while ( *utf_ptr != ')' ) {
1310         get_type(&utf_ptr,desc_end,true);
1311         parametercount++;
1312     }
1313
1314     /* create class-array */
1315     result = builtin_anewarray(parametercount, class_java_lang_Class);
1316
1317     utf_ptr  =  descr->text;
1318     utf_nextu2(&utf_ptr);
1319
1320     /* get returntype classes */
1321     for (i = 0; i < parametercount; i++)
1322             result->data[i] = (java_objectheader *) get_type(&utf_ptr,desc_end, false);
1323
1324     return result;
1325 }
1326
1327
1328
1329
1330
1331 /******************************************************************************************
1332
1333         get the exceptions which can be thrown by a method      
1334
1335 *******************************************************************************************/
1336
1337 java_objectarray* get_exceptiontypes(methodinfo *m) 
1338 {
1339 }
1340
1341
1342
1343
1344
1345 /******************************************************************************************
1346
1347         get the returntype class of a method
1348
1349 *******************************************************************************************/
1350
1351 classinfo *get_returntype(methodinfo *m) 
1352 {
1353         char *utf_ptr;   /* current position in utf-text */
1354         char *desc_end;  /* points behind utf string     */
1355         utf *desc = m->descriptor; /* method-descriptor  */
1356
1357         utf_ptr  = desc->text;
1358         desc_end = utf_end(desc);
1359
1360         /* ignore parametertypes */
1361         while ((utf_ptr<desc_end) && utf_nextu2(&utf_ptr)!=')')
1362                 /* skip */ ;
1363
1364         return get_type(&utf_ptr,desc_end, false);
1365 }
1366
1367
1368 /*****************************************************************************/
1369 /*****************************************************************************/
1370
1371
1372 /*--------------------------------------------------------*/
1373 void printNativeCall(nativeCall nc) {
1374   int i,j;
1375
1376   printf("\n%s's Native Methods call:\n",nc.classname); fflush(stdout);
1377   for (i=0; i<nc.methCnt; i++) {  
1378       printf("\tMethod=%s %s\n",nc.methods[i].methodname, nc.methods[i].descriptor);fflush(stdout);
1379
1380     for (j=0; j<nc.callCnt[i]; j++) {  
1381         printf("\t\t<%i,%i>aCalled = %s %s %s\n",i,j,
1382         nc.methods[i].methodCalls[j].classname, 
1383         nc.methods[i].methodCalls[j].methodname, 
1384         nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
1385       }
1386     }
1387   printf("-+++++--------------------\n");fflush(stdout);
1388 }
1389
1390 /*--------------------------------------------------------*/
1391 void printCompNativeCall(nativeCompCall nc) {
1392   int i,j;
1393   printf("printCompNativeCall BEGIN\n");fflush(stdout); 
1394   printf("\n%s's Native Comp Methods call:\n",nc.classname->text);fflush(stdout);
1395   utf_display(nc.classname); fflush(stdout);
1396   
1397   for (i=0; i<nc.methCnt; i++) {  
1398     printf("\tMethod=%s %s\n",nc.methods[i].methodname->text,nc.methods[i].descriptor->text);fflush(stdout);
1399     utf_display(nc.methods[i].methodname); fflush(stdout);
1400     utf_display(nc.methods[i].descriptor);fflush(stdout);
1401     printf("\n");fflush(stdout);
1402
1403     for (j=0; j<nc.callCnt[i]; j++) {  
1404       printf("\t\t<%i,%i>bCalled = ",i,j);fflush(stdout);
1405         utf_display(nc.methods[i].methodCalls[j].classname);fflush(stdout);
1406         utf_display(nc.methods[i].methodCalls[j].methodname); fflush(stdout);
1407         utf_display(nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
1408         printf("\n");fflush(stdout);
1409       }
1410     }
1411 printf("---------------------\n");fflush(stdout);
1412 }
1413
1414
1415 /*--------------------------------------------------------*/
1416 classMeth findNativeMethodCalls(utf *c, utf *m, utf *d ) 
1417 {
1418     int i = 0;
1419     int j = 0;
1420     int cnt = 0;
1421     classMeth mc;
1422     mc.i_class = i;
1423     mc.j_method = j;
1424     mc.methCnt = cnt;
1425
1426     return mc;
1427 }
1428
1429 /*--------------------------------------------------------*/
1430 nativeCall* findNativeClassCalls(char *aclassname ) {
1431 int i;
1432
1433 for (i=0;i<NATIVECALLSSIZE; i++) {
1434    /* convert table to utf later to speed up search */ 
1435    if (strcmp(nativeCalls[i].classname, aclassname) == 0) 
1436         return &nativeCalls[i];
1437    }
1438
1439 return NULL;
1440 }
1441 /*--------------------------------------------------------*/
1442 /*--------------------------------------------------------*/
1443 void utfNativeCall(nativeCall nc, nativeCompCall *ncc) {
1444   int i,j;
1445
1446
1447   ncc->classname = utf_new_char(nc.classname); 
1448   ncc->methCnt = nc.methCnt;
1449   
1450   for (i=0; i<nc.methCnt; i++) {  
1451     ncc->methods[i].methodname = utf_new_char(nc.methods[i].methodname);
1452     ncc->methods[i].descriptor = utf_new_char(nc.methods[i].descriptor);
1453     ncc->callCnt[i] = nc.callCnt[i];
1454
1455     for (j=0; j<nc.callCnt[i]; j++) {  
1456
1457         ncc->methods[i].methodCalls[j].classname  = utf_new_char(nc.methods[i].methodCalls[j].classname);
1458
1459         if (strcmp("", nc.methods[i].methodCalls[j].methodname) != 0) {
1460           ncc->methods[i].methodCalls[j].methodname = utf_new_char(nc.methods[i].methodCalls[j].methodname);
1461           ncc->methods[i].methodCalls[j].descriptor = utf_new_char(nc.methods[i].methodCalls[j].descriptor);
1462           }
1463         else {
1464           ncc->methods[i].methodCalls[j].methodname = NULL;
1465           ncc->methods[i].methodCalls[j].descriptor = NULL;
1466           }
1467       }
1468     }
1469 }
1470
1471
1472
1473 /*--------------------------------------------------------*/
1474
1475 bool natcall2utf(bool natcallcompdone) {
1476 int i;
1477
1478 if (natcallcompdone) 
1479         return true;
1480
1481 for (i=0;i<NATIVECALLSSIZE; i++) {
1482    utfNativeCall  (nativeCalls[i], &nativeCompCalls[i]);  
1483    }
1484
1485 return true;
1486 }
1487 /*--------------------------------------------------------*/
1488
1489
1490 /*
1491  * These are local overrides for various environment variables in Emacs.
1492  * Please do not remove this and leave it at the end of the file, where
1493  * Emacs will automagically detect them.
1494  * ---------------------------------------------------------------------
1495  * Local variables:
1496  * mode: c
1497  * indent-tabs-mode: t
1498  * c-basic-offset: 4
1499  * tab-width: 4
1500  * End:
1501  */