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 5066 2006-07-02 18:31:02Z 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"
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/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
80 #include "native/include/java_lang_Class.h"
81 #include "native/include/java_lang_Object.h"
82 #include "native/include/java_lang_VMClass.h"
83 #include "native/include/java_lang_VMClassLoader.h"
84 #include "native/include/java_lang_VMObject.h"
85 #include "native/include/java_lang_VMRuntime.h"
86 #include "native/include/java_lang_VMString.h"
87 #include "native/include/java_lang_VMSystem.h"
88 #include "native/include/java_lang_VMThread.h"
89 #include "native/include/java_lang_VMThrowable.h"
90 #include "native/include/java_lang_reflect_Constructor.h"
91 #include "native/include/java_lang_reflect_Field.h"
92 #include "native/include/java_lang_reflect_Method.h"
93 #include "native/include/java_lang_reflect_VMProxy.h"
94 #include "native/include/java_security_VMAccessController.h"
96 #if defined(ENABLE_JVMTI)
97 #include "native/include/gnu_classpath_jdwp_event_EventRequest.h"
98 #include "native/include/java_nio_ByteBuffer.h"
99 #include "native/include/gnu_classpath_jdwp_VMVirtualMachine.h"
100 #include "native/include/gnu_classpath_jdwp_VMFrame.h"
101 #include "native/include/gnu_classpath_jdwp_VMMethod.h"
104 #if defined(WITH_STATIC_CLASSPATH)
106 /* these are required to prevent compiler warnings */
108 #include "native/include/java_net_DatagramPacket.h"
109 #include "native/include/java_net_InetAddress.h"
110 #include "native/include/java_net_SocketImpl.h"
112 #include "native/include/gnu_java_net_PlainDatagramSocketImpl.h"
113 #include "native/include/gnu_java_net_PlainSocketImpl.h"
114 #include "native/include/gnu_java_nio_PipeImpl.h"
115 #include "native/include/gnu_java_nio_channels_FileChannelImpl.h"
116 #include "native/include/gnu_java_nio_charset_iconv_IconvEncoder.h"
117 #include "native/include/gnu_java_nio_charset_iconv_IconvDecoder.h"
118 #include "native/include/java_lang_VMProcess.h"
119 #include "native/include/java_nio_MappedByteBufferImpl.h"
120 #include "native/include/java_nio_channels_spi_SelectorProvider.h"
122 /* now include the native table */
124 #include "native/nativetable.inc"
126 #else /* defined(WITH_STATIC_CLASSPATH) */
128 /* Ensure that symbols for functions implemented within CACAO are used
129 and exported to dlopen. */
131 static functionptr dummynativetable[] = {
132 (functionptr) Java_gnu_classpath_VMStackWalker_getClassContext,
134 (functionptr) Java_gnu_classpath_VMSystemProperties_preInit,
136 (functionptr) Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments,
137 (functionptr) Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime,
139 (functionptr) Java_java_lang_VMClass_isInstance,
140 (functionptr) Java_java_lang_VMClass_isAssignableFrom,
141 (functionptr) Java_java_lang_VMClass_isInterface,
142 (functionptr) Java_java_lang_VMClass_isPrimitive,
143 (functionptr) Java_java_lang_VMClass_getName,
144 (functionptr) Java_java_lang_VMClass_getSuperclass,
145 (functionptr) Java_java_lang_VMClass_getInterfaces,
146 (functionptr) Java_java_lang_VMClass_getComponentType,
147 (functionptr) Java_java_lang_VMClass_getModifiers,
148 (functionptr) Java_java_lang_VMClass_getDeclaringClass,
149 (functionptr) Java_java_lang_VMClass_getDeclaredClasses,
150 (functionptr) Java_java_lang_VMClass_getDeclaredFields,
151 (functionptr) Java_java_lang_VMClass_getDeclaredMethods,
152 (functionptr) Java_java_lang_VMClass_getDeclaredConstructors,
153 (functionptr) Java_java_lang_VMClass_getClassLoader,
154 (functionptr) Java_java_lang_VMClass_forName,
155 (functionptr) Java_java_lang_VMClass_isArray,
156 (functionptr) Java_java_lang_VMClass_throwException,
158 (functionptr) Java_java_lang_VMClassLoader_defineClass,
159 (functionptr) Java_java_lang_VMClassLoader_resolveClass,
160 (functionptr) Java_java_lang_VMClassLoader_loadClass,
161 (functionptr) Java_java_lang_VMClassLoader_getPrimitiveClass,
162 (functionptr) Java_java_lang_VMClassLoader_nativeGetResources,
163 (functionptr) Java_java_lang_VMClassLoader_findLoadedClass,
165 (functionptr) Java_java_lang_VMObject_getClass,
166 (functionptr) Java_java_lang_VMObject_clone,
167 (functionptr) Java_java_lang_VMObject_notify,
168 (functionptr) Java_java_lang_VMObject_notifyAll,
169 (functionptr) Java_java_lang_VMObject_wait,
171 (functionptr) Java_java_lang_VMRuntime_availableProcessors,
172 (functionptr) Java_java_lang_VMRuntime_freeMemory,
173 (functionptr) Java_java_lang_VMRuntime_totalMemory,
174 (functionptr) Java_java_lang_VMRuntime_maxMemory,
175 (functionptr) Java_java_lang_VMRuntime_gc,
176 (functionptr) Java_java_lang_VMRuntime_runFinalization,
177 (functionptr) Java_java_lang_VMRuntime_runFinalizationForExit,
178 (functionptr) Java_java_lang_VMRuntime_traceInstructions,
179 (functionptr) Java_java_lang_VMRuntime_traceMethodCalls,
180 (functionptr) Java_java_lang_VMRuntime_runFinalizersOnExit,
181 (functionptr) Java_java_lang_VMRuntime_exit,
182 (functionptr) Java_java_lang_VMRuntime_nativeLoad,
183 (functionptr) Java_java_lang_VMRuntime_mapLibraryName,
185 (functionptr) Java_java_lang_VMString_intern,
187 (functionptr) Java_java_lang_VMSystem_arraycopy,
188 (functionptr) Java_java_lang_VMSystem_identityHashCode,
190 (functionptr) Java_java_lang_VMThread_start,
191 (functionptr) Java_java_lang_VMThread_interrupt,
192 (functionptr) Java_java_lang_VMThread_isInterrupted,
193 (functionptr) Java_java_lang_VMThread_suspend,
194 (functionptr) Java_java_lang_VMThread_resume,
195 (functionptr) Java_java_lang_VMThread_nativeSetPriority,
196 (functionptr) Java_java_lang_VMThread_nativeStop,
197 (functionptr) Java_java_lang_VMThread_currentThread,
198 (functionptr) Java_java_lang_VMThread_yield,
199 (functionptr) Java_java_lang_VMThread_interrupted,
200 (functionptr) Java_java_lang_VMThread_holdsLock,
202 (functionptr) Java_java_lang_VMThrowable_fillInStackTrace,
203 (functionptr) Java_java_lang_VMThrowable_getStackTrace,
205 (functionptr) Java_java_lang_reflect_Constructor_getModifiersInternal,
206 (functionptr) Java_java_lang_reflect_Constructor_constructNative,
208 (functionptr) Java_java_lang_reflect_Field_getModifiersInternal,
209 (functionptr) Java_java_lang_reflect_Field_getType,
210 (functionptr) Java_java_lang_reflect_Field_get,
211 (functionptr) Java_java_lang_reflect_Field_getBoolean,
212 (functionptr) Java_java_lang_reflect_Field_getByte,
213 (functionptr) Java_java_lang_reflect_Field_getChar,
214 (functionptr) Java_java_lang_reflect_Field_getShort,
215 (functionptr) Java_java_lang_reflect_Field_getInt,
216 (functionptr) Java_java_lang_reflect_Field_getLong,
217 (functionptr) Java_java_lang_reflect_Field_getFloat,
218 (functionptr) Java_java_lang_reflect_Field_getDouble,
219 (functionptr) Java_java_lang_reflect_Field_set,
220 (functionptr) Java_java_lang_reflect_Field_setBoolean,
221 (functionptr) Java_java_lang_reflect_Field_setByte,
222 (functionptr) Java_java_lang_reflect_Field_setChar,
223 (functionptr) Java_java_lang_reflect_Field_setShort,
224 (functionptr) Java_java_lang_reflect_Field_setInt,
225 (functionptr) Java_java_lang_reflect_Field_setLong,
226 (functionptr) Java_java_lang_reflect_Field_setFloat,
227 (functionptr) Java_java_lang_reflect_Field_setDouble,
229 (functionptr) Java_java_lang_reflect_Method_getModifiersInternal,
230 (functionptr) Java_java_lang_reflect_Method_getReturnType,
231 (functionptr) Java_java_lang_reflect_Method_getParameterTypes,
232 (functionptr) Java_java_lang_reflect_Method_getExceptionTypes,
233 (functionptr) Java_java_lang_reflect_Method_invokeNative,
235 (functionptr) Java_java_lang_reflect_VMProxy_getProxyClass,
236 (functionptr) Java_java_lang_reflect_VMProxy_getProxyData,
237 (functionptr) Java_java_lang_reflect_VMProxy_generateProxyClass,
239 (functionptr) Java_java_security_VMAccessController_getStack,
241 #if defined(ENABLE_JVMTI)
242 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread,
243 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_resumeThread,
244 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSuspendCount,
245 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClassesCount,
246 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus,
247 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllClassMethods,
248 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassMethod,
249 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrames,
250 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrame,
251 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount,
252 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getThreadStatus,
253 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getLoadRequests,
254 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_executeMethod,
255 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSourceFile,
256 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_registerEvent,
257 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_unregisterEvent,
258 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_clearEvents,
259 (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClasses,
260 (functionptr) Java_gnu_classpath_jdwp_VMFrame_setValue,
261 (functionptr) Java_gnu_classpath_jdwp_VMFrame_getValue,
262 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getName,
263 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getSignature,
264 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getModifiers,
265 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getLineTable,
266 (functionptr) Java_gnu_classpath_jdwp_VMMethod_getVariableTable
271 #endif /* defined(WITH_STATIC_CLASSPATH) */
274 /* tables for methods *********************************************************/
276 #if defined(WITH_STATIC_CLASSPATH)
277 #define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
279 /* table for fast string comparison */
280 static nativecompref nativecomptable[NATIVETABLESIZE];
282 /* string comparsion table initialized */
283 static bool nativecompdone = false;
287 /* global variables ***********************************************************/
289 #if !defined(WITH_STATIC_CLASSPATH)
290 static hashtable *hashtable_library;
291 static lt_dlhandle mainhandle;
295 /* native_loadclasses **********************************************************
297 Load classes required for native methods.
299 *******************************************************************************/
301 bool native_init(void)
303 #if !defined(WITH_STATIC_CLASSPATH)
306 /* We need to access the dummy native table, not only to remove a
307 warning but to be sure that the table is not optimized away
308 (gcc does this since 3.4). */
310 p = &dummynativetable;
312 /* initialize libltdl */
315 /* XXX how can we throw an exception here? */
316 log_text(lt_dlerror());
321 /* get the handle for the main program */
323 if (!(mainhandle = lt_dlopen(NULL)))
326 /* initialize library hashtable, 10 entries should be enough */
328 hashtable_library = NEW(hashtable);
330 hashtable_create(hashtable_library, 10);
333 /* everything's ok */
339 /* native_hashtable_library_add ************************************************
341 Adds an entry to the native library hashtable.
343 *******************************************************************************/
345 #if !defined(WITH_STATIC_CLASSPATH)
346 void native_hashtable_library_add(utf *filename, java_objectheader *loader,
349 hashtable_library_loader_entry *le;
350 hashtable_library_name_entry *ne; /* library name */
351 u4 key; /* hashkey */
352 u4 slot; /* slot in hashtable */
354 #if defined(ENABLE_THREADS)
355 builtin_monitorenter(hashtable_library->header);
358 /* normally addresses are aligned to 4, 8 or 16 bytes */
360 key = ((u4) (ptrint) loader) >> 4; /* align to 16-byte boundaries */
361 slot = key & (hashtable_library->size - 1);
362 le = hashtable_library->ptr[slot];
364 /* search external hash chain for the entry */
367 if (le->loader == loader)
370 le = le->hashlink; /* next element in external chain */
373 /* no loader found? create a new entry */
376 le = NEW(hashtable_library_loader_entry);
381 /* insert entry into hashtable */
384 (hashtable_library_loader_entry *) hashtable_library->ptr[slot];
385 hashtable_library->ptr[slot] = le;
387 /* update number of hashtable-entries */
389 hashtable_library->entries++;
393 /* search for library name */
398 if (ne->name == filename) {
399 #if defined(ENABLE_THREADS)
400 builtin_monitorexit(hashtable_library->header);
406 ne = ne->hashlink; /* next element in external chain */
409 /* not found? add the library name to the classloader */
411 ne = NEW(hashtable_library_name_entry);
416 /* insert entry into external chain */
418 ne->hashlink = le->namelink;
421 #if defined(ENABLE_THREADS)
422 builtin_monitorexit(hashtable_library->header);
425 #endif /* !defined(WITH_STATIC_CLASSPATH) */
428 /* native_hashtable_library_find ***********************************************
430 Find an entry in the native library hashtable.
432 *******************************************************************************/
434 #if !defined(WITH_STATIC_CLASSPATH)
435 hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
436 java_objectheader *loader)
438 hashtable_library_loader_entry *le;
439 hashtable_library_name_entry *ne; /* library name */
440 u4 key; /* hashkey */
441 u4 slot; /* slot in hashtable */
443 /* normally addresses are aligned to 4, 8 or 16 bytes */
445 key = ((u4) (ptrint) loader) >> 4; /* align to 16-byte boundaries */
446 slot = key & (hashtable_library->size - 1);
447 le = hashtable_library->ptr[slot];
449 /* search external hash chain for the entry */
452 if (le->loader == loader)
455 le = le->hashlink; /* next element in external chain */
458 /* no loader found? return NULL */
463 /* search for library name */
468 if (ne->name == filename)
471 ne = ne->hashlink; /* next element in external chain */
474 /* return entry, if no entry was found, ne is NULL */
478 #endif /* !defined(WITH_STATIC_CLASSPATH) */
481 /* native_findfunction *********************************************************
483 Looks up a method (must have the same class name, method name,
484 descriptor and 'static'ness) and returns a function pointer to it.
485 Returns: function pointer or NULL (if there is no such method)
487 Remark: For faster operation, the names/descriptors are converted
488 from C strings to Unicode the first time this function is called.
490 *******************************************************************************/
492 #if defined(WITH_STATIC_CLASSPATH)
493 functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
496 /* entry of table for fast string comparison */
497 struct nativecompref *n;
500 isstatic = isstatic ? true : false;
502 if (!nativecompdone) {
503 for (i = 0; i < NATIVETABLESIZE; i++) {
504 nativecomptable[i].classname =
505 utf_new_char(nativetable[i].classname);
507 nativecomptable[i].methodname =
508 utf_new_char(nativetable[i].methodname);
510 nativecomptable[i].descriptor =
511 utf_new_char(nativetable[i].descriptor);
513 nativecomptable[i].isstatic = nativetable[i].isstatic;
514 nativecomptable[i].func = nativetable[i].func;
517 nativecompdone = true;
520 for (i = 0; i < NATIVETABLESIZE; i++) {
521 n = &(nativecomptable[i]);
523 if (cname == n->classname && mname == n->methodname &&
524 desc == n->descriptor && isstatic == n->isstatic)
529 /* no function was found, throw exception */
532 new_exception_utfmessage(string_java_lang_UnsatisfiedLinkError,
537 #endif /* defined(WITH_STATIC_CLASSPATH) */
540 /* native_make_overloaded_function *********************************************
544 *******************************************************************************/
546 #if !defined(WITH_STATIC_CLASSPATH)
547 static char *native_make_overloaded_function(char *name, utf *desc)
555 utf_ptr = desc->text;
556 namelen = strlen(name) + strlen("__") + strlen("0");
558 /* calculate additional length */
560 while ((c = utf_nextu2(&utf_ptr)) != ')') {
577 while (utf_nextu2(&utf_ptr) != ';')
589 /* reallocate memory */
593 newname = DMNEW(char, namelen);
594 MCOPY(newname, name, char, i);
596 utf_ptr = desc->text;
601 while ((c = utf_nextu2(&utf_ptr)) != ')') {
619 while ((c = utf_nextu2(&utf_ptr)) != ';')
620 if (((c >= 'a') && (c <= 'z')) ||
621 ((c >= 'A') && (c <= 'Z')) ||
622 ((c >= '0') && (c <= '9')))
644 /* native_resolve_function *****************************************************
646 Resolves a native function, maybe from a dynamic library.
648 *******************************************************************************/
650 functionptr native_resolve_function(methodinfo *m)
659 hashtable_library_loader_entry *le;
660 hashtable_library_name_entry *ne;
661 u4 key; /* hashkey */
662 u4 slot; /* slot in hashtable */
668 if (opt_verbosejni) {
669 printf("[Dynamic-linking native method ");
670 utf_display_printable_ascii_classname(m->class->name);
672 utf_display_printable_ascii(m->name);
676 /* calculate length of native function name */
678 namelen = strlen("Java_") + utf_get_number_of_u2s(m->class->name) + strlen("_") +
679 utf_get_number_of_u2s(m->name) + strlen("0");
681 /* check for underscores in class name */
683 utf_ptr = m->class->name->text;
684 utf_endptr = UTF_END(m->class->name);
686 while (utf_ptr < utf_endptr)
687 if (utf_nextu2(&utf_ptr) == '_')
690 /* check for underscores in method name */
692 utf_ptr = m->name->text;
693 utf_endptr = UTF_END(m->name);
695 while (utf_ptr < utf_endptr)
696 if (utf_nextu2(&utf_ptr) == '_')
699 /* allocate memory */
701 dumpsize = dump_size();
703 name = DMNEW(char, namelen);
706 /* generate name of native functions */
708 strcpy(name, "Java_");
711 utf_ptr = m->class->name->text;
712 utf_endptr = UTF_END(m->class->name);
714 for (; utf_ptr < utf_endptr; utf_ptr++, i++) {
717 /* escape sequence for '_' is '_1' */
722 /* replace '/' with '_' */
728 /* seperator between class and method */
732 utf_ptr = m->name->text;
733 utf_endptr = UTF_END(m->name);
735 for (; utf_ptr < utf_endptr; utf_ptr++, i++) {
738 /* escape sequence for '_' is '_1' */
749 /* generate overloaded function (having the types in it's name) */
751 newname = native_make_overloaded_function(name, m->descriptor);
753 /* check the library hash entries of the classloader of the
758 /* normally addresses are aligned to 4, 8 or 16 bytes */
760 key = ((u4) (ptrint) m->class->classloader) >> 4; /* align to 16-byte */
761 slot = key & (hashtable_library->size - 1);
762 le = hashtable_library->ptr[slot];
764 /* iterate through loaders in this hash slot */
766 while ((le != NULL) && (sym == NULL)) {
767 /* iterate through names in this loader */
771 while ((ne != NULL) && (sym == NULL)) {
772 sym = lt_dlsym(ne->handle, name);
775 sym = lt_dlsym(ne->handle, newname);
788 /* If not found, try to find the native function symbol in the
792 sym = lt_dlsym(mainhandle, name);
795 sym = lt_dlsym(mainhandle, newname);
799 printf("internal ]\n");
803 #if defined(ENABLE_JVMTI)
804 /* fire Native Method Bind event */
805 if (jvmti) jvmti_NativeMethodBind(m, sym, &sym);
808 /* no symbol found? throw exception */
812 printf("failed ]\n");
815 new_exception_utfmessage(string_java_lang_UnsatisfiedLinkError,
821 dump_release(dumpsize);
823 return (functionptr) (ptrint) sym;
825 #endif /* !defined(WITH_STATIC_CLASSPATH) */
828 /* native_new_and_init *********************************************************
830 Creates a new object on the heap and calls the initializer.
831 Returns the object pointer or NULL if memory is exhausted.
833 *******************************************************************************/
835 java_objectheader *native_new_and_init(classinfo *c)
838 java_objectheader *o;
841 return *exceptionptr;
850 /* try to find the initializer */
852 m = class_findmethod(c, utf_init, utf_void__void);
854 /* ATTENTION: returning the object here is ok, since the class may
855 not have an initializer */
860 /* call initializer */
862 (void) vm_call_method(m, o);
868 java_objectheader *native_new_and_init_string(classinfo *c, java_lang_String *s)
871 java_objectheader *o;
874 return *exceptionptr;
883 /* find initializer */
885 m = class_resolveclassmethod(c,
887 utf_java_lang_String__void,
891 /* initializer not found */
896 /* call initializer */
898 (void) vm_call_method(m, o, s);
904 java_objectheader *native_new_and_init_int(classinfo *c, s4 i)
907 java_objectheader *o;
910 return *exceptionptr;
919 /* find initializer */
921 m = class_resolveclassmethod(c, utf_init, utf_int__void, NULL, true);
923 /* initializer not found */
928 /* call initializer */
930 (void) vm_call_method(m, o, i);
936 java_objectheader *native_new_and_init_throwable(classinfo *c, java_lang_Throwable *t)
939 java_objectheader *o;
942 return *exceptionptr;
951 /* find initializer */
953 m = class_findmethod(c, utf_init, utf_java_lang_Throwable__void);
955 /* initializer not found */
960 /* call initializer */
962 (void) vm_call_method(m, o, t);
968 /* native_get_parametertypes ***************************************************
970 Use the descriptor of a method to generate a java/lang/Class array
971 which contains the classes of the parametertypes of the method.
973 *******************************************************************************/
975 java_objectarray *native_get_parametertypes(methodinfo *m)
978 typedesc *paramtypes;
980 java_objectarray *oa;
985 /* is the descriptor fully parsed? */
987 if (!m->parseddesc->params)
988 if (!descriptor_params_from_paramtypes(md, m->flags))
991 paramtypes = md->paramtypes;
992 paramcount = md->paramcount;
994 /* skip `this' pointer */
996 if (!(m->flags & ACC_STATIC)) {
1001 /* create class-array */
1003 oa = builtin_anewarray(paramcount, class_java_lang_Class);
1010 for (i = 0; i < paramcount; i++)
1011 if (!resolve_class_from_typedesc(¶mtypes[i], true, false,
1012 (classinfo **) &oa->data[i]))
1019 /* native_get_exceptiontypes ***************************************************
1021 Get the exceptions which can be thrown by a method.
1023 *******************************************************************************/
1025 java_objectarray *native_get_exceptiontypes(methodinfo *m)
1027 java_objectarray *oa;
1031 /* create class-array */
1033 oa = builtin_anewarray(m->thrownexceptionscount, class_java_lang_Class);
1038 for (i = 0; i < m->thrownexceptionscount; i++) {
1039 if (!resolve_classref_or_classinfo(NULL, m->thrownexceptions[i],
1040 resolveEager, true, false, &c))
1043 oa->data[i] = (java_objectheader *) c;
1050 /* native_get_returntype *******************************************************
1052 Get the returntype class of a method.
1054 *******************************************************************************/
1056 classinfo *native_get_returntype(methodinfo *m)
1060 if (!resolve_class_from_typedesc(&(m->parseddesc->returntype), true, false,
1069 * These are local overrides for various environment variables in Emacs.
1070 * Please do not remove this and leave it at the end of the file, where
1071 * Emacs will automagically detect them.
1072 * ---------------------------------------------------------------------
1075 * indent-tabs-mode: t