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 2465 2005-05-13 00:02:01Z twisti $
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"
100 #if defined(STATIC_CLASSPATH)
102 #include "native/nativetable.inc"
104 #else /* defined(STATIC_CLASSPATH) */
106 /* Ensure that symbols for functions implemented within CACAO are used and */
107 /* exported to dlopen. */
109 static functionptr dummynativetable[] = {
110 (functionptr) Java_gnu_classpath_VMStackWalker_getClassContext,
112 (functionptr) Java_gnu_classpath_VMSystemProperties_preInit,
114 (functionptr) Java_java_lang_VMClass_isInstance,
115 (functionptr) Java_java_lang_VMClass_isAssignableFrom,
116 (functionptr) Java_java_lang_VMClass_isInterface,
117 (functionptr) Java_java_lang_VMClass_isPrimitive,
118 (functionptr) Java_java_lang_VMClass_getName,
119 (functionptr) Java_java_lang_VMClass_getSuperclass,
120 (functionptr) Java_java_lang_VMClass_getInterfaces,
121 (functionptr) Java_java_lang_VMClass_getComponentType,
122 (functionptr) Java_java_lang_VMClass_getModifiers,
123 (functionptr) Java_java_lang_VMClass_getDeclaringClass,
124 (functionptr) Java_java_lang_VMClass_getDeclaredClasses,
125 (functionptr) Java_java_lang_VMClass_getDeclaredFields,
126 (functionptr) Java_java_lang_VMClass_getDeclaredMethods,
127 (functionptr) Java_java_lang_VMClass_getDeclaredConstructors,
128 (functionptr) Java_java_lang_VMClass_getClassLoader,
129 (functionptr) Java_java_lang_VMClass_forName,
130 (functionptr) Java_java_lang_VMClass_isArray,
131 (functionptr) Java_java_lang_VMClass_initialize,
132 (functionptr) Java_java_lang_VMClass_loadArrayClass,
133 (functionptr) Java_java_lang_VMClass_throwException,
135 (functionptr) Java_java_lang_VMClassLoader_defineClass,
136 (functionptr) Java_java_lang_VMClassLoader_resolveClass,
137 (functionptr) Java_java_lang_VMClassLoader_loadClass,
138 (functionptr) Java_java_lang_VMClassLoader_getPrimitiveClass,
139 (functionptr) Java_java_lang_VMClassLoader_nativeGetResources,
141 (functionptr) Java_java_lang_VMObject_getClass,
142 (functionptr) Java_java_lang_VMObject_clone,
143 (functionptr) Java_java_lang_VMObject_notify,
144 (functionptr) Java_java_lang_VMObject_notifyAll,
145 (functionptr) Java_java_lang_VMObject_wait,
147 (functionptr) Java_java_lang_VMRuntime_availableProcessors,
148 (functionptr) Java_java_lang_VMRuntime_freeMemory,
149 (functionptr) Java_java_lang_VMRuntime_totalMemory,
150 (functionptr) Java_java_lang_VMRuntime_maxMemory,
151 (functionptr) Java_java_lang_VMRuntime_gc,
152 (functionptr) Java_java_lang_VMRuntime_runFinalization,
153 (functionptr) Java_java_lang_VMRuntime_runFinalizationForExit,
154 (functionptr) Java_java_lang_VMRuntime_traceInstructions,
155 (functionptr) Java_java_lang_VMRuntime_traceMethodCalls,
156 (functionptr) Java_java_lang_VMRuntime_runFinalizersOnExit,
157 (functionptr) Java_java_lang_VMRuntime_exit,
158 (functionptr) Java_java_lang_VMRuntime_nativeLoad,
159 (functionptr) Java_java_lang_VMRuntime_mapLibraryName,
161 (functionptr) Java_java_lang_VMString_intern,
163 (functionptr) Java_java_lang_VMSystem_arraycopy,
164 (functionptr) Java_java_lang_VMSystem_identityHashCode,
166 (functionptr) Java_java_lang_VMThread_start,
167 (functionptr) Java_java_lang_VMThread_interrupt,
168 (functionptr) Java_java_lang_VMThread_isInterrupted,
169 (functionptr) Java_java_lang_VMThread_suspend,
170 (functionptr) Java_java_lang_VMThread_resume,
171 (functionptr) Java_java_lang_VMThread_nativeSetPriority,
172 (functionptr) Java_java_lang_VMThread_nativeStop,
173 (functionptr) Java_java_lang_VMThread_currentThread,
174 (functionptr) Java_java_lang_VMThread_yield,
175 (functionptr) Java_java_lang_VMThread_interrupted,
176 (functionptr) Java_java_lang_VMThread_holdsLock,
178 (functionptr) Java_java_lang_VMThrowable_fillInStackTrace,
179 (functionptr) Java_java_lang_VMThrowable_getStackTrace,
181 (functionptr) Java_java_lang_reflect_Constructor_getModifiers,
182 (functionptr) Java_java_lang_reflect_Constructor_constructNative,
184 (functionptr) Java_java_lang_reflect_Field_getModifiers,
185 (functionptr) Java_java_lang_reflect_Field_getType,
186 (functionptr) Java_java_lang_reflect_Field_get,
187 (functionptr) Java_java_lang_reflect_Field_getBoolean,
188 (functionptr) Java_java_lang_reflect_Field_getByte,
189 (functionptr) Java_java_lang_reflect_Field_getChar,
190 (functionptr) Java_java_lang_reflect_Field_getShort,
191 (functionptr) Java_java_lang_reflect_Field_getInt,
192 (functionptr) Java_java_lang_reflect_Field_getLong,
193 (functionptr) Java_java_lang_reflect_Field_getFloat,
194 (functionptr) Java_java_lang_reflect_Field_getDouble,
195 (functionptr) Java_java_lang_reflect_Field_set,
196 (functionptr) Java_java_lang_reflect_Field_setBoolean,
197 (functionptr) Java_java_lang_reflect_Field_setByte,
198 (functionptr) Java_java_lang_reflect_Field_setChar,
199 (functionptr) Java_java_lang_reflect_Field_setShort,
200 (functionptr) Java_java_lang_reflect_Field_setInt,
201 (functionptr) Java_java_lang_reflect_Field_setLong,
202 (functionptr) Java_java_lang_reflect_Field_setFloat,
203 (functionptr) Java_java_lang_reflect_Field_setDouble,
205 (functionptr) Java_java_lang_reflect_Proxy_getProxyClass0,
206 (functionptr) Java_java_lang_reflect_Proxy_getProxyData0,
207 (functionptr) Java_java_lang_reflect_Proxy_generateProxyClass0,
209 (functionptr) Java_java_lang_reflect_Method_getModifiers,
210 (functionptr) Java_java_lang_reflect_Method_getReturnType,
211 (functionptr) Java_java_lang_reflect_Method_getParameterTypes,
212 (functionptr) Java_java_lang_reflect_Method_getExceptionTypes,
213 (functionptr) Java_java_lang_reflect_Method_invokeNative,
216 #endif /* defined(STATIC_CLASSPATH) */
219 /************* use classinfo structure as java.lang.Class object **************/
221 void use_class_as_object(classinfo *c)
223 if (!c->classvftbl) {
224 /* is the class loaded */
226 /* if (!class_load(c)) */
227 /* throw_exception_exit(); */
228 log_text("use_class_as_object: class_load should not happen");
232 /* is the class linked */
235 throw_exception_exit();
237 assert(class_java_lang_Class);
239 c->header.vftbl = class_java_lang_Class->vftbl;
240 c->classvftbl = true;
245 /************************** tables for methods ********************************/
250 #ifdef STATIC_CLASSPATH
251 #define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
253 /* table for fast string comparison */
254 static nativecompref nativecomptable[NATIVETABLESIZE];
256 /* string comparsion table initialized */
257 static bool nativecompdone = false;
261 /* XXX don't define this in a header file!!! */
263 static struct nativeCall nativeCalls[] =
265 #include "nativecalls.inc"
268 #define NATIVECALLSSIZE (sizeof(nativeCalls) / sizeof(struct nativeCall))
270 struct nativeCompCall nativeCompCalls[NATIVECALLSSIZE];
273 /* native_loadclasses **********************************************************
275 Load classes required for native methods.
277 *******************************************************************************/
279 bool native_init(void)
281 #if !defined(STATIC_CLASSPATH)
284 /* We need to access the dummy native table, not only to remove a warning */
285 /* but to be sure that the table is not optimized away (gcc does this */
287 p = &dummynativetable;
290 /* everything's ok */
296 /*********************** Function: native_findfunction *************************
298 Looks up a method (must have the same class name, method name, descriptor
299 and 'static'ness) and returns a function pointer to it.
300 Returns: function pointer or NULL (if there is no such method)
302 Remark: For faster operation, the names/descriptors are converted from C
303 strings to Unicode the first time this function is called.
305 *******************************************************************************/
307 functionptr native_findfunction(utf *cname, utf *mname,
308 utf *desc, bool isstatic)
310 #ifdef STATIC_CLASSPATH
312 /* entry of table for fast string comparison */
313 struct nativecompref *n;
314 /* for warning message if no function is found */
318 isstatic = isstatic ? true : false;
320 if (!nativecompdone) {
321 for (i = 0; i < NATIVETABLESIZE; i++) {
322 nativecomptable[i].classname =
323 utf_new_char(nativetable[i].classname);
324 nativecomptable[i].methodname =
325 utf_new_char(nativetable[i].methodname);
326 nativecomptable[i].descriptor =
327 utf_new_char(nativetable[i].descriptor);
328 nativecomptable[i].isstatic =
329 nativetable[i].isstatic;
330 nativecomptable[i].func =
333 nativecompdone = true;
338 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
340 buffer = MNEW(char, buffer_len);
342 strcpy(buffer, "searching matching function in native table:");
343 utf_sprint(buffer+strlen(buffer), mname);
344 strcpy(buffer+strlen(buffer), ": ");
345 utf_sprint(buffer+strlen(buffer), desc);
346 strcpy(buffer+strlen(buffer), " for class ");
347 utf_sprint(buffer+strlen(buffer), cname);
351 MFREE(buffer, char, buffer_len);
354 for (i = 0; i < NATIVETABLESIZE; i++) {
355 n = &(nativecomptable[i]);
357 if (cname == n->classname && mname == n->methodname &&
358 desc == n->descriptor && isstatic == n->isstatic)
362 if (cname == n->classname && mname == n->methodname ) log_text("static and descriptor mismatch");
366 utf_strlen(n->classname) + utf_strlen(n->methodname) + utf_strlen(n->descriptor) + 64;
368 buffer = MNEW(char, buffer_len);
370 strcpy(buffer, "comparing with:");
371 utf_sprint(buffer+strlen(buffer), n->methodname);
372 strcpy (buffer+strlen(buffer), ": ");
373 utf_sprint(buffer+strlen(buffer), n->descriptor);
374 strcpy(buffer+strlen(buffer), " for class ");
375 utf_sprint(buffer+strlen(buffer), n->classname);
379 MFREE(buffer, char, buffer_len);
386 /* no function was found, display warning */
389 utf_strlen(cname) + utf_strlen(mname) + utf_strlen(desc) + 64;
391 buffer = MNEW(char, buffer_len);
393 strcpy(buffer, "warning: native function ");
394 utf_sprint(buffer + strlen(buffer), mname);
395 strcpy(buffer + strlen(buffer), ": ");
396 utf_sprint(buffer + strlen(buffer), desc);
397 strcpy(buffer + strlen(buffer), " not found in class ");
398 utf_sprint(buffer + strlen(buffer), cname);
402 MFREE(buffer, char, buffer_len);
406 /* keep compiler happy */
409 /* dynamic classpath */
415 /****************** function class_findfield_approx ****************************
417 searches in 'classinfo'-structure for a field with the
420 *******************************************************************************/
422 fieldinfo *class_findfield_approx(classinfo *c, utf *name)
426 for (i = 0; i < c->fieldscount; i++) {
427 /* compare field names */
428 if ((c->fields[i].name == name))
429 return &(c->fields[i]);
432 /* field was not found, raise exception */
433 *exceptionptr = new_exception(string_java_lang_NoSuchFieldException);
439 s4 class_findfield_index_approx(classinfo *c, utf *name)
443 for (i = 0; i < c->fieldscount; i++) {
444 /* compare field names */
445 if ((c->fields[i].name == name))
449 /* field was not found, raise exception */
450 *exceptionptr = new_exception(string_java_lang_NoSuchFieldException);
456 /* native_new_and_init *********************************************************
458 Creates a new object on the heap and calls the initializer.
459 Returns the object pointer or NULL if memory is exhausted.
461 *******************************************************************************/
463 java_objectheader *native_new_and_init(classinfo *c)
466 java_objectheader *o;
469 return *exceptionptr;
478 /* find initializer */
480 m = class_findmethod(c, utf_init, utf_void__void);
482 /* initializer not found */
487 /* call initializer */
489 asm_calljavafunction(m, o, NULL, NULL, NULL);
495 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s)
498 java_objectheader *o;
501 return *exceptionptr;
510 /* find initializer */
512 m = class_resolveclassmethod(c,
514 utf_java_lang_String__void,
518 /* initializer not found */
523 /* call initializer */
525 asm_calljavafunction(m, o, s, NULL, NULL);
531 java_objectheader *native_new_and_init_int(classinfo *c, s4 i)
534 java_objectheader *o;
537 return *exceptionptr;
546 /* find initializer */
548 m = class_resolveclassmethod(c, utf_init, utf_int__void, NULL, true);
550 /* initializer not found */
555 /* call initializer */
557 asm_calljavafunction(m, o, (void *) (ptrint) i, NULL, NULL);
563 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t)
566 java_objectheader *o;
569 return *exceptionptr;
578 /* find initializer */
580 m = class_findmethod(c, utf_init, utf_java_lang_Throwable__void);
582 /* initializer not found */
587 /* call initializer */
589 asm_calljavafunction(m, o, t, NULL, NULL);
595 void copy_vftbl(vftbl_t **dest, vftbl_t *src)
599 /* XXX this kind of copying does not work (in the general
600 * case). The interface tables would have to be copied, too. I
601 * don't see why we should make a copy anyway. -Edwin
603 *dest = mem_alloc(sizeof(vftbl) + sizeof(methodptr)*(src->vftbllength-1));
604 memcpy(*dest, src, sizeof(vftbl) - sizeof(methodptr));
605 memcpy(&(*dest)->table, &src->table, src->vftbllength * sizeof(methodptr));
610 /******************************************************************************************
612 creates method signature (excluding return type) from array of
613 class-objects representing the parameters of the method
615 *******************************************************************************************/
618 utf *create_methodsig(java_objectarray* types, char *retType)
620 char *buffer; /* buffer for building the desciptor */
621 char *pos; /* current position in buffer */
622 utf *result; /* the method signature */
623 u4 buffer_size = 3; /* minimal size=3: room for parenthesis and returntype */
626 if (!types) return NULL;
628 /* determine required buffer-size */
629 for (i = 0; i < types->header.size; i++) {
630 classinfo *c = (classinfo *) types->data[i];
631 buffer_size = buffer_size + c->name->blength + 2;
634 if (retType) buffer_size += strlen(retType);
636 /* allocate buffer */
637 buffer = MNEW(char, buffer_size);
640 /* method-desciptor starts with parenthesis */
643 for (i = 0; i < types->header.size; i++) {
646 /* current argument */
647 classinfo *c = (classinfo *) types->data[i];
649 /* current position in utf-text */
650 char *utf_ptr = c->name->text;
652 /* determine type of argument */
653 if ((ch = utf_nextu2(&utf_ptr)) == '[') {
655 for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
656 *pos++ = *utf_ptr; /* copy text */
660 /* check for primitive types */
661 for (j = 0; j < PRIMITIVETYPE_COUNT; j++) {
662 char *utf_pos = utf_ptr - 1;
663 char *primitive = primitivetype_table[j].wrapname;
666 while (utf_pos < utf_end(c->name)) {
667 if (*utf_pos++ != *primitive++) goto nomatch;
670 /* primitive type found */
671 *pos++ = primitivetype_table[j].typesig;
678 /* no primitive type and no arrayclass, so must be object */
682 for (utf_ptr--; utf_ptr < utf_end(c->name); utf_ptr++) {
696 for (i = 0; i < strlen(retType); i++) {
701 /* create utf-string */
702 result = utf_new(buffer, (pos - buffer));
703 MFREE(buffer, char, buffer_size);
709 /* get_parametertypes **********************************************************
711 use the descriptor of a method to generate a java/lang/Class array
712 which contains the classes of the parametertypes of the method
714 *******************************************************************************/
716 java_objectarray* get_parametertypes(methodinfo *m)
718 methoddesc *descr = m->parseddesc; /* method-descriptor */
719 java_objectarray* result;
720 int parametercount = descr->paramcount;
723 /* create class-array */
724 assert(class_java_lang_Class);
726 result = builtin_anewarray(parametercount, class_java_lang_Class);
729 for (i = 0; i < parametercount; i++) {
730 if (!resolve_class_from_typedesc(descr->paramtypes + i,false,
731 (classinfo **) (result->data + i)))
732 return NULL; /* exception */
733 use_class_as_object((classinfo*) result->data[i]);
740 /* get_exceptiontypes **********************************************************
742 get the exceptions which can be thrown by a method
744 *******************************************************************************/
746 java_objectarray* get_exceptiontypes(methodinfo *m)
750 java_objectarray *result;
753 excount = m->thrownexceptionscount;
755 /* create class-array */
756 assert(class_java_lang_Class);
758 result = builtin_anewarray(excount, class_java_lang_Class);
760 for (i = 0; i < excount; i++) {
761 if (!resolve_classref_or_classinfo(NULL,m->thrownexceptions[i],resolveEager,false,&cls))
762 return NULL; /* exception */
763 use_class_as_object(cls);
764 result->data[i] = (java_objectheader *)cls;
771 /******************************************************************************************
773 get the returntype class of a method
775 *******************************************************************************************/
777 classinfo *get_returntype(methodinfo *m)
781 if (!resolve_class_from_typedesc(&(m->parseddesc->returntype),false,&cls))
782 return NULL; /* exception */
784 use_class_as_object(cls);
789 /*****************************************************************************/
790 /*****************************************************************************/
793 /*--------------------------------------------------------*/
794 void printNativeCall(nativeCall nc) {
797 printf("\n%s's Native Methods call:\n",nc.classname); fflush(stdout);
798 for (i=0; i<nc.methCnt; i++) {
799 printf("\tMethod=%s %s\n",nc.methods[i].methodname, nc.methods[i].descriptor);fflush(stdout);
801 for (j=0; j<nc.callCnt[i]; j++) {
802 printf("\t\t<%i,%i>aCalled = %s %s %s\n",i,j,
803 nc.methods[i].methodCalls[j].classname,
804 nc.methods[i].methodCalls[j].methodname,
805 nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
808 printf("-+++++--------------------\n");fflush(stdout);
811 /*--------------------------------------------------------*/
812 void printCompNativeCall(nativeCompCall nc) {
814 printf("printCompNativeCall BEGIN\n");fflush(stdout);
815 printf("\n%s's Native Comp Methods call:\n",nc.classname->text);fflush(stdout);
816 utf_display(nc.classname); fflush(stdout);
818 for (i=0; i<nc.methCnt; i++) {
819 printf("\tMethod=%s %s\n",nc.methods[i].methodname->text,nc.methods[i].descriptor->text);fflush(stdout);
820 utf_display(nc.methods[i].methodname); fflush(stdout);
821 utf_display(nc.methods[i].descriptor);fflush(stdout);
822 printf("\n");fflush(stdout);
824 for (j=0; j<nc.callCnt[i]; j++) {
825 printf("\t\t<%i,%i>bCalled = ",i,j);fflush(stdout);
826 utf_display(nc.methods[i].methodCalls[j].classname);fflush(stdout);
827 utf_display(nc.methods[i].methodCalls[j].methodname); fflush(stdout);
828 utf_display(nc.methods[i].methodCalls[j].descriptor);fflush(stdout);
829 printf("\n");fflush(stdout);
832 printf("---------------------\n");fflush(stdout);
836 /*--------------------------------------------------------*/
837 classMeth findNativeMethodCalls(utf *c, utf *m, utf *d )
850 /*--------------------------------------------------------*/
851 nativeCall* findNativeClassCalls(char *aclassname ) {
854 for (i=0;i<NATIVECALLSSIZE; i++) {
855 /* convert table to utf later to speed up search */
856 if (strcmp(nativeCalls[i].classname, aclassname) == 0)
857 return &nativeCalls[i];
862 /*--------------------------------------------------------*/
863 /*--------------------------------------------------------*/
864 void utfNativeCall(nativeCall nc, nativeCompCall *ncc) {
868 ncc->classname = utf_new_char(nc.classname);
869 ncc->methCnt = nc.methCnt;
871 for (i=0; i<nc.methCnt; i++) {
872 ncc->methods[i].methodname = utf_new_char(nc.methods[i].methodname);
873 ncc->methods[i].descriptor = utf_new_char(nc.methods[i].descriptor);
874 ncc->callCnt[i] = nc.callCnt[i];
876 for (j=0; j<nc.callCnt[i]; j++) {
878 ncc->methods[i].methodCalls[j].classname = utf_new_char(nc.methods[i].methodCalls[j].classname);
880 if (strcmp("", nc.methods[i].methodCalls[j].methodname) != 0) {
881 ncc->methods[i].methodCalls[j].methodname = utf_new_char(nc.methods[i].methodCalls[j].methodname);
882 ncc->methods[i].methodCalls[j].descriptor = utf_new_char(nc.methods[i].methodCalls[j].descriptor);
885 ncc->methods[i].methodCalls[j].methodname = NULL;
886 ncc->methods[i].methodCalls[j].descriptor = NULL;
894 /*--------------------------------------------------------*/
896 bool natcall2utf(bool natcallcompdone) {
902 for (i=0;i<NATIVECALLSSIZE; i++) {
903 utfNativeCall (nativeCalls[i], &nativeCompCalls[i]);
909 /*--------------------------------------------------------*/
912 java_objectarray *builtin_asm_createclasscontextarray(classinfo **end, classinfo **start)
914 /* XXX platform dependend */
916 java_objectarray *tmpArray;
922 size = (((size_t) start) - ((size_t) end)) / sizeof(classinfo*);
924 /*printf("end %p, start %p, size %ld\n",end,start,size);*/
927 if (*start == class_java_lang_SecurityManager) {
933 tmpArray = builtin_anewarray(size, class_java_lang_Class);
935 for(i = 0, current = start; i < size; i++, current--) {
938 utf_display(c->name);*/
939 use_class_as_object(c);
940 tmpArray->data[i] = (java_objectheader *) c;
947 java_lang_ClassLoader *builtin_asm_getclassloader(classinfo **end, classinfo **start)
949 /* XXX platform dependend */
954 classinfo *privilegedAction;
957 size = (((size_t) start) - ((size_t) end)) / sizeof(classinfo*);
959 /* log_text("builtin_asm_getclassloader");
960 printf("end %p, start %p, size %ld\n",end,start,size);*/
962 if (!class_java_lang_SecurityManager)
963 if (!load_class_bootstrap(utf_new_char("java/lang/SecurityManager"),&class_java_lang_SecurityManager))
967 if (*start == class_java_lang_SecurityManager) {
973 if (!load_class_bootstrap(utf_new_char("java/security/PrivilegedAction"),&privilegedAction))
976 for(i = 0, current = start; i < size; i++, current--) {
979 if (c == privilegedAction)
983 return (java_lang_ClassLoader *) c->classloader;
991 * These are local overrides for various environment variables in Emacs.
992 * Please do not remove this and leave it at the end of the file, where
993 * Emacs will automagically detect them.
994 * ---------------------------------------------------------------------
997 * indent-tabs-mode: t