1 /* src/vm/javaobjects.hpp - functions to create and access Java objects
3 Copyright (C) 2008, 2009 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.hpp"
34 #include "native/llni.h"
36 #include "threads/atomic.hpp"
38 #include "vm/class.hpp"
39 #include "vm/field.hpp"
40 #include "vm/global.h"
41 #include "vm/globals.hpp"
42 #include "vm/method.hpp"
48 * This class provides low-level functions to access Java object
51 * These functions do NOT take care about the GC critical section!
52 * Please use FieldAccess wherever possible.
54 class RawFieldAccess {
56 template<class T> static inline T raw_get(void* address, const off_t offset);
57 template<class T> static inline void raw_set(void* address, const off_t offset, T value);
61 template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
63 T* p = (T*) (((uintptr_t) address) + offset);
68 template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
70 T* p = (T*) (((uintptr_t) address) + offset);
76 * This classes provides functions to access Java object instance
77 * fields. These functions enter a critical GC section before
78 * accessing the Java object throught the handle and leave it
81 class FieldAccess : private RawFieldAccess {
83 // Normal field accessors.
84 template<class T> static inline T get(java_handle_t* h, const off_t offset);
85 template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
87 // Volatile field accessors.
88 template<class T> static inline T get_volatile(java_handle_t* h, const off_t offset);
89 template<class T> static inline void set_volatile(java_handle_t* h, const off_t offset, T value);
93 template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
95 // This function is inside a critical section.
98 // XXX This should be _handle->get_object();
99 java_object_t* ho = LLNI_UNWRAP(h);
100 return raw_get<T>(ho, offset);
103 template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
105 // This function is inside a critical section.
106 GCCriticalSection cs;
108 // XXX This should be _handle->get_object();
109 java_object_t* o = LLNI_UNWRAP(h);
110 java_object_t* result = raw_get<java_object_t*>(o, offset);
111 return LLNI_WRAP(result);
115 template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
117 // This function is inside a critical section.
118 GCCriticalSection cs;
120 java_object_t* ho = LLNI_UNWRAP(h);
121 raw_set(ho, offset, value);
124 template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
126 // This function is inside a critical section.
127 GCCriticalSection cs;
129 // XXX This should be h->get_object();
130 java_object_t* o = LLNI_UNWRAP(h);
131 java_object_t* ovalue = LLNI_UNWRAP(value);
132 raw_set(o, offset, ovalue);
136 template<class T> inline T FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
138 // This function is inside a critical section.
139 GCCriticalSection cs;
141 // XXX This should be _handle->get_object();
142 java_object_t* ho = LLNI_UNWRAP(h);
143 return raw_get<volatile T>(ho, offset);
146 template<> inline java_handle_t* FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
148 // This function is inside a critical section.
149 GCCriticalSection cs;
151 // XXX This should be _handle->get_object();
152 java_object_t* o = LLNI_UNWRAP(h);
153 java_object_t* result = (java_object_t*) raw_get<volatile java_object_t*>(o, offset);
154 return LLNI_WRAP(result);
158 template<class T> inline void FieldAccess::set_volatile(java_handle_t* h, const off_t offset, T value)
160 // This function is inside a critical section.
161 GCCriticalSection cs;
163 java_object_t* ho = LLNI_UNWRAP(h);
164 raw_set(ho, offset, (volatile T) value);
166 // Memory barrier for the Java Memory Model.
167 Atomic::memory_barrier();
170 template<> inline void FieldAccess::set_volatile<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
172 // This function is inside a critical section.
173 GCCriticalSection cs;
175 // XXX This should be h->get_object();
176 java_object_t* o = LLNI_UNWRAP(h);
177 java_object_t* ovalue = LLNI_UNWRAP(value);
178 raw_set(o, offset, (volatile java_object_t*) ovalue);
180 // Memory barrier for the Java Memory Model.
181 Atomic::memory_barrier();
192 class java_lang_Object {
194 // Handle of Java object.
195 java_handle_t* _handle;
198 java_lang_Object() : _handle(NULL) {}
199 java_lang_Object(java_handle_t* h) : _handle(h) {}
200 virtual ~java_lang_Object() {}
203 virtual java_handle_t* get_handle () const { return _handle; }
204 vftbl_t* get_vftbl () const;
205 classinfo* get_Class () const;
206 int32_t get_hashcode() const;
208 bool is_null () const;
209 bool is_non_null() const;
213 inline vftbl_t* java_lang_Object::get_vftbl() const
215 // This function is inside a critical section.
216 GCCriticalSection cs;
218 // XXX This should be h->get_object();
219 java_object_t* o = LLNI_UNWRAP(_handle);
223 inline classinfo* java_lang_Object::get_Class() const
225 return get_vftbl()->clazz;
228 inline int32_t java_lang_Object::get_hashcode() const
230 #if defined(ENABLE_GC_CACAO)
231 return heap_get_hashcode(_handle);
233 // This function is inside a critical section.
234 GCCriticalSection cs;
236 // XXX This should be h->get_object();
237 java_object_t* o = LLNI_UNWRAP(_handle);
238 return (int32_t) (intptr_t) o;
243 inline bool java_lang_Object::is_null() const
245 return (_handle == NULL);
248 inline bool java_lang_Object::is_non_null() const
250 return (_handle != NULL);
262 class java_lang_Boolean : public java_lang_Object, private FieldAccess {
264 // Static offsets of the object's instance fields.
265 // TODO These offsets need to be checked on VM startup.
266 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
269 java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {}
272 void set_value(uint8_t value);
275 inline uint8_t java_lang_Boolean::get_value()
277 return get<int32_t>(_handle, offset_value);
280 inline void java_lang_Boolean::set_value(uint8_t value)
282 set(_handle, offset_value, (uint32_t) value);
294 class java_lang_Byte : public java_lang_Object, private FieldAccess {
296 // Static offsets of the object's instance fields.
297 // TODO These offsets need to be checked on VM startup.
298 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
301 java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {}
304 void set_value(int8_t value);
307 inline int8_t java_lang_Byte::get_value()
309 return get<int32_t>(_handle, offset_value);
312 inline void java_lang_Byte::set_value(int8_t value)
314 set(_handle, offset_value, (int32_t) value);
319 * java/lang/Character
326 class java_lang_Character : public java_lang_Object, private FieldAccess {
328 // Static offsets of the object's instance fields.
329 // TODO These offsets need to be checked on VM startup.
330 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
333 java_lang_Character(java_handle_t* h) : java_lang_Object(h) {}
335 uint16_t get_value();
336 void set_value(uint16_t value);
339 inline uint16_t java_lang_Character::get_value()
341 return get<int32_t>(_handle, offset_value);
344 inline void java_lang_Character::set_value(uint16_t value)
346 set(_handle, offset_value, (uint32_t) value);
358 class java_lang_Short : public java_lang_Object, private FieldAccess {
360 // Static offsets of the object's instance fields.
361 // TODO These offsets need to be checked on VM startup.
362 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
365 java_lang_Short(java_handle_t* h) : java_lang_Object(h) {}
368 void set_value(int16_t value);
371 inline int16_t java_lang_Short::get_value()
373 return get<int32_t>(_handle, offset_value);
376 inline void java_lang_Short::set_value(int16_t value)
378 set(_handle, offset_value, (int32_t) value);
390 class java_lang_Integer : public java_lang_Object, private FieldAccess {
392 // Static offsets of the object's instance fields.
393 // TODO These offsets need to be checked on VM startup.
394 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
397 java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
400 void set_value(int32_t value);
403 inline int32_t java_lang_Integer::get_value()
405 return get<int32_t>(_handle, offset_value);
408 inline void java_lang_Integer::set_value(int32_t value)
410 set(_handle, offset_value, value);
422 class java_lang_Long : public java_lang_Object, private FieldAccess {
424 // Static offsets of the object's instance fields.
425 // TODO These offsets need to be checked on VM startup.
426 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
429 java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
432 void set_value(int64_t value);
435 inline int64_t java_lang_Long::get_value()
437 return get<int64_t>(_handle, offset_value);
440 inline void java_lang_Long::set_value(int64_t value)
442 set(_handle, offset_value, value);
454 class java_lang_Float : public java_lang_Object, private FieldAccess {
456 // Static offsets of the object's instance fields.
457 // TODO These offsets need to be checked on VM startup.
458 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
461 java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
464 void set_value(float value);
467 inline float java_lang_Float::get_value()
469 return get<float>(_handle, offset_value);
472 inline void java_lang_Float::set_value(float value)
474 set(_handle, offset_value, value);
486 class java_lang_Double : public java_lang_Object, private FieldAccess {
488 // Static offsets of the object's instance fields.
489 // TODO These offsets need to be checked on VM startup.
490 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
493 java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
496 void set_value(double value);
499 inline double java_lang_Double::get_value()
501 return get<double>(_handle, offset_value);
504 inline void java_lang_Double::set_value(double value)
506 set(_handle, offset_value, value);
510 #if defined(ENABLE_JAVASE)
513 * java/lang/management/MemoryUsage
518 * [other fields are not used]
520 class java_lang_management_MemoryUsage : public java_lang_Object, private FieldAccess {
522 java_lang_management_MemoryUsage(java_handle_t* h) : java_lang_Object(h) {}
523 java_lang_management_MemoryUsage(int64_t init, int64_t used, int64_t commited, int64_t maximum);
527 # if defined(ENABLE_ANNOTATIONS)
529 * OpenJDK sun/reflect/ConstantPool
534 * 1. java.lang.Object constantPoolOop;
536 class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
538 // Static offsets of the object's instance fields.
539 // TODO These offsets need to be checked on VM startup.
540 static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
543 sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
544 sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
547 void set_constantPoolOop(classinfo* value);
548 void set_constantPoolOop(jclass value);
552 inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
554 set_constantPoolOop(constantPoolOop);
558 inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
560 set(_handle, offset_constantPoolOop, value);
563 inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
565 // XXX jclass is a boxed object.
566 set_constantPoolOop(LLNI_classinfo_unwrap(value));
568 # endif // ENABLE_ANNOTATIONS
570 #endif // ENABLE_JAVASE
573 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
576 * GNU Classpath java/lang/Class
581 * 1. java.lang.Object[] signers;
582 * 2. java.security.ProtectionDomain pd;
583 * 3. java.lang.Object vmdata;
584 * 4. java.lang.reflect.Constructor constructor;
586 class java_lang_Class : public java_lang_Object, private FieldAccess {
588 // Static offsets of the object's instance fields.
589 // TODO These offsets need to be checked on VM startup.
590 static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
591 static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
592 static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
593 static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
596 java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
599 void set_pd(java_handle_t* value);
602 inline void java_lang_Class::set_pd(java_handle_t* value)
604 set(_handle, offset_pd, value);
609 * GNU Classpath java/lang/ClassLoader
614 * 1. java.util.HashMap definedPackages
615 * 2. java.lang.ClassLoader parent
616 * [other fields are not used]
618 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
620 // Static offsets of the object's instance fields.
621 // TODO These offsets need to be checked on VM startup.
622 static const off_t offset_definedPackages = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
623 static const off_t offset_parent = MEMORY_ALIGN(offset_definedPackages + SIZEOF_VOID_P, SIZEOF_VOID_P);
626 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
629 java_handle_t* get_parent() const;
631 // Invocation wrappers for static methods.
632 static java_handle_t* invoke_getSystemClassLoader();
635 inline java_handle_t* java_lang_ClassLoader::get_parent() const
637 return get<java_handle_t*>(_handle, offset_parent);
642 * GNU Classpath java/lang/StackTraceElement
647 * 1. java.lang.String fileName;
649 * 3. java.lang.String declaringClass;
650 * 4. java.lang.String methodName;
651 * 5. boolean isNative;
653 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
655 // Static offsets of the object's instance fields.
656 // TODO These offsets need to be checked on VM startup.
657 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
658 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
659 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
660 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
661 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
664 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
665 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);
668 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)
670 java_lang_StackTraceElement((java_handle_t*) h);
672 set(_handle, offset_fileName, fileName);
673 set(_handle, offset_lineNumber, lineNumber);
674 set(_handle, offset_declaringClass, declaringClass);
675 set(_handle, offset_methodName, methodName);
676 set(_handle, offset_isNative, isNative);
681 * GNU Classpath java/lang/String
688 * 3. int cachedHashCode;
691 class java_lang_String : public java_lang_Object, private FieldAccess {
693 // Static offsets of the object's instance fields.
694 // TODO These offsets need to be checked on VM startup.
695 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
696 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
697 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
698 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
701 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
702 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
705 java_handle_chararray_t* get_value () const;
706 int32_t get_count () const;
707 int32_t get_offset() const;
710 void set_value (java_handle_chararray_t* value);
711 void set_count (int32_t value);
712 void set_offset(int32_t value);
715 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)
722 inline java_handle_chararray_t* java_lang_String::get_value() const
724 return get<java_handle_chararray_t*>(_handle, offset_value);
727 inline int32_t java_lang_String::get_count() const
729 return get<int32_t>(_handle, offset_count);
732 inline int32_t java_lang_String::get_offset() const
734 return get<int32_t>(_handle, offset_offset);
737 inline void java_lang_String::set_value(java_handle_chararray_t* value)
739 set(_handle, offset_value, value);
742 inline void java_lang_String::set_count(int32_t value)
744 set(_handle, offset_count, value);
747 inline void java_lang_String::set_offset(int32_t value)
749 set(_handle, offset_offset, value);
754 * GNU Classpath java/lang/Thread
759 * 1. java.lang.VMThread vmThread;
760 * 2. java.lang.ThreadGroup group;
761 * 3. java.lang.Runnable runnable;
762 * 4. java.lang.String name;
766 * 8. java.lang.Throwable stillborn;
767 * 9. java.lang.ClassLoader contextClassLoader;
768 * 10. boolean contextClassLoaderIsSystemClassLoader;
770 * 12. java.lang.Object parkBlocker;
771 * 13. gnu.java.util.WeakIdentityHashMap locals;
772 * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
774 class java_lang_Thread : public java_lang_Object, private FieldAccess {
776 // Static offsets of the object's instance fields.
777 // TODO These offsets need to be checked on VM startup.
778 static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
779 static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
780 static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
781 static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
782 static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
783 static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
784 static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
785 static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
786 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
787 static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
788 static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
789 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
790 static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
791 static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
794 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
795 // java_lang_Thread(threadobject* t);
798 java_handle_t* get_vmThread () const;
799 java_handle_t* get_group () const;
800 java_handle_t* get_name () const;
801 int32_t get_daemon () const;
802 int32_t get_priority () const;
803 java_handle_t* get_exceptionHandler() const;
806 void set_group(java_handle_t* value);
810 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
812 // java_lang_Thread(thread_get_object(t));
816 inline java_handle_t* java_lang_Thread::get_vmThread() const
818 return get<java_handle_t*>(_handle, offset_vmThread);
821 inline java_handle_t* java_lang_Thread::get_group() const
823 return get<java_handle_t*>(_handle, offset_group);
826 inline java_handle_t* java_lang_Thread::get_name() const
828 return get<java_handle_t*>(_handle, offset_name);
831 inline int32_t java_lang_Thread::get_daemon() const
833 return get<int32_t>(_handle, offset_daemon);
836 inline int32_t java_lang_Thread::get_priority() const
838 return get<int32_t>(_handle, offset_priority);
841 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
843 return get<java_handle_t*>(_handle, offset_exceptionHandler);
847 inline void java_lang_Thread::set_group(java_handle_t* value)
849 set(_handle, offset_group, value);
854 * GNU Classpath java/lang/VMThread
859 * 1. java.lang.Thread thread;
860 * 2. boolean running;
861 * 3. java.lang.VMThread vmdata;
863 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
865 // Static offsets of the object's instance fields.
866 // TODO These offsets need to be checked on VM startup.
867 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
868 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
869 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
872 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
873 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
876 java_handle_t* get_thread() const;
877 threadobject* get_vmdata() const;
880 void set_thread(java_handle_t* value);
881 void set_vmdata(threadobject* value);
885 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
892 inline java_handle_t* java_lang_VMThread::get_thread() const
894 return get<java_handle_t*>(_handle, offset_thread);
897 inline threadobject* java_lang_VMThread::get_vmdata() const
899 return get<threadobject*>(_handle, offset_vmdata);
903 inline void java_lang_VMThread::set_thread(java_handle_t* value)
905 set(_handle, offset_thread, value);
908 inline void java_lang_VMThread::set_vmdata(threadobject* value)
910 set(_handle, offset_vmdata, value);
915 * GNU Classpath java/lang/Throwable
920 * 1. java.lang.String detailMessage;
921 * 2. java.lang.Throwable cause;
922 * 3. java.lang.StackTraceElement[] stackTrace;
923 * 4. java.lang.VMThrowable vmState;
925 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
927 // Static offsets of the object's instance fields.
928 // TODO These offsets need to be checked on VM startup.
929 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
930 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
931 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
932 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
935 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
938 java_handle_t* get_detailMessage() const;
939 java_handle_t* get_cause () const;
940 java_handle_t* get_vmState () const;
944 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
946 return get<java_handle_t*>(_handle, offset_detailMessage);
949 inline java_handle_t* java_lang_Throwable::get_cause() const
951 return get<java_handle_t*>(_handle, offset_cause);
954 inline java_handle_t* java_lang_Throwable::get_vmState() const
956 return get<java_handle_t*>(_handle, offset_vmState);
961 * GNU Classpath java/lang/VMThrowable
966 * 1. java.lang.Object vmdata;
968 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
970 // Static offsets of the object's instance fields.
971 // TODO These offsets need to be checked on VM startup.
972 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
975 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
977 java_handle_bytearray_t* get_vmdata() const;
978 void set_vmdata(java_handle_bytearray_t* value);
982 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
984 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
987 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
989 set(_handle, offset_vmdata, value);
994 * GNU Classpath java/lang/reflect/VMConstructor
999 * 1. java.lang.Class clazz;
1001 * 3. byte[] annotations;
1002 * 4. byte[] parameterAnnotations;
1003 * 5. java.util.Map declaredAnnotations;
1004 * 6. java.lang.reflect.Constructor cons;
1006 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
1008 // Static offsets of the object's instance fields.
1009 // TODO These offsets need to be checked on VM startup.
1010 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1011 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
1012 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1013 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1014 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1015 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1018 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
1019 java_lang_reflect_VMConstructor(methodinfo* m);
1022 classinfo* get_clazz () const;
1023 int32_t get_slot () const;
1024 java_handle_bytearray_t* get_annotations () const;
1025 java_handle_bytearray_t* get_parameterAnnotations() const;
1026 java_handle_t* get_declaredAnnotations () const;
1027 java_handle_t* get_cons () const;
1030 void set_clazz (classinfo* value);
1031 void set_slot (int32_t value);
1032 void set_annotations (java_handle_bytearray_t* value);
1033 void set_parameterAnnotations(java_handle_bytearray_t* value);
1034 void set_declaredAnnotations (java_handle_t* value);
1035 void set_cons (java_handle_t* value);
1037 // Convenience functions.
1038 methodinfo* get_method();
1042 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
1044 _handle = builtin_new(class_java_lang_reflect_VMConstructor);
1049 int slot = m - m->clazz->methods;
1050 java_handle_bytearray_t* annotations = method_get_annotations(m);
1051 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1053 set_clazz(m->clazz);
1055 set_annotations(annotations);
1056 set_parameterAnnotations(parameterAnnotations);
1060 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1062 return get<classinfo*>(_handle, offset_clazz);
1065 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1067 return get<int32_t>(_handle, offset_slot);
1070 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1072 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1075 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1077 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1080 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1082 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1085 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1087 return get<java_handle_t*>(_handle, offset_cons);
1090 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1092 set(_handle, offset_clazz, value);
1095 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1097 set(_handle, offset_slot, value);
1100 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1102 set(_handle, offset_annotations, value);
1105 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1107 set(_handle, offset_parameterAnnotations, value);
1110 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1112 set(_handle, offset_declaredAnnotations, value);
1115 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1117 set(_handle, offset_cons, value);
1120 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1122 classinfo* c = get_clazz();
1123 int32_t slot = get_slot();
1124 methodinfo* m = &(c->methods[slot]);
1130 * GNU Classpath java/lang/reflect/Constructor
1136 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1137 * 3. java.lang.reflect.VMConstructor cons;
1139 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
1141 // Static offsets of the object's instance fields.
1142 // TODO These offsets need to be checked on VM startup.
1143 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1144 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1145 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1148 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
1149 java_lang_reflect_Constructor(methodinfo* m);
1151 java_handle_t* new_instance(java_handle_objectarray_t* args);
1154 int32_t get_flag() const;
1155 java_handle_t* get_cons() const;
1158 void set_cons(java_handle_t* value);
1160 // Convenience functions.
1161 methodinfo* get_method () const;
1162 int32_t get_override() const;
1166 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
1168 java_lang_reflect_VMConstructor jlrvmc(m);
1170 if (jlrvmc.is_null())
1173 _handle = builtin_new(class_java_lang_reflect_Constructor);
1178 // Link the two Java objects.
1179 set_cons(jlrvmc.get_handle());
1180 jlrvmc.set_cons(get_handle());
1184 inline int32_t java_lang_reflect_Constructor::get_flag() const
1186 return get<int32_t>(_handle, offset_flag);
1189 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
1191 return get<java_handle_t*>(_handle, offset_cons);
1195 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
1197 set(_handle, offset_cons, value);
1201 inline methodinfo* java_lang_reflect_Constructor::get_method() const
1203 java_lang_reflect_VMConstructor jlrvmc(get_cons());
1204 return jlrvmc.get_method();
1207 inline int32_t java_lang_reflect_Constructor::get_override() const
1214 * GNU Classpath java/lang/reflect/VMField
1219 * 1. java.lang.Class clazz;
1220 * 2. java.lang.String name;
1222 * 4. byte[] annotations;
1223 * 5. java.lang.Map declaredAnnotations;
1224 * 6. java.lang.reflect.Field f;
1226 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1228 // Static offsets of the object's instance fields.
1229 // TODO These offsets need to be checked on VM startup.
1230 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1231 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1232 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1233 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1234 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1235 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1238 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1239 java_lang_reflect_VMField(fieldinfo* f);
1242 classinfo* get_clazz () const;
1243 int32_t get_slot () const;
1244 java_handle_bytearray_t* get_annotations () const;
1245 java_handle_t* get_declaredAnnotations() const;
1246 java_handle_t* get_f () const;
1249 void set_clazz (classinfo* value);
1250 void set_name (java_handle_t* value);
1251 void set_slot (int32_t value);
1252 void set_annotations (java_handle_bytearray_t* value);
1253 void set_declaredAnnotations(java_handle_t* value);
1254 void set_f (java_handle_t* value);
1256 // Convenience functions.
1257 fieldinfo* get_field() const;
1261 inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
1263 _handle = builtin_new(class_java_lang_reflect_VMField);
1268 java_handle_t* name = javastring_intern(javastring_new(f->name));
1269 int slot = f - f->clazz->fields;
1270 java_handle_bytearray_t* annotations = field_get_annotations(f);
1272 set_clazz(f->clazz);
1275 set_annotations(annotations);
1279 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1281 return get<classinfo*>(_handle, offset_clazz);
1284 inline int32_t java_lang_reflect_VMField::get_slot() const
1286 return get<int32_t>(_handle, offset_slot);
1289 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1291 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1294 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1296 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1299 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1301 return get<java_handle_t*>(_handle, offset_f);
1305 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1307 set(_handle, offset_clazz, value);
1310 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1312 set(_handle, offset_name, value);
1315 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1317 set(_handle, offset_slot, value);
1320 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1322 set(_handle, offset_annotations, value);
1325 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1327 set(_handle, offset_declaredAnnotations, value);
1330 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1332 set(_handle, offset_f, value);
1335 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1337 classinfo* c = get_clazz();
1338 int32_t slot = get_slot();
1339 fieldinfo* f = &(c->fields[slot]);
1345 * GNU Classpath java/lang/reflect/Field
1351 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1352 * 3. java.lang.reflect.VMField f;
1354 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1356 // Static offsets of the object's instance fields.
1357 // TODO These offsets need to be checked on VM startup.
1358 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1359 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1360 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1363 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1364 java_lang_reflect_Field(fieldinfo* f);
1367 int32_t get_flag() const;
1368 java_handle_t* get_f() const;
1371 void set_f(java_handle_t* value);
1373 // Convenience functions.
1374 fieldinfo* get_field() const;
1378 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
1380 java_lang_reflect_VMField jlrvmf(f);
1382 if (jlrvmf.is_null())
1385 _handle = builtin_new(class_java_lang_reflect_Field);
1390 // Link the two Java objects.
1391 set_f(jlrvmf.get_handle());
1392 jlrvmf.set_f(get_handle());
1396 inline int32_t java_lang_reflect_Field::get_flag() const
1398 return get<int32_t>(_handle, offset_flag);
1401 inline java_handle_t* java_lang_reflect_Field::get_f() const
1403 return get<java_handle_t*>(_handle, offset_f);
1407 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1409 set(_handle, offset_f, value);
1413 inline fieldinfo* java_lang_reflect_Field::get_field() const
1415 java_lang_reflect_VMField jlrvmf(get_f());
1416 return jlrvmf.get_field();
1421 * GNU Classpath java/lang/reflect/VMMethod
1426 * 1. java.lang.Class clazz;
1427 * 2. java.lang.String name;
1429 * 4. byte[] annotations;
1430 * 5. byte[] parameterAnnotations;
1431 * 6. byte[] annotationDefault;
1432 * 7. java.lang.Map declaredAnnotations;
1433 * 8. java.lang.reflect.Method m;
1435 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1437 // Static offsets of the object's instance fields.
1438 // TODO These offsets need to be checked on VM startup.
1439 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1440 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1441 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1442 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1443 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1444 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1445 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1446 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1449 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1450 java_lang_reflect_VMMethod(methodinfo* m);
1453 classinfo* get_clazz () const;
1454 int32_t get_slot () const;
1455 java_handle_bytearray_t* get_annotations () const;
1456 java_handle_bytearray_t* get_parameterAnnotations() const;
1457 java_handle_bytearray_t* get_annotationDefault () const;
1458 java_handle_t* get_declaredAnnotations () const;
1459 java_handle_t* get_m () const;
1462 void set_clazz (classinfo* value);
1463 void set_name (java_handle_t* value);
1464 void set_slot (int32_t value);
1465 void set_annotations (java_handle_bytearray_t* value);
1466 void set_parameterAnnotations(java_handle_bytearray_t* value);
1467 void set_annotationDefault (java_handle_bytearray_t* value);
1468 void set_declaredAnnotations (java_handle_t* value);
1469 void set_m (java_handle_t* value);
1471 // Convenience functions.
1472 methodinfo* get_method() const;
1476 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
1478 _handle = builtin_new(class_java_lang_reflect_VMMethod);
1483 java_handle_t* name = javastring_intern(javastring_new(m->name));
1484 int slot = m - m->clazz->methods;
1485 java_handle_bytearray_t* annotations = method_get_annotations(m);
1486 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1487 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1489 set_clazz(m->clazz);
1492 set_annotations(annotations);
1493 set_parameterAnnotations(parameterAnnotations);
1494 set_annotationDefault(annotationDefault);
1497 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1499 return get<classinfo*>(_handle, offset_clazz);
1502 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1504 return get<int32_t>(_handle, offset_slot);
1507 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1509 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1512 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1514 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1517 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1519 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1522 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1524 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1527 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1529 return get<java_handle_t*>(_handle, offset_m);
1532 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1534 set(_handle, offset_clazz, value);
1537 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1539 set(_handle, offset_name, value);
1542 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1544 set(_handle, offset_slot, value);
1547 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1549 set(_handle, offset_annotations, value);
1552 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1554 set(_handle, offset_parameterAnnotations, value);
1557 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1559 set(_handle, offset_annotationDefault, value);
1562 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1564 set(_handle, offset_declaredAnnotations, value);
1567 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1569 set(_handle, offset_m, value);
1572 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1574 classinfo* c = get_clazz();
1575 int32_t slot = get_slot();
1576 methodinfo* m = &(c->methods[slot]);
1582 * GNU Classpath java/lang/reflect/Method
1588 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1589 * 3. java.lang.reflect.VMMethod m;
1591 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1593 // Static offsets of the object's instance fields.
1594 // TODO These offsets need to be checked on VM startup.
1595 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1596 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1597 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1600 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1601 java_lang_reflect_Method(methodinfo* m);
1603 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
1606 int32_t get_flag() const;
1607 java_handle_t* get_m() const;
1610 void set_m(java_handle_t* value);
1612 // Convenience functions.
1613 methodinfo* get_method () const;
1614 int32_t get_override() const;
1618 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
1620 java_lang_reflect_VMMethod jlrvmm(m);
1622 if (jlrvmm.is_null())
1625 _handle = builtin_new(class_java_lang_reflect_Method);
1630 // Link the two Java objects.
1631 set_m(jlrvmm.get_handle());
1632 jlrvmm.set_m(get_handle());
1636 inline int32_t java_lang_reflect_Method::get_flag() const
1638 return get<int32_t>(_handle, offset_flag);
1641 inline java_handle_t* java_lang_reflect_Method::get_m() const
1643 return get<java_handle_t*>(_handle, offset_m);
1647 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1649 set(_handle, offset_m, value);
1653 inline methodinfo* java_lang_reflect_Method::get_method() const
1655 java_lang_reflect_VMMethod jlrvmm(get_m());
1656 return jlrvmm.get_method();
1659 inline int32_t java_lang_reflect_Method::get_override() const
1666 * GNU Classpath java/nio/Buffer
1675 * 5. gnu.classpath.Pointer address;
1677 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1679 // Static offsets of the object's instance fields.
1680 // TODO These offsets need to be checked on VM startup.
1681 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1682 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1683 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1684 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1685 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1688 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1691 int32_t get_cap() const;
1694 inline int32_t java_nio_Buffer::get_cap() const
1696 return get<int32_t>(_handle, offset_cap);
1701 * GNU Classpath java/nio/DirectByteBufferImpl
1710 * 5. gnu.classpath.Pointer address;
1711 * 6. java.nio.ByteOrder endian;
1712 * 7. byte[] backing_buffer;
1713 * 8. int array_offset;
1714 * 9. java.lang.Object owner;
1716 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1718 // Static offsets of the object's instance fields.
1719 // TODO These offsets need to be checked on VM startup.
1720 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1721 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1722 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1723 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1724 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1725 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1726 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1727 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1728 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1731 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1734 java_handle_t* get_address() const;
1738 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1740 return get<java_handle_t*>(_handle, offset_address);
1745 * GNU Classpath gnu/classpath/Pointer
1747 * Actually there are two classes, gnu.classpath.Pointer32 and
1748 * gnu.classpath.Pointer64, but we only define the abstract super
1749 * class and use the int/long field as void* type.
1756 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1758 // Static offsets of the object's instance fields.
1759 // TODO These offsets need to be checked on VM startup.
1760 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1763 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1764 gnu_classpath_Pointer(java_handle_t* h, void* data);
1767 void* get_data() const;
1770 void set_data(void* value);
1773 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1778 inline void* gnu_classpath_Pointer::get_data() const
1780 return get<void*>(_handle, offset_data);
1783 inline void gnu_classpath_Pointer::set_data(void* value)
1785 set(_handle, offset_data, value);
1788 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1791 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1794 * OpenJDK java/lang/AssertionStatusDirectives
1799 * 1. java.lang.String[] classes;
1800 * 2. boolean[] classEnabled;
1801 * 3. java.lang.String[] packages;
1802 * 4. boolean[] packageEnabled;
1805 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1807 // Static offsets of the object's instance fields.
1808 // TODO These offsets need to be checked on VM startup.
1809 static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1810 static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1811 static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1812 static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1813 static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1816 java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1819 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)
1821 classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1823 // FIXME Load the class at VM startup.
1827 _handle = builtin_new(c);
1832 set(_handle, offset_classes, classes);
1833 set(_handle, offset_classEnabled, classEnabled);
1834 set(_handle, offset_packages, packages);
1835 set(_handle, offset_packageEnabled, packageEnabled);
1840 * OpenJDK java/lang/ClassLoader
1845 * 1. boolean initialized
1846 * 2. java.lang.ClassLoader parent
1847 * [other fields are not used]
1849 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
1851 // Static offsets of the object's instance fields.
1852 // TODO These offsets need to be checked on VM startup.
1853 static const off_t offset_initialized = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1854 static const off_t offset_parent = MEMORY_ALIGN(offset_initialized + sizeof(int32_t), SIZEOF_VOID_P);
1857 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
1860 java_handle_t* get_parent() const;
1862 // Invocation wrappers for static methods.
1863 static java_handle_t* invoke_getSystemClassLoader();
1866 inline java_handle_t* java_lang_ClassLoader::get_parent() const
1868 return get<java_handle_t*>(_handle, offset_parent);
1873 * OpenJDK java/lang/StackTraceElement
1878 * 1. java.lang.String declaringClass;
1879 * 2. java.lang.String methodName;
1880 * 3. java.lang.String fileName;
1881 * 4. int lineNumber;
1883 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
1885 // Static offsets of the object's instance fields.
1886 // TODO These offsets need to be checked on VM startup.
1887 static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1888 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1889 static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1890 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1893 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
1894 java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1897 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1899 _handle = builtin_new(class_java_lang_StackTraceElement);
1904 set(_handle, offset_declaringClass, declaringClass);
1905 set(_handle, offset_methodName, methodName);
1906 set(_handle, offset_fileName, fileName);
1907 set(_handle, offset_lineNumber, lineNumber);
1912 * OpenJDK java/lang/String
1922 class java_lang_String : public java_lang_Object, private FieldAccess {
1924 // Static offsets of the object's instance fields.
1925 // TODO These offsets need to be checked on VM startup.
1926 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1927 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1928 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1929 static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
1932 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1933 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1936 java_handle_chararray_t* get_value () const;
1937 int32_t get_offset() const;
1938 int32_t get_count () const;
1941 void set_value (java_handle_chararray_t* value);
1942 void set_offset(int32_t value);
1943 void set_count (int32_t value);
1946 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)
1953 inline java_handle_chararray_t* java_lang_String::get_value() const
1955 return get<java_handle_chararray_t*>(_handle, offset_value);
1958 inline int32_t java_lang_String::get_offset() const
1960 return get<int32_t>(_handle, offset_offset);
1963 inline int32_t java_lang_String::get_count() const
1965 return get<int32_t>(_handle, offset_count);
1968 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1970 set(_handle, offset_value, value);
1973 inline void java_lang_String::set_offset(int32_t value)
1975 set(_handle, offset_offset, value);
1978 inline void java_lang_String::set_count(int32_t value)
1980 set(_handle, offset_count, value);
1985 * OpenJDK java/lang/Thread
1992 * 3. java_lang_Thread threadQ;
1994 * 5. boolean single_step;
1995 * 6. boolean daemon;
1996 * 7. boolean stillborn;
1997 * 8. java_lang_Runnable target;
1998 * 9. java_lang_ThreadGroup group;
1999 * 10. java_lang_ClassLoader contextClassLoader;
2000 * 11. java_security_AccessControlContext inheritedAccessControlContext;
2001 * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals;
2002 * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals;
2003 * 14. long stackSize;
2004 * 15. long nativeParkEventPointer;
2006 * 17. int threadStatus;
2007 * 18. java_lang_Object parkBlocker;
2008 * 19. sun_nio_ch_Interruptible blocker;
2009 * 20. java_lang_Object blockerLock;
2010 * 21. boolean stopBeforeStart;
2011 * 22. java_lang_Throwable throwableFromStop;
2012 * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
2014 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2016 // Static offsets of the object's instance fields.
2017 // TODO These offsets need to be checked on VM startup.
2018 static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2019 static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
2020 static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2021 static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t));
2022 static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t));
2023 static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t));
2024 static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
2025 static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2026 static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P);
2027 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
2028 static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
2029 static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P);
2030 static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P);
2031 static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t));
2032 static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t));
2033 static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t));
2034 static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t));
2035 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P);
2036 static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
2037 static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
2038 static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t));
2039 static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P);
2040 static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P);
2043 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2044 // java_lang_Thread(threadobject* t);
2047 int32_t get_priority () const;
2048 int32_t get_daemon () const;
2049 java_handle_t* get_group () const;
2050 java_handle_t* get_uncaughtExceptionHandler() const;
2053 void set_priority (int32_t value);
2054 void set_group (java_handle_t* value);
2055 void set_threadStatus(int32_t value);
2059 inline int32_t java_lang_Thread::get_priority() const
2061 return get<int32_t>(_handle, offset_priority);
2064 inline int32_t java_lang_Thread::get_daemon() const
2066 return get<int32_t>(_handle, offset_daemon);
2069 inline java_handle_t* java_lang_Thread::get_group() const
2071 return get<java_handle_t*>(_handle, offset_group);
2074 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
2076 return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
2080 inline void java_lang_Thread::set_priority(int32_t value)
2082 set(_handle, offset_priority, value);
2085 inline void java_lang_Thread::set_group(java_handle_t* value)
2087 set(_handle, offset_group, value);
2090 inline void java_lang_Thread::set_threadStatus(int32_t value)
2092 set(_handle, offset_threadStatus, value);
2098 * OpenJDK java/lang/Throwable
2103 * 1. java.lang.Object backtrace;
2104 * 2. java.lang.String detailMessage;
2105 * 3. java.lang.Throwable cause;
2106 * 4. java.lang.StackTraceElement[] stackTrace;
2108 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2110 // Static offsets of the object's instance fields.
2111 // TODO These offsets need to be checked on VM startup.
2112 static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2113 static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2114 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2115 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2118 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2119 java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
2122 java_handle_bytearray_t* get_backtrace () const;
2123 java_handle_t* get_detailMessage() const;
2124 java_handle_t* get_cause () const;
2127 void set_backtrace(java_handle_bytearray_t* value);
2131 inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
2133 set_backtrace(backtrace);
2137 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2139 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2142 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2144 return get<java_handle_t*>(_handle, offset_detailMessage);
2147 inline java_handle_t* java_lang_Throwable::get_cause() const
2149 return get<java_handle_t*>(_handle, offset_cause);
2153 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2155 set(_handle, offset_backtrace, value);
2160 * OpenJDK java/lang/reflect/Constructor
2165 * 1. boolean override;
2166 * 2. java.lang.Class clazz;
2168 * 4. java.lang.Class[] parameterTypes;
2169 * 5. java.lang.Class[] exceptionTypes;
2171 * 7. java.lang.String signature;
2172 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2173 * 9. byte[] annotations;
2174 * 10. byte[] parameterAnnotations;
2175 * 11. java.lang.Class securityCheckCache;
2176 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2177 * 13. java.lang.reflect.Constructor root;
2178 * 14. java.util.Map declaredAnnotations;
2180 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
2182 // Static offsets of the object's instance fields.
2183 // TODO These offsets need to be checked on VM startup.
2184 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2185 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2186 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2187 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2188 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2189 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2190 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2191 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2192 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2193 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2194 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2195 static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2196 static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2197 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2200 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
2201 java_lang_reflect_Constructor(methodinfo* m);
2203 java_handle_t* new_instance(java_handle_objectarray_t* args);
2206 int32_t get_override () const;
2207 classinfo* get_clazz () const;
2208 int32_t get_slot () const;
2209 java_handle_bytearray_t* get_annotations() const;
2212 void set_clazz (classinfo* value);
2213 void set_slot (int32_t value);
2214 void set_parameterTypes (java_handle_objectarray_t* value);
2215 void set_exceptionTypes (java_handle_objectarray_t* value);
2216 void set_modifiers (int32_t value);
2217 void set_signature (java_handle_t* value);
2218 void set_annotations (java_handle_bytearray_t* value);
2219 void set_parameterAnnotations(java_handle_bytearray_t* value);
2221 // Convenience functions.
2222 methodinfo* get_method();
2226 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
2228 _handle = builtin_new(class_java_lang_reflect_Constructor);
2233 int slot = m - m->clazz->methods;
2234 java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
2235 java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
2236 java_handle_bytearray_t* annotations = method_get_annotations(m);
2237 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2239 set_clazz(m->clazz);
2241 set_parameterTypes(parameterTypes);
2242 set_exceptionTypes(exceptionTypes);
2243 set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2244 set_signature(m->signature ? javastring_new(m->signature) : NULL);
2245 set_annotations(annotations);
2246 set_parameterAnnotations(parameterAnnotations);
2250 inline int32_t java_lang_reflect_Constructor::get_override() const
2252 return get<int32_t>(_handle, offset_override);
2255 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2257 return get<classinfo*>(_handle, offset_clazz);
2260 inline int32_t java_lang_reflect_Constructor::get_slot() const
2262 return get<int32_t>(_handle, offset_slot);
2265 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2267 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2271 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2273 set(_handle, offset_clazz, value);
2276 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2278 set(_handle, offset_slot, value);
2281 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2283 set(_handle, offset_parameterTypes, value);
2286 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2288 set(_handle, offset_exceptionTypes, value);
2291 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2293 set(_handle, offset_modifiers, value);
2296 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2298 set(_handle, offset_signature, value);
2301 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2303 set(_handle, offset_annotations, value);
2306 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2308 set(_handle, offset_parameterAnnotations, value);
2312 inline methodinfo* java_lang_reflect_Constructor::get_method()
2314 classinfo* c = get_clazz();
2315 int32_t slot = get_slot();
2316 methodinfo* m = &(c->methods[slot]);
2322 * OpenJDK java/lang/reflect/Field
2327 * 1. boolean override;
2328 * 2. java.lang.Class clazz;
2330 * 4. java.lang.String name;
2331 * 5. java.lang.Class type;
2333 * 7. java.lang.String signature;
2334 * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2335 * 9. byte[] annotations;
2336 * 10. sun.reflect.FieldAccessor fieldAccessor;
2337 * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2338 * 12. java.lang.reflect.Field root;
2339 * 13. java.lang.Class securityCheckCache;
2340 * 14. java.lang.Class securityCheckTargetClassCache;
2341 * 15. java.util.Map declaredAnnotations;
2343 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2345 // Static offsets of the object's instance fields.
2346 // TODO These offsets need to be checked on VM startup.
2347 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2348 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2349 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2350 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2351 static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2352 static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2353 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2354 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2355 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2356 static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2357 static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2358 static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2359 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2360 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2361 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2364 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
2365 java_lang_reflect_Field(fieldinfo* f);
2368 int32_t get_override () const;
2369 classinfo* get_clazz () const;
2370 int32_t get_slot () const;
2371 java_handle_bytearray_t* get_annotations() const;
2374 void set_clazz (classinfo* value);
2375 void set_slot (int32_t value);
2376 void set_name (java_handle_t* value);
2377 void set_type (classinfo* value);
2378 void set_modifiers (int32_t value);
2379 void set_signature (java_handle_t* value);
2380 void set_annotations(java_handle_bytearray_t* value);
2382 // Convenience functions.
2383 fieldinfo* get_field() const;
2387 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
2389 _handle = builtin_new(class_java_lang_reflect_Field);
2395 set_clazz(f->clazz);
2396 set_slot(f - f->clazz->fields);
2397 set_name(javastring_intern(javastring_new(f->name)));
2398 set_type(field_get_type(f));
2399 set_modifiers(f->flags);
2400 set_signature(f->signature ? javastring_new(f->signature) : NULL);
2401 set_annotations(field_get_annotations(f));
2405 inline int32_t java_lang_reflect_Field::get_override() const
2407 return get<int32_t>(_handle, offset_override);
2410 inline classinfo* java_lang_reflect_Field::get_clazz() const
2412 return get<classinfo*>(_handle, offset_clazz);
2415 inline int32_t java_lang_reflect_Field::get_slot() const
2417 return get<int32_t>(_handle, offset_slot);
2420 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2422 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2426 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2428 set(_handle, offset_clazz, value);
2431 inline void java_lang_reflect_Field::set_slot(int32_t value)
2433 set(_handle, offset_slot, value);
2436 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2438 set(_handle, offset_name, value);
2441 inline void java_lang_reflect_Field::set_type(classinfo* value)
2443 set(_handle, offset_type, value);
2446 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2448 set(_handle, offset_modifiers, value);
2451 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2453 set(_handle, offset_signature, value);
2456 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2458 set(_handle, offset_annotations, value);
2462 inline fieldinfo* java_lang_reflect_Field::get_field() const
2464 classinfo* c = get_clazz();
2465 int32_t slot = get_slot();
2466 fieldinfo* f = &(c->fields[slot]);
2472 * OpenJDK java/lang/reflect/Method
2477 * 1. boolean override;
2478 * 2. java.lang.Class clazz;
2480 * 4. java.lang.String name;
2481 * 5. java.lang.Class returnType;
2482 * 6. java.lang.Class[] parameterTypes;
2483 * 7. java.lang.Class[] exceptionTypes;
2485 * 9. java.lang.String signature;
2486 * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2487 * 11. byte[] annotations;
2488 * 12. byte[] parameterAnnotations;
2489 * 13. byte[] annotationDefault;
2490 * 14. sun.reflect.MethodAccessor methodAccessor;
2491 * 15. java.lang.reflect.Method root;
2492 * 16. java.lang.Class securityCheckCache;
2493 * 17. java.lang.Class securityCheckTargetClassCache;
2494 * 18. java.util.Map declaredAnnotations;
2496 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2498 // Static offsets of the object's instance fields.
2499 // TODO These offsets need to be checked on VM startup.
2500 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2501 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2502 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2503 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2504 static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2505 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2506 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2507 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2508 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2509 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2510 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2511 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2512 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2513 static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2514 static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2515 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2516 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2517 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2520 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
2521 java_lang_reflect_Method(methodinfo* m);
2523 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
2526 int32_t get_override () const;
2527 classinfo* get_clazz () const;
2528 int32_t get_slot () const;
2529 java_handle_bytearray_t* get_annotations () const;
2530 java_handle_bytearray_t* get_parameterAnnotations() const;
2531 java_handle_bytearray_t* get_annotationDefault () const;
2535 // Convenience functions.
2536 methodinfo* get_method() const;
2540 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
2542 _handle = builtin_new(class_java_lang_reflect_Method);
2547 set(_handle, offset_clazz, m->clazz);
2548 set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2549 set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
2550 set(_handle, offset_returnType, method_returntype_get(m));
2551 set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2552 set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2553 set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2554 set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
2555 set(_handle, offset_annotations, method_get_annotations(m));
2556 set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2557 set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2561 inline int32_t java_lang_reflect_Method::get_override() const
2563 return get<int32_t>(_handle, offset_override);
2566 inline classinfo* java_lang_reflect_Method::get_clazz() const
2568 return get<classinfo*>(_handle, offset_clazz);
2571 inline int32_t java_lang_reflect_Method::get_slot() const
2573 return get<int32_t>(_handle, offset_slot);
2576 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2578 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2581 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2583 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2586 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2588 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2592 inline methodinfo* java_lang_reflect_Method::get_method() const
2594 classinfo* c = get_clazz();
2595 int32_t slot = get_slot();
2596 methodinfo* m = &(c->methods[slot]);
2602 * OpenJDK java/nio/Buffer
2613 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2615 // Static offsets of the object's instance fields.
2616 // TODO These offsets need to be checked on VM startup.
2617 static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2618 static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2619 static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2620 static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2621 static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2624 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
2627 void* get_address() const;
2631 inline void* java_nio_Buffer::get_address() const
2633 return get<void*>(_handle, offset_address);
2636 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2639 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2642 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2651 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2653 // Static offsets of the object's instance fields.
2654 // TODO These offsets need to be checked on VM startup.
2655 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2656 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2657 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2660 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2661 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2662 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2665 int64_t get_pointer () const;
2666 int32_t get_position() const;
2667 int32_t get_length () const;
2670 void set_pointer (int64_t value);
2671 void set_position(int32_t value);
2672 void set_length (int32_t value);
2676 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)
2678 set_pointer(pointer);
2679 set_position(position);
2683 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)
2685 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2689 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2691 return get<int64_t>(_handle, offset_pointer);
2694 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2696 return get<int32_t>(_handle, offset_position);
2699 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2701 return get<int32_t>(_handle, offset_length);
2705 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2707 set(_handle, offset_pointer, value);
2710 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2712 set(_handle, offset_position, value);
2715 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2717 set(_handle, offset_length, value);
2722 * CLDC 1.1 java/lang/String
2731 class java_lang_String : public java_lang_Object, private FieldAccess {
2733 // Static offsets of the object's instance fields.
2734 // TODO These offsets need to be checked on VM startup.
2735 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2736 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2737 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2740 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
2741 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2744 java_handle_chararray_t* get_value () const;
2745 int32_t get_offset() const;
2746 int32_t get_count () const;
2749 void set_value (java_handle_chararray_t* value);
2750 void set_offset(int32_t value);
2751 void set_count (int32_t value);
2755 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)
2762 inline java_handle_chararray_t* java_lang_String::get_value() const
2764 return get<java_handle_chararray_t*>(_handle, offset_value);
2767 inline int32_t java_lang_String::get_offset() const
2769 return get<int32_t>(_handle, offset_offset);
2772 inline int32_t java_lang_String::get_count() const
2774 return get<int32_t>(_handle, offset_count);
2777 inline void java_lang_String::set_value(java_handle_chararray_t* value)
2779 set(_handle, offset_value, value);
2782 inline void java_lang_String::set_offset(int32_t value)
2784 set(_handle, offset_offset, value);
2787 inline void java_lang_String::set_count(int32_t value)
2789 set(_handle, offset_count, value);
2794 * CLDC 1.1 java/lang/Thread
2800 * 2. java.lang.Runnable runnable;
2801 * 3. java.lang.Object vm_thread;
2802 * 4. int is_terminated;
2803 * 5. int is_stillborn;
2806 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2808 // Static offsets of the object's instance fields.
2809 // TODO These offsets need to be checked on VM startup.
2810 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2811 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2812 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2813 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2814 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2815 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2818 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2819 // java_lang_Thread(threadobject* t);
2822 int32_t get_priority () const;
2823 threadobject* get_vm_thread() const;
2824 java_handle_chararray_t* get_name () const;
2827 void set_vm_thread(threadobject* value);
2831 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
2833 // java_lang_Thread(thread_get_object(t));
2837 inline int32_t java_lang_Thread::get_priority() const
2839 return get<int32_t>(_handle, offset_priority);
2842 inline threadobject* java_lang_Thread::get_vm_thread() const
2844 return get<threadobject*>(_handle, offset_vm_thread);
2847 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2849 return get<java_handle_chararray_t*>(_handle, offset_name);
2853 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2855 set(_handle, offset_vm_thread, value);
2860 * CLDC 1.1 java/lang/Throwable
2865 * 1. java.lang.String detailMessage;
2866 * 2. java.lang.Object backtrace;
2868 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2870 // Static offsets of the object's instance fields.
2871 // TODO These offsets need to be checked on VM startup.
2872 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2873 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2876 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2879 java_handle_t* get_detailMessage() const;
2880 java_handle_bytearray_t* get_backtrace () const;
2883 void set_backtrace(java_handle_bytearray_t* value);
2887 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2889 return get<java_handle_t*>(_handle, offset_detailMessage);
2892 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2894 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2898 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2900 set(_handle, offset_backtrace, value);
2903 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2907 #endif // _JAVAOBJECTS_HPP
2911 * These are local overrides for various environment variables in Emacs.
2912 * Please do not remove this and leave it at the end of the file, where
2913 * Emacs will automagically detect them.
2914 * ---------------------------------------------------------------------
2917 * indent-tabs-mode: t