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 2482 2005-05-19 08:48:55Z jowenn $
47 /* Include files for IO functions */
51 #include <sys/types.h>
58 #include "cacao/cacao.h"
59 #include "mm/memory.h"
60 #include "native/jni.h"
61 #include "native/native.h"
62 #include "native/include/java_lang_Throwable.h"
63 #include "toolbox/logging.h"
64 #include "vm/builtin.h"
65 #include "vm/exceptions.h"
66 #include "vm/global.h"
67 #include "vm/loader.h"
68 #include "vm/options.h"
69 #include "vm/stringlocal.h"
70 #include "vm/tables.h"
71 #include "vm/jit/asmpart.h"
72 #include "vm/jit/jit.h"
73 #include "vm/resolve.h"
76 /* include table of native functions ******************************************/
78 #include "native/include/java_lang_Cloneable.h"
79 #include "native/include/java_util_Properties.h"
80 #include "native/include/java_io_InputStream.h"
81 #include "native/include/java_io_PrintStream.h"
83 #include "native/include/gnu_classpath_VMStackWalker.h"
84 #include "native/include/gnu_classpath_VMSystemProperties.h"
85 #include "native/include/java_lang_Class.h"
86 #include "native/include/java_lang_Object.h"
87 #include "native/include/java_lang_VMClass.h"
88 #include "native/include/java_lang_VMClassLoader.h"
89 #include "native/include/java_lang_VMObject.h"
90 #include "native/include/java_lang_VMRuntime.h"
91 #include "native/include/java_lang_VMString.h"
92 #include "native/include/java_lang_VMSystem.h"
93 #include "native/include/java_lang_VMThread.h"
94 #include "native/include/java_lang_VMThrowable.h"
95 #include "native/include/java_lang_reflect_Constructor.h"
96 #include "native/include/java_lang_reflect_Field.h"
97 #include "native/include/java_lang_reflect_Proxy.h"
98 #include "native/include/java_lang_reflect_Method.h"
99 #include "native/include/java_security_VMAccessController.h"
101 #if defined(STATIC_CLASSPATH)
103 #include "native/nativetable.inc"
105 #else /* defined(STATIC_CLASSPATH) */
107 /* Ensure that symbols for functions implemented within CACAO are used and */
108 /* exported to dlopen. */
110 static functionptr dummynativetable[] = {
111 (functionptr) Java_gnu_classpath_VMStackWalker_getClassContext,
113 (functionptr) Java_gnu_classpath_VMSystemProperties_preInit,
115 (functionptr) Java_java_lang_VMClass_isInstance,
116 (functionptr) Java_java_lang_VMClass_isAssignableFrom,
117 (functionptr) Java_java_lang_VMClass_isInterface,
118 (functionptr) Java_java_lang_VMClass_isPrimitive,
119 (functionptr) Java_java_lang_VMClass_getName,
120 (functionptr) Java_java_lang_VMClass_getSuperclass,
121 (functionptr) Java_java_lang_VMClass_getInterfaces,
122 (functionptr) Java_java_lang_VMClass_getComponentType,
123 (functionptr) Java_java_lang_VMClass_getModifiers,
124 (functionptr) Java_java_lang_VMClass_getDeclaringClass,
125 (functionptr) Java_java_lang_VMClass_getDeclaredClasses,
126 (functionptr) Java_java_lang_VMClass_getDeclaredFields,
127 (functionptr) Java_java_lang_VMClass_getDeclaredMethods,
128 (functionptr) Java_java_lang_VMClass_getDeclaredConstructors,
129 (functionptr) Java_java_lang_VMClass_getClassLoader,
130 (functionptr) Java_java_lang_VMClass_forName,
131 (functionptr) Java_java_lang_VMClass_isArray,
132 (functionptr) Java_java_lang_VMClass_initialize,
133 (functionptr) Java_java_lang_VMClass_loadArrayClass,
134 (functionptr) Java_java_lang_VMClass_throwException,
136 (functionptr) Java_java_lang_VMClassLoader_defineClass,
137 (functionptr) Java_java_lang_VMClassLoader_resolveClass,
138 (functionptr) Java_java_lang_VMClassLoader_loadClass,
139 (functionptr) Java_java_lang_VMClassLoader_getPrimitiveClass,
140 (functionptr) Java_java_lang_VMClassLoader_nativeGetResources,
142 (functionptr) Java_java_lang_VMObject_getClass,
143 (functionptr) Java_java_lang_VMObject_clone,
144 (functionptr) Java_java_lang_VMObject_notify,
145 (functionptr) Java_java_lang_VMObject_notifyAll,
146 (functionptr) Java_java_lang_VMObject_wait,
148 (functionptr) Java_java_lang_VMRuntime_availableProcessors,
149 (functionptr) Java_java_lang_VMRuntime_freeMemory,
150 (functionptr) Java_java_lang_VMRuntime_totalMemory,
151 (functionptr) Java_java_lang_VMRuntime_maxMemory,
152 (functionptr) Java_java_lang_VMRuntime_gc,
153 (functionptr) Java_java_lang_VMRuntime_runFinalization,
154 (functionptr) Java_java_lang_VMRuntime_runFinalizationForExit,
155 (functionptr) Java_java_lang_VMRuntime_traceInstructions,
156 (functionptr) Java_java_lang_VMRuntime_traceMethodCalls,
157 (functionptr) Java_java_lang_VMRuntime_runFinalizersOnExit,
158 (functionptr) Java_java_lang_VMRuntime_exit,
159 (functionptr) Java_java_lang_VMRuntime_nativeLoad,
160 (functionptr) Java_java_lang_VMRuntime_mapLibraryName,
162 (functionptr) Java_java_lang_VMString_intern,
164 (functionptr) Java_java_lang_VMSystem_arraycopy,
165 (functionptr) Java_java_lang_VMSystem_identityHashCode,
167 (functionptr) Java_java_lang_VMThread_start,
168 (functionptr) Java_java_lang_VMThread_interrupt,
169 (functionptr) Java_java_lang_VMThread_isInterrupted,
170 (functionptr) Java_java_lang_VMThread_suspend,
171 (functionptr) Java_java_lang_VMThread_resume,
172 (functionptr) Java_java_lang_VMThread_nativeSetPriority,
173 (functionptr) Java_java_lang_VMThread_nativeStop,
174 (functionptr) Java_java_lang_VMThread_currentThread,
175 (functionptr) Java_java_lang_VMThread_yield,
176 (functionptr) Java_java_lang_VMThread_interrupted,
177 (functionptr) Java_java_lang_VMThread_holdsLock,
179 (functionptr) Java_java_lang_VMThrowable_fillInStackTrace,
180 (functionptr) Java_java_lang_VMThrowable_getStackTrace,
182 (functionptr) Java_java_lang_reflect_Constructor_getModifiers,
183 (functionptr) Java_java_lang_reflect_Constructor_constructNative,
185 (functionptr) Java_java_lang_reflect_Field_getModifiers,
186 (functionptr) Java_java_lang_reflect_Field_getType,
187 (functionptr) Java_java_lang_reflect_Field_get,
188 (functionptr) Java_java_lang_reflect_Field_getBoolean,
189 (functionptr) Java_java_lang_reflect_Field_getByte,
190 (functionptr) Java_java_lang_reflect_Field_getChar,
191 (functionptr) Java_java_lang_reflect_Field_getShort,
192 (functionptr) Java_java_lang_reflect_Field_getInt,
193 (functionptr) Java_java_lang_reflect_Field_getLong,
194 (functionptr) Java_java_lang_reflect_Field_getFloat,
195 (functionptr) Java_java_lang_reflect_Field_getDouble,
196 (functionptr) Java_java_lang_reflect_Field_set,
197 (functionptr) Java_java_lang_reflect_Field_setBoolean,
198 (functionptr) Java_java_lang_reflect_Field_setByte,
199 (functionptr) Java_java_lang_reflect_Field_setChar,
200 (functionptr) Java_java_lang_reflect_Field_setShort,
201 (functionptr) Java_java_lang_reflect_Field_setInt,
202 (functionptr) Java_java_lang_reflect_Field_setLong,
203 (functionptr) Java_java_lang_reflect_Field_setFloat,
204 (functionptr) Java_java_lang_reflect_Field_setDouble,
206 (functionptr) Java_java_lang_reflect_Proxy_getProxyClass0,
207 (functionptr) Java_java_lang_reflect_Proxy_getProxyData0,
208 (functionptr) Java_java_lang_reflect_Proxy_generateProxyClass0,
210 (functionptr) Java_java_lang_reflect_Method_getModifiers,
211 (functionptr) Java_java_lang_reflect_Method_getReturnType,
212 (functionptr) Java_java_lang_reflect_Method_getParameterTypes,
213 (functionptr) Java_java_lang_reflect_Method_getExceptionTypes,
214 (functionptr) Java_java_lang_reflect_Method_invokeNative,
216 (functionptr) Java_java_security_VMAccessController_getStack,
219 #endif /* defined(STATIC_CLASSPATH) */
222 /************* use classinfo structure as java.lang.Class object **************/
224 void use_class_as_object(classinfo *c)
226 if (!c->classvftbl) {
227 /* is the class loaded */
229 /* if (!class_load(c)) */
230 /* throw_exception_exit(); */
231 log_text("use_class_as_object: class_load should not happen");
235 /* is the class linked */
238 throw_exception_exit();
240 assert(class_java_lang_Class);
242 c->header.vftbl = class_java_lang_Class->vftbl;
243 c->classvftbl = true;
248 /************************** tables for methods ********************************/
253 #ifdef STATIC_CLASSPATH
254 #define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
256 /* table for fast string comparison */
257 static nativecompref nativecomptable[NATIVETABLESIZE];
259 /* string comparsion table initialized */
260 static bool nativecompdone = false;
264 /* XXX don't define this in a header file!!! */
266 static struct nativeCall nativeCalls[] =
268 #include "nativecalls.inc"
271 #define NATIVECALLSSIZE (sizeof(nativeCalls) / sizeof(struct nativeCall))
273 struct nativeCompCall nativeCompCalls[NATIVECALLSSIZE];
276 /* native_loadclasses **********************************************************
278 Load classes required for native methods.
280 *******************************************************************************/
282 bool native_init(void)
284 #if !defined(STATIC_CLASSPATH)
287 /* We need to access the dummy native table, not only to remove a warning */
288 /* but to be sure that the table is not optimized away (gcc does this */
290 p = &dummynativetable;
293 /* everything's ok */
299 /*********************** Function: native_findfunction *************************
301 Looks up a method (must have the same class name, method name, descriptor
302 and 'static'ness) and returns a function pointer to it.
303 Returns: function pointer or NULL (if there is no such method)
305 Remark: For faster operation, the names/descriptors are converted from C
306 strings to Unicode the first time this function is called.
308 *******************************************************************************/
310 functionptr native_findfunction(utf *cname, utf *mname,
311 utf *desc, bool isstatic)
313 #ifdef STATIC_CLASSPATH
315 /* entry of table for fast string comparison */
316 struct nativecompref *n;
317 /* for warning message if no function is found */
321 isstatic = isstatic ? true : false;
323 if (!nativecompdone) {
324 for (i = 0; i < NATIVETABLESIZE; i++) {
325 nativecomptable[i].classname =
326 utf_new_char(nativetable[i].classname);
327 nativecomptable[i].methodname =
328 utf_new_char(nativetable[i].methodname);
329 nativecomptable[i].descriptor =
330 utf_new_char(nativetable[i].descriptor);
331 nativecomptable[i].isstatic =
332 nativetable[i].isstatic;
333 nativecomptable[i].func =
336 nativecompdone = true;
341 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
343 buffer = MNEW(char, buffer_len);
345 strcpy(buffer, "searching matching function in native table:");
346 utf_sprint(buffer+strlen(buffer), mname);
347 strcpy(buffer+strlen(buffer), ": ");
348 utf_sprint(buffer+strlen(buffer), desc);
349 strcpy(buffer+strlen(buffer), " for class ");
350 utf_sprint(buffer+strlen(buffer), cname);
354 MFREE(buffer, char, buffer_len);
357 for (i = 0; i < NATIVETABLESIZE; i++) {
358 n = &(nativecomptable[i]);
360 if (cname == n->classname && mname == n->methodname &&
361 desc == n->descriptor && isstatic == n->isstatic)
365 if (cname == n->classname && mname == n->methodname ) log_text("static and descriptor mismatch");
369 utf_strlen(n->classname) + utf_strlen(n->methodname) + utf_strlen(n->descriptor) + 64;
371 buffer = MNEW(char, buffer_len);
373 strcpy(buffer, "comparing with:");
374 utf_sprint(buffer+strlen(buffer), n->methodname);
375 strcpy (buffer+strlen(buffer), ": ");
376 utf_sprint(buffer+strlen(buffer), n->descriptor);
377 strcpy(buffer+strlen(buffer), " for class ");
378 utf_sprint(buffer+strlen(buffer), n->classname);
382 MFREE(buffer, char, buffer_len);
389 /* no function was found, display warning */
392 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
394 buffer = MNEW(char, buffer_len);
396 strcpy(buffer, "warning: native function ");
397 utf_sprint(buffer + strlen(buffer), mname);
398 strcpy(buffer + strlen(buffer), ": ");
399 utf_sprint(buffer + strlen(buffer), desc);
400 strcpy(buffer + strlen(buffer), " not found in class ");
401 utf_sprint(buffer + strlen(buffer), cname);
405 MFREE(buffer, char, buffer_len);
409 /* keep compiler happy */
412 /* dynamic classpath */
418 /****************** function class_findfield_approx ****************************
420 searches in 'classinfo'-structure for a field with the
423 *******************************************************************************/
425 fieldinfo *class_findfield_approx(classinfo *c, utf *name)
429 for (i = 0; i < c->fieldscount; i++) {
430 /* compare field names */
431 if ((c->fields[i].name == name))
432 return &(c->fields[i]);
435 /* field was not found, raise exception */
436 *exceptionptr = new_exception(string_java_lang_NoSuchFieldException);
442 s4 class_findfield_index_approx(classinfo *c, utf *name)
446 for (i = 0; i < c->fieldscount; i++) {
447 /* compare field names */
448 if ((c->fields[i].name == name))
452 /* field was not found, raise exception */
453 *exceptionptr = new_exception(string_java_lang_NoSuchFieldException);
459 /* native_new_and_init *********************************************************
461 Creates a new object on the heap and calls the initializer.
462 Returns the object pointer or NULL if memory is exhausted.
464 *******************************************************************************/
466 java_objectheader *native_new_and_init(classinfo *c)
469 java_objectheader *o;
472 return *exceptionptr;
481 /* find initializer */
483 m = class_findmethod(c, utf_init, utf_void__void);
485 /* initializer not found */
490 /* call initializer */
492 asm_calljavafunction(m, o, NULL, NULL, NULL);
498 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s)
501 java_objectheader *o;
504 return *exceptionptr;
513 /* find initializer */
515 m = class_resolveclassmethod(c,
517 utf_java_lang_String__void,
521 /* initializer not found */
526 /* call initializer */
528 asm_calljavafunction(m, o, s, NULL, NULL);
534 java_objectheader *native_new_and_init_int(classinfo *c, s4 i)
537 java_objectheader *o;
540 return *exceptionptr;
549 /* find initializer */
551 m = class_resolveclassmethod(c, utf_init, utf_int__void, NULL, true);
553 /* initializer not found */
558 /* call initializer */
560 asm_calljavafunction(m, o, (void *) (ptrint) i, NULL, NULL);
566 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t)
569 java_objectheader *o;
572 return *exceptionptr;
581 /* find initializer */
583 m = class_findmethod(c, utf_init, utf_java_lang_Throwable__void);
585 /* initializer not found */
590 /* call initializer */
592 asm_calljavafunction(m, o, t, NULL, NULL);
598 void copy_vftbl(vftbl_t **dest, vftbl_t *src)
602 /* XXX this kind of copying does not work (in the general
603 * case). The interface tables would have to be copied, too. I
604 * don't see why we should make a copy anyway. -Edwin
606 *dest = mem_alloc(sizeof(vftbl) + sizeof(methodptr)*(src->vftbllength-1));
607 memcpy(*dest, src, sizeof(vftbl) - sizeof(methodptr));
608 memcpy(&(*dest)->table, &src->table, src->vftbllength * sizeof(methodptr));
613 /******************************************************************************************
615 creates method signature (excluding return type) from array of
616 class-objects representing the parameters of the method
618 *******************************************************************************************/
621 utf *create_methodsig(java_objectarray* types, char *retType)
623 char *buffer; /* buffer for building the desciptor */
624 char *pos; /* current position in buffer */
625 utf *result; /* the method signature */
626 u4 buffer_size = 3; /* minimal size=3: room for parenthesis and returntype */
629 if (!types) return NULL;
631 /* determine required buffer-size */
632 for (i = 0; i < types->header.size; i++) {
633 classinfo *c = (classinfo *) types->data[i];
634 buffer_size = buffer_size + c->name->blength + 2;
637 if (retType) buffer_size += strlen(retType);
639 /* allocate buffer */
640 buffer = MNEW(char, buffer_size);
643 /* method-desciptor starts with parenthesis */
646 for (i = 0; i < types->header.size; i++) {
649 /* current argument */
650 classinfo *c = (classinfo *) types->data[i];
652 /* current position in utf-text */
653 char *utf_ptr = c->name->text;
655 /* determine type of argument */
656 if ((ch = utf_nextu2(&utf_ptr)) == '[') {
658 for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
659 *pos++ = *utf_ptr; /* copy text */
663 /* check for primitive types */
664 for (j = 0; j < PRIMITIVETYPE_COUNT; j++) {
665 char *utf_pos = utf_ptr - 1;
666 char *primitive = primitivetype_table[j].wrapname;
669 while (utf_pos < utf_end(c->name)) {
670 if (*utf_pos++ != *primitive++) goto nomatch;
673 /* primitive type found */
674 *pos++ = primitivetype_table[j].typesig;
681 /* no primitive type and no arrayclass, so must be object */
685 for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
699 for (i = 0; i < strlen(retType); i++) {
704 /* create utf-string */
705 result = utf_new(buffer, (pos - buffer));
706 MFREE(buffer, char, buffer_size);
712 /* get_parametertypes **********************************************************
714 use the descriptor of a method to generate a java/lang/Class array
715 which contains the classes of the parametertypes of the method
717 *******************************************************************************/
719 java_objectarray* get_parametertypes(methodinfo *m)
721 methoddesc *descr = m->parseddesc; /* method-descriptor */
722 java_objectarray* result;
723 int parametercount = descr->paramcount;
726 /* create class-array */
727 assert(class_java_lang_Class);
729 result = builtin_anewarray(parametercount, class_java_lang_Class);
732 for (i = 0; i < parametercount; i++) {
733 if (!resolve_class_from_typedesc(descr->paramtypes + i,false,
734 (classinfo **) (result->data + i)))
735 return NULL; /* exception */
736 use_class_as_object((classinfo*) result->data[i]);
743 /* get_exceptiontypes **********************************************************
745 get the exceptions which can be thrown by a method
747 *******************************************************************************/
749 java_objectarray* get_exceptiontypes(methodinfo *m)
753 java_objectarray *result;
756 excount = m->thrownexceptionscount;
758 /* create class-array */
759 assert(class_java_lang_Class);
761 result = builtin_anewarray(excount, class_java_lang_Class);
763 for (i = 0; i < excount; i++) {
764 if (!resolve_classref_or_classinfo(NULL,m->thrownexceptions[i],resolveEager,false,&cls))
765 return NULL; /* exception */
766 use_class_as_object(cls);
767 result->data[i] = (java_objectheader *)cls;
774 /******************************************************************************************
776 get the returntype class of a method
778 *******************************************************************************************/
780 classinfo *get_returntype(methodinfo *m)
784 if (!resolve_class_from_typedesc(&(m->parseddesc->returntype),false,&cls))
785 return NULL; /* exception */
787 use_class_as_object(cls);
792 /*****************************************************************************/
793 /*****************************************************************************/
796 /*--------------------------------------------------------*/
797 void printNativeCall(nativeCall nc) {
800 printf("\n%s's Native Methods call:\n",nc.classname); fflush(stdout);
801 for (i=0; i<nc.methCnt; i++) {
802 printf("\tMethod=%s %s\n",nc.methods[i].methodname, nc.methods[i].descriptor);fflush(stdout);
804 for (j=0; j<nc.callCnt[i]; j++) {
805 printf("\t\t<%i,%i>aCalled = %s %s %s\n",i,j,
806 nc.methods[i].methodCalls[j].classname,
807 nc.methods[i].methodCalls[j].methodname,
808 nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
811 printf("-+++++--------------------\n");fflush(stdout);
814 /*--------------------------------------------------------*/
815 void printCompNativeCall(nativeCompCall nc) {
817 printf("printCompNativeCall BEGIN\n");fflush(stdout);
818 printf("\n%s's Native Comp Methods call:\n",nc.classname->text);fflush(stdout);
819 utf_display(nc.classname); fflush(stdout);
821 for (i=0; i<nc.methCnt; i++) {
822 printf("\tMethod=%s %s\n",nc.methods[i].methodname->text,nc.methods[i].descriptor->text);fflush(stdout);
823 utf_display(nc.methods[i].methodname); fflush(stdout);
824 utf_display(nc.methods[i].descriptor);fflush(stdout);
825 printf("\n");fflush(stdout);
827 for (j=0; j<nc.callCnt[i]; j++) {
828 printf("\t\t<%i,%i>bCalled = ",i,j);fflush(stdout);
829 utf_display(nc.methods[i].methodCalls[j].classname);fflush(stdout);
830 utf_display(nc.methods[i].methodCalls[j].methodname); fflush(stdout);
831 utf_display(nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
832 printf("\n");fflush(stdout);
835 printf("---------------------\n");fflush(stdout);
839 /*--------------------------------------------------------*/
840 classMeth findNativeMethodCalls(utf *c, utf *m, utf *d )
853 /*--------------------------------------------------------*/
854 nativeCall* findNativeClassCalls(char *aclassname ) {
857 for (i=0;i<NATIVECALLSSIZE; i++) {
858 /* convert table to utf later to speed up search */
859 if (strcmp(nativeCalls[i].classname, aclassname) == 0)
860 return &nativeCalls[i];
865 /*--------------------------------------------------------*/
866 /*--------------------------------------------------------*/
867 void utfNativeCall(nativeCall nc, nativeCompCall *ncc) {
871 ncc->classname = utf_new_char(nc.classname);
872 ncc->methCnt = nc.methCnt;
874 for (i=0; i<nc.methCnt; i++) {
875 ncc->methods[i].methodname = utf_new_char(nc.methods[i].methodname);
876 ncc->methods[i].descriptor = utf_new_char(nc.methods[i].descriptor);
877 ncc->callCnt[i] = nc.callCnt[i];
879 for (j=0; j<nc.callCnt[i]; j++) {
881 ncc->methods[i].methodCalls[j].classname = utf_new_char(nc.methods[i].methodCalls[j].classname);
883 if (strcmp("", nc.methods[i].methodCalls[j].methodname) != 0) {
884 ncc->methods[i].methodCalls[j].methodname = utf_new_char(nc.methods[i].methodCalls[j].methodname);
885 ncc->methods[i].methodCalls[j].descriptor = utf_new_char(nc.methods[i].methodCalls[j].descriptor);
888 ncc->methods[i].methodCalls[j].methodname = NULL;
889 ncc->methods[i].methodCalls[j].descriptor = NULL;
897 /*--------------------------------------------------------*/
899 bool natcall2utf(bool natcallcompdone) {
905 for (i=0;i<NATIVECALLSSIZE; i++) {
906 utfNativeCall (nativeCalls[i], &nativeCompCalls[i]);
912 /*--------------------------------------------------------*/
915 java_objectarray *builtin_asm_createclasscontextarray(classinfo **end, classinfo **start)
917 /* XXX platform dependend */
919 java_objectarray *tmpArray;
925 size = (((size_t) start) - ((size_t) end)) / sizeof(classinfo*);
927 /*printf("end %p, start %p, size %ld\n",end,start,size);*/
930 if (*start == class_java_lang_SecurityManager) {
936 tmpArray = builtin_anewarray(size, class_java_lang_Class);
938 for(i = 0, current = start; i < size; i++, current--) {
941 utf_display(c->name);*/
942 use_class_as_object(c);
943 tmpArray->data[i] = (java_objectheader *) c;
950 java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end, classinfo **start)
952 /* XXX platform dependend */
957 classinfo *privilegedAction;
960 size = (((size_t) start) - ((size_t) end)) / sizeof(classinfo*);
962 /* log_text("builtin_asm_getclassloader");
963 printf("end %p, start %p, size %ld\n",end,start,size);*/
965 if (!class_java_lang_SecurityManager)
966 if (!load_class_bootstrap(utf_new_char("java/lang/SecurityManager"),&class_java_lang_SecurityManager))
970 if (*start == class_java_lang_SecurityManager) {
976 if (!load_class_bootstrap(utf_new_char("java/security/PrivilegedAction"),&privilegedAction))
979 for(i = 0, current = start; i < size; i++, current--) {
982 if (c == privilegedAction)
986 return (java_lang_ClassLoader *) c->classloader;
994 * These are local overrides for various environment variables in Emacs.
995 * Please do not remove this and leave it at the end of the file, where
996 * Emacs will automagically detect them.
997 * ---------------------------------------------------------------------
1000 * indent-tabs-mode: t