1 /* src/native/native.c - table of native functions
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
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., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Reinhard Grafl
31 Changes: Christian Thalinger
33 $Id: native.c 4921 2006-05-15 14:24:36Z twisti $
42 #if !defined(WITH_STATIC_CLASSPATH)
48 #include "mm/memory.h"
49 #include "native/jni.h"
50 #include "native/native.h"
51 #include "native/include/java_lang_Throwable.h"
52 #include "toolbox/logging.h"
53 #include "vm/builtin.h"
54 #include "vm/exceptions.h"
55 #include "vm/global.h"
56 #include "vm/hashtable.h"
57 #include "vm/loader.h"
58 #include "vm/options.h"
59 #include "vm/resolve.h"
60 #include "vm/stringlocal.h"
62 #include "vm/jit/asmpart.h"
63 #include "vm/jit/jit.h"
66 /* include table of native functions ******************************************/
68 #include "native/include/java_lang_Cloneable.h"
69 #include "native/include/java_util_Properties.h"
70 #include "native/include/java_io_InputStream.h"
71 #include "native/include/java_io_PrintStream.h"
73 #include "native/include/gnu_classpath_VMStackWalker.h"
74 #include "native/include/gnu_classpath_VMSystemProperties.h"
75 #include "native/include/java_lang_Class.h"
76 #include "native/include/java_lang_Object.h"
77 #include "native/include/java_lang_VMClass.h"
78 #include "native/include/java_lang_VMClassLoader.h"
79 #include "native/include/java_lang_VMObject.h"
80 #include "native/include/java_lang_VMRuntime.h"
81 #include "native/include/java_lang_VMString.h"
82 #include "native/include/java_lang_VMSystem.h"
83 #include "native/include/java_lang_VMThread.h"
84 #include "native/include/java_lang_VMThrowable.h"
85 #include "native/include/java_lang_reflect_Constructor.h"
86 #include "native/include/java_lang_reflect_Field.h"
87 #include "native/include/java_lang_reflect_Method.h"
88 #include "native/include/java_lang_reflect_VMProxy.h"
89 #include "native/include/java_security_VMAccessController.h"
90 #if defined(ENABLE_JVMTI)
91 #include "native/include/gnu_classpath_jdwp_event_EventRequest.h"
92 #include "native/include/java_nio_ByteBuffer.h"
93 #include "native/include/gnu_classpath_jdwp_VMVirtualMachine.h"
94 #include "native/include/gnu_classpath_jdwp_VMFrame.h"
95 #include "native/include/gnu_classpath_jdwp_VMMethod.h"
98 #if defined(WITH_STATIC_CLASSPATH)
100 /* these are required to prevent compiler warnings */
102 #include "native/include/java_net_DatagramPacket.h"
103 #include "native/include/java_net_InetAddress.h"
104 #include "native/include/java_net_SocketImpl.h"
106 #include "native/include/gnu_java_net_PlainDatagramSocketImpl.h"
107 #include "native/include/gnu_java_net_PlainSocketImpl.h"
108 #include "native/include/gnu_java_nio_PipeImpl.h"
109 #include "native/include/gnu_java_nio_channels_FileChannelImpl.h"
110 #include "native/include/gnu_java_nio_charset_iconv_IconvEncoder.h"
111 #include "native/include/gnu_java_nio_charset_iconv_IconvDecoder.h"
112 #include "native/include/java_lang_VMProcess.h"
113 #include "native/include/java_nio_MappedByteBufferImpl.h"
114 #include "native/include/java_nio_channels_spi_SelectorProvider.h"
116 /* now include the native table */
118 #include "native/nativetable.inc"
120 #else /* defined(WITH_STATIC_CLASSPATH) */
122 /* Ensure that symbols for functions implemented within CACAO are used
123 and exported to dlopen. */
125 static functionptr dummynativetable[] = {
126 (functionptr) Java_gnu_classpath_VMStackWalker_getClassContext,
128 (functionptr) Java_gnu_classpath_VMSystemProperties_preInit,
130 (functionptr) Java_java_lang_VMClass_isInstance,
131 (functionptr) Java_java_lang_VMClass_isAssignableFrom,
132 (functionptr) Java_java_lang_VMClass_isInterface,
133 (functionptr) Java_java_lang_VMClass_isPrimitive,
134 (functionptr) Java_java_lang_VMClass_getName,
135 (functionptr) Java_java_lang_VMClass_getSuperclass,
136 (functionptr) Java_java_lang_VMClass_getInterfaces,
137 (functionptr) Java_java_lang_VMClass_getComponentType,
138 (functionptr) Java_java_lang_VMClass_getModifiers,
139 (functionptr) Java_java_lang_VMClass_getDeclaringClass,
140 (functionptr) Java_java_lang_VMClass_getDeclaredClasses,
141 (functionptr) Java_java_lang_VMClass_getDeclaredFields,
142 (functionptr) Java_java_lang_VMClass_getDeclaredMethods,
143 (functionptr) Java_java_lang_VMClass_getDeclaredConstructors,
144 (functionptr) Java_java_lang_VMClass_getClassLoader,
145 (functionptr) Java_java_lang_VMClass_forName,
146 (functionptr) Java_java_lang_VMClass_isArray,
147 (functionptr) Java_java_lang_VMClass_throwException,
149 (functionptr) Java_java_lang_VMClassLoader_defineClass,
150 (functionptr) Java_java_lang_VMClassLoader_resolveClass,
151 (functionptr) Java_java_lang_VMClassLoader_loadClass,
152 (functionptr) Java_java_lang_VMClassLoader_getPrimitiveClass,
153 (functionptr) Java_java_lang_VMClassLoader_nativeGetResources,
154 (functionptr) Java_java_lang_VMClassLoader_findLoadedClass,
156 (functionptr) Java_java_lang_VMObject_getClass,
157 (functionptr) Java_java_lang_VMObject_clone,
158 (functionptr) Java_java_lang_VMObject_notify,
159 (functionptr) Java_java_lang_VMObject_notifyAll,
160 (functionptr) Java_java_lang_VMObject_wait,
162 (functionptr) Java_java_lang_VMRuntime_availableProcessors,
163 (functionptr) Java_java_lang_VMRuntime_freeMemory,
164 (functionptr) Java_java_lang_VMRuntime_totalMemory,
165 (functionptr) Java_java_lang_VMRuntime_maxMemory,
166 (functionptr) Java_java_lang_VMRuntime_gc,
167 (functionptr) Java_java_lang_VMRuntime_runFinalization,
168 (functionptr) Java_java_lang_VMRuntime_runFinalizationForExit,
169 (functionptr) Java_java_lang_VMRuntime_traceInstructions,
170 (functionptr) Java_java_lang_VMRuntime_traceMethodCalls,
171 (functionptr) Java_java_lang_VMRuntime_runFinalizersOnExit,
172 (functionptr) Java_java_lang_VMRuntime_exit,
173 (functionptr) Java_java_lang_VMRuntime_nativeLoad,
174 (functionptr) Java_java_lang_VMRuntime_mapLibraryName,
176 (functionptr) Java_java_lang_VMString_intern,
178 (functionptr) Java_java_lang_VMSystem_arraycopy,
179 (functionptr) Java_java_lang_VMSystem_identityHashCode,
181 (functionptr) Java_java_lang_VMThread_start,
182 (functionptr) Java_java_lang_VMThread_interrupt,
183 (functionptr) Java_java_lang_VMThread_isInterrupted,
184 (functionptr) Java_java_lang_VMThread_suspend,
185 (functionptr) Java_java_lang_VMThread_resume,
186 (functionptr) Java_java_lang_VMThread_nativeSetPriority,
187 (functionptr) Java_java_lang_VMThread_nativeStop,
188 (functionptr) Java_java_lang_VMThread_currentThread,
189 (functionptr) Java_java_lang_VMThread_yield,
190 (functionptr) Java_java_lang_VMThread_interrupted,
191 (functionptr) Java_java_lang_VMThread_holdsLock,
193 (functionptr) Java_java_lang_VMThrowable_fillInStackTrace,
194 (functionptr) Java_java_lang_VMThrowable_getStackTrace,
196 (functionptr) Java_java_lang_reflect_Constructor_getModifiersInternal,
197 (functionptr) Java_java_lang_reflect_Constructor_constructNative,
199 (functionptr) Java_java_lang_reflect_Field_getModifiersInternal,
200 (functionptr) Java_java_lang_reflect_Field_getType,
201 (functionptr) Java_java_lang_reflect_Field_get,
202 (functionptr) Java_java_lang_reflect_Field_getBoolean,
203 (functionptr) Java_java_lang_reflect_Field_getByte,
204 (functionptr) Java_java_lang_reflect_Field_getChar,
205 (functionptr) Java_java_lang_reflect_Field_getShort,
206 (functionptr) Java_java_lang_reflect_Field_getInt,
207 (functionptr) Java_java_lang_reflect_Field_getLong,
208 (functionptr) Java_java_lang_reflect_Field_getFloat,
209 (functionptr) Java_java_lang_reflect_Field_getDouble,
210 (functionptr) Java_java_lang_reflect_Field_set,
211 (functionptr) Java_java_lang_reflect_Field_setBoolean,
212 (functionptr) Java_java_lang_reflect_Field_setByte,
213 (functionptr) Java_java_lang_reflect_Field_setChar,
214 (functionptr) Java_java_lang_reflect_Field_setShort,
215 (functionptr) Java_java_lang_reflect_Field_setInt,
216 (functionptr) Java_java_lang_reflect_Field_setLong,
217 (functionptr) Java_java_lang_reflect_Field_setFloat,
218 (functionptr) Java_java_lang_reflect_Field_setDouble,
220 (functionptr) Java_java_lang_reflect_Method_getModifiersInternal,
221 (functionptr) Java_java_lang_reflect_Method_getReturnType,
222 (functionptr) Java_java_lang_reflect_Method_getParameterTypes,
223 (functionptr) Java_java_lang_reflect_Method_getExceptionTypes,
224 (functionptr) Java_java_lang_reflect_Method_invokeNative,
226 (functionptr) Java_java_lang_reflect_VMProxy_getProxyClass,
227 (functionptr) Java_java_lang_reflect_VMProxy_getProxyData,
228 (functionptr) Java_java_lang_reflect_VMProxy_generateProxyClass,
230 (functionptr) Java_java_security_VMAccessController_getStack,
231 #if defined(ENABLE_JVMTI)
232 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread,
233 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_resumeThread,
234 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSuspendCount,
235 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClassesCount,
236 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus,
237 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllClassMethods,
238 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassMethod,
239 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrames,
240 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrame,
241 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount,
242 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getThreadStatus,
243 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getLoadRequests,
244 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_executeMethod,
245 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSourceFile,
246 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_registerEvent,
247 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_unregisterEvent,
248 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_clearEvents,
249 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClasses,
250 (functionptr) Java_gnu_classpath_jdwp_VMFrame_setValue,
251 (functionptr) Java_gnu_classpath_jdwp_VMFrame_getValue,
252 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getName,
253 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getSignature,
254 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getModifiers,
255 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getLineTable,
256 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getVariableTable
261 #endif /* defined(WITH_STATIC_CLASSPATH) */
264 /* tables for methods *********************************************************/
266 #if defined(WITH_STATIC_CLASSPATH)
267 #define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
269 /* table for fast string comparison */
270 static nativecompref nativecomptable[NATIVETABLESIZE];
272 /* string comparsion table initialized */
273 static bool nativecompdone = false;
277 /* global variables ***********************************************************/
279 #if !defined(WITH_STATIC_CLASSPATH)
280 static hashtable *hashtable_library;
281 static lt_dlhandle mainhandle;
285 /* native_loadclasses **********************************************************
287 Load classes required for native methods.
289 *******************************************************************************/
291 bool native_init(void)
293 #if !defined(WITH_STATIC_CLASSPATH)
296 /* We need to access the dummy native table, not only to remove a
297 warning but to be sure that the table is not optimized away
298 (gcc does this since 3.4). */
300 p = &dummynativetable;
302 /* initialize libltdl */
305 /* XXX how can we throw an exception here? */
306 log_text(lt_dlerror());
311 /* get the handle for the main program */
313 if (!(mainhandle = lt_dlopen(NULL)))
316 /* initialize library hashtable, 10 entries should be enough */
318 hashtable_library = NEW(hashtable);
320 hashtable_create(hashtable_library, 10);
323 /* everything's ok */
329 /* native_hashtable_library_add ************************************************
331 Adds an entry to the native library hashtable.
333 *******************************************************************************/
335 #if !defined(WITH_STATIC_CLASSPATH)
336 void native_hashtable_library_add(utf *filename, java_objectheader *loader,
339 hashtable_library_loader_entry *le;
340 hashtable_library_name_entry *ne; /* library name */
341 u4 key; /* hashkey */
342 u4 slot; /* slot in hashtable */
344 #if defined(ENABLE_THREADS)
345 builtin_monitorenter(hashtable_library->header);
348 /* normally addresses are aligned to 4, 8 or 16 bytes */
350 key = ((u4) (ptrint) loader) >> 4; /* align to 16-byte boundaries */
351 slot = key & (hashtable_library->size - 1);
352 le = hashtable_library->ptr[slot];
354 /* search external hash chain for the entry */
357 if (le->loader == loader)
360 le = le->hashlink; /* next element in external chain */
363 /* no loader found? create a new entry */
366 le = NEW(hashtable_library_loader_entry);
371 /* insert entry into hashtable */
374 (hashtable_library_loader_entry *) hashtable_library->ptr[slot];
375 hashtable_library->ptr[slot] = le;
377 /* update number of hashtable-entries */
379 hashtable_library->entries++;
383 /* search for library name */
388 if (ne->name == filename) {
389 #if defined(ENABLE_THREADS)
390 builtin_monitorexit(hashtable_library->header);
396 ne = ne->hashlink; /* next element in external chain */
399 /* not found? add the library name to the classloader */
401 ne = NEW(hashtable_library_name_entry);
406 /* insert entry into external chain */
408 ne->hashlink = le->namelink;
411 #if defined(ENABLE_THREADS)
412 builtin_monitorexit(hashtable_library->header);
415 #endif /* !defined(WITH_STATIC_CLASSPATH) */
418 /* native_hashtable_library_find ***********************************************
420 Find an entry in the native library hashtable.
422 *******************************************************************************/
424 #if !defined(WITH_STATIC_CLASSPATH)
425 hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
426 java_objectheader *loader)
428 hashtable_library_loader_entry *le;
429 hashtable_library_name_entry *ne; /* library name */
430 u4 key; /* hashkey */
431 u4 slot; /* slot in hashtable */
433 /* normally addresses are aligned to 4, 8 or 16 bytes */
435 key = ((u4) (ptrint) loader) >> 4; /* align to 16-byte boundaries */
436 slot = key & (hashtable_library->size - 1);
437 le = hashtable_library->ptr[slot];
439 /* search external hash chain for the entry */
442 if (le->loader == loader)
445 le = le->hashlink; /* next element in external chain */
448 /* no loader found? return NULL */
453 /* search for library name */
458 if (ne->name == filename)
461 ne = ne->hashlink; /* next element in external chain */
464 /* return entry, if no entry was found, ne is NULL */
468 #endif /* !defined(WITH_STATIC_CLASSPATH) */
471 /* native_findfunction *********************************************************
473 Looks up a method (must have the same class name, method name,
474 descriptor and 'static'ness) and returns a function pointer to it.
475 Returns: function pointer or NULL (if there is no such method)
477 Remark: For faster operation, the names/descriptors are converted
478 from C strings to Unicode the first time this function is called.
480 *******************************************************************************/
482 #if defined(WITH_STATIC_CLASSPATH)
483 functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
486 /* entry of table for fast string comparison */
487 struct nativecompref *n;
490 isstatic = isstatic ? true : false;
492 if (!nativecompdone) {
493 for (i = 0; i < NATIVETABLESIZE; i++) {
494 nativecomptable[i].classname =
495 utf_new_char(nativetable[i].classname);
497 nativecomptable[i].methodname =
498 utf_new_char(nativetable[i].methodname);
500 nativecomptable[i].descriptor =
501 utf_new_char(nativetable[i].descriptor);
503 nativecomptable[i].isstatic = nativetable[i].isstatic;
504 nativecomptable[i].func = nativetable[i].func;
507 nativecompdone = true;
510 for (i = 0; i < NATIVETABLESIZE; i++) {
511 n = &(nativecomptable[i]);
513 if (cname == n->classname && mname == n->methodname &&
514 desc == n->descriptor && isstatic == n->isstatic)
519 /* no function was found, throw exception */
522 new_exception_utfmessage(string_java_lang_UnsatisfiedLinkError,
527 #endif /* defined(WITH_STATIC_CLASSPATH) */
530 /* native_make_overloaded_function *********************************************
534 *******************************************************************************/
536 #if !defined(WITH_STATIC_CLASSPATH)
537 static char *native_make_overloaded_function(char *name, utf *desc)
545 utf_ptr = desc->text;
546 namelen = strlen(name) + strlen("__") + strlen("0");
548 /* calculate additional length */
550 while ((c = utf_nextu2(&utf_ptr)) != ')') {
567 while (utf_nextu2(&utf_ptr) != ';')
579 /* reallocate memory */
583 newname = DMNEW(char, namelen);
584 MCOPY(newname, name, char, i);
586 utf_ptr = desc->text;
591 while ((c = utf_nextu2(&utf_ptr)) != ')') {
609 while ((c = utf_nextu2(&utf_ptr)) != ';')
610 if (((c >= 'a') && (c <= 'z')) ||
611 ((c >= 'A') && (c <= 'Z')) ||
612 ((c >= '0') && (c <= '9')))
634 /* native_resolve_function *****************************************************
636 Resolves a native function, maybe from a dynamic library.
638 *******************************************************************************/
640 functionptr native_resolve_function(methodinfo *m)
649 hashtable_library_loader_entry *le;
650 hashtable_library_name_entry *ne;
651 u4 key; /* hashkey */
652 u4 slot; /* slot in hashtable */
658 if (opt_verbosejni) {
659 printf("[Dynamic-linking native method ");
660 utf_display_printable_ascii_classname(m->class->name);
662 utf_display_printable_ascii(m->name);
666 /* calculate length of native function name */
668 namelen = strlen("Java_") + utf_get_number_of_u2s(m->class->name) + strlen("_") +
669 utf_get_number_of_u2s(m->name) + strlen("0");
671 /* check for underscores in class name */
673 utf_ptr = m->class->name->text;
674 utf_endptr = UTF_END(m->class->name);
676 while (utf_ptr < utf_endptr)
677 if (utf_nextu2(&utf_ptr) == '_')
680 /* check for underscores in method name */
682 utf_ptr = m->name->text;
683 utf_endptr = UTF_END(m->name);
685 while (utf_ptr < utf_endptr)
686 if (utf_nextu2(&utf_ptr) == '_')
689 /* allocate memory */
691 dumpsize = dump_size();
693 name = DMNEW(char, namelen);
696 /* generate name of native functions */
698 strcpy(name, "Java_");
701 utf_ptr = m->class->name->text;
702 utf_endptr = UTF_END(m->class->name);
704 for (; utf_ptr < utf_endptr; utf_ptr++, i++) {
707 /* escape sequence for '_' is '_1' */
712 /* replace '/' with '_' */
718 /* seperator between class and method */
722 utf_ptr = m->name->text;
723 utf_endptr = UTF_END(m->name);
725 for (; utf_ptr < utf_endptr; utf_ptr++, i++) {
728 /* escape sequence for '_' is '_1' */
739 /* generate overloaded function (having the types in it's name) */
741 newname = native_make_overloaded_function(name, m->descriptor);
743 /* check the library hash entries of the classloader of the
748 /* normally addresses are aligned to 4, 8 or 16 bytes */
750 key = ((u4) (ptrint) m->class->classloader) >> 4; /* align to 16-byte */
751 slot = key & (hashtable_library->size - 1);
752 le = hashtable_library->ptr[slot];
754 /* iterate through loaders in this hash slot */
756 while ((le != NULL) && (sym == NULL)) {
757 /* iterate through names in this loader */
761 while ((ne != NULL) && (sym == NULL)) {
762 sym = lt_dlsym(ne->handle, name);
765 sym = lt_dlsym(ne->handle, newname);
778 /* If not found, try to find the native function symbol in the
782 sym = lt_dlsym(mainhandle, name);
785 sym = lt_dlsym(mainhandle, newname);
789 printf("internal ]\n");
793 /* no symbol found? throw exception */
797 printf("failed ]\n");
800 new_exception_utfmessage(string_java_lang_UnsatisfiedLinkError,
806 dump_release(dumpsize);
808 return (functionptr) (ptrint) sym;
810 #endif /* !defined(WITH_STATIC_CLASSPATH) */
813 /* native_new_and_init *********************************************************
815 Creates a new object on the heap and calls the initializer.
816 Returns the object pointer or NULL if memory is exhausted.
818 *******************************************************************************/
820 java_objectheader *native_new_and_init(classinfo *c)
823 java_objectheader *o;
826 return *exceptionptr;
835 /* try to find the initializer */
837 m = class_findmethod(c, utf_init, utf_void__void);
839 /* ATTENTION: returning the object here is ok, since the class may
840 not have an initializer */
845 /* call initializer */
847 (void) vm_call_method(m, o);
853 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s)
856 java_objectheader *o;
859 return *exceptionptr;
868 /* find initializer */
870 m = class_resolveclassmethod(c,
872 utf_java_lang_String__void,
876 /* initializer not found */
881 /* call initializer */
883 (void) vm_call_method(m, o, s);
889 java_objectheader *native_new_and_init_int(classinfo *c, s4 i)
892 java_objectheader *o;
895 return *exceptionptr;
904 /* find initializer */
906 m = class_resolveclassmethod(c, utf_init, utf_int__void, NULL, true);
908 /* initializer not found */
913 /* call initializer */
915 (void) vm_call_method(m, o, i);
921 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t)
924 java_objectheader *o;
927 return *exceptionptr;
936 /* find initializer */
938 m = class_findmethod(c, utf_init, utf_java_lang_Throwable__void);
940 /* initializer not found */
945 /* call initializer */
947 (void) vm_call_method(m, o, t);
953 /* native_get_parametertypes ***************************************************
955 Use the descriptor of a method to generate a java/lang/Class array
956 which contains the classes of the parametertypes of the method.
958 *******************************************************************************/
960 java_objectarray *native_get_parametertypes(methodinfo *m)
963 typedesc *paramtypes;
965 java_objectarray *oa;
970 /* is the descriptor fully parsed? */
972 if (!m->parseddesc->params)
973 if (!descriptor_params_from_paramtypes(md, m->flags))
976 paramtypes = md->paramtypes;
977 paramcount = md->paramcount;
979 /* skip `this' pointer */
981 if (!(m->flags & ACC_STATIC)) {
986 /* create class-array */
988 oa = builtin_anewarray(paramcount, class_java_lang_Class);
995 for (i = 0; i < paramcount; i++)
996 if (!resolve_class_from_typedesc(¶mtypes[i], true, false,
997 (classinfo **) &oa->data[i]))
1004 /* native_get_exceptiontypes ***************************************************
1006 Get the exceptions which can be thrown by a method.
1008 *******************************************************************************/
1010 java_objectarray *native_get_exceptiontypes(methodinfo *m)
1012 java_objectarray *oa;
1016 /* create class-array */
1018 oa = builtin_anewarray(m->thrownexceptionscount, class_java_lang_Class);
1023 for (i = 0; i < m->thrownexceptionscount; i++) {
1024 if (!resolve_classref_or_classinfo(NULL, m->thrownexceptions[i],
1025 resolveEager, true, false, &c))
1028 oa->data[i] = (java_objectheader *) c;
1035 /* native_get_returntype *******************************************************
1037 Get the returntype class of a method.
1039 *******************************************************************************/
1041 classinfo *native_get_returntype(methodinfo *m)
1045 if (!resolve_class_from_typedesc(&(m->parseddesc->returntype), true, false,
1054 * These are local overrides for various environment variables in Emacs.
1055 * Please do not remove this and leave it at the end of the file, where
1056 * Emacs will automagically detect them.
1057 * ---------------------------------------------------------------------
1060 * indent-tabs-mode: t