1 /* src/vm/javaobjects.hpp - functions to create and access Java objects
3 Copyright (C) 2010, 2011
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 Copyright (C) 2008, 2009 Theobroma Systems Ltd.
7 This file is part of CACAO.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2, or (at
12 your option) any later version.
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 #ifndef _JAVAOBJECTS_HPP
28 #define _JAVAOBJECTS_HPP
34 #include "mm/memory.hpp"
36 #include "native/llni.h"
38 #include "threads/atomic.hpp"
40 #include "vm/class.hpp"
41 #include "vm/field.hpp"
42 #include "vm/global.h"
43 #include "vm/globals.hpp"
44 #include "vm/method.hpp"
50 * This class provides low-level functions to access Java object
53 * These functions do NOT take care about the GC critical section!
54 * Please use FieldAccess wherever possible.
56 class RawFieldAccess {
58 template<class T> static inline T raw_get(void* address, const off_t offset);
59 template<class T> static inline void raw_set(void* address, const off_t offset, T value);
63 template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
65 T* p = (T*) (((uintptr_t) address) + offset);
70 template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
72 T* p = (T*) (((uintptr_t) address) + offset);
78 * This classes provides functions to access Java object instance
79 * fields. These functions enter a critical GC section before
80 * accessing the Java object throught the handle and leave it
83 class FieldAccess : private RawFieldAccess {
85 // Normal field accessors.
86 template<class T> static inline T get(java_handle_t* h, const off_t offset);
87 template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
89 // Volatile field accessors.
90 template<class T> static inline T get_volatile(java_handle_t* h, const off_t offset);
91 template<class T> static inline void set_volatile(java_handle_t* h, const off_t offset, T value);
95 template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
97 // This function is inside a critical section.
100 // XXX This should be _handle->get_object();
101 java_object_t* ho = LLNI_UNWRAP(h);
102 return raw_get<T>(ho, offset);
105 template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
107 // This function is inside a critical section.
108 GCCriticalSection cs;
110 // XXX This should be _handle->get_object();
111 java_object_t* o = LLNI_UNWRAP(h);
112 java_object_t* result = raw_get<java_object_t*>(o, offset);
113 return LLNI_WRAP(result);
117 template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
119 // This function is inside a critical section.
120 GCCriticalSection cs;
122 java_object_t* ho = LLNI_UNWRAP(h);
123 raw_set(ho, offset, value);
126 template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
128 // This function is inside a critical section.
129 GCCriticalSection cs;
131 // XXX This should be h->get_object();
132 java_object_t* o = LLNI_UNWRAP(h);
133 java_object_t* ovalue = LLNI_UNWRAP(value);
134 raw_set(o, offset, ovalue);
138 template<class T> inline T FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
140 // This function is inside a critical section.
141 GCCriticalSection cs;
143 // XXX This should be _handle->get_object();
144 java_object_t* ho = LLNI_UNWRAP(h);
145 return raw_get<volatile T>(ho, offset);
148 template<> inline java_handle_t* FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
150 // This function is inside a critical section.
151 GCCriticalSection cs;
153 // XXX This should be _handle->get_object();
154 java_object_t* o = LLNI_UNWRAP(h);
155 java_object_t* result = (java_object_t*) raw_get<volatile java_object_t*>(o, offset);
156 return LLNI_WRAP(result);
160 template<class T> inline void FieldAccess::set_volatile(java_handle_t* h, const off_t offset, T value)
162 // This function is inside a critical section.
163 GCCriticalSection cs;
165 java_object_t* ho = LLNI_UNWRAP(h);
166 raw_set(ho, offset, (volatile T) value);
168 // Memory barrier for the Java Memory Model.
169 Atomic::memory_barrier();
172 template<> inline void FieldAccess::set_volatile<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
174 // This function is inside a critical section.
175 GCCriticalSection cs;
177 // XXX This should be h->get_object();
178 java_object_t* o = LLNI_UNWRAP(h);
179 java_object_t* ovalue = LLNI_UNWRAP(value);
180 raw_set(o, offset, (volatile java_object_t*) ovalue);
182 // Memory barrier for the Java Memory Model.
183 Atomic::memory_barrier();
194 class java_lang_Object {
196 // Handle of Java object.
197 java_handle_t* _handle;
200 java_lang_Object() : _handle(NULL) {}
201 java_lang_Object(java_handle_t* h) : _handle(h) {}
202 virtual ~java_lang_Object() {}
205 virtual java_handle_t* get_handle () const { return _handle; }
206 vftbl_t* get_vftbl () const;
207 classinfo* get_Class () const;
208 int32_t get_hashcode() const;
210 bool is_null () const;
211 bool is_non_null() const;
215 inline vftbl_t* java_lang_Object::get_vftbl() const
217 // This function is inside a critical section.
218 GCCriticalSection cs;
220 // XXX This should be h->get_object();
221 java_object_t* o = LLNI_UNWRAP(_handle);
225 inline classinfo* java_lang_Object::get_Class() const
227 return get_vftbl()->clazz;
230 inline int32_t java_lang_Object::get_hashcode() const
232 #if defined(ENABLE_GC_CACAO)
233 return heap_get_hashcode(_handle);
235 // This function is inside a critical section.
236 GCCriticalSection cs;
238 // XXX This should be h->get_object();
239 java_object_t* o = LLNI_UNWRAP(_handle);
240 return (int32_t) (intptr_t) o;
245 inline bool java_lang_Object::is_null() const
247 return (_handle == NULL);
250 inline bool java_lang_Object::is_non_null() const
252 return (_handle != NULL);
264 class java_lang_Boolean : 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_Boolean(java_handle_t* h) : java_lang_Object(h) {}
274 void set_value(uint8_t value);
277 inline uint8_t java_lang_Boolean::get_value()
279 return get<int32_t>(_handle, offset_value);
282 inline void java_lang_Boolean::set_value(uint8_t value)
284 set(_handle, offset_value, (uint32_t) value);
296 class java_lang_Byte : 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_Byte(java_handle_t* h) : java_lang_Object(h) {}
306 void set_value(int8_t value);
309 inline int8_t java_lang_Byte::get_value()
311 return get<int32_t>(_handle, offset_value);
314 inline void java_lang_Byte::set_value(int8_t value)
316 set(_handle, offset_value, (int32_t) value);
321 * java/lang/Character
328 class java_lang_Character : 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_Character(java_handle_t* h) : java_lang_Object(h) {}
337 uint16_t get_value();
338 void set_value(uint16_t value);
341 inline uint16_t java_lang_Character::get_value()
343 return get<int32_t>(_handle, offset_value);
346 inline void java_lang_Character::set_value(uint16_t value)
348 set(_handle, offset_value, (uint32_t) value);
360 class java_lang_Short : 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_Short(java_handle_t* h) : java_lang_Object(h) {}
370 void set_value(int16_t value);
373 inline int16_t java_lang_Short::get_value()
375 return get<int32_t>(_handle, offset_value);
378 inline void java_lang_Short::set_value(int16_t value)
380 set(_handle, offset_value, (int32_t) value);
392 class java_lang_Integer : 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(int32_t));
399 java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
402 void set_value(int32_t value);
405 inline int32_t java_lang_Integer::get_value()
407 return get<int32_t>(_handle, offset_value);
410 inline void java_lang_Integer::set_value(int32_t value)
412 set(_handle, offset_value, value);
424 class java_lang_Long : 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(int64_t));
431 java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
434 void set_value(int64_t value);
437 inline int64_t java_lang_Long::get_value()
439 return get<int64_t>(_handle, offset_value);
442 inline void java_lang_Long::set_value(int64_t value)
444 set(_handle, offset_value, value);
456 class java_lang_Float : 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(float));
463 java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
466 void set_value(float value);
469 inline float java_lang_Float::get_value()
471 return get<float>(_handle, offset_value);
474 inline void java_lang_Float::set_value(float value)
476 set(_handle, offset_value, value);
488 class java_lang_Double : public java_lang_Object, private FieldAccess {
490 // Static offsets of the object's instance fields.
491 // TODO These offsets need to be checked on VM startup.
492 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
495 java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
498 void set_value(double value);
501 inline double java_lang_Double::get_value()
503 return get<double>(_handle, offset_value);
506 inline void java_lang_Double::set_value(double value)
508 set(_handle, offset_value, value);
512 #if defined(ENABLE_JAVASE)
515 * java/lang/management/MemoryUsage
520 * [other fields are not used]
522 class java_lang_management_MemoryUsage : public java_lang_Object, private FieldAccess {
524 java_lang_management_MemoryUsage(java_handle_t* h) : java_lang_Object(h) {}
525 java_lang_management_MemoryUsage(int64_t init, int64_t used, int64_t commited, int64_t maximum);
529 # if defined(ENABLE_ANNOTATIONS)
531 * OpenJDK sun/reflect/ConstantPool
536 * 1. java.lang.Object constantPoolOop;
538 class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
540 // Static offsets of the object's instance fields.
541 // TODO These offsets need to be checked on VM startup.
542 static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
545 sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
546 sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
549 void set_constantPoolOop(classinfo* value);
550 void set_constantPoolOop(jclass value);
554 inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
556 set_constantPoolOop(constantPoolOop);
560 inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
562 set(_handle, offset_constantPoolOop, value);
565 inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
567 // XXX jclass is a boxed object.
568 set_constantPoolOop(LLNI_classinfo_unwrap(value));
570 # endif // ENABLE_ANNOTATIONS
572 #endif // ENABLE_JAVASE
574 void jobjects_register_dyn_offsets();
575 bool jobjects_run_dynoffsets_hook(classinfo *c);
577 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
580 * GNU Classpath java/lang/Class
585 * 1. java.lang.Object[] signers;
586 * 2. java.security.ProtectionDomain pd;
587 * 3. java.lang.Object vmdata;
588 * 4. java.lang.reflect.Constructor constructor;
590 class java_lang_Class : public java_lang_Object, private FieldAccess {
592 // Static offsets of the object's instance fields.
593 // TODO These offsets need to be checked on VM startup.
594 static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
595 static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
596 static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
597 static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
600 java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
603 void set_pd(java_handle_t* value);
606 inline void java_lang_Class::set_pd(java_handle_t* value)
608 set(_handle, offset_pd, value);
613 * GNU Classpath java/lang/ClassLoader
618 * 1. java.util.HashMap definedPackages
619 * 2. java.lang.ClassLoader parent
620 * [other fields are not used]
622 class java_lang_ClassLoader : 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_definedPackages = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
627 static const off_t offset_parent = MEMORY_ALIGN(offset_definedPackages + SIZEOF_VOID_P, SIZEOF_VOID_P);
630 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
633 java_handle_t* get_parent() const;
635 // Invocation wrappers for static methods.
636 static java_handle_t* invoke_getSystemClassLoader();
639 inline java_handle_t* java_lang_ClassLoader::get_parent() const
641 return get<java_handle_t*>(_handle, offset_parent);
646 * GNU Classpath java/lang/StackTraceElement
651 * 1. java.lang.String fileName;
653 * 3. java.lang.String declaringClass;
654 * 4. java.lang.String methodName;
655 * 5. boolean isNative;
657 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
659 // Static offsets of the object's instance fields.
660 // TODO These offsets need to be checked on VM startup.
661 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
662 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
663 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
664 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
665 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
668 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
669 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);
672 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)
674 java_lang_StackTraceElement((java_handle_t*) h);
676 set(_handle, offset_fileName, fileName);
677 set(_handle, offset_lineNumber, lineNumber);
678 set(_handle, offset_declaringClass, declaringClass);
679 set(_handle, offset_methodName, methodName);
680 set(_handle, offset_isNative, isNative);
685 * GNU Classpath java/lang/String
692 * 3. int cachedHashCode;
695 class java_lang_String : public java_lang_Object, private FieldAccess {
697 // Static offsets of the object's instance fields.
698 // TODO These offsets need to be checked on VM startup.
699 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
700 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
701 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
702 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
705 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
706 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
709 java_handle_chararray_t* get_value () const;
710 int32_t get_count () const;
711 int32_t get_offset() const;
714 void set_value (java_handle_chararray_t* value);
715 void set_count (int32_t value);
716 void set_offset(int32_t value);
719 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)
726 inline java_handle_chararray_t* java_lang_String::get_value() const
728 return get<java_handle_chararray_t*>(_handle, offset_value);
731 inline int32_t java_lang_String::get_count() const
733 return get<int32_t>(_handle, offset_count);
736 inline int32_t java_lang_String::get_offset() const
738 return get<int32_t>(_handle, offset_offset);
741 inline void java_lang_String::set_value(java_handle_chararray_t* value)
743 set(_handle, offset_value, value);
746 inline void java_lang_String::set_count(int32_t value)
748 set(_handle, offset_count, value);
751 inline void java_lang_String::set_offset(int32_t value)
753 set(_handle, offset_offset, value);
758 * GNU Classpath java/lang/Thread
763 * 1. java.lang.VMThread vmThread;
764 * 2. java.lang.ThreadGroup group;
765 * 3. java.lang.Runnable runnable;
766 * 4. java.lang.String name;
770 * 8. java.lang.Throwable stillborn;
771 * 9. java.lang.ClassLoader contextClassLoader;
772 * 10. boolean contextClassLoaderIsSystemClassLoader;
774 * 12. java.lang.Object parkBlocker;
775 * 13. gnu.java.util.WeakIdentityHashMap locals;
776 * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
778 class java_lang_Thread : public java_lang_Object, private FieldAccess {
780 // Static offsets of the object's instance fields.
781 // TODO These offsets need to be checked on VM startup.
782 static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
783 static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
784 static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
785 static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
786 static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
787 static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
788 static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
789 static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
790 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
791 static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
792 static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
793 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
794 static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
795 static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
798 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
799 // java_lang_Thread(threadobject* t);
802 java_handle_t* get_vmThread () const;
803 java_handle_t* get_group () const;
804 java_handle_t* get_name () const;
805 int32_t get_daemon () const;
806 int32_t get_priority () const;
807 java_handle_t* get_exceptionHandler() const;
810 void set_group(java_handle_t* value);
814 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
816 // java_lang_Thread(thread_get_object(t));
820 inline java_handle_t* java_lang_Thread::get_vmThread() const
822 return get<java_handle_t*>(_handle, offset_vmThread);
825 inline java_handle_t* java_lang_Thread::get_group() const
827 return get<java_handle_t*>(_handle, offset_group);
830 inline java_handle_t* java_lang_Thread::get_name() const
832 return get<java_handle_t*>(_handle, offset_name);
835 inline int32_t java_lang_Thread::get_daemon() const
837 return get<int32_t>(_handle, offset_daemon);
840 inline int32_t java_lang_Thread::get_priority() const
842 return get<int32_t>(_handle, offset_priority);
845 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
847 return get<java_handle_t*>(_handle, offset_exceptionHandler);
851 inline void java_lang_Thread::set_group(java_handle_t* value)
853 set(_handle, offset_group, value);
858 * GNU Classpath java/lang/VMThread
863 * 1. java.lang.Thread thread;
864 * 2. boolean running;
865 * 3. java.lang.VMThread vmdata;
867 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
869 // Static offsets of the object's instance fields.
870 // TODO These offsets need to be checked on VM startup.
871 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
872 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
873 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
876 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
877 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
880 java_handle_t* get_thread() const;
881 threadobject* get_vmdata() const;
884 void set_thread(java_handle_t* value);
885 void set_vmdata(threadobject* value);
889 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
896 inline java_handle_t* java_lang_VMThread::get_thread() const
898 return get<java_handle_t*>(_handle, offset_thread);
901 inline threadobject* java_lang_VMThread::get_vmdata() const
903 return get<threadobject*>(_handle, offset_vmdata);
907 inline void java_lang_VMThread::set_thread(java_handle_t* value)
909 set(_handle, offset_thread, value);
912 inline void java_lang_VMThread::set_vmdata(threadobject* value)
914 set(_handle, offset_vmdata, value);
919 * GNU Classpath java/lang/Throwable
924 * 1. java.lang.String detailMessage;
925 * 2. java.lang.Throwable cause;
926 * 3. java.lang.StackTraceElement[] stackTrace;
927 * 4. java.lang.VMThrowable vmState;
929 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
931 // Static offsets of the object's instance fields.
932 // TODO These offsets need to be checked on VM startup.
933 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
934 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
935 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
936 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
939 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
942 java_handle_t* get_detailMessage() const;
943 java_handle_t* get_cause () const;
944 java_handle_t* get_vmState () const;
948 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
950 return get<java_handle_t*>(_handle, offset_detailMessage);
953 inline java_handle_t* java_lang_Throwable::get_cause() const
955 return get<java_handle_t*>(_handle, offset_cause);
958 inline java_handle_t* java_lang_Throwable::get_vmState() const
960 return get<java_handle_t*>(_handle, offset_vmState);
965 * GNU Classpath java/lang/VMThrowable
970 * 1. java.lang.Object vmdata;
972 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
974 // Static offsets of the object's instance fields.
975 // TODO These offsets need to be checked on VM startup.
976 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
979 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
981 java_handle_bytearray_t* get_vmdata() const;
982 void set_vmdata(java_handle_bytearray_t* value);
986 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
988 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
991 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
993 set(_handle, offset_vmdata, value);
998 * GNU Classpath java/lang/reflect/VMConstructor
1003 * 1. java.lang.Class clazz;
1005 * 3. byte[] annotations;
1006 * 4. byte[] parameterAnnotations;
1007 * 5. java.util.Map declaredAnnotations;
1008 * 6. java.lang.reflect.Constructor cons;
1010 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
1012 // Static offsets of the object's instance fields.
1013 // TODO These offsets need to be checked on VM startup.
1014 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1015 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
1016 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1017 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1018 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1019 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1022 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
1023 java_lang_reflect_VMConstructor(methodinfo* m);
1026 classinfo* get_clazz () const;
1027 int32_t get_slot () const;
1028 java_handle_bytearray_t* get_annotations () const;
1029 java_handle_bytearray_t* get_parameterAnnotations() const;
1030 java_handle_t* get_declaredAnnotations () const;
1031 java_handle_t* get_cons () const;
1034 void set_clazz (classinfo* value);
1035 void set_slot (int32_t value);
1036 void set_annotations (java_handle_bytearray_t* value);
1037 void set_parameterAnnotations(java_handle_bytearray_t* value);
1038 void set_declaredAnnotations (java_handle_t* value);
1039 void set_cons (java_handle_t* value);
1041 // Convenience functions.
1042 methodinfo* get_method();
1046 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
1048 _handle = builtin_new(class_java_lang_reflect_VMConstructor);
1053 int slot = m - m->clazz->methods;
1054 java_handle_bytearray_t* annotations = method_get_annotations(m);
1055 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1057 set_clazz(m->clazz);
1059 set_annotations(annotations);
1060 set_parameterAnnotations(parameterAnnotations);
1064 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1066 return get<classinfo*>(_handle, offset_clazz);
1069 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1071 return get<int32_t>(_handle, offset_slot);
1074 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1076 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1079 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1081 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1084 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1086 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1089 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1091 return get<java_handle_t*>(_handle, offset_cons);
1094 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1096 set(_handle, offset_clazz, value);
1099 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1101 set(_handle, offset_slot, value);
1104 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1106 set(_handle, offset_annotations, value);
1109 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1111 set(_handle, offset_parameterAnnotations, value);
1114 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1116 set(_handle, offset_declaredAnnotations, value);
1119 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1121 set(_handle, offset_cons, value);
1124 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1126 classinfo* c = get_clazz();
1127 int32_t slot = get_slot();
1128 methodinfo* m = &(c->methods[slot]);
1134 * GNU Classpath java/lang/reflect/Constructor
1140 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1141 * 3. java.lang.reflect.VMConstructor cons;
1143 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
1145 // Static offsets of the object's instance fields.
1146 // TODO These offsets need to be checked on VM startup.
1147 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1148 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1149 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1152 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
1153 java_lang_reflect_Constructor(methodinfo* m);
1155 java_handle_t* new_instance(java_handle_objectarray_t* args);
1158 int32_t get_flag() const;
1159 java_handle_t* get_cons() const;
1162 void set_cons(java_handle_t* value);
1164 // Convenience functions.
1165 methodinfo* get_method () const;
1166 int32_t get_override() const;
1170 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
1172 java_lang_reflect_VMConstructor jlrvmc(m);
1174 if (jlrvmc.is_null())
1177 _handle = builtin_new(class_java_lang_reflect_Constructor);
1182 // Link the two Java objects.
1183 set_cons(jlrvmc.get_handle());
1184 jlrvmc.set_cons(get_handle());
1188 inline int32_t java_lang_reflect_Constructor::get_flag() const
1190 return get<int32_t>(_handle, offset_flag);
1193 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
1195 return get<java_handle_t*>(_handle, offset_cons);
1199 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
1201 set(_handle, offset_cons, value);
1205 inline methodinfo* java_lang_reflect_Constructor::get_method() const
1207 java_lang_reflect_VMConstructor jlrvmc(get_cons());
1208 return jlrvmc.get_method();
1211 inline int32_t java_lang_reflect_Constructor::get_override() const
1218 * GNU Classpath java/lang/reflect/VMField
1223 * 1. java.lang.Class clazz;
1224 * 2. java.lang.String name;
1226 * 4. byte[] annotations;
1227 * 5. java.lang.Map declaredAnnotations;
1228 * 6. java.lang.reflect.Field f;
1230 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1232 // Static offsets of the object's instance fields.
1233 // TODO These offsets need to be checked on VM startup.
1234 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1235 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1236 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1237 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1238 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1239 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1242 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1243 java_lang_reflect_VMField(fieldinfo* f);
1246 classinfo* get_clazz () const;
1247 int32_t get_slot () const;
1248 java_handle_bytearray_t* get_annotations () const;
1249 java_handle_t* get_declaredAnnotations() const;
1250 java_handle_t* get_f () const;
1253 void set_clazz (classinfo* value);
1254 void set_name (java_handle_t* value);
1255 void set_slot (int32_t value);
1256 void set_annotations (java_handle_bytearray_t* value);
1257 void set_declaredAnnotations(java_handle_t* value);
1258 void set_f (java_handle_t* value);
1260 // Convenience functions.
1261 fieldinfo* get_field() const;
1265 inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
1267 _handle = builtin_new(class_java_lang_reflect_VMField);
1272 java_handle_t* name = javastring_intern(javastring_new(f->name));
1273 int slot = f - f->clazz->fields;
1274 java_handle_bytearray_t* annotations = field_get_annotations(f);
1276 set_clazz(f->clazz);
1279 set_annotations(annotations);
1283 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1285 return get<classinfo*>(_handle, offset_clazz);
1288 inline int32_t java_lang_reflect_VMField::get_slot() const
1290 return get<int32_t>(_handle, offset_slot);
1293 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1295 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1298 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1300 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1303 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1305 return get<java_handle_t*>(_handle, offset_f);
1309 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1311 set(_handle, offset_clazz, value);
1314 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1316 set(_handle, offset_name, value);
1319 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1321 set(_handle, offset_slot, value);
1324 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1326 set(_handle, offset_annotations, value);
1329 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1331 set(_handle, offset_declaredAnnotations, value);
1334 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1336 set(_handle, offset_f, value);
1339 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1341 classinfo* c = get_clazz();
1342 int32_t slot = get_slot();
1343 fieldinfo* f = &(c->fields[slot]);
1349 * GNU Classpath java/lang/reflect/Field
1355 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1356 * 3. java.lang.reflect.VMField f;
1358 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1360 // Static offsets of the object's instance fields.
1361 // TODO These offsets need to be checked on VM startup.
1362 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1363 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1364 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1367 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1368 java_lang_reflect_Field(fieldinfo* f);
1371 int32_t get_flag() const;
1372 java_handle_t* get_f() const;
1375 void set_f(java_handle_t* value);
1377 // Convenience functions.
1378 fieldinfo* get_field() const;
1382 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
1384 java_lang_reflect_VMField jlrvmf(f);
1386 if (jlrvmf.is_null())
1389 _handle = builtin_new(class_java_lang_reflect_Field);
1394 // Link the two Java objects.
1395 set_f(jlrvmf.get_handle());
1396 jlrvmf.set_f(get_handle());
1400 inline int32_t java_lang_reflect_Field::get_flag() const
1402 return get<int32_t>(_handle, offset_flag);
1405 inline java_handle_t* java_lang_reflect_Field::get_f() const
1407 return get<java_handle_t*>(_handle, offset_f);
1411 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1413 set(_handle, offset_f, value);
1417 inline fieldinfo* java_lang_reflect_Field::get_field() const
1419 java_lang_reflect_VMField jlrvmf(get_f());
1420 return jlrvmf.get_field();
1425 * GNU Classpath java/lang/reflect/VMMethod
1430 * 1. java.lang.Class clazz;
1431 * 2. java.lang.String name;
1433 * 4. byte[] annotations;
1434 * 5. byte[] parameterAnnotations;
1435 * 6. byte[] annotationDefault;
1436 * 7. java.lang.Map declaredAnnotations;
1437 * 8. java.lang.reflect.Method m;
1439 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1441 // Static offsets of the object's instance fields.
1442 // TODO These offsets need to be checked on VM startup.
1443 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1444 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1445 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1446 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1447 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1448 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1449 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1450 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1453 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1454 java_lang_reflect_VMMethod(methodinfo* m);
1457 classinfo* get_clazz () const;
1458 int32_t get_slot () const;
1459 java_handle_bytearray_t* get_annotations () const;
1460 java_handle_bytearray_t* get_parameterAnnotations() const;
1461 java_handle_bytearray_t* get_annotationDefault () const;
1462 java_handle_t* get_declaredAnnotations () const;
1463 java_handle_t* get_m () const;
1466 void set_clazz (classinfo* value);
1467 void set_name (java_handle_t* value);
1468 void set_slot (int32_t value);
1469 void set_annotations (java_handle_bytearray_t* value);
1470 void set_parameterAnnotations(java_handle_bytearray_t* value);
1471 void set_annotationDefault (java_handle_bytearray_t* value);
1472 void set_declaredAnnotations (java_handle_t* value);
1473 void set_m (java_handle_t* value);
1475 // Convenience functions.
1476 methodinfo* get_method() const;
1480 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
1482 _handle = builtin_new(class_java_lang_reflect_VMMethod);
1487 java_handle_t* name = javastring_intern(javastring_new(m->name));
1488 int slot = m - m->clazz->methods;
1489 java_handle_bytearray_t* annotations = method_get_annotations(m);
1490 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1491 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1493 set_clazz(m->clazz);
1496 set_annotations(annotations);
1497 set_parameterAnnotations(parameterAnnotations);
1498 set_annotationDefault(annotationDefault);
1501 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1503 return get<classinfo*>(_handle, offset_clazz);
1506 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1508 return get<int32_t>(_handle, offset_slot);
1511 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1513 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1516 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1518 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1521 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1523 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1526 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1528 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1531 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1533 return get<java_handle_t*>(_handle, offset_m);
1536 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1538 set(_handle, offset_clazz, value);
1541 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1543 set(_handle, offset_name, value);
1546 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1548 set(_handle, offset_slot, value);
1551 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1553 set(_handle, offset_annotations, value);
1556 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1558 set(_handle, offset_parameterAnnotations, value);
1561 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1563 set(_handle, offset_annotationDefault, value);
1566 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1568 set(_handle, offset_declaredAnnotations, value);
1571 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1573 set(_handle, offset_m, value);
1576 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1578 classinfo* c = get_clazz();
1579 int32_t slot = get_slot();
1580 methodinfo* m = &(c->methods[slot]);
1586 * GNU Classpath java/lang/reflect/Method
1592 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1593 * 3. java.lang.reflect.VMMethod m;
1595 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1597 // Static offsets of the object's instance fields.
1598 // TODO These offsets need to be checked on VM startup.
1599 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1600 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1601 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1604 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1605 java_lang_reflect_Method(methodinfo* m);
1607 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
1610 int32_t get_flag() const;
1611 java_handle_t* get_m() const;
1614 void set_m(java_handle_t* value);
1616 // Convenience functions.
1617 methodinfo* get_method () const;
1618 int32_t get_override() const;
1622 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
1624 java_lang_reflect_VMMethod jlrvmm(m);
1626 if (jlrvmm.is_null())
1629 _handle = builtin_new(class_java_lang_reflect_Method);
1634 // Link the two Java objects.
1635 set_m(jlrvmm.get_handle());
1636 jlrvmm.set_m(get_handle());
1640 inline int32_t java_lang_reflect_Method::get_flag() const
1642 return get<int32_t>(_handle, offset_flag);
1645 inline java_handle_t* java_lang_reflect_Method::get_m() const
1647 return get<java_handle_t*>(_handle, offset_m);
1651 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1653 set(_handle, offset_m, value);
1657 inline methodinfo* java_lang_reflect_Method::get_method() const
1659 java_lang_reflect_VMMethod jlrvmm(get_m());
1660 return jlrvmm.get_method();
1663 inline int32_t java_lang_reflect_Method::get_override() const
1670 * GNU Classpath java/nio/Buffer
1679 * 5. gnu.classpath.Pointer address;
1681 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1683 // Static offsets of the object's instance fields.
1684 // TODO These offsets need to be checked on VM startup.
1685 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1686 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1687 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1688 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1689 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1692 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1695 int32_t get_cap() const;
1698 inline int32_t java_nio_Buffer::get_cap() const
1700 return get<int32_t>(_handle, offset_cap);
1705 * GNU Classpath java/nio/DirectByteBufferImpl
1714 * 5. gnu.classpath.Pointer address;
1715 * 6. java.nio.ByteOrder endian;
1716 * 7. byte[] backing_buffer;
1717 * 8. int array_offset;
1718 * 9. java.lang.Object owner;
1720 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1722 // Static offsets of the object's instance fields.
1723 // TODO These offsets need to be checked on VM startup.
1724 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1725 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1726 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1727 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1728 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1729 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1730 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1731 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1732 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1735 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1738 java_handle_t* get_address() const;
1742 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1744 return get<java_handle_t*>(_handle, offset_address);
1749 * GNU Classpath gnu/classpath/Pointer
1751 * Actually there are two classes, gnu.classpath.Pointer32 and
1752 * gnu.classpath.Pointer64, but we only define the abstract super
1753 * class and use the int/long field as void* type.
1760 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1762 // Static offsets of the object's instance fields.
1763 // TODO These offsets need to be checked on VM startup.
1764 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1767 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1768 gnu_classpath_Pointer(java_handle_t* h, void* data);
1771 void* get_data() const;
1774 void set_data(void* value);
1777 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1782 inline void* gnu_classpath_Pointer::get_data() const
1784 return get<void*>(_handle, offset_data);
1787 inline void gnu_classpath_Pointer::set_data(void* value)
1789 set(_handle, offset_data, value);
1792 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1795 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1798 * OpenJDK java/lang/AssertionStatusDirectives
1803 * 1. java.lang.String[] classes;
1804 * 2. boolean[] classEnabled;
1805 * 3. java.lang.String[] packages;
1806 * 4. boolean[] packageEnabled;
1809 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1811 // Static offsets of the object's instance fields.
1812 // TODO These offsets need to be checked on VM startup.
1813 static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1814 static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1815 static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1816 static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1817 static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1820 java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1823 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)
1825 classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1827 // FIXME Load the class at VM startup.
1831 _handle = builtin_new(c);
1836 set(_handle, offset_classes, classes);
1837 set(_handle, offset_classEnabled, classEnabled);
1838 set(_handle, offset_packages, packages);
1839 set(_handle, offset_packageEnabled, packageEnabled);
1844 * OpenJDK java/lang/ClassLoader
1849 * 1. boolean initialized
1850 * 2. java.lang.ClassLoader parent
1851 * [other fields are not used]
1853 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
1855 // Static offsets of the object's instance fields.
1856 // TODO These offsets need to be checked on VM startup.
1857 static const off_t offset_initialized = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1858 static const off_t offset_parent = MEMORY_ALIGN(offset_initialized + sizeof(int32_t), SIZEOF_VOID_P);
1861 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
1864 java_handle_t* get_parent() const;
1866 // Invocation wrappers for static methods.
1867 static java_handle_t* invoke_getSystemClassLoader();
1870 inline java_handle_t* java_lang_ClassLoader::get_parent() const
1872 return get<java_handle_t*>(_handle, offset_parent);
1877 * OpenJDK java/lang/StackTraceElement
1882 * 1. java.lang.String declaringClass;
1883 * 2. java.lang.String methodName;
1884 * 3. java.lang.String fileName;
1885 * 4. int lineNumber;
1887 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
1889 // Static offsets of the object's instance fields.
1890 // TODO These offsets need to be checked on VM startup.
1891 static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1892 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1893 static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1894 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1897 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
1898 java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1901 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1903 _handle = builtin_new(class_java_lang_StackTraceElement);
1908 set(_handle, offset_declaringClass, declaringClass);
1909 set(_handle, offset_methodName, methodName);
1910 set(_handle, offset_fileName, fileName);
1911 set(_handle, offset_lineNumber, lineNumber);
1916 * OpenJDK java/lang/String
1926 class java_lang_String : public java_lang_Object, private FieldAccess {
1928 // Static offsets of the object's instance fields.
1929 // TODO These offsets need to be checked on VM startup.
1930 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1931 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1932 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1933 static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
1936 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1937 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1940 java_handle_chararray_t* get_value () const;
1941 int32_t get_offset() const;
1942 int32_t get_count () const;
1945 void set_value (java_handle_chararray_t* value);
1946 void set_offset(int32_t value);
1947 void set_count (int32_t value);
1950 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)
1957 inline java_handle_chararray_t* java_lang_String::get_value() const
1959 return get<java_handle_chararray_t*>(_handle, offset_value);
1962 inline int32_t java_lang_String::get_offset() const
1964 return get<int32_t>(_handle, offset_offset);
1967 inline int32_t java_lang_String::get_count() const
1969 return get<int32_t>(_handle, offset_count);
1972 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1974 set(_handle, offset_value, value);
1977 inline void java_lang_String::set_offset(int32_t value)
1979 set(_handle, offset_offset, value);
1982 inline void java_lang_String::set_count(int32_t value)
1984 set(_handle, offset_count, value);
1989 * OpenJDK java/lang/Thread
1996 * 3. java_lang_Thread threadQ;
1998 * 5. boolean single_step;
1999 * 6. boolean daemon;
2000 * 7. boolean stillborn;
2001 * 8. java_lang_Runnable target;
2002 * 9. java_lang_ThreadGroup group;
2003 * 10. java_lang_ClassLoader contextClassLoader;
2004 * 11. java_security_AccessControlContext inheritedAccessControlContext;
2005 * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals;
2006 * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals;
2007 * 14. long stackSize;
2008 * 15. long nativeParkEventPointer;
2010 * 17. int threadStatus;
2011 * 18. java_lang_Object parkBlocker;
2012 * 19. sun_nio_ch_Interruptible blocker;
2013 * 20. java_lang_Object blockerLock;
2014 * 21. boolean stopBeforeStart;
2015 * 22. java_lang_Throwable throwableFromStop;
2016 * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
2018 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2020 // Static offsets of the object's instance fields.
2021 // TODO These offsets need to be checked on VM startup.
2022 static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2023 static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
2024 static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2025 static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t));
2026 static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t));
2027 static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t));
2028 static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
2029 static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2030 static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P);
2031 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
2032 static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
2033 static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P);
2034 static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P);
2035 static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t));
2036 static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t));
2037 static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t));
2038 static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t));
2039 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P);
2040 static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
2041 static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
2042 static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t));
2043 static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P);
2044 static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P);
2047 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2048 // java_lang_Thread(threadobject* t);
2051 int32_t get_priority () const;
2052 int32_t get_daemon () const;
2053 java_handle_t* get_group () const;
2054 java_handle_t* get_uncaughtExceptionHandler() const;
2057 void set_priority (int32_t value);
2058 void set_group (java_handle_t* value);
2059 void set_threadStatus(int32_t value);
2063 inline int32_t java_lang_Thread::get_priority() const
2065 return get<int32_t>(_handle, offset_priority);
2068 inline int32_t java_lang_Thread::get_daemon() const
2070 return get<int32_t>(_handle, offset_daemon);
2073 inline java_handle_t* java_lang_Thread::get_group() const
2075 return get<java_handle_t*>(_handle, offset_group);
2078 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
2080 return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
2084 inline void java_lang_Thread::set_priority(int32_t value)
2086 set(_handle, offset_priority, value);
2089 inline void java_lang_Thread::set_group(java_handle_t* value)
2091 set(_handle, offset_group, value);
2094 inline void java_lang_Thread::set_threadStatus(int32_t value)
2096 set(_handle, offset_threadStatus, value);
2102 * OpenJDK java/lang/Throwable
2107 * 1. java.lang.Object backtrace;
2108 * 2. java.lang.String detailMessage;
2109 * 3. java.lang.Throwable cause;
2110 * 4. java.lang.StackTraceElement[] stackTrace;
2112 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2114 // Static offsets of the object's instance fields.
2115 // TODO These offsets need to be checked on VM startup.
2116 static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2117 static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2118 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2119 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2122 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2123 java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
2126 java_handle_bytearray_t* get_backtrace () const;
2127 java_handle_t* get_detailMessage() const;
2128 java_handle_t* get_cause () const;
2131 void set_backtrace(java_handle_bytearray_t* value);
2135 inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
2137 set_backtrace(backtrace);
2141 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2143 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2146 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2148 return get<java_handle_t*>(_handle, offset_detailMessage);
2151 inline java_handle_t* java_lang_Throwable::get_cause() const
2153 return get<java_handle_t*>(_handle, offset_cause);
2157 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2159 set(_handle, offset_backtrace, value);
2164 * OpenJDK java/lang/reflect/Constructor
2169 * 1. boolean override;
2170 * 2. java.lang.Class clazz;
2172 * 4. java.lang.Class[] parameterTypes;
2173 * 5. java.lang.Class[] exceptionTypes;
2175 * 7. java.lang.String signature;
2176 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2177 * 9. byte[] annotations;
2178 * 10. byte[] parameterAnnotations;
2179 * 11. java.lang.Class securityCheckCache;
2180 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2181 * 13. java.lang.reflect.Constructor root;
2182 * 14. java.util.Map declaredAnnotations;
2184 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
2186 // Static offsets of the object's instance fields.
2187 // TODO These offsets need to be checked on VM startup.
2188 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2189 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2190 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2191 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2192 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2193 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2194 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2195 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2196 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2197 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2198 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2199 static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2200 static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2201 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2204 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
2205 java_lang_reflect_Constructor(methodinfo* m);
2207 java_handle_t* new_instance(java_handle_objectarray_t* args);
2210 int32_t get_override () const;
2211 classinfo* get_clazz () const;
2212 int32_t get_slot () const;
2213 java_handle_bytearray_t* get_annotations() const;
2216 void set_clazz (classinfo* value);
2217 void set_slot (int32_t value);
2218 void set_parameterTypes (java_handle_objectarray_t* value);
2219 void set_exceptionTypes (java_handle_objectarray_t* value);
2220 void set_modifiers (int32_t value);
2221 void set_signature (java_handle_t* value);
2222 void set_annotations (java_handle_bytearray_t* value);
2223 void set_parameterAnnotations(java_handle_bytearray_t* value);
2225 // Convenience functions.
2226 methodinfo* get_method();
2230 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
2232 _handle = builtin_new(class_java_lang_reflect_Constructor);
2237 int slot = m - m->clazz->methods;
2238 java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
2239 java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
2240 java_handle_bytearray_t* annotations = method_get_annotations(m);
2241 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2243 set_clazz(m->clazz);
2245 set_parameterTypes(parameterTypes);
2246 set_exceptionTypes(exceptionTypes);
2247 set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2248 set_signature(m->signature ? javastring_new(m->signature) : NULL);
2249 set_annotations(annotations);
2250 set_parameterAnnotations(parameterAnnotations);
2254 inline int32_t java_lang_reflect_Constructor::get_override() const
2256 return get<int32_t>(_handle, offset_override);
2259 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2261 return get<classinfo*>(_handle, offset_clazz);
2264 inline int32_t java_lang_reflect_Constructor::get_slot() const
2266 return get<int32_t>(_handle, offset_slot);
2269 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2271 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2275 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2277 set(_handle, offset_clazz, value);
2280 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2282 set(_handle, offset_slot, value);
2285 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2287 set(_handle, offset_parameterTypes, value);
2290 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2292 set(_handle, offset_exceptionTypes, value);
2295 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2297 set(_handle, offset_modifiers, value);
2300 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2302 set(_handle, offset_signature, value);
2305 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2307 set(_handle, offset_annotations, value);
2310 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2312 set(_handle, offset_parameterAnnotations, value);
2316 inline methodinfo* java_lang_reflect_Constructor::get_method()
2318 classinfo* c = get_clazz();
2319 int32_t slot = get_slot();
2320 methodinfo* m = &(c->methods[slot]);
2326 * OpenJDK java/lang/reflect/Field
2331 * 1. boolean override;
2332 * 2. java.lang.Class clazz;
2334 * 4. java.lang.String name;
2335 * 5. java.lang.Class type;
2337 * 7. java.lang.String signature;
2338 * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2339 * 9. byte[] annotations;
2340 * 10. sun.reflect.FieldAccessor fieldAccessor;
2341 * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2342 * 12. java.lang.reflect.Field root;
2343 * 13. java.lang.Class securityCheckCache;
2344 * 14. java.lang.Class securityCheckTargetClassCache;
2345 * 15. java.util.Map declaredAnnotations;
2347 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2349 // Static offsets of the object's instance fields.
2350 // TODO These offsets need to be checked on VM startup.
2351 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2352 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2353 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2354 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2355 static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2356 static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2357 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2358 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2359 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2360 static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2361 static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2362 static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2363 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2364 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2365 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2368 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
2369 java_lang_reflect_Field(fieldinfo* f);
2372 int32_t get_override () const;
2373 classinfo* get_clazz () const;
2374 int32_t get_slot () const;
2375 java_handle_bytearray_t* get_annotations() const;
2378 void set_clazz (classinfo* value);
2379 void set_slot (int32_t value);
2380 void set_name (java_handle_t* value);
2381 void set_type (classinfo* value);
2382 void set_modifiers (int32_t value);
2383 void set_signature (java_handle_t* value);
2384 void set_annotations(java_handle_bytearray_t* value);
2386 // Convenience functions.
2387 fieldinfo* get_field() const;
2391 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
2393 _handle = builtin_new(class_java_lang_reflect_Field);
2399 set_clazz(f->clazz);
2400 set_slot(f - f->clazz->fields);
2401 set_name(javastring_intern(javastring_new(f->name)));
2402 set_type(field_get_type(f));
2403 set_modifiers(f->flags);
2404 set_signature(f->signature ? javastring_new(f->signature) : NULL);
2405 set_annotations(field_get_annotations(f));
2409 inline int32_t java_lang_reflect_Field::get_override() const
2411 return get<int32_t>(_handle, offset_override);
2414 inline classinfo* java_lang_reflect_Field::get_clazz() const
2416 return get<classinfo*>(_handle, offset_clazz);
2419 inline int32_t java_lang_reflect_Field::get_slot() const
2421 return get<int32_t>(_handle, offset_slot);
2424 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2426 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2430 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2432 set(_handle, offset_clazz, value);
2435 inline void java_lang_reflect_Field::set_slot(int32_t value)
2437 set(_handle, offset_slot, value);
2440 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2442 set(_handle, offset_name, value);
2445 inline void java_lang_reflect_Field::set_type(classinfo* value)
2447 set(_handle, offset_type, value);
2450 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2452 set(_handle, offset_modifiers, value);
2455 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2457 set(_handle, offset_signature, value);
2460 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2462 set(_handle, offset_annotations, value);
2466 inline fieldinfo* java_lang_reflect_Field::get_field() const
2468 classinfo* c = get_clazz();
2469 int32_t slot = get_slot();
2470 fieldinfo* f = &(c->fields[slot]);
2476 * OpenJDK java/lang/reflect/Method
2481 * 1. boolean override;
2482 * 2. java.lang.Class clazz;
2484 * 4. java.lang.String name;
2485 * 5. java.lang.Class returnType;
2486 * 6. java.lang.Class[] parameterTypes;
2487 * 7. java.lang.Class[] exceptionTypes;
2489 * 9. java.lang.String signature;
2490 * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2491 * 11. byte[] annotations;
2492 * 12. byte[] parameterAnnotations;
2493 * 13. byte[] annotationDefault;
2494 * 14. sun.reflect.MethodAccessor methodAccessor;
2495 * 15. java.lang.reflect.Method root;
2496 * 16. java.lang.Class securityCheckCache;
2497 * 17. java.lang.Class securityCheckTargetClassCache;
2498 * 18. java.util.Map declaredAnnotations;
2500 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2502 // Static offsets of the object's instance fields.
2503 // TODO These offsets need to be checked on VM startup.
2504 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2505 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2506 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2507 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2508 static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2509 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2510 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2511 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2512 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2513 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2514 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2515 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2516 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2517 static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2518 static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2519 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2520 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2521 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2524 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
2525 java_lang_reflect_Method(methodinfo* m);
2527 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
2530 int32_t get_override () const;
2531 classinfo* get_clazz () const;
2532 int32_t get_slot () const;
2533 java_handle_bytearray_t* get_annotations () const;
2534 java_handle_bytearray_t* get_parameterAnnotations() const;
2535 java_handle_bytearray_t* get_annotationDefault () const;
2539 // Convenience functions.
2540 methodinfo* get_method() const;
2544 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
2546 _handle = builtin_new(class_java_lang_reflect_Method);
2551 set(_handle, offset_clazz, m->clazz);
2552 set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2553 set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
2554 set(_handle, offset_returnType, method_returntype_get(m));
2555 set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2556 set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2557 set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2558 set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
2559 set(_handle, offset_annotations, method_get_annotations(m));
2560 set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2561 set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2565 inline int32_t java_lang_reflect_Method::get_override() const
2567 return get<int32_t>(_handle, offset_override);
2570 inline classinfo* java_lang_reflect_Method::get_clazz() const
2572 return get<classinfo*>(_handle, offset_clazz);
2575 inline int32_t java_lang_reflect_Method::get_slot() const
2577 return get<int32_t>(_handle, offset_slot);
2580 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2582 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2585 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2587 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2590 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2592 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2596 inline methodinfo* java_lang_reflect_Method::get_method() const
2598 classinfo* c = get_clazz();
2599 int32_t slot = get_slot();
2600 methodinfo* m = &(c->methods[slot]);
2606 * OpenJDK java/nio/Buffer
2617 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2619 // Static offsets of the object's instance fields.
2620 // TODO These offsets need to be checked on VM startup.
2621 static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2622 static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2623 static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2624 static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2625 static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2628 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
2631 void* get_address() const;
2635 inline void* java_nio_Buffer::get_address() const
2637 return get<void*>(_handle, offset_address);
2640 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2643 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2646 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2655 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2657 // Static offsets of the object's instance fields.
2658 // TODO These offsets need to be checked on VM startup.
2659 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2660 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2661 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2664 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2665 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2666 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2669 int64_t get_pointer () const;
2670 int32_t get_position() const;
2671 int32_t get_length () const;
2674 void set_pointer (int64_t value);
2675 void set_position(int32_t value);
2676 void set_length (int32_t value);
2680 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)
2682 set_pointer(pointer);
2683 set_position(position);
2687 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)
2689 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2693 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2695 return get<int64_t>(_handle, offset_pointer);
2698 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2700 return get<int32_t>(_handle, offset_position);
2703 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2705 return get<int32_t>(_handle, offset_length);
2709 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2711 set(_handle, offset_pointer, value);
2714 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2716 set(_handle, offset_position, value);
2719 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2721 set(_handle, offset_length, value);
2726 * CLDC 1.1 java/lang/String
2735 class java_lang_String : public java_lang_Object, private FieldAccess {
2737 // Static offsets of the object's instance fields.
2738 // TODO These offsets need to be checked on VM startup.
2739 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2740 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2741 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2744 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
2745 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2748 java_handle_chararray_t* get_value () const;
2749 int32_t get_offset() const;
2750 int32_t get_count () const;
2753 void set_value (java_handle_chararray_t* value);
2754 void set_offset(int32_t value);
2755 void set_count (int32_t value);
2759 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)
2766 inline java_handle_chararray_t* java_lang_String::get_value() const
2768 return get<java_handle_chararray_t*>(_handle, offset_value);
2771 inline int32_t java_lang_String::get_offset() const
2773 return get<int32_t>(_handle, offset_offset);
2776 inline int32_t java_lang_String::get_count() const
2778 return get<int32_t>(_handle, offset_count);
2781 inline void java_lang_String::set_value(java_handle_chararray_t* value)
2783 set(_handle, offset_value, value);
2786 inline void java_lang_String::set_offset(int32_t value)
2788 set(_handle, offset_offset, value);
2791 inline void java_lang_String::set_count(int32_t value)
2793 set(_handle, offset_count, value);
2798 * CLDC 1.1 java/lang/Thread
2804 * 2. java.lang.Runnable runnable;
2805 * 3. java.lang.Object vm_thread;
2806 * 4. int is_terminated;
2807 * 5. int is_stillborn;
2810 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2812 // Static offsets of the object's instance fields.
2813 // TODO These offsets need to be checked on VM startup.
2814 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2815 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2816 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2817 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2818 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2819 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2822 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2823 // java_lang_Thread(threadobject* t);
2826 int32_t get_priority () const;
2827 threadobject* get_vm_thread() const;
2828 java_handle_chararray_t* get_name () const;
2831 void set_vm_thread(threadobject* value);
2835 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
2837 // java_lang_Thread(thread_get_object(t));
2841 inline int32_t java_lang_Thread::get_priority() const
2843 return get<int32_t>(_handle, offset_priority);
2846 inline threadobject* java_lang_Thread::get_vm_thread() const
2848 return get<threadobject*>(_handle, offset_vm_thread);
2851 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2853 return get<java_handle_chararray_t*>(_handle, offset_name);
2857 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2859 set(_handle, offset_vm_thread, value);
2864 * CLDC 1.1 java/lang/Throwable
2869 * 1. java.lang.String detailMessage;
2870 * 2. java.lang.Object backtrace;
2872 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2874 // Static offsets of the object's instance fields.
2875 // TODO These offsets need to be checked on VM startup.
2876 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2877 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2880 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2883 java_handle_t* get_detailMessage() const;
2884 java_handle_bytearray_t* get_backtrace () const;
2887 void set_backtrace(java_handle_bytearray_t* value);
2891 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2893 return get<java_handle_t*>(_handle, offset_detailMessage);
2896 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2898 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2902 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2904 set(_handle, offset_backtrace, value);
2907 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2911 #endif // _JAVAOBJECTS_HPP
2915 * These are local overrides for various environment variables in Emacs.
2916 * Please do not remove this and leave it at the end of the file, where
2917 * Emacs will automagically detect them.
2918 * ---------------------------------------------------------------------
2921 * indent-tabs-mode: t
2925 * vim:noexpandtab:sw=4:ts=4: