1 /* src/vm/javaobjects.hpp - functions to create and access Java objects
3 Copyright (C) 2008 Theobroma Systems Ltd.
5 This file is part of CACAO.
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #ifndef _JAVAOBJECTS_HPP
26 #define _JAVAOBJECTS_HPP
32 #include "mm/memory.h"
34 #include "native/llni.h"
37 #include "vm/field.hpp"
38 #include "vm/global.h"
39 #include "vm/globals.hpp"
40 #include "vm/method.h"
46 * This class provides low-level functions to access Java object
49 * These functions do NOT take care about the GC critical section!
50 * Please use FieldAccess wherever possible.
52 class RawFieldAccess {
54 template<class T> static inline T raw_get(void* address, const off_t offset);
55 template<class T> static inline void raw_set(void* address, const off_t offset, T value);
59 template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
61 T* p = (T*) (((uintptr_t) address) + offset);
66 template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
68 T* p = (T*) (((uintptr_t) address) + offset);
74 * This classes provides functions to access Java object instance
75 * fields. These functions enter a critical GC section before
76 * accessing the Java object throught the handle and leave it
79 class FieldAccess : private RawFieldAccess {
81 template<class T> static inline T get(java_handle_t* h, const off_t offset);
82 template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
85 template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
92 // XXX This should be _handle->get_object();
95 result = raw_get<T>(o, offset);
102 template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
105 java_object_t* result;
106 java_handle_t* hresult;
108 GC::critical_enter();
110 // XXX This should be _handle->get_object();
113 result = raw_get<java_object_t*>(o, offset);
115 hresult = LLNI_WRAP(result);
117 GC::critical_leave();
123 template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
127 GC::critical_enter();
129 // XXX This should be h->get_object();
132 raw_set(o, offset, value);
134 GC::critical_leave();
137 template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
140 java_object_t* ovalue;
142 GC::critical_enter();
144 // XXX This should be h->get_object();
146 ovalue = LLNI_UNWRAP(value);
148 raw_set(o, offset, ovalue);
150 GC::critical_leave();
161 class java_lang_Object {
163 // Handle of Java object.
164 java_handle_t* _handle;
167 java_lang_Object() : _handle(NULL) {}
168 java_lang_Object(java_handle_t* h) : _handle(h) {}
169 virtual ~java_lang_Object() {}
172 virtual inline java_handle_t* get_handle () const { return _handle; }
173 inline vftbl_t* get_vftbl () const;
174 inline classinfo* get_Class () const;
175 inline int32_t get_hashcode() const;
177 inline bool is_null () const;
178 inline bool is_non_null() const;
182 inline vftbl_t* java_lang_Object::get_vftbl() const
184 GC::critical_enter();
186 // XXX This should be h->get_object();
187 java_object_t* o = LLNI_UNWRAP(_handle);
188 vftbl_t* vftbl = o->vftbl;
190 GC::critical_leave();
195 inline classinfo* java_lang_Object::get_Class() const
197 return get_vftbl()->clazz;
200 inline int32_t java_lang_Object::get_hashcode() const
202 #if defined(ENABLE_GC_CACAO)
203 return heap_get_hashcode(_handle);
208 GC::critical_enter();
210 // XXX This should be h->get_object();
211 o = LLNI_UNWRAP(_handle);
213 hashcode = (int32_t)(intptr_t) o;
215 GC::critical_leave();
222 inline bool java_lang_Object::is_null() const
224 return (_handle == NULL);
227 inline bool java_lang_Object::is_non_null() const
229 return (_handle != NULL);
241 class java_lang_Boolean : public java_lang_Object, private FieldAccess {
243 // Static offsets of the object's instance fields.
244 // TODO These offsets need to be checked on VM startup.
245 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
248 java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {}
250 inline uint8_t get_value();
251 inline void set_value(uint8_t value);
254 inline uint8_t java_lang_Boolean::get_value()
256 return get<int32_t>(_handle, offset_value);
259 inline void java_lang_Boolean::set_value(uint8_t value)
261 set(_handle, offset_value, (uint32_t) value);
273 class java_lang_Byte : public java_lang_Object, private FieldAccess {
275 // Static offsets of the object's instance fields.
276 // TODO These offsets need to be checked on VM startup.
277 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
280 java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {}
282 inline int8_t get_value();
283 inline void set_value(int8_t value);
286 inline int8_t java_lang_Byte::get_value()
288 return get<int32_t>(_handle, offset_value);
291 inline void java_lang_Byte::set_value(int8_t value)
293 set(_handle, offset_value, (int32_t) value);
298 * java/lang/Character
305 class java_lang_Character : public java_lang_Object, private FieldAccess {
307 // Static offsets of the object's instance fields.
308 // TODO These offsets need to be checked on VM startup.
309 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
312 java_lang_Character(java_handle_t* h) : java_lang_Object(h) {}
314 inline uint16_t get_value();
315 inline void set_value(uint16_t value);
318 inline uint16_t java_lang_Character::get_value()
320 return get<int32_t>(_handle, offset_value);
323 inline void java_lang_Character::set_value(uint16_t value)
325 set(_handle, offset_value, (uint32_t) value);
337 class java_lang_Short : public java_lang_Object, private FieldAccess {
339 // Static offsets of the object's instance fields.
340 // TODO These offsets need to be checked on VM startup.
341 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
344 java_lang_Short(java_handle_t* h) : java_lang_Object(h) {}
346 inline int16_t get_value();
347 inline void set_value(int16_t value);
350 inline int16_t java_lang_Short::get_value()
352 return get<int32_t>(_handle, offset_value);
355 inline void java_lang_Short::set_value(int16_t value)
357 set(_handle, offset_value, (int32_t) value);
369 class java_lang_Integer : public java_lang_Object, private FieldAccess {
371 // Static offsets of the object's instance fields.
372 // TODO These offsets need to be checked on VM startup.
373 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
376 java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
378 inline int32_t get_value();
379 inline void set_value(int32_t value);
382 inline int32_t java_lang_Integer::get_value()
384 return get<int32_t>(_handle, offset_value);
387 inline void java_lang_Integer::set_value(int32_t value)
389 set(_handle, offset_value, value);
401 class java_lang_Long : public java_lang_Object, private FieldAccess {
403 // Static offsets of the object's instance fields.
404 // TODO These offsets need to be checked on VM startup.
405 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
408 java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
410 inline int64_t get_value();
411 inline void set_value(int64_t value);
414 inline int64_t java_lang_Long::get_value()
416 return get<int64_t>(_handle, offset_value);
419 inline void java_lang_Long::set_value(int64_t value)
421 set(_handle, offset_value, value);
433 class java_lang_Float : public java_lang_Object, private FieldAccess {
435 // Static offsets of the object's instance fields.
436 // TODO These offsets need to be checked on VM startup.
437 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
440 java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
442 inline float get_value();
443 inline void set_value(float value);
446 inline float java_lang_Float::get_value()
448 return get<float>(_handle, offset_value);
451 inline void java_lang_Float::set_value(float value)
453 set(_handle, offset_value, value);
465 class java_lang_Double : public java_lang_Object, private FieldAccess {
467 // Static offsets of the object's instance fields.
468 // TODO These offsets need to be checked on VM startup.
469 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
472 java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
474 inline double get_value();
475 inline void set_value(double value);
478 inline double java_lang_Double::get_value()
480 return get<double>(_handle, offset_value);
483 inline void java_lang_Double::set_value(double value)
485 set(_handle, offset_value, value);
489 #if defined(ENABLE_JAVASE)
491 # if defined(ENABLE_ANNOTATIONS)
493 * OpenJDK sun/reflect/ConstantPool
498 * 1. java.lang.Object constantPoolOop;
500 class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
502 // Static offsets of the object's instance fields.
503 // TODO These offsets need to be checked on VM startup.
504 static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
507 sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
508 sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
511 inline void set_constantPoolOop(classinfo* value);
512 inline void set_constantPoolOop(jclass value);
516 inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
518 set_constantPoolOop(constantPoolOop);
522 inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
524 set(_handle, offset_constantPoolOop, value);
527 inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
529 // XXX jclass is a boxed object.
530 set_constantPoolOop(LLNI_classinfo_unwrap(value));
532 # endif // ENABLE_ANNOTATIONS
534 #endif // ENABLE_JAVASE
537 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
540 * GNU Classpath java/lang/Class
545 * 1. java.lang.Object[] signers;
546 * 2. java.security.ProtectionDomain pd;
547 * 3. java.lang.Object vmdata;
548 * 4. java.lang.reflect.Constructor constructor;
550 class java_lang_Class : public java_lang_Object, private FieldAccess {
552 // Static offsets of the object's instance fields.
553 // TODO These offsets need to be checked on VM startup.
554 static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
555 static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
556 static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
557 static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
560 java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
563 inline void set_pd(java_handle_t* value);
566 inline void java_lang_Class::set_pd(java_handle_t* value)
568 set(_handle, offset_pd, value);
573 * GNU Classpath java/lang/StackTraceElement
578 * 1. java.lang.String fileName;
580 * 3. java.lang.String declaringClass;
581 * 4. java.lang.String methodName;
582 * 5. boolean isNative;
584 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
586 // Static offsets of the object's instance fields.
587 // TODO These offsets need to be checked on VM startup.
588 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
589 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
590 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
591 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
592 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
595 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
596 java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative);
599 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative) : java_lang_Object(h)
601 java_lang_StackTraceElement((java_handle_t*) h);
603 set(_handle, offset_fileName, fileName);
604 set(_handle, offset_lineNumber, lineNumber);
605 set(_handle, offset_declaringClass, declaringClass);
606 set(_handle, offset_methodName, methodName);
607 set(_handle, offset_isNative, isNative);
612 * GNU Classpath java/lang/String
619 * 3. int cachedHashCode;
622 class java_lang_String : public java_lang_Object, private FieldAccess {
624 // Static offsets of the object's instance fields.
625 // TODO These offsets need to be checked on VM startup.
626 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
627 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
628 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
629 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
632 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
633 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
636 inline java_handle_chararray_t* get_value () const;
637 inline int32_t get_count () const;
638 inline int32_t get_offset() const;
641 inline void set_value (java_handle_chararray_t* value);
642 inline void set_count (int32_t value);
643 inline void set_offset(int32_t value);
646 inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
653 inline java_handle_chararray_t* java_lang_String::get_value() const
655 return get<java_handle_chararray_t*>(_handle, offset_value);
658 inline int32_t java_lang_String::get_count() const
660 return get<int32_t>(_handle, offset_count);
663 inline int32_t java_lang_String::get_offset() const
665 return get<int32_t>(_handle, offset_offset);
668 inline void java_lang_String::set_value(java_handle_chararray_t* value)
670 set(_handle, offset_value, value);
673 inline void java_lang_String::set_count(int32_t value)
675 set(_handle, offset_count, value);
678 inline void java_lang_String::set_offset(int32_t value)
680 set(_handle, offset_offset, value);
685 * GNU Classpath java/lang/Thread
690 * 1. java.lang.VMThread vmThread;
691 * 2. java.lang.ThreadGroup group;
692 * 3. java.lang.Runnable runnable;
693 * 4. java.lang.String name;
697 * 8. java.lang.Throwable stillborn;
698 * 9. java.lang.ClassLoader contextClassLoader;
699 * 10. boolean contextClassLoaderIsSystemClassLoader;
701 * 12. java.lang.Object parkBlocker;
702 * 13. gnu.java.util.WeakIdentityHashMap locals;
703 * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
705 class java_lang_Thread : public java_lang_Object, private FieldAccess {
707 // Static offsets of the object's instance fields.
708 // TODO These offsets need to be checked on VM startup.
709 static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
710 static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
711 static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
712 static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
713 static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
714 static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
715 static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
716 static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
717 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
718 static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
719 static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
720 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
721 static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
722 static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
725 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
726 // java_lang_Thread(threadobject* t);
729 inline java_handle_t* get_vmThread () const;
730 inline java_handle_t* get_group () const;
731 inline java_handle_t* get_name () const;
732 inline int32_t get_daemon () const;
733 inline int32_t get_priority () const;
734 inline java_handle_t* get_exceptionHandler() const;
737 inline void set_group(java_handle_t* value);
741 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
743 // java_lang_Thread(thread_get_object(t));
747 inline java_handle_t* java_lang_Thread::get_vmThread() const
749 return get<java_handle_t*>(_handle, offset_vmThread);
752 inline java_handle_t* java_lang_Thread::get_group() const
754 return get<java_handle_t*>(_handle, offset_group);
757 inline java_handle_t* java_lang_Thread::get_name() const
759 return get<java_handle_t*>(_handle, offset_name);
762 inline int32_t java_lang_Thread::get_daemon() const
764 return get<int32_t>(_handle, offset_daemon);
767 inline int32_t java_lang_Thread::get_priority() const
769 return get<int32_t>(_handle, offset_priority);
772 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
774 return get<java_handle_t*>(_handle, offset_exceptionHandler);
778 inline void java_lang_Thread::set_group(java_handle_t* value)
780 set(_handle, offset_group, value);
785 * GNU Classpath java/lang/VMThread
790 * 1. java.lang.Thread thread;
791 * 2. boolean running;
792 * 3. java.lang.VMThread vmdata;
794 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
796 // Static offsets of the object's instance fields.
797 // TODO These offsets need to be checked on VM startup.
798 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
799 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
800 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
803 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
804 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
807 inline java_handle_t* get_thread() const;
808 inline threadobject* get_vmdata() const;
811 inline void set_thread(java_handle_t* value);
812 inline void set_vmdata(threadobject* value);
816 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
823 inline java_handle_t* java_lang_VMThread::get_thread() const
825 return get<java_handle_t*>(_handle, offset_thread);
828 inline threadobject* java_lang_VMThread::get_vmdata() const
830 return get<threadobject*>(_handle, offset_vmdata);
834 inline void java_lang_VMThread::set_thread(java_handle_t* value)
836 set(_handle, offset_thread, value);
839 inline void java_lang_VMThread::set_vmdata(threadobject* value)
841 set(_handle, offset_vmdata, value);
846 * GNU Classpath java/lang/Throwable
851 * 1. java.lang.String detailMessage;
852 * 2. java.lang.Throwable cause;
853 * 3. java.lang.StackTraceElement[] stackTrace;
854 * 4. java.lang.VMThrowable vmState;
856 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
858 // Static offsets of the object's instance fields.
859 // TODO These offsets need to be checked on VM startup.
860 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
861 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
862 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
863 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
866 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
869 inline java_handle_t* get_detailMessage() const;
870 inline java_handle_t* get_cause () const;
871 inline java_handle_t* get_vmState () const;
875 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
877 return get<java_handle_t*>(_handle, offset_detailMessage);
880 inline java_handle_t* java_lang_Throwable::get_cause() const
882 return get<java_handle_t*>(_handle, offset_cause);
885 inline java_handle_t* java_lang_Throwable::get_vmState() const
887 return get<java_handle_t*>(_handle, offset_vmState);
892 * GNU Classpath java/lang/VMThrowable
897 * 1. java.lang.Object vmdata;
899 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
901 // Static offsets of the object's instance fields.
902 // TODO These offsets need to be checked on VM startup.
903 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
906 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
908 inline java_handle_bytearray_t* get_vmdata() const;
909 inline void set_vmdata(java_handle_bytearray_t* value);
913 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
915 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
918 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
920 set(_handle, offset_vmdata, value);
925 * GNU Classpath java/lang/reflect/VMConstructor
930 * 1. java.lang.Class clazz;
932 * 3. byte[] annotations;
933 * 4. byte[] parameterAnnotations;
934 * 5. java.util.Map declaredAnnotations;
935 * 6. java.lang.reflect.Constructor cons;
937 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
939 // Static offsets of the object's instance fields.
940 // TODO These offsets need to be checked on VM startup.
941 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
942 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
943 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
944 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
945 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
946 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
949 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
950 java_lang_reflect_VMConstructor(methodinfo* m);
953 inline classinfo* get_clazz () const;
954 inline int32_t get_slot () const;
955 inline java_handle_bytearray_t* get_annotations () const;
956 inline java_handle_bytearray_t* get_parameterAnnotations() const;
957 inline java_handle_t* get_declaredAnnotations () const;
958 inline java_handle_t* get_cons () const;
961 inline void set_clazz (classinfo* value);
962 inline void set_slot (int32_t value);
963 inline void set_annotations (java_handle_bytearray_t* value);
964 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
965 inline void set_declaredAnnotations (java_handle_t* value);
966 inline void set_cons (java_handle_t* value);
968 // Convenience functions.
969 inline methodinfo* get_method();
973 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
975 _handle = builtin_new(class_java_lang_reflect_VMConstructor);
980 int slot = m - m->clazz->methods;
981 java_handle_bytearray_t* annotations = method_get_annotations(m);
982 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
986 set_annotations(annotations);
987 set_parameterAnnotations(parameterAnnotations);
991 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
993 return get<classinfo*>(_handle, offset_clazz);
996 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
998 return get<int32_t>(_handle, offset_slot);
1001 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1003 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1006 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1008 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1011 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1013 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1016 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1018 return get<java_handle_t*>(_handle, offset_cons);
1021 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1023 set(_handle, offset_clazz, value);
1026 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1028 set(_handle, offset_slot, value);
1031 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1033 set(_handle, offset_annotations, value);
1036 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1038 set(_handle, offset_parameterAnnotations, value);
1041 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1043 set(_handle, offset_declaredAnnotations, value);
1046 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1048 set(_handle, offset_cons, value);
1051 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1053 classinfo* c = get_clazz();
1054 int32_t slot = get_slot();
1055 methodinfo* m = &(c->methods[slot]);
1061 * GNU Classpath java/lang/reflect/Constructor
1067 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1068 * 3. java.lang.reflect.VMConstructor cons;
1070 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
1072 // Static offsets of the object's instance fields.
1073 // TODO These offsets need to be checked on VM startup.
1074 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1075 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1076 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1079 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
1080 java_lang_reflect_Constructor(methodinfo* m);
1082 java_handle_t* new_instance(java_handle_objectarray_t* args);
1085 inline int32_t get_flag() const;
1086 inline java_handle_t* get_cons() const;
1089 inline void set_cons(java_handle_t* value);
1091 // Convenience functions.
1092 inline methodinfo* get_method () const;
1093 inline int32_t get_override() const;
1097 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
1099 java_lang_reflect_VMConstructor jlrvmc(m);
1101 if (jlrvmc.is_null())
1104 _handle = builtin_new(class_java_lang_reflect_Constructor);
1109 // Link the two Java objects.
1110 set_cons(jlrvmc.get_handle());
1111 jlrvmc.set_cons(get_handle());
1115 inline int32_t java_lang_reflect_Constructor::get_flag() const
1117 return get<int32_t>(_handle, offset_flag);
1120 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
1122 return get<java_handle_t*>(_handle, offset_cons);
1126 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
1128 set(_handle, offset_cons, value);
1132 inline methodinfo* java_lang_reflect_Constructor::get_method() const
1134 java_lang_reflect_VMConstructor jlrvmc(get_cons());
1135 return jlrvmc.get_method();
1138 inline int32_t java_lang_reflect_Constructor::get_override() const
1145 * GNU Classpath java/lang/reflect/VMField
1150 * 1. java.lang.Class clazz;
1151 * 2. java.lang.String name;
1153 * 4. byte[] annotations;
1154 * 5. java.lang.Map declaredAnnotations;
1155 * 6. java.lang.reflect.Field f;
1157 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1159 // Static offsets of the object's instance fields.
1160 // TODO These offsets need to be checked on VM startup.
1161 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1162 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1163 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1164 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1165 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1166 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1169 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1170 java_lang_reflect_VMField(fieldinfo* f);
1173 inline classinfo* get_clazz () const;
1174 inline int32_t get_slot () const;
1175 inline java_handle_bytearray_t* get_annotations () const;
1176 inline java_handle_t* get_declaredAnnotations() const;
1177 inline java_handle_t* get_f () const;
1180 inline void set_clazz (classinfo* value);
1181 inline void set_name (java_handle_t* value);
1182 inline void set_slot (int32_t value);
1183 inline void set_annotations (java_handle_bytearray_t* value);
1184 inline void set_declaredAnnotations(java_handle_t* value);
1185 inline void set_f (java_handle_t* value);
1187 // Convenience functions.
1188 inline fieldinfo* get_field() const;
1192 inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
1194 _handle = builtin_new(class_java_lang_reflect_VMField);
1199 java_handle_t* name = javastring_intern(javastring_new(f->name));
1200 int slot = f - f->clazz->fields;
1201 java_handle_bytearray_t* annotations = field_get_annotations(f);
1203 set_clazz(f->clazz);
1206 set_annotations(annotations);
1210 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1212 return get<classinfo*>(_handle, offset_clazz);
1215 inline int32_t java_lang_reflect_VMField::get_slot() const
1217 return get<int32_t>(_handle, offset_slot);
1220 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1222 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1225 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1227 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1230 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1232 return get<java_handle_t*>(_handle, offset_f);
1236 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1238 set(_handle, offset_clazz, value);
1241 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1243 set(_handle, offset_name, value);
1246 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1248 set(_handle, offset_slot, value);
1251 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1253 set(_handle, offset_annotations, value);
1256 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1258 set(_handle, offset_declaredAnnotations, value);
1261 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1263 set(_handle, offset_f, value);
1266 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1268 classinfo* c = get_clazz();
1269 int32_t slot = get_slot();
1270 fieldinfo* f = &(c->fields[slot]);
1276 * GNU Classpath java/lang/reflect/Field
1282 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1283 * 3. java.lang.reflect.VMField f;
1285 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1287 // Static offsets of the object's instance fields.
1288 // TODO These offsets need to be checked on VM startup.
1289 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1290 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1291 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1294 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1295 java_lang_reflect_Field(fieldinfo* f);
1298 inline int32_t get_flag() const;
1299 inline java_handle_t* get_f() const;
1302 inline void set_f(java_handle_t* value);
1304 // Convenience functions.
1305 inline fieldinfo* get_field() const;
1309 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
1311 java_lang_reflect_VMField jlrvmf(f);
1313 if (jlrvmf.is_null())
1316 _handle = builtin_new(class_java_lang_reflect_Field);
1321 // Link the two Java objects.
1322 set_f(jlrvmf.get_handle());
1323 jlrvmf.set_f(get_handle());
1327 inline int32_t java_lang_reflect_Field::get_flag() const
1329 return get<int32_t>(_handle, offset_flag);
1332 inline java_handle_t* java_lang_reflect_Field::get_f() const
1334 return get<java_handle_t*>(_handle, offset_f);
1338 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1340 set(_handle, offset_f, value);
1344 inline fieldinfo* java_lang_reflect_Field::get_field() const
1346 java_lang_reflect_VMField jlrvmf(get_f());
1347 return jlrvmf.get_field();
1352 * GNU Classpath java/lang/reflect/VMMethod
1357 * 1. java.lang.Class clazz;
1358 * 2. java.lang.String name;
1360 * 4. byte[] annotations;
1361 * 5. byte[] parameterAnnotations;
1362 * 6. byte[] annotationDefault;
1363 * 7. java.lang.Map declaredAnnotations;
1364 * 8. java.lang.reflect.Method m;
1366 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1368 // Static offsets of the object's instance fields.
1369 // TODO These offsets need to be checked on VM startup.
1370 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1371 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1372 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1373 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1374 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1375 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1376 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1377 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1380 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1381 java_lang_reflect_VMMethod(methodinfo* m);
1384 inline classinfo* get_clazz () const;
1385 inline int32_t get_slot () const;
1386 inline java_handle_bytearray_t* get_annotations () const;
1387 inline java_handle_bytearray_t* get_parameterAnnotations() const;
1388 inline java_handle_bytearray_t* get_annotationDefault () const;
1389 inline java_handle_t* get_declaredAnnotations () const;
1390 inline java_handle_t* get_m () const;
1393 inline void set_clazz (classinfo* value);
1394 inline void set_name (java_handle_t* value);
1395 inline void set_slot (int32_t value);
1396 inline void set_annotations (java_handle_bytearray_t* value);
1397 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
1398 inline void set_annotationDefault (java_handle_bytearray_t* value);
1399 inline void set_declaredAnnotations (java_handle_t* value);
1400 inline void set_m (java_handle_t* value);
1402 // Convenience functions.
1403 inline methodinfo* get_method() const;
1407 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
1409 _handle = builtin_new(class_java_lang_reflect_VMMethod);
1414 java_handle_t* name = javastring_intern(javastring_new(m->name));
1415 int slot = m - m->clazz->methods;
1416 java_handle_bytearray_t* annotations = method_get_annotations(m);
1417 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1418 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1420 set_clazz(m->clazz);
1423 set_annotations(annotations);
1424 set_parameterAnnotations(parameterAnnotations);
1425 set_annotationDefault(annotationDefault);
1428 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1430 return get<classinfo*>(_handle, offset_clazz);
1433 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1435 return get<int32_t>(_handle, offset_slot);
1438 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1440 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1443 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1445 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1448 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1450 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1453 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1455 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1458 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1460 return get<java_handle_t*>(_handle, offset_m);
1463 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1465 set(_handle, offset_clazz, value);
1468 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1470 set(_handle, offset_name, value);
1473 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1475 set(_handle, offset_slot, value);
1478 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1480 set(_handle, offset_annotations, value);
1483 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1485 set(_handle, offset_parameterAnnotations, value);
1488 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1490 set(_handle, offset_annotationDefault, value);
1493 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1495 set(_handle, offset_declaredAnnotations, value);
1498 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1500 set(_handle, offset_m, value);
1503 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1505 classinfo* c = get_clazz();
1506 int32_t slot = get_slot();
1507 methodinfo* m = &(c->methods[slot]);
1513 * GNU Classpath java/lang/reflect/Method
1519 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1520 * 3. java.lang.reflect.VMMethod m;
1522 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1524 // Static offsets of the object's instance fields.
1525 // TODO These offsets need to be checked on VM startup.
1526 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1527 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1528 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1531 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1532 java_lang_reflect_Method(methodinfo* m);
1534 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
1537 inline int32_t get_flag() const;
1538 inline java_handle_t* get_m() const;
1541 inline void set_m(java_handle_t* value);
1543 // Convenience functions.
1544 inline methodinfo* get_method () const;
1545 inline int32_t get_override() const;
1549 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
1551 java_lang_reflect_VMMethod jlrvmm(m);
1553 if (jlrvmm.is_null())
1556 _handle = builtin_new(class_java_lang_reflect_Method);
1561 // Link the two Java objects.
1562 set_m(jlrvmm.get_handle());
1563 jlrvmm.set_m(get_handle());
1567 inline int32_t java_lang_reflect_Method::get_flag() const
1569 return get<int32_t>(_handle, offset_flag);
1572 inline java_handle_t* java_lang_reflect_Method::get_m() const
1574 return get<java_handle_t*>(_handle, offset_m);
1578 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1580 set(_handle, offset_m, value);
1584 inline methodinfo* java_lang_reflect_Method::get_method() const
1586 java_lang_reflect_VMMethod jlrvmm(get_m());
1587 return jlrvmm.get_method();
1590 inline int32_t java_lang_reflect_Method::get_override() const
1597 * GNU Classpath java/nio/Buffer
1606 * 5. gnu.classpath.Pointer address;
1608 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1610 // Static offsets of the object's instance fields.
1611 // TODO These offsets need to be checked on VM startup.
1612 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1613 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1614 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1615 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1616 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1619 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1622 inline int32_t get_cap() const;
1625 inline int32_t java_nio_Buffer::get_cap() const
1627 return get<int32_t>(_handle, offset_cap);
1632 * GNU Classpath java/nio/DirectByteBufferImpl
1641 * 5. gnu.classpath.Pointer address;
1642 * 6. java.nio.ByteOrder endian;
1643 * 7. byte[] backing_buffer;
1644 * 8. int array_offset;
1645 * 9. java.lang.Object owner;
1647 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1649 // Static offsets of the object's instance fields.
1650 // TODO These offsets need to be checked on VM startup.
1651 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1652 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1653 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1654 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1655 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1656 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1657 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1658 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1659 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1662 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1665 inline java_handle_t* get_address() const;
1669 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1671 return get<java_handle_t*>(_handle, offset_address);
1676 * GNU Classpath gnu/classpath/Pointer
1678 * Actually there are two classes, gnu.classpath.Pointer32 and
1679 * gnu.classpath.Pointer64, but we only define the abstract super
1680 * class and use the int/long field as void* type.
1687 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1689 // Static offsets of the object's instance fields.
1690 // TODO These offsets need to be checked on VM startup.
1691 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1694 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1695 gnu_classpath_Pointer(java_handle_t* h, void* data);
1698 inline void* get_data() const;
1701 inline void set_data(void* value);
1704 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1709 inline void* gnu_classpath_Pointer::get_data() const
1711 return get<void*>(_handle, offset_data);
1714 inline void gnu_classpath_Pointer::set_data(void* value)
1716 set(_handle, offset_data, value);
1719 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1722 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1725 * OpenJDK java/lang/AssertionStatusDirectives
1730 * 1. java.lang.String[] classes;
1731 * 2. boolean[] classEnabled;
1732 * 3. java.lang.String[] packages;
1733 * 4. boolean[] packageEnabled;
1736 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1738 // Static offsets of the object's instance fields.
1739 // TODO These offsets need to be checked on VM startup.
1740 static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1741 static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1742 static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1743 static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1744 static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1747 java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1750 inline java_lang_AssertionStatusDirectives::java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled)
1752 classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1754 // FIXME Load the class at VM startup.
1758 _handle = builtin_new(c);
1763 set(_handle, offset_classes, classes);
1764 set(_handle, offset_classEnabled, classEnabled);
1765 set(_handle, offset_packages, packages);
1766 set(_handle, offset_packageEnabled, packageEnabled);
1771 * OpenJDK java/lang/StackTraceElement
1776 * 1. java.lang.String declaringClass;
1777 * 2. java.lang.String methodName;
1778 * 3. java.lang.String fileName;
1779 * 4. int lineNumber;
1781 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
1783 // Static offsets of the object's instance fields.
1784 // TODO These offsets need to be checked on VM startup.
1785 static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1786 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1787 static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1788 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1791 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
1792 java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1795 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1797 _handle = builtin_new(class_java_lang_StackTraceElement);
1802 set(_handle, offset_declaringClass, declaringClass);
1803 set(_handle, offset_methodName, methodName);
1804 set(_handle, offset_fileName, fileName);
1805 set(_handle, offset_lineNumber, lineNumber);
1810 * OpenJDK java/lang/String
1820 class java_lang_String : public java_lang_Object, private FieldAccess {
1822 // Static offsets of the object's instance fields.
1823 // TODO These offsets need to be checked on VM startup.
1824 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1825 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1826 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1827 static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
1830 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1831 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1834 inline java_handle_chararray_t* get_value () const;
1835 inline int32_t get_offset() const;
1836 inline int32_t get_count () const;
1839 inline void set_value (java_handle_chararray_t* value);
1840 inline void set_offset(int32_t value);
1841 inline void set_count (int32_t value);
1844 inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
1851 inline java_handle_chararray_t* java_lang_String::get_value() const
1853 return get<java_handle_chararray_t*>(_handle, offset_value);
1856 inline int32_t java_lang_String::get_offset() const
1858 return get<int32_t>(_handle, offset_offset);
1861 inline int32_t java_lang_String::get_count() const
1863 return get<int32_t>(_handle, offset_count);
1866 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1868 set(_handle, offset_value, value);
1871 inline void java_lang_String::set_offset(int32_t value)
1873 set(_handle, offset_offset, value);
1876 inline void java_lang_String::set_count(int32_t value)
1878 set(_handle, offset_count, value);
1883 * OpenJDK java/lang/Thread
1890 * 3. java_lang_Thread threadQ;
1892 * 5. boolean single_step;
1893 * 6. boolean daemon;
1894 * 7. boolean stillborn;
1895 * 8. java_lang_Runnable target;
1896 * 9. java_lang_ThreadGroup group;
1897 * 10. java_lang_ClassLoader contextClassLoader;
1898 * 11. java_security_AccessControlContext inheritedAccessControlContext;
1899 * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals;
1900 * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals;
1901 * 14. long stackSize;
1902 * 15. long nativeParkEventPointer;
1904 * 17. int threadStatus;
1905 * 18. java_lang_Object parkBlocker;
1906 * 19. sun_nio_ch_Interruptible blocker;
1907 * 20. java_lang_Object blockerLock;
1908 * 21. boolean stopBeforeStart;
1909 * 22. java_lang_Throwable throwableFromStop;
1910 * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
1912 class java_lang_Thread : public java_lang_Object, private FieldAccess {
1914 // Static offsets of the object's instance fields.
1915 // TODO These offsets need to be checked on VM startup.
1916 static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1917 static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1918 static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
1919 static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t));
1920 static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t));
1921 static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t));
1922 static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
1923 static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
1924 static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P);
1925 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
1926 static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
1927 static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P);
1928 static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P);
1929 static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t));
1930 static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t));
1931 static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t));
1932 static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t));
1933 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P);
1934 static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
1935 static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
1936 static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t));
1937 static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P);
1938 static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P);
1941 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
1942 // java_lang_Thread(threadobject* t);
1945 inline int32_t get_priority () const;
1946 inline int32_t get_daemon () const;
1947 inline java_handle_t* get_group () const;
1948 inline java_handle_t* get_uncaughtExceptionHandler() const;
1951 inline void set_priority(int32_t value);
1952 inline void set_group (java_handle_t* value);
1956 inline int32_t java_lang_Thread::get_priority() const
1958 return get<int32_t>(_handle, offset_priority);
1961 inline int32_t java_lang_Thread::get_daemon() const
1963 return get<int32_t>(_handle, offset_daemon);
1966 inline java_handle_t* java_lang_Thread::get_group() const
1968 return get<java_handle_t*>(_handle, offset_group);
1971 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
1973 return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
1977 inline void java_lang_Thread::set_priority(int32_t value)
1979 set(_handle, offset_priority, value);
1982 inline void java_lang_Thread::set_group(java_handle_t* value)
1984 set(_handle, offset_group, value);
1990 * OpenJDK java/lang/Throwable
1995 * 1. java.lang.Object backtrace;
1996 * 2. java.lang.String detailMessage;
1997 * 3. java.lang.Throwable cause;
1998 * 4. java.lang.StackTraceElement[] stackTrace;
2000 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2002 // Static offsets of the object's instance fields.
2003 // TODO These offsets need to be checked on VM startup.
2004 static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2005 static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2006 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2007 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2010 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2011 java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
2014 inline java_handle_bytearray_t* get_backtrace () const;
2015 inline java_handle_t* get_detailMessage() const;
2016 inline java_handle_t* get_cause () const;
2019 inline void set_backtrace(java_handle_bytearray_t* value);
2023 inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
2025 set_backtrace(backtrace);
2029 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2031 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2034 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2036 return get<java_handle_t*>(_handle, offset_detailMessage);
2039 inline java_handle_t* java_lang_Throwable::get_cause() const
2041 return get<java_handle_t*>(_handle, offset_cause);
2045 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2047 set(_handle, offset_backtrace, value);
2052 * OpenJDK java/lang/reflect/Constructor
2057 * 1. boolean override;
2058 * 2. java.lang.Class clazz;
2060 * 4. java.lang.Class[] parameterTypes;
2061 * 5. java.lang.Class[] exceptionTypes;
2063 * 7. java.lang.String signature;
2064 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2065 * 9. byte[] annotations;
2066 * 10. byte[] parameterAnnotations;
2067 * 11. java.lang.Class securityCheckCache;
2068 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2069 * 13. java.lang.reflect.Constructor root;
2070 * 14. java.util.Map declaredAnnotations;
2072 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
2074 // Static offsets of the object's instance fields.
2075 // TODO These offsets need to be checked on VM startup.
2076 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2077 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2078 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2079 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2080 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2081 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2082 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2083 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2084 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2085 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2086 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2087 static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2088 static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2089 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2092 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
2093 java_lang_reflect_Constructor(methodinfo* m);
2095 java_handle_t* new_instance(java_handle_objectarray_t* args);
2098 inline int32_t get_override () const;
2099 inline classinfo* get_clazz () const;
2100 inline int32_t get_slot () const;
2101 inline java_handle_bytearray_t* get_annotations() const;
2104 inline void set_clazz (classinfo* value);
2105 inline void set_slot (int32_t value);
2106 inline void set_parameterTypes (java_handle_objectarray_t* value);
2107 inline void set_exceptionTypes (java_handle_objectarray_t* value);
2108 inline void set_modifiers (int32_t value);
2109 inline void set_signature (java_handle_t* value);
2110 inline void set_annotations (java_handle_bytearray_t* value);
2111 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
2113 // Convenience functions.
2114 inline methodinfo* get_method();
2118 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
2120 _handle = builtin_new(class_java_lang_reflect_Constructor);
2125 int slot = m - m->clazz->methods;
2126 java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
2127 java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
2128 java_handle_bytearray_t* annotations = method_get_annotations(m);
2129 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2131 set_clazz(m->clazz);
2133 set_parameterTypes(parameterTypes);
2134 set_exceptionTypes(exceptionTypes);
2135 set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2136 set_signature(m->signature ? javastring_new(m->signature) : NULL);
2137 set_annotations(annotations);
2138 set_parameterAnnotations(parameterAnnotations);
2142 inline int32_t java_lang_reflect_Constructor::get_override() const
2144 return get<int32_t>(_handle, offset_override);
2147 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2149 return get<classinfo*>(_handle, offset_clazz);
2152 inline int32_t java_lang_reflect_Constructor::get_slot() const
2154 return get<int32_t>(_handle, offset_slot);
2157 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2159 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2163 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2165 set(_handle, offset_clazz, value);
2168 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2170 set(_handle, offset_slot, value);
2173 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2175 set(_handle, offset_parameterTypes, value);
2178 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2180 set(_handle, offset_exceptionTypes, value);
2183 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2185 set(_handle, offset_modifiers, value);
2188 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2190 set(_handle, offset_signature, value);
2193 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2195 set(_handle, offset_annotations, value);
2198 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2200 set(_handle, offset_parameterAnnotations, value);
2204 inline methodinfo* java_lang_reflect_Constructor::get_method()
2206 classinfo* c = get_clazz();
2207 int32_t slot = get_slot();
2208 methodinfo* m = &(c->methods[slot]);
2214 * OpenJDK java/lang/reflect/Field
2219 * 1. boolean override;
2220 * 2. java.lang.Class clazz;
2222 * 4. java.lang.String name;
2223 * 5. java.lang.Class type;
2225 * 7. java.lang.String signature;
2226 * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2227 * 9. byte[] annotations;
2228 * 10. sun.reflect.FieldAccessor fieldAccessor;
2229 * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2230 * 12. java.lang.reflect.Field root;
2231 * 13. java.lang.Class securityCheckCache;
2232 * 14. java.lang.Class securityCheckTargetClassCache;
2233 * 15. java.util.Map declaredAnnotations;
2235 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2237 // Static offsets of the object's instance fields.
2238 // TODO These offsets need to be checked on VM startup.
2239 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2240 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2241 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2242 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2243 static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2244 static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2245 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2246 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2247 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2248 static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2249 static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2250 static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2251 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2252 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2253 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2256 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
2257 java_lang_reflect_Field(fieldinfo* f);
2260 inline int32_t get_override () const;
2261 inline classinfo* get_clazz () const;
2262 inline int32_t get_slot () const;
2263 inline java_handle_bytearray_t* get_annotations() const;
2266 inline void set_clazz (classinfo* value);
2267 inline void set_slot (int32_t value);
2268 inline void set_name (java_handle_t* value);
2269 inline void set_type (classinfo* value);
2270 inline void set_modifiers (int32_t value);
2271 inline void set_signature (java_handle_t* value);
2272 inline void set_annotations(java_handle_bytearray_t* value);
2274 // Convenience functions.
2275 inline fieldinfo* get_field() const;
2279 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
2281 _handle = builtin_new(class_java_lang_reflect_Field);
2287 set_clazz(f->clazz);
2288 set_slot(f - f->clazz->fields);
2289 set_name(javastring_intern(javastring_new(f->name)));
2290 set_type(field_get_type(f));
2291 set_modifiers(f->flags);
2292 set_signature(f->signature ? javastring_new(f->signature) : NULL);
2293 set_annotations(field_get_annotations(f));
2297 inline int32_t java_lang_reflect_Field::get_override() const
2299 return get<int32_t>(_handle, offset_override);
2302 inline classinfo* java_lang_reflect_Field::get_clazz() const
2304 return get<classinfo*>(_handle, offset_clazz);
2307 inline int32_t java_lang_reflect_Field::get_slot() const
2309 return get<int32_t>(_handle, offset_slot);
2312 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2314 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2318 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2320 set(_handle, offset_clazz, value);
2323 inline void java_lang_reflect_Field::set_slot(int32_t value)
2325 set(_handle, offset_slot, value);
2328 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2330 set(_handle, offset_name, value);
2333 inline void java_lang_reflect_Field::set_type(classinfo* value)
2335 set(_handle, offset_type, value);
2338 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2340 set(_handle, offset_modifiers, value);
2343 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2345 set(_handle, offset_signature, value);
2348 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2350 set(_handle, offset_annotations, value);
2354 inline fieldinfo* java_lang_reflect_Field::get_field() const
2356 classinfo* c = get_clazz();
2357 int32_t slot = get_slot();
2358 fieldinfo* f = &(c->fields[slot]);
2364 * OpenJDK java/lang/reflect/Method
2369 * 1. boolean override;
2370 * 2. java.lang.Class clazz;
2372 * 4. java.lang.String name;
2373 * 5. java.lang.Class returnType;
2374 * 6. java.lang.Class[] parameterTypes;
2375 * 7. java.lang.Class[] exceptionTypes;
2377 * 9. java.lang.String signature;
2378 * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2379 * 11. byte[] annotations;
2380 * 12. byte[] parameterAnnotations;
2381 * 13. byte[] annotationDefault;
2382 * 14. sun.reflect.MethodAccessor methodAccessor;
2383 * 15. java.lang.reflect.Method root;
2384 * 16. java.lang.Class securityCheckCache;
2385 * 17. java.lang.Class securityCheckTargetClassCache;
2386 * 18. java.util.Map declaredAnnotations;
2388 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2390 // Static offsets of the object's instance fields.
2391 // TODO These offsets need to be checked on VM startup.
2392 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2393 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2394 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2395 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2396 static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2397 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2398 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2399 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2400 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2401 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2402 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2403 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2404 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2405 static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2406 static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2407 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2408 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2409 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2412 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
2413 java_lang_reflect_Method(methodinfo* m);
2415 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
2418 inline int32_t get_override () const;
2419 inline classinfo* get_clazz () const;
2420 inline int32_t get_slot () const;
2421 inline java_handle_bytearray_t* get_annotations () const;
2422 inline java_handle_bytearray_t* get_parameterAnnotations() const;
2423 inline java_handle_bytearray_t* get_annotationDefault () const;
2427 // Convenience functions.
2428 inline methodinfo* get_method() const;
2432 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
2434 _handle = builtin_new(class_java_lang_reflect_Method);
2439 set(_handle, offset_clazz, m->clazz);
2440 set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2441 set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
2442 set(_handle, offset_returnType, method_returntype_get(m));
2443 set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2444 set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2445 set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2446 set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
2447 set(_handle, offset_annotations, method_get_annotations(m));
2448 set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2449 set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2453 inline int32_t java_lang_reflect_Method::get_override() const
2455 return get<int32_t>(_handle, offset_override);
2458 inline classinfo* java_lang_reflect_Method::get_clazz() const
2460 return get<classinfo*>(_handle, offset_clazz);
2463 inline int32_t java_lang_reflect_Method::get_slot() const
2465 return get<int32_t>(_handle, offset_slot);
2468 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2470 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2473 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2475 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2478 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2480 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2484 inline methodinfo* java_lang_reflect_Method::get_method() const
2486 classinfo* c = get_clazz();
2487 int32_t slot = get_slot();
2488 methodinfo* m = &(c->methods[slot]);
2494 * OpenJDK java/nio/Buffer
2505 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2507 // Static offsets of the object's instance fields.
2508 // TODO These offsets need to be checked on VM startup.
2509 static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2510 static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2511 static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2512 static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2513 static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2516 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
2519 inline void* get_address() const;
2523 inline void* java_nio_Buffer::get_address() const
2525 return get<void*>(_handle, offset_address);
2528 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2531 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2534 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2543 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2545 // Static offsets of the object's instance fields.
2546 // TODO These offsets need to be checked on VM startup.
2547 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2548 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2549 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2552 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2553 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2554 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2557 inline int64_t get_pointer () const;
2558 inline int32_t get_position() const;
2559 inline int32_t get_length () const;
2562 inline void set_pointer (int64_t value);
2563 inline void set_position(int32_t value);
2564 inline void set_length (int32_t value);
2568 inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length) : java_lang_Object(h)
2570 set_pointer(pointer);
2571 set_position(position);
2575 inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd) : java_lang_Object(h)
2577 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2581 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2583 return get<int64_t>(_handle, offset_pointer);
2586 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2588 return get<int32_t>(_handle, offset_position);
2591 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2593 return get<int32_t>(_handle, offset_length);
2597 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2599 set(_handle, offset_pointer, value);
2602 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2604 set(_handle, offset_position, value);
2607 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2609 set(_handle, offset_length, value);
2614 * CLDC 1.1 java/lang/String
2623 class java_lang_String : public java_lang_Object, private FieldAccess {
2625 // Static offsets of the object's instance fields.
2626 // TODO These offsets need to be checked on VM startup.
2627 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2628 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2629 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2632 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
2633 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2636 inline java_handle_chararray_t* get_value () const;
2637 inline int32_t get_offset() const;
2638 inline int32_t get_count () const;
2641 inline void set_value (java_handle_chararray_t* value);
2642 inline void set_offset(int32_t value);
2643 inline void set_count (int32_t value);
2647 inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
2654 inline java_handle_chararray_t* java_lang_String::get_value() const
2656 return get<java_handle_chararray_t*>(_handle, offset_value);
2659 inline int32_t java_lang_String::get_offset() const
2661 return get<int32_t>(_handle, offset_offset);
2664 inline int32_t java_lang_String::get_count() const
2666 return get<int32_t>(_handle, offset_count);
2669 inline void java_lang_String::set_value(java_handle_chararray_t* value)
2671 set(_handle, offset_value, value);
2674 inline void java_lang_String::set_offset(int32_t value)
2676 set(_handle, offset_offset, value);
2679 inline void java_lang_String::set_count(int32_t value)
2681 set(_handle, offset_count, value);
2686 * CLDC 1.1 java/lang/Thread
2692 * 2. java.lang.Runnable runnable;
2693 * 3. java.lang.Object vm_thread;
2694 * 4. int is_terminated;
2695 * 5. int is_stillborn;
2698 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2700 // Static offsets of the object's instance fields.
2701 // TODO These offsets need to be checked on VM startup.
2702 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2703 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2704 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2705 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2706 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2707 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2710 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2711 // java_lang_Thread(threadobject* t);
2714 inline int32_t get_priority () const;
2715 inline threadobject* get_vm_thread() const;
2716 inline java_handle_chararray_t* get_name () const;
2719 inline void set_vm_thread(threadobject* value);
2723 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
2725 // java_lang_Thread(thread_get_object(t));
2729 inline int32_t java_lang_Thread::get_priority() const
2731 return get<int32_t>(_handle, offset_priority);
2734 inline threadobject* java_lang_Thread::get_vm_thread() const
2736 return get<threadobject*>(_handle, offset_vm_thread);
2739 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2741 return get<java_handle_chararray_t*>(_handle, offset_name);
2745 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2747 set(_handle, offset_vm_thread, value);
2752 * CLDC 1.1 java/lang/Throwable
2757 * 1. java.lang.String detailMessage;
2758 * 2. java.lang.Object backtrace;
2760 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2762 // Static offsets of the object's instance fields.
2763 // TODO These offsets need to be checked on VM startup.
2764 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2765 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2768 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2771 inline java_handle_t* get_detailMessage() const;
2772 inline java_handle_bytearray_t* get_backtrace () const;
2775 inline void set_backtrace(java_handle_bytearray_t* value);
2779 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2781 return get<java_handle_t*>(_handle, offset_detailMessage);
2784 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2786 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2790 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2792 set(_handle, offset_backtrace, value);
2795 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2799 // Legacy C interface.
2800 java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m);
2801 java_handle_t* java_lang_reflect_Field_create(fieldinfo* f);
2802 java_handle_t* java_lang_reflect_Method_create(methodinfo* m);
2806 #endif // _JAVAOBJECTS_HPP
2810 * These are local overrides for various environment variables in Emacs.
2811 * Please do not remove this and leave it at the end of the file, where
2812 * Emacs will automagically detect them.
2813 * ---------------------------------------------------------------------
2816 * indent-tabs-mode: t