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 5032 2006-06-14 18:55:35Z motse $
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"
65 #if defined(ENABLE_JVMTI)
66 #include "native/jvmti/cacaodbg.h"
70 /* include table of native functions ******************************************/
72 #include "native/include/java_lang_Cloneable.h"
73 #include "native/include/java_util_Properties.h"
74 #include "native/include/java_io_InputStream.h"
75 #include "native/include/java_io_PrintStream.h"
77 #include "native/include/gnu_classpath_VMStackWalker.h"
78 #include "native/include/gnu_classpath_VMSystemProperties.h"
79 #include "native/include/java_lang_Class.h"
80 #include "native/include/java_lang_Object.h"
81 #include "native/include/java_lang_VMClass.h"
82 #include "native/include/java_lang_VMClassLoader.h"
83 #include "native/include/java_lang_VMObject.h"
84 #include "native/include/java_lang_VMRuntime.h"
85 #include "native/include/java_lang_VMString.h"
86 #include "native/include/java_lang_VMSystem.h"
87 #include "native/include/java_lang_VMThread.h"
88 #include "native/include/java_lang_VMThrowable.h"
89 #include "native/include/java_lang_reflect_Constructor.h"
90 #include "native/include/java_lang_reflect_Field.h"
91 #include "native/include/java_lang_reflect_Method.h"
92 #include "native/include/java_lang_reflect_VMProxy.h"
93 #include "native/include/java_security_VMAccessController.h"
94 #if defined(ENABLE_JVMTI)
95 #include "native/include/gnu_classpath_jdwp_event_EventRequest.h"
96 #include "native/include/java_nio_ByteBuffer.h"
97 #include "native/include/gnu_classpath_jdwp_VMVirtualMachine.h"
98 #include "native/include/gnu_classpath_jdwp_VMFrame.h"
99 #include "native/include/gnu_classpath_jdwp_VMMethod.h"
102 #if defined(WITH_STATIC_CLASSPATH)
104 /* these are required to prevent compiler warnings */
106 #include "native/include/java_net_DatagramPacket.h"
107 #include "native/include/java_net_InetAddress.h"
108 #include "native/include/java_net_SocketImpl.h"
110 #include "native/include/gnu_java_net_PlainDatagramSocketImpl.h"
111 #include "native/include/gnu_java_net_PlainSocketImpl.h"
112 #include "native/include/gnu_java_nio_PipeImpl.h"
113 #include "native/include/gnu_java_nio_channels_FileChannelImpl.h"
114 #include "native/include/gnu_java_nio_charset_iconv_IconvEncoder.h"
115 #include "native/include/gnu_java_nio_charset_iconv_IconvDecoder.h"
116 #include "native/include/java_lang_VMProcess.h"
117 #include "native/include/java_nio_MappedByteBufferImpl.h"
118 #include "native/include/java_nio_channels_spi_SelectorProvider.h"
120 /* now include the native table */
122 #include "native/nativetable.inc"
124 #else /* defined(WITH_STATIC_CLASSPATH) */
126 /* Ensure that symbols for functions implemented within CACAO are used
127 and exported to dlopen. */
129 static functionptr dummynativetable[] = {
130 (functionptr) Java_gnu_classpath_VMStackWalker_getClassContext,
132 (functionptr) Java_gnu_classpath_VMSystemProperties_preInit,
134 (functionptr) Java_java_lang_VMClass_isInstance,
135 (functionptr) Java_java_lang_VMClass_isAssignableFrom,
136 (functionptr) Java_java_lang_VMClass_isInterface,
137 (functionptr) Java_java_lang_VMClass_isPrimitive,
138 (functionptr) Java_java_lang_VMClass_getName,
139 (functionptr) Java_java_lang_VMClass_getSuperclass,
140 (functionptr) Java_java_lang_VMClass_getInterfaces,
141 (functionptr) Java_java_lang_VMClass_getComponentType,
142 (functionptr) Java_java_lang_VMClass_getModifiers,
143 (functionptr) Java_java_lang_VMClass_getDeclaringClass,
144 (functionptr) Java_java_lang_VMClass_getDeclaredClasses,
145 (functionptr) Java_java_lang_VMClass_getDeclaredFields,
146 (functionptr) Java_java_lang_VMClass_getDeclaredMethods,
147 (functionptr) Java_java_lang_VMClass_getDeclaredConstructors,
148 (functionptr) Java_java_lang_VMClass_getClassLoader,
149 (functionptr) Java_java_lang_VMClass_forName,
150 (functionptr) Java_java_lang_VMClass_isArray,
151 (functionptr) Java_java_lang_VMClass_throwException,
153 (functionptr) Java_java_lang_VMClassLoader_defineClass,
154 (functionptr) Java_java_lang_VMClassLoader_resolveClass,
155 (functionptr) Java_java_lang_VMClassLoader_loadClass,
156 (functionptr) Java_java_lang_VMClassLoader_getPrimitiveClass,
157 (functionptr) Java_java_lang_VMClassLoader_nativeGetResources,
158 (functionptr) Java_java_lang_VMClassLoader_findLoadedClass,
160 (functionptr) Java_java_lang_VMObject_getClass,
161 (functionptr) Java_java_lang_VMObject_clone,
162 (functionptr) Java_java_lang_VMObject_notify,
163 (functionptr) Java_java_lang_VMObject_notifyAll,
164 (functionptr) Java_java_lang_VMObject_wait,
166 (functionptr) Java_java_lang_VMRuntime_availableProcessors,
167 (functionptr) Java_java_lang_VMRuntime_freeMemory,
168 (functionptr) Java_java_lang_VMRuntime_totalMemory,
169 (functionptr) Java_java_lang_VMRuntime_maxMemory,
170 (functionptr) Java_java_lang_VMRuntime_gc,
171 (functionptr) Java_java_lang_VMRuntime_runFinalization,
172 (functionptr) Java_java_lang_VMRuntime_runFinalizationForExit,
173 (functionptr) Java_java_lang_VMRuntime_traceInstructions,
174 (functionptr) Java_java_lang_VMRuntime_traceMethodCalls,
175 (functionptr) Java_java_lang_VMRuntime_runFinalizersOnExit,
176 (functionptr) Java_java_lang_VMRuntime_exit,
177 (functionptr) Java_java_lang_VMRuntime_nativeLoad,
178 (functionptr) Java_java_lang_VMRuntime_mapLibraryName,
180 (functionptr) Java_java_lang_VMString_intern,
182 (functionptr) Java_java_lang_VMSystem_arraycopy,
183 (functionptr) Java_java_lang_VMSystem_identityHashCode,
185 (functionptr) Java_java_lang_VMThread_start,
186 (functionptr) Java_java_lang_VMThread_interrupt,
187 (functionptr) Java_java_lang_VMThread_isInterrupted,
188 (functionptr) Java_java_lang_VMThread_suspend,
189 (functionptr) Java_java_lang_VMThread_resume,
190 (functionptr) Java_java_lang_VMThread_nativeSetPriority,
191 (functionptr) Java_java_lang_VMThread_nativeStop,
192 (functionptr) Java_java_lang_VMThread_currentThread,
193 (functionptr) Java_java_lang_VMThread_yield,
194 (functionptr) Java_java_lang_VMThread_interrupted,
195 (functionptr) Java_java_lang_VMThread_holdsLock,
197 (functionptr) Java_java_lang_VMThrowable_fillInStackTrace,
198 (functionptr) Java_java_lang_VMThrowable_getStackTrace,
200 (functionptr) Java_java_lang_reflect_Constructor_getModifiersInternal,
201 (functionptr) Java_java_lang_reflect_Constructor_constructNative,
203 (functionptr) Java_java_lang_reflect_Field_getModifiersInternal,
204 (functionptr) Java_java_lang_reflect_Field_getType,
205 (functionptr) Java_java_lang_reflect_Field_get,
206 (functionptr) Java_java_lang_reflect_Field_getBoolean,
207 (functionptr) Java_java_lang_reflect_Field_getByte,
208 (functionptr) Java_java_lang_reflect_Field_getChar,
209 (functionptr) Java_java_lang_reflect_Field_getShort,
210 (functionptr) Java_java_lang_reflect_Field_getInt,
211 (functionptr) Java_java_lang_reflect_Field_getLong,
212 (functionptr) Java_java_lang_reflect_Field_getFloat,
213 (functionptr) Java_java_lang_reflect_Field_getDouble,
214 (functionptr) Java_java_lang_reflect_Field_set,
215 (functionptr) Java_java_lang_reflect_Field_setBoolean,
216 (functionptr) Java_java_lang_reflect_Field_setByte,
217 (functionptr) Java_java_lang_reflect_Field_setChar,
218 (functionptr) Java_java_lang_reflect_Field_setShort,
219 (functionptr) Java_java_lang_reflect_Field_setInt,
220 (functionptr) Java_java_lang_reflect_Field_setLong,
221 (functionptr) Java_java_lang_reflect_Field_setFloat,
222 (functionptr) Java_java_lang_reflect_Field_setDouble,
224 (functionptr) Java_java_lang_reflect_Method_getModifiersInternal,
225 (functionptr) Java_java_lang_reflect_Method_getReturnType,
226 (functionptr) Java_java_lang_reflect_Method_getParameterTypes,
227 (functionptr) Java_java_lang_reflect_Method_getExceptionTypes,
228 (functionptr) Java_java_lang_reflect_Method_invokeNative,
230 (functionptr) Java_java_lang_reflect_VMProxy_getProxyClass,
231 (functionptr) Java_java_lang_reflect_VMProxy_getProxyData,
232 (functionptr) Java_java_lang_reflect_VMProxy_generateProxyClass,
234 (functionptr) Java_java_security_VMAccessController_getStack,
235 #if defined(ENABLE_JVMTI)
236 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread,
237 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_resumeThread,
238 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSuspendCount,
239 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClassesCount,
240 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus,
241 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllClassMethods,
242 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassMethod,
243 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrames,
244 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrame,
245 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount,
246 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getThreadStatus,
247 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getLoadRequests,
248 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_executeMethod,
249 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSourceFile,
250 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_registerEvent,
251 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_unregisterEvent,
252 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_clearEvents,
253 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClasses,
254 (functionptr) Java_gnu_classpath_jdwp_VMFrame_setValue,
255 (functionptr) Java_gnu_classpath_jdwp_VMFrame_getValue,
256 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getName,
257 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getSignature,
258 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getModifiers,
259 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getLineTable,
260 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getVariableTable
265 #endif /* defined(WITH_STATIC_CLASSPATH) */
268 /* tables for methods *********************************************************/
270 #if defined(WITH_STATIC_CLASSPATH)
271 #define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
273 /* table for fast string comparison */
274 static nativecompref nativecomptable[NATIVETABLESIZE];
276 /* string comparsion table initialized */
277 static bool nativecompdone = false;
281 /* global variables ***********************************************************/
283 #if !defined(WITH_STATIC_CLASSPATH)
284 static hashtable *hashtable_library;
285 static lt_dlhandle mainhandle;
289 /* native_loadclasses **********************************************************
291 Load classes required for native methods.
293 *******************************************************************************/
295 bool native_init(void)
297 #if !defined(WITH_STATIC_CLASSPATH)
300 /* We need to access the dummy native table, not only to remove a
301 warning but to be sure that the table is not optimized away
302 (gcc does this since 3.4). */
304 p = &dummynativetable;
306 /* initialize libltdl */
309 /* XXX how can we throw an exception here? */
310 log_text(lt_dlerror());
315 /* get the handle for the main program */
317 if (!(mainhandle = lt_dlopen(NULL)))
320 /* initialize library hashtable, 10 entries should be enough */
322 hashtable_library = NEW(hashtable);
324 hashtable_create(hashtable_library, 10);
327 /* everything's ok */
333 /* native_hashtable_library_add ************************************************
335 Adds an entry to the native library hashtable.
337 *******************************************************************************/
339 #if !defined(WITH_STATIC_CLASSPATH)
340 void native_hashtable_library_add(utf *filename, java_objectheader *loader,
343 hashtable_library_loader_entry *le;
344 hashtable_library_name_entry *ne; /* library name */
345 u4 key; /* hashkey */
346 u4 slot; /* slot in hashtable */
348 #if defined(ENABLE_THREADS)
349 builtin_monitorenter(hashtable_library->header);
352 /* normally addresses are aligned to 4, 8 or 16 bytes */
354 key = ((u4) (ptrint) loader) >> 4; /* align to 16-byte boundaries */
355 slot = key & (hashtable_library->size - 1);
356 le = hashtable_library->ptr[slot];
358 /* search external hash chain for the entry */
361 if (le->loader == loader)
364 le = le->hashlink; /* next element in external chain */
367 /* no loader found? create a new entry */
370 le = NEW(hashtable_library_loader_entry);
375 /* insert entry into hashtable */
378 (hashtable_library_loader_entry *) hashtable_library->ptr[slot];
379 hashtable_library->ptr[slot] = le;
381 /* update number of hashtable-entries */
383 hashtable_library->entries++;
387 /* search for library name */
392 if (ne->name == filename) {
393 #if defined(ENABLE_THREADS)
394 builtin_monitorexit(hashtable_library->header);
400 ne = ne->hashlink; /* next element in external chain */
403 /* not found? add the library name to the classloader */
405 ne = NEW(hashtable_library_name_entry);
410 /* insert entry into external chain */
412 ne->hashlink = le->namelink;
415 #if defined(ENABLE_THREADS)
416 builtin_monitorexit(hashtable_library->header);
419 #endif /* !defined(WITH_STATIC_CLASSPATH) */
422 /* native_hashtable_library_find ***********************************************
424 Find an entry in the native library hashtable.
426 *******************************************************************************/
428 #if !defined(WITH_STATIC_CLASSPATH)
429 hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
430 java_objectheader *loader)
432 hashtable_library_loader_entry *le;
433 hashtable_library_name_entry *ne; /* library name */
434 u4 key; /* hashkey */
435 u4 slot; /* slot in hashtable */
437 /* normally addresses are aligned to 4, 8 or 16 bytes */
439 key = ((u4) (ptrint) loader) >> 4; /* align to 16-byte boundaries */
440 slot = key & (hashtable_library->size - 1);
441 le = hashtable_library->ptr[slot];
443 /* search external hash chain for the entry */
446 if (le->loader == loader)
449 le = le->hashlink; /* next element in external chain */
452 /* no loader found? return NULL */
457 /* search for library name */
462 if (ne->name == filename)
465 ne = ne->hashlink; /* next element in external chain */
468 /* return entry, if no entry was found, ne is NULL */
472 #endif /* !defined(WITH_STATIC_CLASSPATH) */
475 /* native_findfunction *********************************************************
477 Looks up a method (must have the same class name, method name,
478 descriptor and 'static'ness) and returns a function pointer to it.
479 Returns: function pointer or NULL (if there is no such method)
481 Remark: For faster operation, the names/descriptors are converted
482 from C strings to Unicode the first time this function is called.
484 *******************************************************************************/
486 #if defined(WITH_STATIC_CLASSPATH)
487 functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
490 /* entry of table for fast string comparison */
491 struct nativecompref *n;
494 isstatic = isstatic ? true : false;
496 if (!nativecompdone) {
497 for (i = 0; i < NATIVETABLESIZE; i++) {
498 nativecomptable[i].classname =
499 utf_new_char(nativetable[i].classname);
501 nativecomptable[i].methodname =
502 utf_new_char(nativetable[i].methodname);
504 nativecomptable[i].descriptor =
505 utf_new_char(nativetable[i].descriptor);
507 nativecomptable[i].isstatic = nativetable[i].isstatic;
508 nativecomptable[i].func = nativetable[i].func;
511 nativecompdone = true;
514 for (i = 0; i < NATIVETABLESIZE; i++) {
515 n = &(nativecomptable[i]);
517 if (cname == n->classname && mname == n->methodname &&
518 desc == n->descriptor && isstatic == n->isstatic)
523 /* no function was found, throw exception */
526 new_exception_utfmessage(string_java_lang_UnsatisfiedLinkError,
531 #endif /* defined(WITH_STATIC_CLASSPATH) */
534 /* native_make_overloaded_function *********************************************
538 *******************************************************************************/
540 #if !defined(WITH_STATIC_CLASSPATH)
541 static char *native_make_overloaded_function(char *name, utf *desc)
549 utf_ptr = desc->text;
550 namelen = strlen(name) + strlen("__") + strlen("0");
552 /* calculate additional length */
554 while ((c = utf_nextu2(&utf_ptr)) != ')') {
571 while (utf_nextu2(&utf_ptr) != ';')
583 /* reallocate memory */
587 newname = DMNEW(char, namelen);
588 MCOPY(newname, name, char, i);
590 utf_ptr = desc->text;
595 while ((c = utf_nextu2(&utf_ptr)) != ')') {
613 while ((c = utf_nextu2(&utf_ptr)) != ';')
614 if (((c >= 'a') && (c <= 'z')) ||
615 ((c >= 'A') && (c <= 'Z')) ||
616 ((c >= '0') && (c <= '9')))
638 /* native_resolve_function *****************************************************
640 Resolves a native function, maybe from a dynamic library.
642 *******************************************************************************/
644 functionptr native_resolve_function(methodinfo *m)
653 hashtable_library_loader_entry *le;
654 hashtable_library_name_entry *ne;
655 u4 key; /* hashkey */
656 u4 slot; /* slot in hashtable */
662 if (opt_verbosejni) {
663 printf("[Dynamic-linking native method ");
664 utf_display_printable_ascii_classname(m->class->name);
666 utf_display_printable_ascii(m->name);
670 /* calculate length of native function name */
672 namelen = strlen("Java_") + utf_get_number_of_u2s(m->class->name) + strlen("_") +
673 utf_get_number_of_u2s(m->name) + strlen("0");
675 /* check for underscores in class name */
677 utf_ptr = m->class->name->text;
678 utf_endptr = UTF_END(m->class->name);
680 while (utf_ptr < utf_endptr)
681 if (utf_nextu2(&utf_ptr) == '_')
684 /* check for underscores in method name */
686 utf_ptr = m->name->text;
687 utf_endptr = UTF_END(m->name);
689 while (utf_ptr < utf_endptr)
690 if (utf_nextu2(&utf_ptr) == '_')
693 /* allocate memory */
695 dumpsize = dump_size();
697 name = DMNEW(char, namelen);
700 /* generate name of native functions */
702 strcpy(name, "Java_");
705 utf_ptr = m->class->name->text;
706 utf_endptr = UTF_END(m->class->name);
708 for (; utf_ptr < utf_endptr; utf_ptr++, i++) {
711 /* escape sequence for '_' is '_1' */
716 /* replace '/' with '_' */
722 /* seperator between class and method */
726 utf_ptr = m->name->text;
727 utf_endptr = UTF_END(m->name);
729 for (; utf_ptr < utf_endptr; utf_ptr++, i++) {
732 /* escape sequence for '_' is '_1' */
743 /* generate overloaded function (having the types in it's name) */
745 newname = native_make_overloaded_function(name, m->descriptor);
747 /* check the library hash entries of the classloader of the
752 /* normally addresses are aligned to 4, 8 or 16 bytes */
754 key = ((u4) (ptrint) m->class->classloader) >> 4; /* align to 16-byte */
755 slot = key & (hashtable_library->size - 1);
756 le = hashtable_library->ptr[slot];
758 /* iterate through loaders in this hash slot */
760 while ((le != NULL) && (sym == NULL)) {
761 /* iterate through names in this loader */
765 while ((ne != NULL) && (sym == NULL)) {
766 sym = lt_dlsym(ne->handle, name);
769 sym = lt_dlsym(ne->handle, newname);
782 /* If not found, try to find the native function symbol in the
786 sym = lt_dlsym(mainhandle, name);
789 sym = lt_dlsym(mainhandle, newname);
793 printf("internal ]\n");
797 #if defined(ENABLE_JVMTI)
798 /* fire Native Method Bind event */
799 if (jvmti) jvmti_NativeMethodBind(m, sym, &sym);
802 /* no symbol found? throw exception */
806 printf("failed ]\n");
809 new_exception_utfmessage(string_java_lang_UnsatisfiedLinkError,
815 dump_release(dumpsize);
817 return (functionptr) (ptrint) sym;
819 #endif /* !defined(WITH_STATIC_CLASSPATH) */
822 /* native_new_and_init *********************************************************
824 Creates a new object on the heap and calls the initializer.
825 Returns the object pointer or NULL if memory is exhausted.
827 *******************************************************************************/
829 java_objectheader *native_new_and_init(classinfo *c)
832 java_objectheader *o;
835 return *exceptionptr;
844 /* try to find the initializer */
846 m = class_findmethod(c, utf_init, utf_void__void);
848 /* ATTENTION: returning the object here is ok, since the class may
849 not have an initializer */
854 /* call initializer */
856 (void) vm_call_method(m, o);
862 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s)
865 java_objectheader *o;
868 return *exceptionptr;
877 /* find initializer */
879 m = class_resolveclassmethod(c,
881 utf_java_lang_String__void,
885 /* initializer not found */
890 /* call initializer */
892 (void) vm_call_method(m, o, s);
898 java_objectheader *native_new_and_init_int(classinfo *c, s4 i)
901 java_objectheader *o;
904 return *exceptionptr;
913 /* find initializer */
915 m = class_resolveclassmethod(c, utf_init, utf_int__void, NULL, true);
917 /* initializer not found */
922 /* call initializer */
924 (void) vm_call_method(m, o, i);
930 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t)
933 java_objectheader *o;
936 return *exceptionptr;
945 /* find initializer */
947 m = class_findmethod(c, utf_init, utf_java_lang_Throwable__void);
949 /* initializer not found */
954 /* call initializer */
956 (void) vm_call_method(m, o, t);
962 /* native_get_parametertypes ***************************************************
964 Use the descriptor of a method to generate a java/lang/Class array
965 which contains the classes of the parametertypes of the method.
967 *******************************************************************************/
969 java_objectarray *native_get_parametertypes(methodinfo *m)
972 typedesc *paramtypes;
974 java_objectarray *oa;
979 /* is the descriptor fully parsed? */
981 if (!m->parseddesc->params)
982 if (!descriptor_params_from_paramtypes(md, m->flags))
985 paramtypes = md->paramtypes;
986 paramcount = md->paramcount;
988 /* skip `this' pointer */
990 if (!(m->flags & ACC_STATIC)) {
995 /* create class-array */
997 oa = builtin_anewarray(paramcount, class_java_lang_Class);
1004 for (i = 0; i < paramcount; i++)
1005 if (!resolve_class_from_typedesc(¶mtypes[i], true, false,
1006 (classinfo **) &oa->data[i]))
1013 /* native_get_exceptiontypes ***************************************************
1015 Get the exceptions which can be thrown by a method.
1017 *******************************************************************************/
1019 java_objectarray *native_get_exceptiontypes(methodinfo *m)
1021 java_objectarray *oa;
1025 /* create class-array */
1027 oa = builtin_anewarray(m->thrownexceptionscount, class_java_lang_Class);
1032 for (i = 0; i < m->thrownexceptionscount; i++) {
1033 if (!resolve_classref_or_classinfo(NULL, m->thrownexceptions[i],
1034 resolveEager, true, false, &c))
1037 oa->data[i] = (java_objectheader *) c;
1044 /* native_get_returntype *******************************************************
1046 Get the returntype class of a method.
1048 *******************************************************************************/
1050 classinfo *native_get_returntype(methodinfo *m)
1054 if (!resolve_class_from_typedesc(&(m->parseddesc->returntype), true, false,
1063 * These are local overrides for various environment variables in Emacs.
1064 * Please do not remove this and leave it at the end of the file, where
1065 * Emacs will automagically detect them.
1066 * ---------------------------------------------------------------------
1069 * indent-tabs-mode: t