1 /* src/vmcore/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"
36 #include "vm/global.h"
38 #include "vmcore/field.h"
39 #include "vmcore/method.h"
45 * This class provides low-level functions to access Java object
48 * These functions do NOT take care about the GC critical section!
49 * Please use FieldAccess wherever possible.
51 class RawFieldAccess {
53 template<class T> static inline T raw_get(void* address, const off_t offset);
54 template<class T> static inline void raw_set(void* address, const off_t offset, T value);
58 template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
60 T* p = (T*) (((uintptr_t) address) + offset);
65 template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
67 T* p = (T*) (((uintptr_t) address) + offset);
73 * This classes provides functions to access Java object instance
74 * fields. These functions enter a critical GC section before
75 * accessing the Java object throught the handle and leave it
78 class FieldAccess : private RawFieldAccess {
80 template<class T> static inline T get(java_handle_t* h, const off_t offset);
81 template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
84 template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
89 // XXX Move this to a GC inline function, e.g.
90 // gc->enter_critical();
93 // XXX This should be _handle->get_object();
96 result = raw_get<T>(o, offset);
98 // XXX Move this to a GC inline function.
99 // gc->leave_critical();
105 template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
108 java_object_t* result;
109 java_handle_t* hresult;
111 // XXX Move this to a GC inline function, e.g.
112 // gc->enter_critical();
115 // XXX This should be _handle->get_object();
118 result = raw_get<java_object_t*>(o, offset);
120 hresult = LLNI_WRAP(result);
122 // XXX Move this to a GC inline function.
123 // gc->leave_critical();
130 template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
134 // XXX Move this to a GC inline function, e.g.
135 // gc->enter_critical();
138 // XXX This should be h->get_object();
141 raw_set(o, offset, value);
143 // XXX Move this to a GC inline function.
144 // gc->leave_critical();
148 template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
151 java_object_t* ovalue;
153 // XXX Move this to a GC inline function, e.g.
154 // gc->enter_critical();
157 // XXX This should be h->get_object();
159 ovalue = LLNI_UNWRAP(value);
161 raw_set(o, offset, ovalue);
163 // XXX Move this to a GC inline function.
164 // gc->leave_critical();
176 class java_lang_Object {
178 // Handle of Java object.
179 java_handle_t* _handle;
182 java_lang_Object(java_handle_t* h) : _handle(h) {}
183 java_lang_Object(jobject h) : _handle((java_handle_t*) h) {}
187 virtual inline java_handle_t* get_handle() const { return _handle; }
188 inline vftbl_t* get_vftbl () const;
189 inline classinfo* get_Class () const;
191 inline bool is_null() const;
195 inline vftbl_t* java_lang_Object::get_vftbl() const
197 // XXX Move this to a GC inline function, e.g.
198 // gc->enter_critical();
201 // XXX This should be h->get_object();
202 java_object_t* o = LLNI_UNWRAP(_handle);
203 vftbl_t* vftbl = o->vftbl;
205 // XXX Move this to a GC inline function.
206 // gc->leave_critical();
212 inline classinfo* java_lang_Object::get_Class() const
214 return get_vftbl()->clazz;
218 inline bool java_lang_Object::is_null() const
220 return (_handle == NULL);
232 class java_lang_Boolean : public java_lang_Object, private FieldAccess {
234 // Static offsets of the object's instance fields.
235 // TODO These offsets need to be checked on VM startup.
236 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
239 java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {}
241 inline uint8_t get_value();
242 inline void set_value(uint8_t value);
245 inline uint8_t java_lang_Boolean::get_value()
247 return get<int32_t>(_handle, offset_value);
250 inline void java_lang_Boolean::set_value(uint8_t value)
252 set(_handle, offset_value, (uint32_t) value);
264 class java_lang_Byte : public java_lang_Object, private FieldAccess {
266 // Static offsets of the object's instance fields.
267 // TODO These offsets need to be checked on VM startup.
268 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
271 java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {}
273 inline int8_t get_value();
274 inline void set_value(int8_t value);
277 inline int8_t java_lang_Byte::get_value()
279 return get<int32_t>(_handle, offset_value);
282 inline void java_lang_Byte::set_value(int8_t value)
284 set(_handle, offset_value, (int32_t) value);
289 * java/lang/Character
296 class java_lang_Character : public java_lang_Object, private FieldAccess {
298 // Static offsets of the object's instance fields.
299 // TODO These offsets need to be checked on VM startup.
300 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
303 java_lang_Character(java_handle_t* h) : java_lang_Object(h) {}
305 inline uint16_t get_value();
306 inline void set_value(uint16_t value);
309 inline uint16_t java_lang_Character::get_value()
311 return get<int32_t>(_handle, offset_value);
314 inline void java_lang_Character::set_value(uint16_t value)
316 set(_handle, offset_value, (uint32_t) value);
328 class java_lang_Short : public java_lang_Object, private FieldAccess {
330 // Static offsets of the object's instance fields.
331 // TODO These offsets need to be checked on VM startup.
332 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
335 java_lang_Short(java_handle_t* h) : java_lang_Object(h) {}
337 inline int16_t get_value();
338 inline void set_value(int16_t value);
341 inline int16_t java_lang_Short::get_value()
343 return get<int32_t>(_handle, offset_value);
346 inline void java_lang_Short::set_value(int16_t value)
348 set(_handle, offset_value, (int32_t) value);
360 class java_lang_Integer : public java_lang_Object, private FieldAccess {
362 // Static offsets of the object's instance fields.
363 // TODO These offsets need to be checked on VM startup.
364 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
367 java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
369 inline int32_t get_value();
370 inline void set_value(int32_t value);
373 inline int32_t java_lang_Integer::get_value()
375 return get<int32_t>(_handle, offset_value);
378 inline void java_lang_Integer::set_value(int32_t value)
380 set(_handle, offset_value, value);
392 class java_lang_Long : public java_lang_Object, private FieldAccess {
394 // Static offsets of the object's instance fields.
395 // TODO These offsets need to be checked on VM startup.
396 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
399 java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
401 inline int64_t get_value();
402 inline void set_value(int64_t value);
405 inline int64_t java_lang_Long::get_value()
407 return get<int64_t>(_handle, offset_value);
410 inline void java_lang_Long::set_value(int64_t value)
412 set(_handle, offset_value, value);
424 class java_lang_Float : public java_lang_Object, private FieldAccess {
426 // Static offsets of the object's instance fields.
427 // TODO These offsets need to be checked on VM startup.
428 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
431 java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
433 inline float get_value();
434 inline void set_value(float value);
437 inline float java_lang_Float::get_value()
439 return get<float>(_handle, offset_value);
442 inline void java_lang_Float::set_value(float value)
444 set(_handle, offset_value, value);
456 class java_lang_Double : public java_lang_Object, private FieldAccess {
458 // Static offsets of the object's instance fields.
459 // TODO These offsets need to be checked on VM startup.
460 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
463 java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
465 inline double get_value();
466 inline void set_value(double value);
469 inline double java_lang_Double::get_value()
471 return get<double>(_handle, offset_value);
474 inline void java_lang_Double::set_value(double value)
476 set(_handle, offset_value, value);
480 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
483 * GNU Classpath java/lang/Class
488 * 1. java.lang.Object[] signers;
489 * 2. java.security.ProtectionDomain pd;
490 * 3. java.lang.Object vmdata;
491 * 4. java.lang.reflect.Constructor constructor;
493 class java_lang_Class : public java_lang_Object, private FieldAccess {
495 // Static offsets of the object's instance fields.
496 // TODO These offsets need to be checked on VM startup.
497 static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
498 static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
499 static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
500 static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
503 java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
506 inline void set_pd(java_handle_t* value);
507 inline void set_pd(jobject value);
510 inline void java_lang_Class::set_pd(java_handle_t* value)
512 set(_handle, offset_pd, value);
515 inline void java_lang_Class::set_pd(jobject value)
517 set_pd((java_handle_t*) value);
522 * GNU Classpath java/lang/StackTraceElement
527 * 1. java.lang.String fileName;
529 * 3. java.lang.String declaringClass;
530 * 4. java.lang.String methodName;
531 * 5. boolean isNative;
533 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
535 // Static offsets of the object's instance fields.
536 // TODO These offsets need to be checked on VM startup.
537 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
538 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
539 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
540 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
541 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
544 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
545 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);
548 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)
550 java_lang_StackTraceElement((java_handle_t*) h);
552 set(_handle, offset_fileName, fileName);
553 set(_handle, offset_lineNumber, lineNumber);
554 set(_handle, offset_declaringClass, declaringClass);
555 set(_handle, offset_methodName, methodName);
556 set(_handle, offset_isNative, isNative);
561 * GNU Classpath java/lang/String
568 * 3. int cachedHashCode;
571 class java_lang_String : public java_lang_Object, private FieldAccess {
573 // Static offsets of the object's instance fields.
574 // TODO These offsets need to be checked on VM startup.
575 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
576 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
577 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
578 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
581 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
582 java_lang_String(jstring h);
583 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
586 inline java_handle_chararray_t* get_value () const;
587 inline int32_t get_count () const;
588 inline int32_t get_offset() const;
591 inline void set_value (java_handle_chararray_t* value);
592 inline void set_count (int32_t value);
593 inline void set_offset(int32_t value);
596 inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h)
598 java_lang_String((java_handle_t*) h);
601 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)
608 inline java_handle_chararray_t* java_lang_String::get_value() const
610 return get<java_handle_chararray_t*>(_handle, offset_value);
613 inline int32_t java_lang_String::get_count() const
615 return get<int32_t>(_handle, offset_count);
618 inline int32_t java_lang_String::get_offset() const
620 return get<int32_t>(_handle, offset_offset);
623 inline void java_lang_String::set_value(java_handle_chararray_t* value)
625 set(_handle, offset_value, value);
628 inline void java_lang_String::set_count(int32_t value)
630 set(_handle, offset_count, value);
633 inline void java_lang_String::set_offset(int32_t value)
635 set(_handle, offset_offset, value);
640 * GNU Classpath java/lang/Thread
645 * 1. java.lang.VMThread vmThread;
646 * 2. java.lang.ThreadGroup group;
647 * 3. java.lang.Runnable runnable;
648 * 4. java.lang.String name;
652 * 8. java.lang.Throwable stillborn;
653 * 9. java.lang.ClassLoader contextClassLoader;
654 * 10. boolean contextClassLoaderIsSystemClassLoader;
656 * 12. java.lang.Object parkBlocker;
657 * 13. gnu.java.util.WeakIdentityHashMap locals;
658 * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
660 class java_lang_Thread : public java_lang_Object, private FieldAccess {
662 // Static offsets of the object's instance fields.
663 // TODO These offsets need to be checked on VM startup.
664 static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
665 static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
666 static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
667 static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
668 static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
669 static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
670 static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
671 static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
672 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
673 static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
674 static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
675 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
676 static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
677 static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
680 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
681 // java_lang_Thread(threadobject* t);
684 inline java_handle_t* get_vmThread () const;
685 inline java_handle_t* get_group () const;
686 inline java_handle_t* get_name () const;
687 inline int32_t get_daemon () const;
688 inline int32_t get_priority () const;
689 inline java_handle_t* get_exceptionHandler() const;
692 inline void set_group(java_handle_t* value);
696 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
698 // java_lang_Thread(thread_get_object(t));
702 inline java_handle_t* java_lang_Thread::get_vmThread() const
704 return get<java_handle_t*>(_handle, offset_vmThread);
707 inline java_handle_t* java_lang_Thread::get_group() const
709 return get<java_handle_t*>(_handle, offset_group);
712 inline java_handle_t* java_lang_Thread::get_name() const
714 return get<java_handle_t*>(_handle, offset_name);
717 inline int32_t java_lang_Thread::get_daemon() const
719 return get<int32_t>(_handle, offset_daemon);
722 inline int32_t java_lang_Thread::get_priority() const
724 return get<int32_t>(_handle, offset_priority);
727 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
729 return get<java_handle_t*>(_handle, offset_exceptionHandler);
733 inline void java_lang_Thread::set_group(java_handle_t* value)
735 set(_handle, offset_group, value);
740 * GNU Classpath java/lang/VMThread
745 * 1. java.lang.Thread thread;
746 * 2. boolean running;
747 * 3. java.lang.VMThread vmdata;
749 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
751 // Static offsets of the object's instance fields.
752 // TODO These offsets need to be checked on VM startup.
753 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
754 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
755 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
758 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
759 java_lang_VMThread(jobject h);
760 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
763 inline java_handle_t* get_thread() const;
764 inline threadobject* get_vmdata() const;
767 inline void set_thread(java_handle_t* value);
768 inline void set_vmdata(threadobject* value);
772 inline java_lang_VMThread::java_lang_VMThread(jobject h) : java_lang_Object(h)
774 java_lang_VMThread((java_handle_t*) h);
777 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
784 inline java_handle_t* java_lang_VMThread::get_thread() const
786 return get<java_handle_t*>(_handle, offset_thread);
789 inline threadobject* java_lang_VMThread::get_vmdata() const
791 return get<threadobject*>(_handle, offset_vmdata);
795 inline void java_lang_VMThread::set_thread(java_handle_t* value)
797 set(_handle, offset_thread, value);
800 inline void java_lang_VMThread::set_vmdata(threadobject* value)
802 set(_handle, offset_vmdata, value);
807 * GNU Classpath java/lang/Throwable
812 * 1. java.lang.String detailMessage;
813 * 2. java.lang.Throwable cause;
814 * 3. java.lang.StackTraceElement[] stackTrace;
815 * 4. java.lang.VMThrowable vmState;
817 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
819 // Static offsets of the object's instance fields.
820 // TODO These offsets need to be checked on VM startup.
821 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
822 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
823 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
824 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
827 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
830 inline java_handle_t* get_detailMessage() const;
831 inline java_handle_t* get_cause () const;
832 inline java_handle_t* get_vmState () const;
836 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
838 return get<java_handle_t*>(_handle, offset_detailMessage);
841 inline java_handle_t* java_lang_Throwable::get_cause() const
843 return get<java_handle_t*>(_handle, offset_cause);
846 inline java_handle_t* java_lang_Throwable::get_vmState() const
848 return get<java_handle_t*>(_handle, offset_vmState);
853 * GNU Classpath java/lang/VMThrowable
858 * 1. java.lang.Object vmdata;
860 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
862 // Static offsets of the object's instance fields.
863 // TODO These offsets need to be checked on VM startup.
864 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
867 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
868 java_lang_VMThrowable(jobject h);
870 inline java_handle_bytearray_t* get_vmdata() const;
871 inline void set_vmdata(java_handle_bytearray_t* value);
874 inline java_lang_VMThrowable::java_lang_VMThrowable(jobject h) : java_lang_Object(h)
876 java_lang_VMThrowable((java_handle_t*) h);
879 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
881 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
884 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
886 set(_handle, offset_vmdata, value);
891 * GNU Classpath java/lang/reflect/Constructor
897 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
898 * 3. java.lang.reflect.VMConstructor cons;
900 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
902 // Static offsets of the object's instance fields.
903 // TODO These offsets need to be checked on VM startup.
904 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
905 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
906 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
909 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
910 java_lang_reflect_Constructor(jobject h);
912 static java_handle_t* create(methodinfo* m);
913 static java_handle_t* new_instance(methodinfo* m, java_handle_objectarray_t* args, bool override);
916 inline int32_t get_flag() const;
917 inline java_handle_t* get_cons() const;
920 inline void set_cons(java_handle_t* value);
923 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h)
925 java_lang_reflect_Constructor((java_handle_t*) h);
928 inline int32_t java_lang_reflect_Constructor::get_flag() const
930 return get<int32_t>(_handle, offset_flag);
933 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
935 return get<java_handle_t*>(_handle, offset_cons);
938 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
940 set(_handle, offset_cons, value);
945 * GNU Classpath java/lang/reflect/VMConstructor
950 * 1. java.lang.Class clazz;
952 * 3. byte[] annotations;
953 * 4. byte[] parameterAnnotations;
954 * 5. java.util.Map declaredAnnotations;
955 * 6. java.lang.reflect.Constructor cons;
957 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
959 // Static offsets of the object's instance fields.
960 // TODO These offsets need to be checked on VM startup.
961 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
962 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
963 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
964 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
965 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
966 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
969 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
970 java_lang_reflect_VMConstructor(jobject h);
971 java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m);
974 inline classinfo* get_clazz () const;
975 inline int32_t get_slot () const;
976 inline java_handle_bytearray_t* get_annotations () const;
977 inline java_handle_bytearray_t* get_parameterAnnotations() const;
978 inline java_handle_t* get_declaredAnnotations () const;
979 inline java_handle_t* get_cons () const;
982 inline void set_clazz (classinfo* value);
983 inline void set_slot (int32_t value);
984 inline void set_annotations (java_handle_bytearray_t* value);
985 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
986 inline void set_declaredAnnotations (java_handle_t* value);
987 inline void set_cons (java_handle_t* value);
989 // Convenience functions.
990 inline methodinfo* get_method();
993 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(jobject h) : java_lang_Object(h)
995 java_lang_reflect_VMConstructor((java_handle_t*) h);
998 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m) : java_lang_Object(h)
1000 int slot = m - m->clazz->methods;
1001 java_handle_bytearray_t* annotations = method_get_annotations(m);
1002 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1004 set_clazz(m->clazz);
1006 set_annotations(annotations);
1007 set_parameterAnnotations(parameterAnnotations);
1010 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1012 return get<classinfo*>(_handle, offset_clazz);
1015 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1017 return get<int32_t>(_handle, offset_slot);
1020 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1022 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1025 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1027 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1030 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1032 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1035 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1037 return get<java_handle_t*>(_handle, offset_cons);
1040 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1042 set(_handle, offset_clazz, value);
1045 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1047 set(_handle, offset_slot, value);
1050 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1052 set(_handle, offset_annotations, value);
1055 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1057 set(_handle, offset_parameterAnnotations, value);
1060 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1062 set(_handle, offset_declaredAnnotations, value);
1065 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1067 set(_handle, offset_cons, value);
1070 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1072 classinfo* c = get_clazz();
1073 int32_t slot = get_slot();
1074 methodinfo* m = &(c->methods[slot]);
1080 * GNU Classpath java/lang/reflect/Field
1086 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1087 * 3. java.lang.reflect.VMField f;
1089 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1091 // Static offsets of the object's instance fields.
1092 // TODO These offsets need to be checked on VM startup.
1093 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1094 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1095 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1098 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1099 java_lang_reflect_Field(jobject h);
1101 static java_handle_t* create(fieldinfo* f);
1104 inline int32_t get_flag() const;
1105 inline java_handle_t* get_f() const;
1108 inline void set_f(java_handle_t* value);
1111 inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h)
1113 java_lang_reflect_Field((java_handle_t*) h);
1116 inline int32_t java_lang_reflect_Field::get_flag() const
1118 return get<int32_t>(_handle, offset_flag);
1121 inline java_handle_t* java_lang_reflect_Field::get_f() const
1123 return get<java_handle_t*>(_handle, offset_f);
1126 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1128 set(_handle, offset_f, value);
1133 * GNU Classpath java/lang/reflect/VMField
1138 * 1. java.lang.Class clazz;
1139 * 2. java.lang.String name;
1141 * 4. byte[] annotations;
1142 * 5. java.lang.Map declaredAnnotations;
1143 * 6. java.lang.reflect.Field f;
1145 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1147 // Static offsets of the object's instance fields.
1148 // TODO These offsets need to be checked on VM startup.
1149 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1150 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1151 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1152 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1153 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1154 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1157 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1158 java_lang_reflect_VMField(jobject h);
1159 java_lang_reflect_VMField(java_handle_t* h, fieldinfo* f);
1162 inline classinfo* get_clazz () const;
1163 inline int32_t get_slot () const;
1164 inline java_handle_bytearray_t* get_annotations () const;
1165 inline java_handle_t* get_declaredAnnotations() const;
1166 inline java_handle_t* get_f () const;
1169 inline void set_clazz (classinfo* value);
1170 inline void set_name (java_handle_t* value);
1171 inline void set_slot (int32_t value);
1172 inline void set_annotations (java_handle_bytearray_t* value);
1173 inline void set_declaredAnnotations(java_handle_t* value);
1174 inline void set_f (java_handle_t* value);
1176 // Convenience functions.
1177 inline fieldinfo* get_field() const;
1180 inline java_lang_reflect_VMField::java_lang_reflect_VMField(jobject h) : java_lang_Object(h)
1182 java_lang_reflect_VMField((java_handle_t*) h);
1185 inline java_lang_reflect_VMField::java_lang_reflect_VMField(java_handle_t* h, fieldinfo* f) : java_lang_Object(h)
1187 java_handle_t* name = javastring_intern(javastring_new(f->name));
1188 int slot = f - f->clazz->fields;
1189 java_handle_bytearray_t* annotations = field_get_annotations(f);
1191 set_clazz(f->clazz);
1194 set_annotations(annotations);
1197 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1199 return get<classinfo*>(_handle, offset_clazz);
1202 inline int32_t java_lang_reflect_VMField::get_slot() const
1204 return get<int32_t>(_handle, offset_slot);
1207 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1209 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1212 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1214 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1217 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1219 return get<java_handle_t*>(_handle, offset_f);
1222 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1224 set(_handle, offset_clazz, value);
1227 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1229 set(_handle, offset_name, value);
1232 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1234 set(_handle, offset_slot, value);
1237 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1239 set(_handle, offset_annotations, value);
1242 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1244 set(_handle, offset_declaredAnnotations, value);
1247 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1249 set(_handle, offset_f, value);
1252 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1254 classinfo* c = get_clazz();
1255 int32_t slot = get_slot();
1256 fieldinfo* f = &(c->fields[slot]);
1262 * GNU Classpath java/lang/reflect/Method
1268 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1269 * 3. java.lang.reflect.VMMethod m;
1271 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1273 // Static offsets of the object's instance fields.
1274 // TODO These offsets need to be checked on VM startup.
1275 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1276 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1277 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1280 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1281 java_lang_reflect_Method(jobject h);
1283 static java_handle_t* create(methodinfo* m);
1286 inline int32_t get_flag() const;
1287 inline java_handle_t* get_m() const;
1290 inline void set_m(java_handle_t* value);
1293 inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h)
1295 java_lang_reflect_Method((java_handle_t*) h);
1298 inline int32_t java_lang_reflect_Method::get_flag() const
1300 return get<int32_t>(_handle, offset_flag);
1303 inline java_handle_t* java_lang_reflect_Method::get_m() const
1305 return get<java_handle_t*>(_handle, offset_m);
1308 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1310 set(_handle, offset_m, value);
1315 * GNU Classpath java/lang/reflect/VMMethod
1320 * 1. java.lang.Class clazz;
1321 * 2. java.lang.String name;
1323 * 4. byte[] annotations;
1324 * 5. byte[] parameterAnnotations;
1325 * 6. byte[] annotationDefault;
1326 * 7. java.lang.Map declaredAnnotations;
1327 * 8. java.lang.reflect.Method m;
1329 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1331 // Static offsets of the object's instance fields.
1332 // TODO These offsets need to be checked on VM startup.
1333 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1334 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1335 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1336 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1337 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1338 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1339 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1340 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1343 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1344 java_lang_reflect_VMMethod(jobject h);
1345 java_lang_reflect_VMMethod(java_handle_t* h, methodinfo* m);
1348 inline classinfo* get_clazz () const;
1349 inline int32_t get_slot () const;
1350 inline java_handle_bytearray_t* get_annotations () const;
1351 inline java_handle_bytearray_t* get_parameterAnnotations() const;
1352 inline java_handle_bytearray_t* get_annotationDefault () const;
1353 inline java_handle_t* get_declaredAnnotations () const;
1354 inline java_handle_t* get_m () const;
1357 inline void set_clazz (classinfo* value);
1358 inline void set_name (java_handle_t* value);
1359 inline void set_slot (int32_t value);
1360 inline void set_annotations (java_handle_bytearray_t* value);
1361 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
1362 inline void set_annotationDefault (java_handle_bytearray_t* value);
1363 inline void set_declaredAnnotations (java_handle_t* value);
1364 inline void set_m (java_handle_t* value);
1366 // Convenience functions.
1367 inline methodinfo* get_method() const;
1370 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(jobject h) : java_lang_Object(h)
1372 java_lang_reflect_VMMethod((java_handle_t*) h);
1375 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(java_handle_t* h, methodinfo* m) : java_lang_Object(h)
1377 java_handle_t* name = javastring_intern(javastring_new(m->name));
1378 int slot = m - m->clazz->methods;
1379 java_handle_bytearray_t* annotations = method_get_annotations(m);
1380 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1381 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1383 set_clazz(m->clazz);
1386 set_annotations(annotations);
1387 set_parameterAnnotations(parameterAnnotations);
1388 set_annotationDefault(annotationDefault);
1391 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1393 return get<classinfo*>(_handle, offset_clazz);
1396 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1398 return get<int32_t>(_handle, offset_slot);
1401 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1403 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1406 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1408 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1411 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1413 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1416 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1418 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1421 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1423 return get<java_handle_t*>(_handle, offset_m);
1426 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1428 set(_handle, offset_clazz, value);
1431 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1433 set(_handle, offset_name, value);
1436 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1438 set(_handle, offset_slot, value);
1441 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1443 set(_handle, offset_annotations, value);
1446 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1448 set(_handle, offset_parameterAnnotations, value);
1451 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1453 set(_handle, offset_annotationDefault, value);
1456 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1458 set(_handle, offset_declaredAnnotations, value);
1461 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1463 set(_handle, offset_m, value);
1466 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1468 classinfo* c = get_clazz();
1469 int32_t slot = get_slot();
1470 methodinfo* m = &(c->methods[slot]);
1476 * GNU Classpath java/nio/Buffer
1485 * 5. gnu.classpath.Pointer address;
1487 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1489 // Static offsets of the object's instance fields.
1490 // TODO These offsets need to be checked on VM startup.
1491 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1492 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1493 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1494 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1495 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1498 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1501 inline int32_t get_cap() const;
1504 inline int32_t java_nio_Buffer::get_cap() const
1506 return get<int32_t>(_handle, offset_cap);
1511 * GNU Classpath java/nio/DirectByteBufferImpl
1520 * 5. gnu.classpath.Pointer address;
1521 * 6. java.nio.ByteOrder endian;
1522 * 7. byte[] backing_buffer;
1523 * 8. int array_offset;
1524 * 9. java.lang.Object owner;
1526 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1528 // Static offsets of the object's instance fields.
1529 // TODO These offsets need to be checked on VM startup.
1530 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1531 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1532 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1533 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1534 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1535 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1536 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1537 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1538 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1541 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1542 java_nio_DirectByteBufferImpl(jobject h);
1545 inline java_handle_t* get_address() const;
1548 inline java_nio_DirectByteBufferImpl::java_nio_DirectByteBufferImpl(jobject h) : java_lang_Object(h)
1550 java_nio_DirectByteBufferImpl((java_handle_t*) h);
1553 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1555 return get<java_handle_t*>(_handle, offset_address);
1560 * GNU Classpath gnu/classpath/Pointer
1562 * Actually there are two classes, gnu.classpath.Pointer32 and
1563 * gnu.classpath.Pointer64, but we only define the abstract super
1564 * class and use the int/long field as void* type.
1571 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1573 // Static offsets of the object's instance fields.
1574 // TODO These offsets need to be checked on VM startup.
1575 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1578 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1579 gnu_classpath_Pointer(java_handle_t* h, void* data);
1582 inline void* get_data() const;
1585 inline void set_data(void* value);
1588 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1593 inline void* gnu_classpath_Pointer::get_data() const
1595 return get<void*>(_handle, offset_data);
1598 inline void gnu_classpath_Pointer::set_data(void* value)
1600 set(_handle, offset_data, value);
1604 # if defined(ENABLE_ANNOTATIONS)
1606 * GNU Classpath sun/reflect/ConstantPool
1611 * 1. java.lang.Object constantPoolOop;
1613 class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
1615 // Static offsets of the object's instance fields.
1616 // TODO These offsets need to be checked on VM startup.
1617 static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1620 sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
1623 inline void set_constantPoolOop(classinfo* value);
1624 inline void set_constantPoolOop(jclass value);
1627 inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
1629 set(_handle, offset_constantPoolOop, value);
1632 inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
1634 // XXX jclass is a boxed object.
1635 set_constantPoolOop(LLNI_classinfo_unwrap(value));
1637 # endif // ENABLE_ANNOTATIONS
1639 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1642 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1645 * OpenJDK java/lang/reflect/Constructor
1650 * 1. boolean override;
1651 * 2. java.lang.Class clazz;
1653 * 4. java.lang.Class[] parameterTypes;
1654 * 5. java.lang.Class[] exceptionTypes;
1656 * 7. java.lang.String signature;
1657 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
1658 * 9. byte[] annotations;
1659 * 10. byte[] parameterAnnotations;
1660 * 11. java.lang.Class securityCheckCache;
1661 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
1662 * 13. java.lang.reflect.Constructor root;
1663 * 14. java.util.Map declaredAnnotations;
1665 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
1667 // Static offsets of the object's instance fields.
1668 // TODO These offsets need to be checked on VM startup.
1669 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1670 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
1671 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1672 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1673 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1674 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1677 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
1678 java_lang_reflect_VMConstructor(jobject h);
1679 java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m);
1682 inline classinfo* get_clazz () const;
1683 inline int32_t get_slot () const;
1684 inline java_handle_bytearray_t* get_annotations () const;
1685 inline java_handle_bytearray_t* get_parameterAnnotations() const;
1686 inline java_handle_t* get_declaredAnnotations () const;
1687 inline java_handle_t* get_cons () const;
1690 inline void set_clazz (classinfo* value);
1691 inline void set_slot (int32_t value);
1692 inline void set_annotations (java_handle_bytearray_t* value);
1693 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
1694 inline void set_declaredAnnotations (java_handle_t* value);
1695 inline void set_cons (java_handle_t* value);
1697 // Convenience functions.
1698 inline methodinfo* get_method();
1701 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(jobject h) : java_lang_Object(h)
1703 java_lang_reflect_VMConstructor((java_handle_t*) h);
1706 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m) : java_lang_Object(h)
1708 int slot = m - m->clazz->methods;
1709 java_handle_bytearray_t* annotations = method_get_annotations(m);
1710 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1712 set_clazz(m->clazz);
1714 set_annotations(annotations);
1715 set_parameterAnnotations(parameterAnnotations);
1718 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1720 return get<classinfo*>(_handle, offset_clazz);
1723 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1725 return get<int32_t>(_handle, offset_slot);
1728 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1730 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1733 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1735 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1738 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1740 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1743 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1745 return get<java_handle_t*>(_handle, offset_cons);
1748 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1750 set(_handle, offset_clazz, value);
1753 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1755 set(_handle, offset_slot, value);
1758 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1760 set(_handle, offset_annotations, value);
1763 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1765 set(_handle, offset_parameterAnnotations, value);
1768 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1770 set(_handle, offset_declaredAnnotations, value);
1773 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1775 set(_handle, offset_cons, value);
1778 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1780 classinfo* c = get_clazz();
1781 int32_t slot = get_slot();
1782 methodinfo* m = &(c->methods[slot]);
1786 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
1788 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
1791 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
1800 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
1802 // Static offsets of the object's instance fields.
1803 // TODO These offsets need to be checked on VM startup.
1804 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
1805 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
1806 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
1809 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
1810 com_sun_cldchi_jvm_FileDescriptor(jobject h);
1811 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
1812 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
1815 inline int64_t get_pointer () const;
1816 inline int32_t get_position() const;
1817 inline int32_t get_length () const;
1820 inline void set_pointer (int64_t value);
1821 inline void set_position(int32_t value);
1822 inline void set_length (int32_t value);
1826 inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(jobject h) : java_lang_Object(h)
1828 com_sun_cldchi_jvm_FileDescriptor((java_handle_t*) h);
1831 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)
1833 set_pointer(pointer);
1834 set_position(position);
1838 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)
1840 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
1844 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
1846 return get<int64_t>(_handle, offset_pointer);
1849 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
1851 return get<int32_t>(_handle, offset_position);
1854 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
1856 return get<int32_t>(_handle, offset_length);
1860 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
1862 set(_handle, offset_pointer, value);
1865 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
1867 set(_handle, offset_position, value);
1870 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
1872 set(_handle, offset_length, value);
1877 * CLDC 1.1 java/lang/String
1886 class java_lang_String : public java_lang_Object, private FieldAccess {
1888 // Static offsets of the object's instance fields.
1889 // TODO These offsets need to be checked on VM startup.
1890 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1891 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1892 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1895 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1896 java_lang_String(jstring h);
1897 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1900 inline java_handle_chararray_t* get_value () const;
1901 inline int32_t get_offset() const;
1902 inline int32_t get_count () const;
1905 inline void set_value (java_handle_chararray_t* value);
1906 inline void set_offset(int32_t value);
1907 inline void set_count (int32_t value);
1910 inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h)
1912 java_lang_String((java_handle_t*) h);
1915 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)
1922 inline java_handle_chararray_t* java_lang_String::get_value() const
1924 return get<java_handle_chararray_t*>(_handle, offset_value);
1927 inline int32_t java_lang_String::get_offset() const
1929 return get<int32_t>(_handle, offset_offset);
1932 inline int32_t java_lang_String::get_count() const
1934 return get<int32_t>(_handle, offset_count);
1937 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1939 set(_handle, offset_value, value);
1942 inline void java_lang_String::set_offset(int32_t value)
1944 set(_handle, offset_offset, value);
1947 inline void java_lang_String::set_count(int32_t value)
1949 set(_handle, offset_count, value);
1954 * CLDC 1.1 java/lang/Thread
1960 * 2. java.lang.Runnable runnable;
1961 * 3. java.lang.Object vm_thread;
1962 * 4. int is_terminated;
1963 * 5. int is_stillborn;
1966 class java_lang_Thread : public java_lang_Object, private FieldAccess {
1968 // Static offsets of the object's instance fields.
1969 // TODO These offsets need to be checked on VM startup.
1970 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1971 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
1972 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
1973 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
1974 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
1975 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
1978 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
1979 java_lang_Thread(jobject h);
1980 // java_lang_Thread(threadobject* t);
1983 inline int32_t get_priority () const;
1984 inline threadobject* get_vm_thread() const;
1985 inline java_handle_chararray_t* get_name () const;
1988 inline void set_vm_thread(threadobject* value);
1992 inline java_lang_Thread::java_lang_Thread(jobject h) : java_lang_Object(h)
1994 java_lang_Thread((java_handle_t*) h);
1997 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
1999 // java_lang_Thread(thread_get_object(t));
2003 inline int32_t java_lang_Thread::get_priority() const
2005 return get<int32_t>(_handle, offset_priority);
2008 inline threadobject* java_lang_Thread::get_vm_thread() const
2010 return get<threadobject*>(_handle, offset_vm_thread);
2013 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2015 return get<java_handle_chararray_t*>(_handle, offset_name);
2019 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2021 set(_handle, offset_vm_thread, value);
2026 * CLDC 1.1 java/lang/Throwable
2031 * 1. java.lang.String detailMessage;
2032 * 2. java.lang.Object backtrace;
2034 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2036 // Static offsets of the object's instance fields.
2037 // TODO These offsets need to be checked on VM startup.
2038 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2039 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2042 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2043 java_lang_Throwable(jobject h);
2046 inline java_handle_t* get_detailMessage() const;
2047 inline java_handle_bytearray_t* get_backtrace () const;
2050 inline void set_backtrace(java_handle_bytearray_t* value);
2054 inline java_lang_Throwable::java_lang_Throwable(jobject h) : java_lang_Object(h)
2056 java_lang_Throwable((java_handle_t*) h);
2060 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2062 return get<java_handle_t*>(_handle, offset_detailMessage);
2065 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2067 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2071 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2073 set(_handle, offset_backtrace, value);
2076 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2080 // Legacy C interface.
2081 java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m);
2082 java_handle_t* java_lang_reflect_Field_create(fieldinfo* f);
2083 java_handle_t* java_lang_reflect_Method_create(methodinfo* m);
2087 #endif // _JAVAOBJECTS_HPP
2091 * These are local overrides for various environment variables in Emacs.
2092 * Please do not remove this and leave it at the end of the file, where
2093 * Emacs will automagically detect them.
2094 * ---------------------------------------------------------------------
2097 * indent-tabs-mode: t