* src/native/vm/sun/jvm.c: Set Id keyword.
[cacao.git] / src / native / vm / sun / jvm.c
1 /* src/native/vm/sun/jvm.c - HotSpot JVM interface functions
2
3    Copyright (C) 2007 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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25    $Id: jvm.c 8205 2007-07-15 12:45:40Z twisti $
26
27 */
28
29
30 #define PRINTJVM 0
31
32 #include "config.h"
33
34 #include <errno.h>
35 #include <fcntl.h>
36 #include <ltdl.h>
37 #include <stdio.h>
38 #include <string.h>
39 #include <unistd.h>
40
41 #if defined(HAVE_SYS_IOCTL_H)
42 #define BSD_COMP /* Get FIONREAD on Solaris2 */
43 #include <sys/ioctl.h>
44 #endif
45
46 #include <sys/socket.h>
47 #include <sys/stat.h>
48
49 #include "vm/types.h"
50
51 #include "mm/memory.h"
52
53 #include "native/jni.h"
54 #include "native/native.h"
55
56 #include "native/include/java_lang_AssertionStatusDirectives.h"
57 #include "native/include/java_lang_String.h"            /* required by j.l.CL */
58 #include "native/include/java_nio_ByteBuffer.h"         /* required by j.l.CL */
59 #include "native/include/java_lang_ClassLoader.h"        /* required by j.l.C */
60 #include "native/include/java_lang_StackTraceElement.h"
61 #include "native/include/java_lang_Throwable.h"
62 #include "native/include/java_security_ProtectionDomain.h"
63
64 #include "native/vm/java_lang_Class.h"
65 #include "native/vm/java_lang_ClassLoader.h"
66 #include "native/vm/java_lang_Object.h"
67 #include "native/vm/java_lang_Runtime.h"
68 #include "native/vm/java_lang_String.h"
69 #include "native/vm/java_lang_Thread.h"
70 #include "native/vm/java_lang_reflect_Constructor.h"
71 #include "native/vm/java_lang_reflect_Method.h"
72 #include "native/vm/java_util_concurrent_atomic_AtomicLong.h"
73
74 #include "threads/lock-common.h"
75
76 #include "toolbox/logging.h"
77
78 #include "vm/builtin.h"
79 #include "vm/exceptions.h"
80 #include "vm/initialize.h"
81 #include "vm/properties.h"
82 #include "vm/stringlocal.h"
83 #include "vm/vm.h"
84
85 #include "vm/jit/stacktrace.h"
86
87 #include "vmcore/classcache.h"
88 #include "vmcore/primitive.h"
89
90
91 /* debugging macro ************************************************************/
92
93 #if !defined(NDEBUG)
94 # define DEBUG_JVM(x) \
95     do { \
96         if (opt_TraceJVM) { \
97             log_println("%s", (x)); \
98         } \
99     } while (0)
100 #else
101 # define DEBUG_JVM(x)
102 #endif
103
104
105 typedef struct {
106     /* Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx */
107     unsigned int jvm_version;   /* Consists of major, minor, micro (n.n.n) */
108                                 /* and build number (xx) */
109     unsigned int update_version : 8;         /* Update release version (uu) */
110     unsigned int special_update_version : 8; /* Special update release version (c) */
111     unsigned int reserved1 : 16; 
112     unsigned int reserved2; 
113
114     /* The following bits represents JVM supports that JDK has dependency on.
115      * JDK can use these bits to determine which JVM version
116      * and support it has to maintain runtime compatibility.
117      *
118      * When a new bit is added in a minor or update release, make sure
119      * the new bit is also added in the main/baseline.
120      */
121     unsigned int is_attachable : 1;
122     unsigned int : 31;
123     unsigned int : 32;
124     unsigned int : 32;
125 } jvm_version_info;
126
127
128 /*
129  * A structure used to a capture exception table entry in a Java method.
130  */
131 typedef struct {
132     jint start_pc;
133     jint end_pc;
134     jint handler_pc;
135     jint catchType;
136 } JVM_ExceptionTableEntryType;
137
138
139 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
140 {
141         if ((intptr_t) count <= 0)
142                 return -1;
143
144         return vsnprintf(str, count, fmt, args);
145 }
146
147
148 int jio_snprintf(char *str, size_t count, const char *fmt, ...)
149 {
150         va_list ap;
151         int     len;
152
153         va_start(ap, fmt);
154         len = jio_vsnprintf(str, count, fmt, ap);
155         va_end(ap);
156
157         return len;
158 }
159
160
161 int jio_fprintf(FILE* f, const char *fmt, ...)
162 {
163         log_println("jio_fprintf: IMPLEMENT ME!");
164 }
165
166
167 int jio_vfprintf(FILE* f, const char *fmt, va_list args)
168 {
169         log_println("jio_vfprintf: IMPLEMENT ME!");
170 }
171
172
173 int jio_printf(const char *fmt, ...)
174 {
175         log_println("jio_printf: IMPLEMENT ME!");
176 }
177
178
179 /* JVM_GetInterfaceVersion */
180
181 jint JVM_GetInterfaceVersion()
182 {
183         /* This is defined in hotspot/src/share/vm/prims/jvm.h */
184
185 #define JVM_INTERFACE_VERSION 4
186
187         return JVM_INTERFACE_VERSION;
188 }
189
190
191 /* JVM_CurrentTimeMillis */
192
193 jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored)
194 {
195 #if PRINTJVM
196         log_println("JVM_CurrentTimeMillis");
197 #endif
198         return (jlong) builtin_currenttimemillis();
199 }
200
201
202 /* JVM_NanoTime */
203
204 jlong JVM_NanoTime(JNIEnv *env, jclass ignored)
205 {
206 #if PRINTJVM
207         log_println("JVM_NanoTime");
208 #endif
209         return (jlong) builtin_nanotime();
210 }
211
212
213 /* JVM_ArrayCopy */
214
215 void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length)
216 {
217         java_arrayheader *s;
218         java_arrayheader *d;
219
220         s = (java_arrayheader *) src;
221         d = (java_arrayheader *) dst;
222
223 #if PRINTJVM
224         log_println("JVM_ArrayCopy: src=%p, src_pos=%d, dst=%p, dst_pos=%d, length=%d", src, src_pos, dst, dst_pos, length);
225 #endif
226
227         (void) builtin_arraycopy(s, src_pos, d, dst_pos, length);
228 }
229
230
231 /* JVM_InitProperties */
232
233 jobject JVM_InitProperties(JNIEnv *env, jobject properties)
234 {
235 #if PRINTJVM
236         log_println("JVM_InitProperties: properties=%d", properties);
237 #endif
238         properties_system_add_all((java_objectheader *) properties);
239 }
240
241
242 /* JVM_Exit */
243
244 void JVM_Exit(jint code)
245 {
246         log_println("JVM_Exit: IMPLEMENT ME!");
247 }
248
249
250 /* JVM_Halt */
251
252 void JVM_Halt(jint code)
253 {
254 #if PRINTJVM
255         log_println("JVM_Halt: code=%d", code);
256 #endif
257 /*      vm_exit(code); */
258         vm_shutdown(code);
259 }
260
261
262 /* JVM_OnExit(void (*func)) */
263
264 void JVM_OnExit(void (*func)(void))
265 {
266         log_println("JVM_OnExit(void (*func): IMPLEMENT ME!");
267 }
268
269
270 /* JVM_GC */
271
272 void JVM_GC(void)
273 {
274 #if PRINTJVM
275         log_println("JVM_GC");
276 #endif
277         _Jv_java_lang_Runtime_gc();
278 }
279
280
281 /* JVM_MaxObjectInspectionAge */
282
283 jlong JVM_MaxObjectInspectionAge(void)
284 {
285         log_println("JVM_MaxObjectInspectionAge: IMPLEMENT ME!");
286 }
287
288
289 /* JVM_TraceInstructions */
290
291 void JVM_TraceInstructions(jboolean on)
292 {
293         log_println("JVM_TraceInstructions: IMPLEMENT ME!");
294 }
295
296
297 /* JVM_TraceMethodCalls */
298
299 void JVM_TraceMethodCalls(jboolean on)
300 {
301         log_println("JVM_TraceMethodCalls: IMPLEMENT ME!");
302 }
303
304
305 /* JVM_TotalMemory */
306
307 jlong JVM_TotalMemory(void)
308 {
309 #if PRINTJVM
310         log_println("JVM_TotalMemory");
311 #endif
312         return _Jv_java_lang_Runtime_totalMemory();
313 }
314
315
316 /* JVM_FreeMemory */
317
318 jlong JVM_FreeMemory(void)
319 {
320 #if PRINTJVM
321         log_println("JVM_FreeMemory");
322 #endif
323         return _Jv_java_lang_Runtime_freeMemory();
324 }
325
326
327 /* JVM_MaxMemory */
328
329 jlong JVM_MaxMemory(void)
330 {
331         log_println("JVM_MaxMemory: IMPLEMENT ME!");
332 }
333
334
335 /* JVM_ActiveProcessorCount */
336
337 jint JVM_ActiveProcessorCount(void)
338 {
339         log_println("JVM_ActiveProcessorCount: IMPLEMENT ME!");
340 }
341
342
343 /* JVM_FillInStackTrace */
344
345 void JVM_FillInStackTrace(JNIEnv *env, jobject receiver)
346 {
347         java_lang_Throwable *o;
348         stacktracecontainer *stc;
349
350 #if PRINTJVM
351         log_println("JVM_FillInStackTrace: receiver=%p", receiver);
352 #endif
353
354         o = (java_lang_Throwable *) receiver;
355
356         stc = stacktrace_fillInStackTrace();
357
358         if (stc == NULL)
359                 return;
360
361     o->backtrace = (java_lang_Object *) stc;
362 }
363
364
365 /* JVM_PrintStackTrace */
366
367 void JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable)
368 {
369         log_println("JVM_PrintStackTrace: IMPLEMENT ME!");
370 }
371
372
373 /* JVM_GetStackTraceDepth */
374
375 jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
376 {
377         java_lang_Throwable *o;
378         stacktracecontainer *stc;
379         stacktracebuffer    *stb;
380
381 #if PRINTJVM
382         log_println("JVM_GetStackTraceDepth: throwable=%p", throwable);
383 #endif
384
385         o   = (java_lang_Throwable *) throwable;
386         stc = (stacktracecontainer *) o->backtrace;
387         stb = &(stc->stb);
388
389         return stb->used;
390 }
391
392
393 /* JVM_GetStackTraceElement */
394
395 jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
396 {
397         java_lang_Throwable *t;
398         stacktracecontainer *stc;
399         stacktracebuffer    *stb;
400         stacktrace_entry    *ste;
401         java_lang_StackTraceElement *o;
402         java_lang_String            *declaringclass;
403         java_lang_String            *filename;
404         s4                           linenumber;
405
406 #if PRINTJVM
407         log_println("JVM_GetStackTraceElement: throwable=%p, index=%d", throwable, index);
408 #endif
409
410         t   = (java_lang_Throwable *) throwable;
411         stc = (stacktracecontainer *) t->backtrace;
412         stb = &(stc->stb);
413
414         if ((index < 0) || (index >= stb->used)) {
415                 /* XXX This should be an IndexOutOfBoundsException (check this
416                    again). */
417
418                 exceptions_throw_arrayindexoutofboundsexception();
419                 return NULL;
420         }
421
422         ste = &(stb->entries[index]);
423
424         /* allocate a new StackTraceElement */
425
426         o = (java_lang_StackTraceElement *)
427                 builtin_new(class_java_lang_StackTraceElement);
428
429         if (o == NULL)
430                 return NULL;
431
432         /* get filename */
433
434         if (!(ste->method->flags & ACC_NATIVE)) {
435                 if (ste->method->class->sourcefile)
436                         filename = (java_lang_String *) javastring_new(ste->method->class->sourcefile);
437                 else
438                         filename = NULL;
439         }
440         else
441                 filename = NULL;
442
443         /* get line number */
444
445         if (ste->method->flags & ACC_NATIVE)
446                 linenumber = -2;
447         else
448                 linenumber = (ste->linenumber == 0) ? -1 : ste->linenumber;
449
450         /* get declaring class name */
451
452         declaringclass =
453                 _Jv_java_lang_Class_getName((java_lang_Class *) ste->method->class);
454
455         /* fill the java.lang.StackTraceElement element */
456
457         o->declaringClass = declaringclass;
458         o->methodName     = (java_lang_String *) javastring_new(ste->method->name);
459         o->fileName       = filename;
460         o->lineNumber     = linenumber;
461
462         return (jobject) o;
463 }
464
465
466 /* JVM_IHashCode */
467
468 jint JVM_IHashCode(JNIEnv* env, jobject handle)
469 {
470 #if PRINTJVM
471         log_println("JVM_IHashCode: jobject=%p", handle);
472 #endif
473         return (jint) ((ptrint) handle);
474 }
475
476
477 /* JVM_MonitorWait */
478
479 void JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)
480 {
481 #if PRINTJVM
482         log_println("JVM_MonitorWait: handle=%p, ms=%ld", handle, ms);
483 #endif
484         _Jv_java_lang_Object_wait((java_lang_Object *) handle, ms, 0);
485 }
486
487
488 /* JVM_MonitorNotify */
489
490 void JVM_MonitorNotify(JNIEnv* env, jobject handle)
491 {
492 #if PRINTJVM
493         log_println("JVM_MonitorNotify: IMPLEMENT ME!");
494 #endif
495         _Jv_java_lang_Object_notify((java_lang_Object *) handle);
496 }
497
498
499 /* JVM_MonitorNotifyAll */
500
501 void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)
502 {
503 #if PRINTJVM
504         log_println("JVM_MonitorNotifyAll: handle=%p", handle);
505 #endif
506         _Jv_java_lang_Object_notifyAll((java_lang_Object *) handle);
507 }
508
509
510 /* JVM_Clone */
511
512 jobject JVM_Clone(JNIEnv* env, jobject handle)
513 {
514 #if PRINTJVM
515         log_println("JVM_Clone: handle=%p", handle);
516 #endif
517         return (jobject) builtin_clone(env, (java_objectheader *) handle);
518 }
519
520
521 /* JVM_InitializeCompiler  */
522
523 void JVM_InitializeCompiler (JNIEnv *env, jclass compCls)
524 {
525         log_println("JVM_InitializeCompiler : IMPLEMENT ME!");
526 }
527
528
529 /* JVM_IsSilentCompiler */
530
531 jboolean JVM_IsSilentCompiler(JNIEnv *env, jclass compCls)
532 {
533         log_println("JVM_IsSilentCompiler: IMPLEMENT ME!");
534 }
535
536
537 /* JVM_CompileClass */
538
539 jboolean JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls)
540 {
541         log_println("JVM_CompileClass: IMPLEMENT ME!");
542 }
543
544
545 /* JVM_CompileClasses */
546
547 jboolean JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname)
548 {
549         log_println("JVM_CompileClasses: IMPLEMENT ME!");
550 }
551
552
553 /* JVM_CompilerCommand */
554
555 jobject JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg)
556 {
557         log_println("JVM_CompilerCommand: IMPLEMENT ME!");
558 }
559
560
561 /* JVM_EnableCompiler */
562
563 void JVM_EnableCompiler(JNIEnv *env, jclass compCls)
564 {
565         log_println("JVM_EnableCompiler: IMPLEMENT ME!");
566 }
567
568
569 /* JVM_DisableCompiler */
570
571 void JVM_DisableCompiler(JNIEnv *env, jclass compCls)
572 {
573         log_println("JVM_DisableCompiler: IMPLEMENT ME!");
574 }
575
576
577 /* JVM_GetLastErrorString */
578
579 jint JVM_GetLastErrorString(char *buf, int len)
580 {
581         const char *s;
582         int n;
583
584     if (errno == 0) {
585                 return 0;
586     }
587         else {
588                 s = strerror(errno);
589                 n = strlen(s);
590
591                 if (n >= len)
592                         n = len - 1;
593
594                 strncpy(buf, s, n);
595
596                 buf[n] = '\0';
597
598                 return n;
599     }
600 }
601
602
603 /* JVM_NativePath */
604
605 char* JVM_NativePath(char* path)
606 {
607 #if PRINTJVM
608         log_println("JVM_NativePath: path=%s", path);
609 #endif
610         /* XXX is this correct? */
611
612         return path;
613 }
614
615
616 /* JVM_GetCallerClass */
617
618 jclass JVM_GetCallerClass(JNIEnv* env, int depth)
619 {
620         java_objectarray *oa;
621
622 #if PRINTJVM
623         log_println("JVM_GetCallerClass: depth=%d", depth);
624 #endif
625
626         oa = stacktrace_getClassContext();
627
628         if (oa == NULL)
629                 return NULL;
630
631         if (oa->header.size < depth)
632                 return NULL;
633
634         return (jclass) oa->data[depth - 1];
635
636 }
637
638
639 /* JVM_FindPrimitiveClass */
640
641 jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)
642 {
643 #if PRINTVM
644         log_println("JVM_FindPrimitiveClass: utf=%s", utf);
645 #endif
646         return (jclass) primitive_class_get_by_name(utf_new_char(utf));
647 }
648
649
650 /* JVM_ResolveClass */
651
652 void JVM_ResolveClass(JNIEnv* env, jclass cls)
653 {
654         log_println("JVM_ResolveClass: IMPLEMENT ME!");
655 }
656
657
658 /* JVM_FindClassFromClassLoader */
659
660 jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError)
661 {
662         classinfo *c;
663
664 #if PRINTJVM
665         log_println("JVM_FindClassFromClassLoader: name=%s, init=%d, loader=%p, throwError=%d", name, init, loader, throwError);
666 #endif
667
668         c = load_class_from_classloader(utf_new_char(name), (java_objectheader *) loader);
669
670         if (c == NULL)
671                 return NULL;
672
673         if (init)
674                 if (!(c->state & CLASS_INITIALIZED))
675                         if (!initialize_class(c))
676                                 return NULL;
677
678         return (jclass) c;
679 }
680
681
682 /* JVM_FindClassFromClass */
683
684 jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from)
685 {
686         log_println("JVM_FindClassFromClass: IMPLEMENT ME!");
687 }
688
689
690 /* JVM_DefineClass */
691
692 jclass JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)
693 {
694         log_println("JVM_DefineClass: IMPLEMENT ME!");
695 }
696
697
698 /* JVM_DefineClassWithSource */
699
700 jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)
701 {
702 #if PRINTJVM
703         log_println("JVM_DefineClassWithSource: name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s", name, loader, buf, len, pd, source);
704 #endif
705         /* XXX do something with pd and source */
706
707         return (jclass) class_define(utf_new_char(name), (java_objectheader *) loader, len, (u1 *) buf);
708
709 }
710
711
712 /* JVM_FindLoadedClass */
713
714 jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
715 {
716         classloader *cl;
717         utf         *u;
718         classinfo   *c;
719
720         cl = (classloader *) loader;
721
722 #if PRINTJVM
723         log_println("JVM_FindLoadedClass(loader=%p, name=%p)", loader, name);
724 #endif
725
726         u = javastring_toutf((java_objectheader *) name, true);
727         c = classcache_lookup(cl, u);
728
729         return (jclass) c;
730 }
731
732
733 /* JVM_GetClassName */
734
735 jstring JVM_GetClassName(JNIEnv *env, jclass cls)
736 {
737 #if PRINTJVM
738         log_println("JVM_GetClassName: cls=%p", cls);
739 #endif
740         return (jstring) _Jv_java_lang_Class_getName((java_lang_Class *) cls);
741 }
742
743
744 /* JVM_GetClassInterfaces */
745
746 jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls)
747 {
748 #if PRINTJVM
749         log_println("JVM_GetClassInterfaces: cls=%p", cls);
750 #endif
751         return (jobjectArray) _Jv_java_lang_Class_getInterfaces((java_lang_Class *) cls);
752 }
753
754
755 /* JVM_GetClassLoader */
756
757 jobject JVM_GetClassLoader(JNIEnv *env, jclass cls)
758 {
759 #if PRINTJVM
760         log_println("JVM_GetClassLoader: cls=%p", cls);
761 #endif
762         return (jobject) _Jv_java_lang_Class_getClassLoader((java_lang_Class *) cls);
763 }
764
765
766 /* JVM_IsInterface */
767
768 jboolean JVM_IsInterface(JNIEnv *env, jclass cls)
769 {
770         classinfo *c;
771
772 #if PRINTJVM
773         log_println("JVM_IsInterface: cls=%p", cls);
774 #endif
775
776         c = (classinfo *) cls;
777
778         return class_is_interface(c);
779 }
780
781
782 /* JVM_GetClassSigners */
783
784 jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls)
785 {
786         log_println("JVM_GetClassSigners: IMPLEMENT ME!");
787 }
788
789
790 /* JVM_SetClassSigners */
791
792 void JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers)
793 {
794         log_println("JVM_SetClassSigners: IMPLEMENT ME!");
795 }
796
797
798 /* JVM_GetProtectionDomain */
799
800 jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls)
801 {
802         classinfo *c;
803
804 #if PRINTJVM || 1
805         log_println("JVM_GetProtectionDomain: cls=%p");
806 #endif
807
808         c = (classinfo *) cls;
809
810         if (c == NULL) {
811                 exceptions_throw_nullpointerexception();
812                 return NULL;
813         }
814
815     /* Primitive types do not have a protection domain. */
816
817         if (class_is_primitive(c))
818                 return NULL;
819 }
820
821
822 /* JVM_SetProtectionDomain */
823
824 void JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain)
825 {
826         log_println("JVM_SetProtectionDomain: IMPLEMENT ME!");
827 }
828
829
830 /* JVM_DoPrivileged */
831
832 jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException)
833 {
834         java_objectheader *o;
835         classinfo         *c;
836         methodinfo        *m;
837         java_objectheader *result;
838         java_objectheader *e;
839
840 #if PRINTJVM
841         log_println("JVM_DoPrivileged: action=%p, context=%p, wrapException=%d", action, context, wrapException);
842 #endif
843
844         o = (java_objectheader *) action;
845         c = o->vftbl->class;
846
847         if (action == NULL) {
848                 exceptions_throw_nullpointerexception();
849                 return NULL;
850         }
851
852         /* lookup run() method (throw no exceptions) */
853
854         m = class_resolveclassmethod(c, utf_run, utf_void__java_lang_Object, c,
855                                                                  false);
856
857         if ((m == NULL) || !(m->flags & ACC_PUBLIC) || (m->flags & ACC_STATIC)) {
858                 exceptions_throw_internalerror("No run method");
859                 return NULL;
860         }
861
862         /* XXX It seems something with a privileged stack needs to be done
863            here. */
864
865         result = vm_call_method(m, o);
866
867         e = exceptions_get_and_clear_exception();
868
869         if (e != NULL) {
870                 exceptions_throw_privilegedactionexception(e);
871                 return NULL;
872         }
873
874         return (jobject) result;
875 }
876
877
878 /* JVM_GetInheritedAccessControlContext */
879
880 jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls)
881 {
882         log_println("JVM_GetInheritedAccessControlContext: IMPLEMENT ME!");
883 }
884
885
886 /* JVM_GetStackAccessControlContext */
887
888 jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)
889 {
890         log_println("JVM_GetStackAccessControlContext: IMPLEMENT ME!");
891 }
892
893
894 /* JVM_IsArrayClass */
895
896 jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls)
897 {
898 #if PRINTJVM
899         log_println("JVM_IsArrayClass: cls=%p", cls);
900 #endif
901         return class_is_array((classinfo *) cls);
902 }
903
904
905 /* JVM_IsPrimitiveClass */
906
907 jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)
908 {
909         classinfo *c;
910
911         c = (classinfo *) cls;
912
913 #if PRINTJVM
914         log_println("JVM_IsPrimitiveClass(cls=%p)", cls);
915 #endif
916
917         return class_is_primitive(c);
918 }
919
920
921 /* JVM_GetComponentType */
922
923 jclass JVM_GetComponentType(JNIEnv *env, jclass cls)
924 {
925 #if PRINTJVM
926         log_println("JVM_GetComponentType: cls=%p", cls);
927 #endif
928         return (jclass) _Jv_java_lang_Class_getComponentType((java_lang_Class *) cls);
929 }
930
931
932 /* JVM_GetClassModifiers */
933
934 jint JVM_GetClassModifiers(JNIEnv *env, jclass cls)
935 {
936         classinfo *c;
937
938 #if PRINTJVM
939         log_println("JVM_GetClassModifiers: cls=%p", cls);
940 #endif
941
942         c = (classinfo *) cls;
943
944         /* XXX is this correct? */
945
946         return c->flags & ACC_CLASS_REFLECT_MASK;
947 }
948
949
950 /* JVM_GetDeclaredClasses */
951
952 jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)
953 {
954         log_println("JVM_GetDeclaredClasses: IMPLEMENT ME!");
955 }
956
957
958 /* JVM_GetDeclaringClass */
959
960 jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)
961 {
962         log_println("JVM_GetDeclaringClass: IMPLEMENT ME!");
963 }
964
965
966 /* JVM_GetClassSignature */
967
968 jstring JVM_GetClassSignature(JNIEnv *env, jclass cls)
969 {
970         log_println("JVM_GetClassSignature: IMPLEMENT ME!");
971 }
972
973
974 /* JVM_GetClassAnnotations */
975
976 jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
977 {
978         log_println("JVM_GetClassAnnotations: IMPLEMENT ME!");
979 }
980
981
982 /* JVM_GetFieldAnnotations */
983
984 jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
985 {
986         log_println("JVM_GetFieldAnnotations: IMPLEMENT ME!");
987 }
988
989
990 /* JVM_GetMethodAnnotations */
991
992 jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
993 {
994         log_println("JVM_GetMethodAnnotations: IMPLEMENT ME!");
995 }
996
997
998 /* JVM_GetMethodDefaultAnnotationValue */
999
1000 jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
1001 {
1002         log_println("JVM_GetMethodDefaultAnnotationValue: IMPLEMENT ME!");
1003 }
1004
1005
1006 /* JVM_GetMethodParameterAnnotations */
1007
1008 jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
1009 {
1010         log_println("JVM_GetMethodParameterAnnotations: IMPLEMENT ME!");
1011 }
1012
1013
1014 /* JVM_GetClassDeclaredFields */
1015
1016 jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly)
1017 {
1018 #if PRINTJVM
1019         log_println("JVM_GetClassDeclaredFields: ofClass=%p, publicOnly=%d", ofClass, publicOnly);
1020 #endif
1021         return (jobjectArray) _Jv_java_lang_Class_getDeclaredFields((java_lang_Class *) ofClass, publicOnly);
1022 }
1023
1024
1025 /* JVM_GetClassDeclaredMethods */
1026
1027 jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
1028 {
1029 #if PRINTJVM
1030         log_println("JVM_GetClassDeclaredMethods: ofClass=%p, publicOnly=%d", ofClass, publicOnly);
1031 #endif
1032         return (jobjectArray) _Jv_java_lang_Class_getDeclaredMethods((java_lang_Class *) ofClass, publicOnly);
1033 }
1034
1035
1036 /* JVM_GetClassDeclaredConstructors */
1037
1038 jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly)
1039 {
1040 #if PRINTJVM
1041         log_println("JVM_GetClassDeclaredConstructors: ofClass=%p, publicOnly=%d", ofClass, publicOnly);
1042 #endif
1043         return (jobjectArray) _Jv_java_lang_Class_getDeclaredConstructors((java_lang_Class *) ofClass, publicOnly);
1044 }
1045
1046
1047 /* JVM_GetClassAccessFlags */
1048
1049 jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)
1050 {
1051         classinfo *c;
1052
1053 #if PRINTJVM
1054         log_println("JVM_GetClassAccessFlags: cls=%p", cls);
1055 #endif
1056
1057         c = (classinfo *) cls;
1058
1059         return c->flags & ACC_CLASS_REFLECT_MASK;
1060 }
1061
1062
1063 /* JVM_GetClassConstantPool */
1064
1065 jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
1066 {
1067         log_println("JVM_GetClassConstantPool: IMPLEMENT ME!");
1068 }
1069
1070
1071 /* JVM_ConstantPoolGetSize */
1072
1073 jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
1074 {
1075         log_println("JVM_ConstantPoolGetSize: IMPLEMENT ME!");
1076 }
1077
1078
1079 /* JVM_ConstantPoolGetClassAt */
1080
1081 jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1082 {
1083         log_println("JVM_ConstantPoolGetClassAt: IMPLEMENT ME!");
1084 }
1085
1086
1087 /* JVM_ConstantPoolGetClassAtIfLoaded */
1088
1089 jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1090 {
1091         log_println("JVM_ConstantPoolGetClassAtIfLoaded: IMPLEMENT ME!");
1092 }
1093
1094
1095 /* JVM_ConstantPoolGetMethodAt */
1096
1097 jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1098 {
1099         log_println("JVM_ConstantPoolGetMethodAt: IMPLEMENT ME!");
1100 }
1101
1102
1103 /* JVM_ConstantPoolGetMethodAtIfLoaded */
1104
1105 jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1106 {
1107         log_println("JVM_ConstantPoolGetMethodAtIfLoaded: IMPLEMENT ME!");
1108 }
1109
1110
1111 /* JVM_ConstantPoolGetFieldAt */
1112
1113 jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1114 {
1115         log_println("JVM_ConstantPoolGetFieldAt: IMPLEMENT ME!");
1116 }
1117
1118
1119 /* JVM_ConstantPoolGetFieldAtIfLoaded */
1120
1121 jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1122 {
1123         log_println("JVM_ConstantPoolGetFieldAtIfLoaded: IMPLEMENT ME!");
1124 }
1125
1126
1127 /* JVM_ConstantPoolGetMemberRefInfoAt */
1128
1129 jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1130 {
1131         log_println("JVM_ConstantPoolGetMemberRefInfoAt: IMPLEMENT ME!");
1132 }
1133
1134
1135 /* JVM_ConstantPoolGetIntAt */
1136
1137 jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1138 {
1139         log_println("JVM_ConstantPoolGetIntAt: IMPLEMENT ME!");
1140 }
1141
1142
1143 /* JVM_ConstantPoolGetLongAt */
1144
1145 jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1146 {
1147         log_println("JVM_ConstantPoolGetLongAt: IMPLEMENT ME!");
1148 }
1149
1150
1151 /* JVM_ConstantPoolGetFloatAt */
1152
1153 jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1154 {
1155         log_println("JVM_ConstantPoolGetFloatAt: IMPLEMENT ME!");
1156 }
1157
1158
1159 /* JVM_ConstantPoolGetDoubleAt */
1160
1161 jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1162 {
1163         log_println("JVM_ConstantPoolGetDoubleAt: IMPLEMENT ME!");
1164 }
1165
1166
1167 /* JVM_ConstantPoolGetStringAt */
1168
1169 jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1170 {
1171         log_println("JVM_ConstantPoolGetStringAt: IMPLEMENT ME!");
1172 }
1173
1174
1175 /* JVM_ConstantPoolGetUTF8At */
1176
1177 jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)
1178 {
1179         log_println("JVM_ConstantPoolGetUTF8At: IMPLEMENT ME!");
1180 }
1181
1182
1183 /* JVM_DesiredAssertionStatus */
1184
1185 jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)
1186 {
1187         log_println("JVM_DesiredAssertionStatus: cls=%p, IMPLEMENT ME!", cls);
1188
1189         return false;
1190 }
1191
1192
1193 /* JVM_AssertionStatusDirectives */
1194
1195 jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
1196 {
1197         classinfo         *c;
1198         java_lang_AssertionStatusDirectives *o;
1199         java_objectarray  *classes;
1200         java_objectarray  *packages;
1201
1202 #if PRINTJVM || 1
1203         log_println("JVM_AssertionStatusDirectives");
1204 #endif
1205         /* XXX this is not completely implemented */
1206
1207         c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1208
1209         if (c == NULL)
1210                 return NULL;
1211
1212         o = (java_lang_AssertionStatusDirectives *) builtin_new(c);
1213
1214         if (o == NULL)
1215                 return NULL;
1216
1217         classes = builtin_anewarray(0, class_java_lang_Object);
1218
1219         if (classes == NULL)
1220                 return NULL;
1221
1222         packages = builtin_anewarray(0, class_java_lang_Object);
1223
1224         if (packages == NULL)
1225                 return NULL;
1226
1227         /* set instance fields */
1228
1229         o->classes  = classes;
1230         o->packages = packages;
1231
1232         return (jobject) o;
1233 }
1234
1235
1236 /* JVM_GetClassNameUTF */
1237
1238 const char* JVM_GetClassNameUTF(JNIEnv *env, jclass cls)
1239 {
1240         log_println("JVM_GetClassNameUTF: IMPLEMENT ME!");
1241 }
1242
1243
1244 /* JVM_GetClassCPTypes */
1245
1246 void JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)
1247 {
1248         log_println("JVM_GetClassCPTypes: IMPLEMENT ME!");
1249 }
1250
1251
1252 /* JVM_GetClassCPEntriesCount */
1253
1254 jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)
1255 {
1256         log_println("JVM_GetClassCPEntriesCount: IMPLEMENT ME!");
1257 }
1258
1259
1260 /* JVM_GetClassFieldsCount */
1261
1262 jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)
1263 {
1264         log_println("JVM_GetClassFieldsCount: IMPLEMENT ME!");
1265 }
1266
1267
1268 /* JVM_GetClassMethodsCount */
1269
1270 jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)
1271 {
1272         log_println("JVM_GetClassMethodsCount: IMPLEMENT ME!");
1273 }
1274
1275
1276 /* JVM_GetMethodIxExceptionIndexes */
1277
1278 void JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)
1279 {
1280         log_println("JVM_GetMethodIxExceptionIndexes: IMPLEMENT ME!");
1281 }
1282
1283
1284 /* JVM_GetMethodIxExceptionsCount */
1285
1286 jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)
1287 {
1288         log_println("JVM_GetMethodIxExceptionsCount: IMPLEMENT ME!");
1289 }
1290
1291
1292 /* JVM_GetMethodIxByteCode */
1293
1294 void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)
1295 {
1296         log_println("JVM_GetMethodIxByteCode: IMPLEMENT ME!");
1297 }
1298
1299
1300 /* JVM_GetMethodIxByteCodeLength */
1301
1302 jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)
1303 {
1304         log_println("JVM_GetMethodIxByteCodeLength: IMPLEMENT ME!");
1305 }
1306
1307
1308 /* JVM_GetMethodIxExceptionTableEntry */
1309
1310 void JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)
1311 {
1312         log_println("JVM_GetMethodIxExceptionTableEntry: IMPLEMENT ME!");
1313 }
1314
1315
1316 /* JVM_GetMethodIxExceptionTableLength */
1317
1318 jint JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)
1319 {
1320         log_println("JVM_GetMethodIxExceptionTableLength: IMPLEMENT ME!");
1321 }
1322
1323
1324 /* JVM_GetMethodIxModifiers */
1325
1326 jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)
1327 {
1328         log_println("JVM_GetMethodIxModifiers: IMPLEMENT ME!");
1329 }
1330
1331
1332 /* JVM_GetFieldIxModifiers */
1333
1334 jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)
1335 {
1336         log_println("JVM_GetFieldIxModifiers: IMPLEMENT ME!");
1337 }
1338
1339
1340 /* JVM_GetMethodIxLocalsCount */
1341
1342 jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)
1343 {
1344         log_println("JVM_GetMethodIxLocalsCount: IMPLEMENT ME!");
1345 }
1346
1347
1348 /* JVM_GetMethodIxArgsSize */
1349
1350 jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)
1351 {
1352         log_println("JVM_GetMethodIxArgsSize: IMPLEMENT ME!");
1353 }
1354
1355
1356 /* JVM_GetMethodIxMaxStack */
1357
1358 jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)
1359 {
1360         log_println("JVM_GetMethodIxMaxStack: IMPLEMENT ME!");
1361 }
1362
1363
1364 /* JVM_IsConstructorIx */
1365
1366 jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)
1367 {
1368         log_println("JVM_IsConstructorIx: IMPLEMENT ME!");
1369 }
1370
1371
1372 /* JVM_GetMethodIxNameUTF */
1373
1374 const char* JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)
1375 {
1376         log_println("JVM_GetMethodIxNameUTF: IMPLEMENT ME!");
1377 }
1378
1379
1380 /* JVM_GetMethodIxSignatureUTF */
1381
1382 const char* JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)
1383 {
1384         log_println("JVM_GetMethodIxSignatureUTF: IMPLEMENT ME!");
1385 }
1386
1387
1388 /* JVM_GetCPFieldNameUTF */
1389
1390 const char* JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)
1391 {
1392         log_println("JVM_GetCPFieldNameUTF: IMPLEMENT ME!");
1393 }
1394
1395
1396 /* JVM_GetCPMethodNameUTF */
1397
1398 const char* JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)
1399 {
1400         log_println("JVM_GetCPMethodNameUTF: IMPLEMENT ME!");
1401 }
1402
1403
1404 /* JVM_GetCPMethodSignatureUTF */
1405
1406 const char* JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
1407 {
1408         log_println("JVM_GetCPMethodSignatureUTF: IMPLEMENT ME!");
1409 }
1410
1411
1412 /* JVM_GetCPFieldSignatureUTF */
1413
1414 const char* JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)
1415 {
1416         log_println("JVM_GetCPFieldSignatureUTF: IMPLEMENT ME!");
1417 }
1418
1419
1420 /* JVM_GetCPClassNameUTF */
1421
1422 const char* JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
1423 {
1424         log_println("JVM_GetCPClassNameUTF: IMPLEMENT ME!");
1425 }
1426
1427
1428 /* JVM_GetCPFieldClassNameUTF */
1429
1430 const char* JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
1431 {
1432         log_println("JVM_GetCPFieldClassNameUTF: IMPLEMENT ME!");
1433 }
1434
1435
1436 /* JVM_GetCPMethodClassNameUTF */
1437
1438 const char* JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)
1439 {
1440         log_println("JVM_GetCPMethodClassNameUTF: IMPLEMENT ME!");
1441 }
1442
1443
1444 /* JVM_GetCPFieldModifiers */
1445
1446 jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
1447 {
1448         log_println("JVM_GetCPFieldModifiers: IMPLEMENT ME!");
1449 }
1450
1451
1452 /* JVM_GetCPMethodModifiers */
1453
1454 jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)
1455 {
1456         log_println("JVM_GetCPMethodModifiers: IMPLEMENT ME!");
1457 }
1458
1459
1460 /* JVM_ReleaseUTF */
1461
1462 void JVM_ReleaseUTF(const char *utf)
1463 {
1464         log_println("JVM_ReleaseUTF: IMPLEMENT ME!");
1465 }
1466
1467
1468 /* JVM_IsSameClassPackage */
1469
1470 jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)
1471 {
1472         log_println("JVM_IsSameClassPackage: IMPLEMENT ME!");
1473 }
1474
1475
1476 /* JVM_Open */
1477
1478 jint JVM_Open(const char *fname, jint flags, jint mode)
1479 {
1480         int result;
1481
1482 #if PRINTJVM
1483         log_println("JVM_Open: fname=%s, flags=%d, mode=%d", fname, flags, mode);
1484 #endif
1485
1486         result = open(fname, flags, mode);
1487
1488         if (result >= 0) {
1489                 return result;
1490         }
1491         else {
1492                 switch(errno) {
1493                 case EEXIST:
1494                         /* XXX don't know what to do here */
1495 /*                      return JVM_EEXIST; */
1496                         return -1;
1497                 default:
1498                         return -1;
1499                 }
1500         }
1501 }
1502
1503
1504 /* JVM_Close */
1505
1506 jint JVM_Close(jint fd)
1507 {
1508 #if PRINTJVM
1509         log_println("JVM_Close: fd=%d", fd);
1510 #endif
1511         return close(fd);
1512 }
1513
1514
1515 /* JVM_Read */
1516
1517 jint JVM_Read(jint fd, char *buf, jint nbytes)
1518 {
1519 #if PRINTJVM
1520         log_println("JVM_Read: fd=%d, buf=%p, nbytes=%d", fd, buf, nbytes);
1521 #endif
1522         return read(fd, buf, nbytes);
1523 }
1524
1525
1526 /* JVM_Write */
1527
1528 jint JVM_Write(jint fd, char *buf, jint nbytes)
1529 {
1530 #if PRINTJVM
1531         log_println("JVM_Write: fd=%d, buf=%s, nbytes=%d", fd, buf, nbytes);
1532 #endif
1533         return write(fd, buf, nbytes);
1534 }
1535
1536
1537 /* JVM_Available */
1538
1539 jint JVM_Available(jint fd, jlong *pbytes)
1540 {
1541 #if defined(FIONREAD)
1542         ssize_t n;
1543
1544         *pbytes = 0;
1545
1546         if (ioctl(fd, FIONREAD, (char *) &n) != 0)
1547                 return 0;
1548
1549         *pbytes = n;
1550
1551         return 1;
1552 #elif defined(HAVE_FSTAT)
1553         struct stat statBuffer;
1554         off_t n;
1555         int result;
1556
1557         *pbytes = 0;
1558
1559         if ((fstat(fd, &statBuffer) == 0) && S_ISREG (statBuffer.st_mode)) {
1560                 n = lseek (fd, 0, SEEK_CUR);
1561
1562                 if (n != -1) {
1563                         *pbytes = statBuffer.st_size - n; 
1564                         result = 1;
1565                 }
1566                 else {
1567                         result = 0;
1568                 }
1569         }
1570         else {
1571                 result = 0;
1572         }
1573   
1574         return result;
1575 #elif defined(HAVE_SELECT)
1576         fd_set filedescriptset;
1577         struct timeval tv;
1578         int result;
1579
1580         *pbytes = 0;
1581   
1582         FD_ZERO(&filedescriptset);
1583         FD_SET(fd, &filedescriptset);
1584         memset(&tv, 0, sizeof(tv));
1585
1586         switch (select(fd+1, &filedescriptset, NULL, NULL, &tv))
1587                 {
1588                 case -1: 
1589                         result = errno; 
1590                         break;
1591                 case  0:
1592                         *pbytes = 0;
1593                         result = CPNATIVE_OK;
1594                         break;      
1595                 default: 
1596                         *pbytes = 1;
1597                         result = CPNATIVE_OK;
1598                         break;
1599                 }
1600         return result;
1601 #else
1602         *pbytes = 0;
1603         return 0;
1604 #endif
1605 }
1606
1607
1608 /* JVM_Lseek */
1609
1610 jlong JVM_Lseek(jint fd, jlong offset, jint whence)
1611 {
1612 #if PRINTJVM
1613         log_println("JVM_Lseek: fd=%d, offset=%ld, whence=%d", fd, offset, whence);
1614 #endif
1615         return (jlong) lseek(fd, (off_t) offset, whence);
1616 }
1617
1618
1619 /* JVM_SetLength */
1620
1621 jint JVM_SetLength(jint fd, jlong length)
1622 {
1623         log_println("JVM_SetLength: IMPLEMENT ME!");
1624 }
1625
1626
1627 /* JVM_Sync */
1628
1629 jint JVM_Sync(jint fd)
1630 {
1631         log_println("JVM_Sync: IMPLEMENT ME!");
1632 }
1633
1634
1635 /* JVM_StartThread */
1636
1637 void JVM_StartThread(JNIEnv* env, jobject jthread)
1638 {
1639 #if PRINTJVM
1640         log_println("JVM_StartThread: jthread=%p", jthread);
1641 #endif
1642         _Jv_java_lang_Thread_start((java_lang_Thread *) jthread, 0);
1643 }
1644
1645
1646 /* JVM_StopThread */
1647
1648 void JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable)
1649 {
1650         log_println("JVM_StopThread: IMPLEMENT ME!");
1651 }
1652
1653
1654 /* JVM_IsThreadAlive */
1655
1656 jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread)
1657 {
1658 #if PRINTJVM
1659         log_println("JVM_IsThreadAlive: jthread=%p", jthread);
1660 #endif
1661         return _Jv_java_lang_Thread_isAlive((java_lang_Thread *) jthread);
1662 }
1663
1664
1665 /* JVM_SuspendThread */
1666
1667 void JVM_SuspendThread(JNIEnv* env, jobject jthread)
1668 {
1669         log_println("JVM_SuspendThread: IMPLEMENT ME!");
1670 }
1671
1672
1673 /* JVM_ResumeThread */
1674
1675 void JVM_ResumeThread(JNIEnv* env, jobject jthread)
1676 {
1677         log_println("JVM_ResumeThread: IMPLEMENT ME!");
1678 }
1679
1680
1681 /* JVM_SetThreadPriority */
1682
1683 void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)
1684 {
1685 #if PRINTJVM
1686         log_println("JVM_SetThreadPriority: jthread=%p, prio=%d", jthread, prio);
1687 #endif
1688         _Jv_java_lang_Thread_setPriority((java_lang_Thread *) jthread, prio);
1689 }
1690
1691
1692 /* JVM_Yield */
1693
1694 void JVM_Yield(JNIEnv *env, jclass threadClass)
1695 {
1696         log_println("JVM_Yield: IMPLEMENT ME!");
1697 }
1698
1699
1700 /* JVM_Sleep */
1701
1702 void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)
1703 {
1704 #if PRINTJVM
1705         log_println("JVM_Sleep: threadClass=%p, millis=%ld", threadClass, millis);
1706 #endif
1707         _Jv_java_lang_Thread_sleep(millis);
1708 }
1709
1710
1711 /* JVM_CurrentThread */
1712
1713 jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass)
1714 {
1715 #if PRINTJVM
1716         log_println("JVM_CurrentThread: threadClass=%p", threadClass);
1717 #endif
1718         return (jobject) _Jv_java_lang_Thread_currentThread();
1719 }
1720
1721
1722 /* JVM_CountStackFrames */
1723
1724 jint JVM_CountStackFrames(JNIEnv* env, jobject jthread)
1725 {
1726         log_println("JVM_CountStackFrames: IMPLEMENT ME!");
1727 }
1728
1729
1730 /* JVM_Interrupt */
1731
1732 void JVM_Interrupt(JNIEnv* env, jobject jthread)
1733 {
1734         log_println("JVM_Interrupt: IMPLEMENT ME!");
1735 }
1736
1737
1738 /* JVM_IsInterrupted */
1739
1740 jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)
1741 {
1742 #if PRINTJVM
1743         log_println("JVM_IsInterrupted: jthread=%p, clear_interrupted=%d", jthread, clear_interrupted);
1744 #endif
1745         /* XXX do something with clear_interrupted */
1746         return _Jv_java_lang_Thread_isInterrupted((java_lang_Thread *) jthread);
1747 }
1748
1749
1750 /* JVM_HoldsLock */
1751
1752 jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj)
1753 {
1754         log_println("JVM_HoldsLock: IMPLEMENT ME!");
1755 }
1756
1757
1758 /* JVM_DumpAllStacks */
1759
1760 void JVM_DumpAllStacks(JNIEnv* env, jclass unused)
1761 {
1762         log_println("JVM_DumpAllStacks: IMPLEMENT ME!");
1763 }
1764
1765
1766 /* JVM_CurrentLoadedClass */
1767
1768 jclass JVM_CurrentLoadedClass(JNIEnv *env)
1769 {
1770         log_println("JVM_CurrentLoadedClass: IMPLEMENT ME!");
1771 }
1772
1773
1774 /* JVM_CurrentClassLoader */
1775
1776 jobject JVM_CurrentClassLoader(JNIEnv *env)
1777 {
1778         log_println("JVM_CurrentClassLoader: IMPLEMENT ME!");
1779 }
1780
1781
1782 /* JVM_GetClassContext */
1783
1784 jobjectArray JVM_GetClassContext(JNIEnv *env)
1785 {
1786 #if PRINTJVM
1787         log_println("JVM_GetClassContext");
1788 #endif
1789         return (jobjectArray) stacktrace_getClassContext();
1790 }
1791
1792
1793 /* JVM_ClassDepth */
1794
1795 jint JVM_ClassDepth(JNIEnv *env, jstring name)
1796 {
1797         log_println("JVM_ClassDepth: IMPLEMENT ME!");
1798 }
1799
1800
1801 /* JVM_ClassLoaderDepth */
1802
1803 jint JVM_ClassLoaderDepth(JNIEnv *env)
1804 {
1805         log_println("JVM_ClassLoaderDepth: IMPLEMENT ME!");
1806 }
1807
1808
1809 /* JVM_GetSystemPackage */
1810
1811 jstring JVM_GetSystemPackage(JNIEnv *env, jstring name)
1812 {
1813         log_println("JVM_GetSystemPackage: IMPLEMENT ME!");
1814 }
1815
1816
1817 /* JVM_GetSystemPackages */
1818
1819 jobjectArray JVM_GetSystemPackages(JNIEnv *env)
1820 {
1821         log_println("JVM_GetSystemPackages: IMPLEMENT ME!");
1822 }
1823
1824
1825 /* JVM_AllocateNewObject */
1826
1827 jobject JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)
1828 {
1829         log_println("JVM_AllocateNewObject: IMPLEMENT ME!");
1830 }
1831
1832
1833 /* JVM_AllocateNewArray */
1834
1835 jobject JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length)
1836 {
1837         log_println("JVM_AllocateNewArray: IMPLEMENT ME!");
1838 }
1839
1840
1841 /* JVM_LatestUserDefinedLoader */
1842
1843 jobject JVM_LatestUserDefinedLoader(JNIEnv *env)
1844 {
1845         log_println("JVM_LatestUserDefinedLoader: IMPLEMENT ME!");
1846 }
1847
1848
1849 /* JVM_LoadClass0 */
1850
1851 jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring currClassName)
1852 {
1853         log_println("JVM_LoadClass0: IMPLEMENT ME!");
1854 }
1855
1856
1857 /* JVM_GetArrayLength */
1858
1859 jint JVM_GetArrayLength(JNIEnv *env, jobject arr)
1860 {
1861         log_println("JVM_GetArrayLength: IMPLEMENT ME!");
1862 }
1863
1864
1865 /* JVM_GetArrayElement */
1866
1867 jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
1868 {
1869         log_println("JVM_GetArrayElement: IMPLEMENT ME!");
1870 }
1871
1872
1873 /* JVM_GetPrimitiveArrayElement */
1874
1875 jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode)
1876 {
1877         log_println("JVM_GetPrimitiveArrayElement: IMPLEMENT ME!");
1878 }
1879
1880
1881 /* JVM_SetArrayElement */
1882
1883 void JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val)
1884 {
1885         log_println("JVM_SetArrayElement: IMPLEMENT ME!");
1886 }
1887
1888
1889 /* JVM_SetPrimitiveArrayElement */
1890
1891 void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode)
1892 {
1893         log_println("JVM_SetPrimitiveArrayElement: IMPLEMENT ME!");
1894 }
1895
1896
1897 /* JVM_NewArray */
1898
1899 jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length)
1900 {
1901         classinfo        *c;
1902         classinfo        *pc;
1903         java_arrayheader *a;
1904         java_objectarray *oa;
1905
1906         c = (classinfo *) eltClass;
1907
1908 #if PRINTJVM
1909         log_println("JVM_NewArray(eltClass=%p, length=%d)", eltClass, length);
1910 #endif
1911
1912         /* create primitive or object array */
1913
1914         if (class_is_primitive(c)) {
1915                 pc = primitive_arrayclass_get_by_name(c->name);
1916                 a = builtin_newarray(length, pc);
1917
1918                 return (jobject) a;
1919         }
1920         else {
1921                 oa = builtin_anewarray(length, c);
1922
1923                 return (jobject) oa;
1924         }
1925 }
1926
1927
1928 /* JVM_NewMultiArray */
1929
1930 jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim)
1931 {
1932         log_println("JVM_NewMultiArray: IMPLEMENT ME!");
1933 }
1934
1935
1936 /* JVM_InitializeSocketLibrary */
1937
1938 jint JVM_InitializeSocketLibrary()
1939 {
1940         log_println("JVM_InitializeSocketLibrary: IMPLEMENT ME!");
1941 }
1942
1943
1944 /* JVM_Socket */
1945
1946 jint JVM_Socket(jint domain, jint type, jint protocol)
1947 {
1948 #if PRINTJVM || 1
1949         log_println("JVM_Socket: domain=%d, type=%d, protocol=%d", domain, type, protocol);
1950 #endif
1951         return socket(domain, type, protocol);
1952 }
1953
1954
1955 /* JVM_SocketClose */
1956
1957 jint JVM_SocketClose(jint fd)
1958 {
1959 #if PRINTJVM || 1
1960         log_println("JVM_SocketClose: fd=%d", fd);
1961 #endif
1962         return close(fd);
1963 }
1964
1965
1966 /* JVM_SocketShutdown */
1967
1968 jint JVM_SocketShutdown(jint fd, jint howto)
1969 {
1970 #if PRINTJVM || 1
1971         log_println("JVM_SocketShutdown: fd=%d, howto=%d", fd, howto);
1972 #endif
1973         return shutdown(fd, howto);
1974 }
1975
1976
1977 /* JVM_Recv */
1978
1979 jint JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)
1980 {
1981         log_println("JVM_Recv: IMPLEMENT ME!");
1982 }
1983
1984
1985 /* JVM_Send */
1986
1987 jint JVM_Send(jint fd, char *buf, jint nBytes, jint flags)
1988 {
1989         log_println("JVM_Send: IMPLEMENT ME!");
1990 }
1991
1992
1993 /* JVM_Timeout */
1994
1995 jint JVM_Timeout(int fd, long timeout)
1996 {
1997         log_println("JVM_Timeout: IMPLEMENT ME!");
1998 }
1999
2000
2001 /* JVM_Listen */
2002
2003 jint JVM_Listen(jint fd, jint count)
2004 {
2005 #if PRINTJVM || 1
2006         log_println("JVM_Listen: fd=%d, count=%d", fd, count);
2007 #endif
2008         return listen(fd, count);
2009 }
2010
2011
2012 /* JVM_Connect */
2013
2014 jint JVM_Connect(jint fd, struct sockaddr *him, jint len)
2015 {
2016 #if PRINTJVM || 1
2017         log_println("JVM_Connect: fd=%d, him=%p, len=%d", fd, him, len);
2018 #endif
2019         return connect(fd, him, len);
2020 }
2021
2022
2023 /* JVM_Bind */
2024
2025 jint JVM_Bind(jint fd, struct sockaddr *him, jint len)
2026 {
2027         log_println("JVM_Bind: IMPLEMENT ME!");
2028 }
2029
2030
2031 /* JVM_Accept */
2032
2033 jint JVM_Accept(jint fd, struct sockaddr *him, jint *len)
2034 {
2035 #if PRINTJVM || 1
2036         log_println("JVM_Accept: fd=%d, him=%p, len=%p", fd, him, len);
2037 #endif
2038         return accept(fd, him, (socklen_t *) len);
2039 }
2040
2041
2042 /* JVM_RecvFrom */
2043
2044 jint JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)
2045 {
2046         log_println("JVM_RecvFrom: IMPLEMENT ME!");
2047 }
2048
2049
2050 /* JVM_GetSockName */
2051
2052 jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len)
2053 {
2054 #if PRINTJVM || 1
2055         log_println("JVM_GetSockName: fd=%d, him=%p, len=%p", fd, him, len);
2056 #endif
2057         return getsockname(fd, him, (socklen_t *) len);
2058 }
2059
2060
2061 /* JVM_SendTo */
2062
2063 jint JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)
2064 {
2065         log_println("JVM_SendTo: IMPLEMENT ME!");
2066 }
2067
2068
2069 /* JVM_SocketAvailable */
2070
2071 jint JVM_SocketAvailable(jint fd, jint *pbytes)
2072 {
2073         log_println("JVM_SocketAvailable: IMPLEMENT ME!");
2074 }
2075
2076
2077 /* JVM_GetSockOpt */
2078
2079 jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)
2080 {
2081         log_println("JVM_GetSockOpt: IMPLEMENT ME!");
2082 }
2083
2084
2085 /* JVM_SetSockOpt */
2086
2087 jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)
2088 {
2089 #if PRINTJVM || 1
2090         log_println("JVM_SetSockOpt: fd=%d, level=%d, optname=%d, optval=%s, optlen=%d", fd, level, optname, optval, optlen);
2091 #endif
2092         return setsockopt(fd, level, optname, optval, optlen);
2093 }
2094
2095
2096 /* JVM_GetHostName */
2097
2098 int JVM_GetHostName(char* name, int namelen)
2099 {
2100 #if PRINTJVM || 1
2101         log_println("JVM_GetHostName: name=%s, namelen=%d", name, namelen);
2102 #endif
2103         return gethostname(name, namelen);
2104 }
2105
2106
2107 /* JVM_GetHostByAddr */
2108
2109 struct hostent* JVM_GetHostByAddr(const char* name, int len, int type)
2110 {
2111         log_println("JVM_GetHostByAddr: IMPLEMENT ME!");
2112 }
2113
2114
2115 /* JVM_GetHostByName */
2116
2117 struct hostent* JVM_GetHostByName(char* name)
2118 {
2119         log_println("JVM_GetHostByName: IMPLEMENT ME!");
2120 }
2121
2122
2123 /* JVM_GetProtoByName */
2124
2125 struct protoent* JVM_GetProtoByName(char* name)
2126 {
2127         log_println("JVM_GetProtoByName: IMPLEMENT ME!");
2128 }
2129
2130
2131 /* JVM_LoadLibrary */
2132
2133 void* JVM_LoadLibrary(const char* name)
2134 {
2135 #if PRINTJVM
2136         log_println("JVM_LoadLibrary: name=%s", name);
2137 #endif
2138     return native_library_open(utf_new_char(name));
2139 }
2140
2141
2142 /* JVM_UnloadLibrary */
2143
2144 void JVM_UnloadLibrary(void* handle)
2145 {
2146         log_println("JVM_UnloadLibrary: IMPLEMENT ME!");
2147 }
2148
2149
2150 /* JVM_FindLibraryEntry */
2151
2152 void* JVM_FindLibraryEntry(void* handle, const char* name)
2153 {
2154         lt_ptr symbol;
2155
2156 #if PRINTJVM
2157         log_println("JVM_FindLibraryEntry: handle=%p, name=%s", handle, name);
2158 #endif
2159
2160         symbol = lt_dlsym(handle, name);
2161
2162         return symbol;
2163 }
2164
2165
2166 /* JVM_IsNaN */
2167
2168 jboolean JVM_IsNaN(jdouble a)
2169 {
2170         log_println("JVM_IsNaN: IMPLEMENT ME!");
2171 }
2172
2173
2174 /* JVM_IsSupportedJNIVersion */
2175
2176 jboolean JVM_IsSupportedJNIVersion(jint version)
2177 {
2178 #if PRINTJVM
2179         log_println("JVM_IsSupportedJNIVersion: version=%d", version);
2180 #endif
2181         switch (version) {
2182         case JNI_VERSION_1_1:
2183         case JNI_VERSION_1_2:
2184         case JNI_VERSION_1_4:
2185                 return true;
2186         default:
2187                 return false;
2188         }
2189 }
2190
2191
2192 /* JVM_InternString */
2193
2194 jstring JVM_InternString(JNIEnv *env, jstring str)
2195 {
2196 #if PRINTJVM
2197         log_println("JVM_InternString: str=%p", str);
2198 #endif
2199         return (jstring) _Jv_java_lang_String_intern((java_lang_String *) str);
2200 }
2201
2202
2203 /* JVM_RawMonitorCreate */
2204
2205 JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void)
2206 {
2207         java_objectheader *o;
2208
2209 #if PRINTJVM
2210         log_println("JVM_RawMonitorCreate");
2211 #endif
2212
2213         o = NEW(java_objectheader);
2214
2215         lock_init_object_lock(o);
2216
2217         return o;
2218 }
2219
2220
2221 /* JVM_RawMonitorDestroy */
2222
2223 JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon)
2224 {
2225 #if PRINTJVM
2226         log_println("JVM_RawMonitorDestroy: mon=%p", mon);
2227 #endif
2228         FREE(mon, java_objectheader);
2229 }
2230
2231
2232 /* JVM_RawMonitorEnter */
2233
2234 JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon)
2235 {
2236 #if PRINTJVM
2237         log_println("JVM_RawMonitorEnter: mon=%p", mon);
2238 #endif
2239         (void) lock_monitor_enter((java_objectheader *) mon);
2240
2241         return 0;
2242 }
2243
2244
2245 /* JVM_RawMonitorExit */
2246
2247 JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon)
2248 {
2249 #if PRINTJVM
2250         log_println("JVM_RawMonitorExit: mon=%p", mon);
2251 #endif
2252         (void) lock_monitor_exit((java_objectheader *) mon);
2253 }
2254
2255
2256 /* JVM_SetPrimitiveFieldValues */
2257
2258 void JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
2259 {
2260         log_println("JVM_SetPrimitiveFieldValues: IMPLEMENT ME!");
2261 }
2262
2263
2264 /* JVM_GetPrimitiveFieldValues */
2265
2266 void JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data)
2267 {
2268         log_println("JVM_GetPrimitiveFieldValues: IMPLEMENT ME!");
2269 }
2270
2271
2272 /* JVM_AccessVMBooleanFlag */
2273
2274 jboolean JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)
2275 {
2276         log_println("JVM_AccessVMBooleanFlag: IMPLEMENT ME!");
2277 }
2278
2279
2280 /* JVM_AccessVMIntFlag */
2281
2282 jboolean JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)
2283 {
2284         log_println("JVM_AccessVMIntFlag: IMPLEMENT ME!");
2285 }
2286
2287
2288 /* JVM_VMBreakPoint */
2289
2290 void JVM_VMBreakPoint(JNIEnv *env, jobject obj)
2291 {
2292         log_println("JVM_VMBreakPoint: IMPLEMENT ME!");
2293 }
2294
2295
2296 /* JVM_GetClassFields */
2297
2298 jobjectArray JVM_GetClassFields(JNIEnv *env, jclass cls, jint which)
2299 {
2300         log_println("JVM_GetClassFields: IMPLEMENT ME!");
2301 }
2302
2303
2304 /* JVM_GetClassMethods */
2305
2306 jobjectArray JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which)
2307 {
2308         log_println("JVM_GetClassMethods: IMPLEMENT ME!");
2309 }
2310
2311
2312 /* JVM_GetClassConstructors */
2313
2314 jobjectArray JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which)
2315 {
2316         log_println("JVM_GetClassConstructors: IMPLEMENT ME!");
2317 }
2318
2319
2320 /* JVM_GetClassField */
2321
2322 jobject JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which)
2323 {
2324         log_println("JVM_GetClassField: IMPLEMENT ME!");
2325 }
2326
2327
2328 /* JVM_GetClassMethod */
2329
2330 jobject JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which)
2331 {
2332         log_println("JVM_GetClassMethod: IMPLEMENT ME!");
2333 }
2334
2335
2336 /* JVM_GetClassConstructor */
2337
2338 jobject JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which)
2339 {
2340         log_println("JVM_GetClassConstructor: IMPLEMENT ME!");
2341 }
2342
2343
2344 /* JVM_NewInstance */
2345
2346 jobject JVM_NewInstance(JNIEnv *env, jclass cls)
2347 {
2348         log_println("JVM_NewInstance: IMPLEMENT ME!");
2349 }
2350
2351
2352 /* JVM_GetField */
2353
2354 jobject JVM_GetField(JNIEnv *env, jobject field, jobject obj)
2355 {
2356         log_println("JVM_GetField: IMPLEMENT ME!");
2357 }
2358
2359
2360 /* JVM_GetPrimitiveField */
2361
2362 jvalue JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode)
2363 {
2364         log_println("JVM_GetPrimitiveField: IMPLEMENT ME!");
2365 }
2366
2367
2368 /* JVM_SetField */
2369
2370 void JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val)
2371 {
2372         log_println("JVM_SetField: IMPLEMENT ME!");
2373 }
2374
2375
2376 /* JVM_SetPrimitiveField */
2377
2378 void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode)
2379 {
2380         log_println("JVM_SetPrimitiveField: IMPLEMENT ME!");
2381 }
2382
2383
2384 /* JVM_InvokeMethod */
2385
2386 jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
2387 {
2388 #if PRINTJVM
2389         log_println("JVM_InvokeMethod: method=%p, obj=%p, args0=%p", method, obj, args0);
2390 #endif
2391         return (jobject) _Jv_java_lang_reflect_Method_invoke((java_lang_reflect_Method *) method, (java_lang_Object *) obj, (java_objectarray *) args0);
2392 }
2393
2394
2395 /* JVM_NewInstanceFromConstructor */
2396
2397 jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0)
2398 {
2399 #if PRINTJVM
2400         log_println("JVM_NewInstanceFromConstructor: c=%p, args0=%p", c, args0);
2401 #endif
2402         return (jobject) _Jv_java_lang_reflect_Constructor_newInstance(env, (java_lang_reflect_Constructor *) c, (java_objectarray *) args0);
2403 }
2404
2405
2406 /* JVM_SupportsCX8 */
2407
2408 jboolean JVM_SupportsCX8()
2409 {
2410 #if PRINTJVM
2411         log_println("JVM_SupportsCX8");
2412 #endif
2413         return _Jv_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(NULL, NULL);
2414 }
2415
2416
2417 /* JVM_CX8Field */
2418
2419 jboolean JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal)
2420 {
2421         log_println("JVM_CX8Field: IMPLEMENT ME!");
2422 }
2423
2424
2425 /* JVM_GetAllThreads */
2426
2427 jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy)
2428 {
2429         log_println("JVM_GetAllThreads: IMPLEMENT ME!");
2430 }
2431
2432
2433 /* JVM_DumpThreads */
2434
2435 jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads)
2436 {
2437         log_println("JVM_DumpThreads: IMPLEMENT ME!");
2438 }
2439
2440
2441 /* JVM_GetManagement */
2442
2443 void* JVM_GetManagement(jint version)
2444 {
2445         log_println("JVM_GetManagement: IMPLEMENT ME!");
2446 }
2447
2448
2449 /* JVM_InitAgentProperties */
2450
2451 jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties)
2452 {
2453         log_println("JVM_InitAgentProperties: IMPLEMENT ME!");
2454 }
2455
2456
2457 /* JVM_GetEnclosingMethodInfo */
2458
2459 jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)
2460 {
2461         log_println("JVM_GetEnclosingMethodInfo: IMPLEMENT ME!");
2462 }
2463
2464
2465 /* JVM_GetThreadStateValues */
2466
2467 jintArray JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState)
2468 {
2469         log_println("JVM_GetThreadStateValues: IMPLEMENT ME!");
2470 }
2471
2472
2473 /* JVM_GetThreadStateValues */
2474
2475 jobjectArray JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values)
2476 {
2477         log_println("JVM_GetThreadStateValues: IMPLEMENT ME!");
2478 }
2479
2480
2481 /* JVM_GetVersionInfo */
2482
2483 void JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)
2484 {
2485         log_println("JVM_GetVersionInfo: IMPLEMENT ME!");
2486 }
2487
2488
2489 /* OS: JVM_RegisterSignal */
2490
2491 void* JVM_RegisterSignal(jint sig, void* handler)
2492 {
2493         log_println("JVM_RegisterSignal: sig=%d, handler=%p, IMPLEMENT ME!", sig, handler);
2494         return NULL;
2495 }
2496
2497
2498 /* OS: JVM_FindSignal */
2499
2500 jint JVM_FindSignal(const char *name)
2501 {
2502         log_println("JVM_FindSignal: name=%s", name);
2503         return 0;
2504 }
2505
2506
2507 /*
2508  * These are local overrides for various environment variables in Emacs.
2509  * Please do not remove this and leave it at the end of the file, where
2510  * Emacs will automagically detect them.
2511  * ---------------------------------------------------------------------
2512  * Local variables:
2513  * mode: c
2514  * indent-tabs-mode: t
2515  * c-basic-offset: 4
2516  * tab-width: 4
2517  * End:
2518  */