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