1 /* src/native/native.c - table of native functions
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
31 Changes: Christian Thalinger
33 $Id: native.c 2597 2005-06-08 11:18:01Z twisti $
42 #include "cacao/cacao.h"
43 #include "mm/memory.h"
44 #include "native/jni.h"
45 #include "native/native.h"
46 #include "native/include/java_lang_Throwable.h"
47 #include "toolbox/logging.h"
48 #include "vm/builtin.h"
49 #include "vm/exceptions.h"
50 #include "vm/global.h"
51 #include "vm/loader.h"
52 #include "vm/options.h"
53 #include "vm/resolve.h"
54 #include "vm/stringlocal.h"
55 #include "vm/tables.h"
56 #include "vm/jit/asmpart.h"
57 #include "vm/jit/jit.h"
60 /* include table of native functions ******************************************/
62 #include "native/include/java_lang_Cloneable.h"
63 #include "native/include/java_util_Properties.h"
64 #include "native/include/java_io_InputStream.h"
65 #include "native/include/java_io_PrintStream.h"
67 #include "native/include/gnu_classpath_VMStackWalker.h"
68 #include "native/include/gnu_classpath_VMSystemProperties.h"
69 #include "native/include/java_lang_Class.h"
70 #include "native/include/java_lang_Object.h"
71 #include "native/include/java_lang_VMClass.h"
72 #include "native/include/java_lang_VMClassLoader.h"
73 #include "native/include/java_lang_VMObject.h"
74 #include "native/include/java_lang_VMRuntime.h"
75 #include "native/include/java_lang_VMString.h"
76 #include "native/include/java_lang_VMSystem.h"
77 #include "native/include/java_lang_VMThread.h"
78 #include "native/include/java_lang_VMThrowable.h"
79 #include "native/include/java_lang_reflect_Constructor.h"
80 #include "native/include/java_lang_reflect_Field.h"
81 #include "native/include/java_lang_reflect_Proxy.h"
82 #include "native/include/java_lang_reflect_Method.h"
83 #include "native/include/java_security_VMAccessController.h"
85 #if defined(STATIC_CLASSPATH)
87 /* these are required to prevent compiler warnings */
89 #include "native/include/java_net_DatagramPacket.h"
90 #include "native/include/java_net_InetAddress.h"
91 #include "native/include/java_net_SocketImpl.h"
93 #include "native/include/gnu_java_net_PlainDatagramSocketImpl.h"
94 #include "native/include/gnu_java_net_PlainSocketImpl.h"
95 #include "native/include/gnu_java_nio_PipeImpl.h"
96 #include "native/include/gnu_java_nio_channels_FileChannelImpl.h"
97 #include "native/include/gnu_java_nio_charset_iconv_IconvEncoder.h"
98 #include "native/include/gnu_java_nio_charset_iconv_IconvDecoder.h"
99 #include "native/include/java_lang_VMProcess.h"
100 #include "native/include/java_nio_MappedByteBufferImpl.h"
101 #include "native/include/java_nio_channels_spi_SelectorProvider.h"
103 /* now include the native table */
105 #include "native/nativetable.inc"
107 #else /* defined(STATIC_CLASSPATH) */
109 /* Ensure that symbols for functions implemented within CACAO are used and */
110 /* exported to dlopen. */
112 static functionptr dummynativetable[] = {
113 (functionptr) Java_gnu_classpath_VMStackWalker_getClassContext,
115 (functionptr) Java_gnu_classpath_VMSystemProperties_preInit,
117 (functionptr) Java_java_lang_VMClass_isInstance,
118 (functionptr) Java_java_lang_VMClass_isAssignableFrom,
119 (functionptr) Java_java_lang_VMClass_isInterface,
120 (functionptr) Java_java_lang_VMClass_isPrimitive,
121 (functionptr) Java_java_lang_VMClass_getName,
122 (functionptr) Java_java_lang_VMClass_getSuperclass,
123 (functionptr) Java_java_lang_VMClass_getInterfaces,
124 (functionptr) Java_java_lang_VMClass_getComponentType,
125 (functionptr) Java_java_lang_VMClass_getModifiers,
126 (functionptr) Java_java_lang_VMClass_getDeclaringClass,
127 (functionptr) Java_java_lang_VMClass_getDeclaredClasses,
128 (functionptr) Java_java_lang_VMClass_getDeclaredFields,
129 (functionptr) Java_java_lang_VMClass_getDeclaredMethods,
130 (functionptr) Java_java_lang_VMClass_getDeclaredConstructors,
131 (functionptr) Java_java_lang_VMClass_getClassLoader,
132 (functionptr) Java_java_lang_VMClass_forName,
133 (functionptr) Java_java_lang_VMClass_isArray,
134 (functionptr) Java_java_lang_VMClass_initialize,
135 (functionptr) Java_java_lang_VMClass_loadArrayClass,
136 (functionptr) Java_java_lang_VMClass_throwException,
138 (functionptr) Java_java_lang_VMClassLoader_defineClass,
139 (functionptr) Java_java_lang_VMClassLoader_resolveClass,
140 (functionptr) Java_java_lang_VMClassLoader_loadClass,
141 (functionptr) Java_java_lang_VMClassLoader_getPrimitiveClass,
142 (functionptr) Java_java_lang_VMClassLoader_nativeGetResources,
144 (functionptr) Java_java_lang_VMObject_getClass,
145 (functionptr) Java_java_lang_VMObject_clone,
146 (functionptr) Java_java_lang_VMObject_notify,
147 (functionptr) Java_java_lang_VMObject_notifyAll,
148 (functionptr) Java_java_lang_VMObject_wait,
150 (functionptr) Java_java_lang_VMRuntime_availableProcessors,
151 (functionptr) Java_java_lang_VMRuntime_freeMemory,
152 (functionptr) Java_java_lang_VMRuntime_totalMemory,
153 (functionptr) Java_java_lang_VMRuntime_maxMemory,
154 (functionptr) Java_java_lang_VMRuntime_gc,
155 (functionptr) Java_java_lang_VMRuntime_runFinalization,
156 (functionptr) Java_java_lang_VMRuntime_runFinalizationForExit,
157 (functionptr) Java_java_lang_VMRuntime_traceInstructions,
158 (functionptr) Java_java_lang_VMRuntime_traceMethodCalls,
159 (functionptr) Java_java_lang_VMRuntime_runFinalizersOnExit,
160 (functionptr) Java_java_lang_VMRuntime_exit,
161 (functionptr) Java_java_lang_VMRuntime_nativeLoad,
162 (functionptr) Java_java_lang_VMRuntime_mapLibraryName,
164 (functionptr) Java_java_lang_VMString_intern,
166 (functionptr) Java_java_lang_VMSystem_arraycopy,
167 (functionptr) Java_java_lang_VMSystem_identityHashCode,
169 (functionptr) Java_java_lang_VMThread_start,
170 (functionptr) Java_java_lang_VMThread_interrupt,
171 (functionptr) Java_java_lang_VMThread_isInterrupted,
172 (functionptr) Java_java_lang_VMThread_suspend,
173 (functionptr) Java_java_lang_VMThread_resume,
174 (functionptr) Java_java_lang_VMThread_nativeSetPriority,
175 (functionptr) Java_java_lang_VMThread_nativeStop,
176 (functionptr) Java_java_lang_VMThread_currentThread,
177 (functionptr) Java_java_lang_VMThread_yield,
178 (functionptr) Java_java_lang_VMThread_interrupted,
179 (functionptr) Java_java_lang_VMThread_holdsLock,
181 (functionptr) Java_java_lang_VMThrowable_fillInStackTrace,
182 (functionptr) Java_java_lang_VMThrowable_getStackTrace,
184 (functionptr) Java_java_lang_reflect_Constructor_getModifiers,
185 (functionptr) Java_java_lang_reflect_Constructor_constructNative,
187 (functionptr) Java_java_lang_reflect_Field_getModifiers,
188 (functionptr) Java_java_lang_reflect_Field_getType,
189 (functionptr) Java_java_lang_reflect_Field_get,
190 (functionptr) Java_java_lang_reflect_Field_getBoolean,
191 (functionptr) Java_java_lang_reflect_Field_getByte,
192 (functionptr) Java_java_lang_reflect_Field_getChar,
193 (functionptr) Java_java_lang_reflect_Field_getShort,
194 (functionptr) Java_java_lang_reflect_Field_getInt,
195 (functionptr) Java_java_lang_reflect_Field_getLong,
196 (functionptr) Java_java_lang_reflect_Field_getFloat,
197 (functionptr) Java_java_lang_reflect_Field_getDouble,
198 (functionptr) Java_java_lang_reflect_Field_set,
199 (functionptr) Java_java_lang_reflect_Field_setBoolean,
200 (functionptr) Java_java_lang_reflect_Field_setByte,
201 (functionptr) Java_java_lang_reflect_Field_setChar,
202 (functionptr) Java_java_lang_reflect_Field_setShort,
203 (functionptr) Java_java_lang_reflect_Field_setInt,
204 (functionptr) Java_java_lang_reflect_Field_setLong,
205 (functionptr) Java_java_lang_reflect_Field_setFloat,
206 (functionptr) Java_java_lang_reflect_Field_setDouble,
208 (functionptr) Java_java_lang_reflect_Proxy_getProxyClass0,
209 (functionptr) Java_java_lang_reflect_Proxy_getProxyData0,
210 (functionptr) Java_java_lang_reflect_Proxy_generateProxyClass0,
212 (functionptr) Java_java_lang_reflect_Method_getModifiers,
213 (functionptr) Java_java_lang_reflect_Method_getReturnType,
214 (functionptr) Java_java_lang_reflect_Method_getParameterTypes,
215 (functionptr) Java_java_lang_reflect_Method_getExceptionTypes,
216 (functionptr) Java_java_lang_reflect_Method_invokeNative,
218 (functionptr) Java_java_security_VMAccessController_getStack,
221 #endif /* defined(STATIC_CLASSPATH) */
224 /************* use classinfo structure as java.lang.Class object **************/
226 void use_class_as_object(classinfo *c)
228 if (!c->classvftbl) {
229 /* is the class loaded */
231 /* if (!class_load(c)) */
232 /* throw_exception_exit(); */
233 log_text("use_class_as_object: class_load should not happen");
237 /* is the class linked */
240 throw_exception_exit();
242 assert(class_java_lang_Class);
244 c->header.vftbl = class_java_lang_Class->vftbl;
245 c->classvftbl = true;
250 /************************** tables for methods ********************************/
255 #ifdef STATIC_CLASSPATH
256 #define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
258 /* table for fast string comparison */
259 static nativecompref nativecomptable[NATIVETABLESIZE];
261 /* string comparsion table initialized */
262 static bool nativecompdone = false;
266 /* XXX don't define this in a header file!!! */
268 static struct nativeCall nativeCalls[] =
270 #include "nativecalls.inc"
273 #define NATIVECALLSSIZE (sizeof(nativeCalls) / sizeof(struct nativeCall))
275 struct nativeCompCall nativeCompCalls[NATIVECALLSSIZE];
278 /* native_loadclasses **********************************************************
280 Load classes required for native methods.
282 *******************************************************************************/
284 bool native_init(void)
286 #if !defined(STATIC_CLASSPATH)
289 /* We need to access the dummy native table, not only to remove a warning */
290 /* but to be sure that the table is not optimized away (gcc does this */
292 p = &dummynativetable;
295 /* everything's ok */
301 /*********************** Function: native_findfunction *************************
303 Looks up a method (must have the same class name, method name, descriptor
304 and 'static'ness) and returns a function pointer to it.
305 Returns: function pointer or NULL (if there is no such method)
307 Remark: For faster operation, the names/descriptors are converted from C
308 strings to Unicode the first time this function is called.
310 *******************************************************************************/
312 functionptr native_findfunction(utf *cname, utf *mname,
313 utf *desc, bool isstatic)
315 #ifdef STATIC_CLASSPATH
317 /* entry of table for fast string comparison */
318 struct nativecompref *n;
319 /* for warning message if no function is found */
323 isstatic = isstatic ? true : false;
325 if (!nativecompdone) {
326 for (i = 0; i < NATIVETABLESIZE; i++) {
327 nativecomptable[i].classname =
328 utf_new_char(nativetable[i].classname);
329 nativecomptable[i].methodname =
330 utf_new_char(nativetable[i].methodname);
331 nativecomptable[i].descriptor =
332 utf_new_char(nativetable[i].descriptor);
333 nativecomptable[i].isstatic =
334 nativetable[i].isstatic;
335 nativecomptable[i].func =
338 nativecompdone = true;
343 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
345 buffer = MNEW(char, buffer_len);
347 strcpy(buffer, "searching matching function in native table:");
348 utf_sprint(buffer+strlen(buffer), mname);
349 strcpy(buffer+strlen(buffer), ": ");
350 utf_sprint(buffer+strlen(buffer), desc);
351 strcpy(buffer+strlen(buffer), " for class ");
352 utf_sprint(buffer+strlen(buffer), cname);
356 MFREE(buffer, char, buffer_len);
359 for (i = 0; i < NATIVETABLESIZE; i++) {
360 n = &(nativecomptable[i]);
362 if (cname == n->classname && mname == n->methodname &&
363 desc == n->descriptor && isstatic == n->isstatic)
367 if (cname == n->classname && mname == n->methodname ) log_text("static and descriptor mismatch");
371 utf_strlen(n->classname) + utf_strlen(n->methodname) + utf_strlen(n->descriptor) + 64;
373 buffer = MNEW(char, buffer_len);
375 strcpy(buffer, "comparing with:");
376 utf_sprint(buffer+strlen(buffer), n->methodname);
377 strcpy (buffer+strlen(buffer), ": ");
378 utf_sprint(buffer+strlen(buffer), n->descriptor);
379 strcpy(buffer+strlen(buffer), " for class ");
380 utf_sprint(buffer+strlen(buffer), n->classname);
384 MFREE(buffer, char, buffer_len);
391 /* no function was found, display warning */
394 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
396 buffer = MNEW(char, buffer_len);
398 strcpy(buffer, "warning: native function ");
399 utf_sprint(buffer + strlen(buffer), mname);
400 strcpy(buffer + strlen(buffer), ": ");
401 utf_sprint(buffer + strlen(buffer), desc);
402 strcpy(buffer + strlen(buffer), " not found in class ");
403 utf_sprint(buffer + strlen(buffer), cname);
407 MFREE(buffer, char, buffer_len);
411 /* keep compiler happy */
414 /* dynamic classpath */
420 /****************** function class_findfield_approx ****************************
422 searches in 'classinfo'-structure for a field with the
425 *******************************************************************************/
427 fieldinfo *class_findfield_approx(classinfo *c, utf *name)
431 for (i = 0; i < c->fieldscount; i++) {
432 /* compare field names */
433 if ((c->fields[i].name == name))
434 return &(c->fields[i]);
437 /* field was not found, raise exception */
438 *exceptionptr = new_exception(string_java_lang_NoSuchFieldException);
444 s4 class_findfield_index_approx(classinfo *c, utf *name)
448 for (i = 0; i < c->fieldscount; i++) {
449 /* compare field names */
450 if ((c->fields[i].name == name))
454 /* field was not found, raise exception */
455 *exceptionptr = new_exception(string_java_lang_NoSuchFieldException);
461 /* native_new_and_init *********************************************************
463 Creates a new object on the heap and calls the initializer.
464 Returns the object pointer or NULL if memory is exhausted.
466 *******************************************************************************/
468 java_objectheader *native_new_and_init(classinfo *c)
471 java_objectheader *o;
474 return *exceptionptr;
483 /* find initializer */
485 m = class_findmethod(c, utf_init, utf_void__void);
487 /* initializer not found */
492 /* call initializer */
494 asm_calljavafunction(m, o, NULL, NULL, NULL);
500 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s)
503 java_objectheader *o;
506 return *exceptionptr;
515 /* find initializer */
517 m = class_resolveclassmethod(c,
519 utf_java_lang_String__void,
523 /* initializer not found */
528 /* call initializer */
530 asm_calljavafunction(m, o, s, NULL, NULL);
536 java_objectheader *native_new_and_init_int(classinfo *c, s4 i)
539 java_objectheader *o;
542 return *exceptionptr;
551 /* find initializer */
553 m = class_resolveclassmethod(c, utf_init, utf_int__void, NULL, true);
555 /* initializer not found */
560 /* call initializer */
562 asm_calljavafunction(m, o, (void *) (ptrint) i, NULL, NULL);
568 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t)
571 java_objectheader *o;
574 return *exceptionptr;
583 /* find initializer */
585 m = class_findmethod(c, utf_init, utf_java_lang_Throwable__void);
587 /* initializer not found */
592 /* call initializer */
594 asm_calljavafunction(m, o, t, NULL, NULL);
600 void copy_vftbl(vftbl_t **dest, vftbl_t *src)
604 /* XXX this kind of copying does not work (in the general
605 * case). The interface tables would have to be copied, too. I
606 * don't see why we should make a copy anyway. -Edwin
608 *dest = mem_alloc(sizeof(vftbl) + sizeof(methodptr)*(src->vftbllength-1));
609 memcpy(*dest, src, sizeof(vftbl) - sizeof(methodptr));
610 memcpy(&(*dest)->table, &src->table, src->vftbllength * sizeof(methodptr));
615 /******************************************************************************************
617 creates method signature (excluding return type) from array of
618 class-objects representing the parameters of the method
620 *******************************************************************************************/
623 utf *create_methodsig(java_objectarray* types, char *retType)
625 char *buffer; /* buffer for building the desciptor */
626 char *pos; /* current position in buffer */
627 utf *result; /* the method signature */
628 u4 buffer_size = 3; /* minimal size=3: room for parenthesis and returntype */
631 if (!types) return NULL;
633 /* determine required buffer-size */
634 for (i = 0; i < types->header.size; i++) {
635 classinfo *c = (classinfo *) types->data[i];
636 buffer_size = buffer_size + c->name->blength + 2;
639 if (retType) buffer_size += strlen(retType);
641 /* allocate buffer */
642 buffer = MNEW(char, buffer_size);
645 /* method-desciptor starts with parenthesis */
648 for (i = 0; i < types->header.size; i++) {
651 /* current argument */
652 classinfo *c = (classinfo *) types->data[i];
654 /* current position in utf-text */
655 char *utf_ptr = c->name->text;
657 /* determine type of argument */
658 if ((ch = utf_nextu2(&utf_ptr)) == '[') {
660 for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
661 *pos++ = *utf_ptr; /* copy text */
665 /* check for primitive types */
666 for (j = 0; j < PRIMITIVETYPE_COUNT; j++) {
667 char *utf_pos = utf_ptr - 1;
668 char *primitive = primitivetype_table[j].wrapname;
671 while (utf_pos < utf_end(c->name)) {
672 if (*utf_pos++ != *primitive++) goto nomatch;
675 /* primitive type found */
676 *pos++ = primitivetype_table[j].typesig;
683 /* no primitive type and no arrayclass, so must be object */
687 for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
701 for (i = 0; i < strlen(retType); i++) {
706 /* create utf-string */
707 result = utf_new(buffer, (pos - buffer));
708 MFREE(buffer, char, buffer_size);
714 /* get_parametertypes **********************************************************
716 Use the descriptor of a method to generate a java/lang/Class array
717 which contains the classes of the parametertypes of the method.
719 *******************************************************************************/
721 java_objectarray *get_parametertypes(methodinfo *m)
724 typedesc *paramtypes;
726 java_objectarray *result;
731 /* is the descriptor fully parsed? */
733 if (!m->parseddesc->params)
734 if (!descriptor_params_from_paramtypes(md, m->flags))
737 paramtypes = md->paramtypes;
738 paramcount = md->paramcount;
740 /* skip `this' pointer */
742 if (!(m->flags & ACC_STATIC)) {
747 /* create class-array */
749 result = builtin_anewarray(paramcount, class_java_lang_Class);
753 for (i = 0; i < paramcount; i++) {
754 if (!resolve_class_from_typedesc(¶mtypes[i], false,
755 (classinfo **) &result->data[i]))
758 use_class_as_object((classinfo *) result->data[i]);
765 /* get_exceptiontypes **********************************************************
767 get the exceptions which can be thrown by a method
769 *******************************************************************************/
771 java_objectarray* get_exceptiontypes(methodinfo *m)
775 java_objectarray *result;
778 excount = m->thrownexceptionscount;
780 /* create class-array */
781 assert(class_java_lang_Class);
783 result = builtin_anewarray(excount, class_java_lang_Class);
785 for (i = 0; i < excount; i++) {
786 if (!resolve_classref_or_classinfo(NULL,m->thrownexceptions[i],resolveEager,false,&cls))
787 return NULL; /* exception */
788 use_class_as_object(cls);
789 result->data[i] = (java_objectheader *)cls;
796 /******************************************************************************************
798 get the returntype class of a method
800 *******************************************************************************************/
802 classinfo *get_returntype(methodinfo *m)
806 if (!resolve_class_from_typedesc(&(m->parseddesc->returntype),false,&cls))
807 return NULL; /* exception */
809 use_class_as_object(cls);
814 /*****************************************************************************/
815 /*****************************************************************************/
818 /*--------------------------------------------------------*/
819 void printNativeCall(nativeCall nc) {
822 printf("\n%s's Native Methods call:\n",nc.classname); fflush(stdout);
823 for (i=0; i<nc.methCnt; i++) {
824 printf("\tMethod=%s %s\n",nc.methods[i].methodname, nc.methods[i].descriptor);fflush(stdout);
826 for (j=0; j<nc.callCnt[i]; j++) {
827 printf("\t\t<%i,%i>aCalled = %s %s %s\n",i,j,
828 nc.methods[i].methodCalls[j].classname,
829 nc.methods[i].methodCalls[j].methodname,
830 nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
833 printf("-+++++--------------------\n");fflush(stdout);
836 /*--------------------------------------------------------*/
837 void printCompNativeCall(nativeCompCall nc) {
839 printf("printCompNativeCall BEGIN\n");fflush(stdout);
840 printf("\n%s's Native Comp Methods call:\n",nc.classname->text);fflush(stdout);
841 utf_display(nc.classname); fflush(stdout);
843 for (i=0; i<nc.methCnt; i++) {
844 printf("\tMethod=%s %s\n",nc.methods[i].methodname->text,nc.methods[i].descriptor->text);fflush(stdout);
845 utf_display(nc.methods[i].methodname); fflush(stdout);
846 utf_display(nc.methods[i].descriptor);fflush(stdout);
847 printf("\n");fflush(stdout);
849 for (j=0; j<nc.callCnt[i]; j++) {
850 printf("\t\t<%i,%i>bCalled = ",i,j);fflush(stdout);
851 utf_display(nc.methods[i].methodCalls[j].classname);fflush(stdout);
852 utf_display(nc.methods[i].methodCalls[j].methodname); fflush(stdout);
853 utf_display(nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
854 printf("\n");fflush(stdout);
857 printf("---------------------\n");fflush(stdout);
861 /*--------------------------------------------------------*/
862 classMeth findNativeMethodCalls(utf *c, utf *m, utf *d )
875 /*--------------------------------------------------------*/
876 nativeCall* findNativeClassCalls(char *aclassname ) {
879 for (i=0;i<NATIVECALLSSIZE; i++) {
880 /* convert table to utf later to speed up search */
881 if (strcmp(nativeCalls[i].classname, aclassname) == 0)
882 return &nativeCalls[i];
887 /*--------------------------------------------------------*/
888 /*--------------------------------------------------------*/
889 void utfNativeCall(nativeCall nc, nativeCompCall *ncc) {
893 ncc->classname = utf_new_char(nc.classname);
894 ncc->methCnt = nc.methCnt;
896 for (i=0; i<nc.methCnt; i++) {
897 ncc->methods[i].methodname = utf_new_char(nc.methods[i].methodname);
898 ncc->methods[i].descriptor = utf_new_char(nc.methods[i].descriptor);
899 ncc->callCnt[i] = nc.callCnt[i];
901 for (j=0; j<nc.callCnt[i]; j++) {
903 ncc->methods[i].methodCalls[j].classname = utf_new_char(nc.methods[i].methodCalls[j].classname);
905 if (strcmp("", nc.methods[i].methodCalls[j].methodname) != 0) {
906 ncc->methods[i].methodCalls[j].methodname = utf_new_char(nc.methods[i].methodCalls[j].methodname);
907 ncc->methods[i].methodCalls[j].descriptor = utf_new_char(nc.methods[i].methodCalls[j].descriptor);
910 ncc->methods[i].methodCalls[j].methodname = NULL;
911 ncc->methods[i].methodCalls[j].descriptor = NULL;
919 /*--------------------------------------------------------*/
921 bool natcall2utf(bool natcallcompdone) {
927 for (i=0;i<NATIVECALLSSIZE; i++) {
928 utfNativeCall (nativeCalls[i], &nativeCompCalls[i]);
934 /*--------------------------------------------------------*/
937 java_objectarray *builtin_asm_createclasscontextarray(classinfo **end, classinfo **start)
939 /* XXX platform dependend */
941 java_objectarray *tmpArray;
947 size = (((size_t) start) - ((size_t) end)) / sizeof(classinfo*);
949 /*printf("end %p, start %p, size %ld\n",end,start,size);*/
952 if (*start == class_java_lang_SecurityManager) {
958 tmpArray = builtin_anewarray(size, class_java_lang_Class);
960 for(i = 0, current = start; i < size; i++, current--) {
963 utf_display(c->name);*/
964 use_class_as_object(c);
965 tmpArray->data[i] = (java_objectheader *) c;
972 java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end, classinfo **start)
974 /* XXX platform dependend */
979 classinfo *privilegedAction;
982 size = (((size_t) start) - ((size_t) end)) / sizeof(classinfo*);
984 /* log_text("builtin_asm_getclassloader");
985 printf("end %p, start %p, size %ld\n",end,start,size);*/
987 if (!class_java_lang_SecurityManager)
988 if (!load_class_bootstrap(utf_new_char("java/lang/SecurityManager"),&class_java_lang_SecurityManager))
992 if (*start == class_java_lang_SecurityManager) {
998 if (!load_class_bootstrap(utf_new_char("java/security/PrivilegedAction"),&privilegedAction))
1001 for(i = 0, current = start; i < size; i++, current--) {
1004 if (c == privilegedAction)
1008 return (java_lang_ClassLoader *) c->classloader;
1016 * These are local overrides for various environment variables in Emacs.
1017 * Please do not remove this and leave it at the end of the file, where
1018 * Emacs will automagically detect them.
1019 * ---------------------------------------------------------------------
1022 * indent-tabs-mode: t