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)
512 # if defined(ENABLE_ANNOTATIONS)
514 * OpenJDK sun/reflect/ConstantPool
519 * 1. java.lang.Object constantPoolOop;
521 class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
523 // Static offsets of the object's instance fields.
524 // TODO These offsets need to be checked on VM startup.
525 static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
528 sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
529 sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
532 void set_constantPoolOop(classinfo* value);
533 void set_constantPoolOop(jclass value);
537 inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
539 set_constantPoolOop(constantPoolOop);
543 inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
545 set(_handle, offset_constantPoolOop, value);
548 inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
550 // XXX jclass is a boxed object.
551 set_constantPoolOop(LLNI_classinfo_unwrap(value));
553 # endif // ENABLE_ANNOTATIONS
555 #endif // ENABLE_JAVASE
558 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
561 * GNU Classpath java/lang/Class
566 * 1. java.lang.Object[] signers;
567 * 2. java.security.ProtectionDomain pd;
568 * 3. java.lang.Object vmdata;
569 * 4. java.lang.reflect.Constructor constructor;
571 class java_lang_Class : public java_lang_Object, private FieldAccess {
573 // Static offsets of the object's instance fields.
574 // TODO These offsets need to be checked on VM startup.
575 static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
576 static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
577 static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
578 static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
581 java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
584 void set_pd(java_handle_t* value);
587 inline void java_lang_Class::set_pd(java_handle_t* value)
589 set(_handle, offset_pd, value);
594 * GNU Classpath java/lang/ClassLoader
599 * 1. java.util.HashMap definedPackages
600 * 2. java.lang.ClassLoader parent
601 * [other fields are not used]
603 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
605 // Static offsets of the object's instance fields.
606 // TODO These offsets need to be checked on VM startup.
607 static const off_t offset_definedPackages = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
608 static const off_t offset_parent = MEMORY_ALIGN(offset_definedPackages + SIZEOF_VOID_P, SIZEOF_VOID_P);
611 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
614 java_handle_t* get_parent() const;
616 // Invocation wrappers for static methods.
617 static java_handle_t* invoke_getSystemClassLoader();
620 inline java_handle_t* java_lang_ClassLoader::get_parent() const
622 return get<java_handle_t*>(_handle, offset_parent);
627 * GNU Classpath java/lang/StackTraceElement
632 * 1. java.lang.String fileName;
634 * 3. java.lang.String declaringClass;
635 * 4. java.lang.String methodName;
636 * 5. boolean isNative;
638 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
640 // Static offsets of the object's instance fields.
641 // TODO These offsets need to be checked on VM startup.
642 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
643 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
644 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
645 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
646 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
649 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
650 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);
653 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)
655 java_lang_StackTraceElement((java_handle_t*) h);
657 set(_handle, offset_fileName, fileName);
658 set(_handle, offset_lineNumber, lineNumber);
659 set(_handle, offset_declaringClass, declaringClass);
660 set(_handle, offset_methodName, methodName);
661 set(_handle, offset_isNative, isNative);
666 * GNU Classpath java/lang/String
673 * 3. int cachedHashCode;
676 class java_lang_String : public java_lang_Object, private FieldAccess {
678 // Static offsets of the object's instance fields.
679 // TODO These offsets need to be checked on VM startup.
680 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
681 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
682 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
683 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
686 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
687 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
690 java_handle_chararray_t* get_value () const;
691 int32_t get_count () const;
692 int32_t get_offset() const;
695 void set_value (java_handle_chararray_t* value);
696 void set_count (int32_t value);
697 void set_offset(int32_t value);
700 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)
707 inline java_handle_chararray_t* java_lang_String::get_value() const
709 return get<java_handle_chararray_t*>(_handle, offset_value);
712 inline int32_t java_lang_String::get_count() const
714 return get<int32_t>(_handle, offset_count);
717 inline int32_t java_lang_String::get_offset() const
719 return get<int32_t>(_handle, offset_offset);
722 inline void java_lang_String::set_value(java_handle_chararray_t* value)
724 set(_handle, offset_value, value);
727 inline void java_lang_String::set_count(int32_t value)
729 set(_handle, offset_count, value);
732 inline void java_lang_String::set_offset(int32_t value)
734 set(_handle, offset_offset, value);
739 * GNU Classpath java/lang/Thread
744 * 1. java.lang.VMThread vmThread;
745 * 2. java.lang.ThreadGroup group;
746 * 3. java.lang.Runnable runnable;
747 * 4. java.lang.String name;
751 * 8. java.lang.Throwable stillborn;
752 * 9. java.lang.ClassLoader contextClassLoader;
753 * 10. boolean contextClassLoaderIsSystemClassLoader;
755 * 12. java.lang.Object parkBlocker;
756 * 13. gnu.java.util.WeakIdentityHashMap locals;
757 * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
759 class java_lang_Thread : public java_lang_Object, private FieldAccess {
761 // Static offsets of the object's instance fields.
762 // TODO These offsets need to be checked on VM startup.
763 static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
764 static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
765 static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
766 static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
767 static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
768 static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
769 static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
770 static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
771 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
772 static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
773 static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
774 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
775 static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
776 static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
779 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
780 // java_lang_Thread(threadobject* t);
783 java_handle_t* get_vmThread () const;
784 java_handle_t* get_group () const;
785 java_handle_t* get_name () const;
786 int32_t get_daemon () const;
787 int32_t get_priority () const;
788 java_handle_t* get_exceptionHandler() const;
791 void set_group(java_handle_t* value);
795 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
797 // java_lang_Thread(thread_get_object(t));
801 inline java_handle_t* java_lang_Thread::get_vmThread() const
803 return get<java_handle_t*>(_handle, offset_vmThread);
806 inline java_handle_t* java_lang_Thread::get_group() const
808 return get<java_handle_t*>(_handle, offset_group);
811 inline java_handle_t* java_lang_Thread::get_name() const
813 return get<java_handle_t*>(_handle, offset_name);
816 inline int32_t java_lang_Thread::get_daemon() const
818 return get<int32_t>(_handle, offset_daemon);
821 inline int32_t java_lang_Thread::get_priority() const
823 return get<int32_t>(_handle, offset_priority);
826 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
828 return get<java_handle_t*>(_handle, offset_exceptionHandler);
832 inline void java_lang_Thread::set_group(java_handle_t* value)
834 set(_handle, offset_group, value);
839 * GNU Classpath java/lang/VMThread
844 * 1. java.lang.Thread thread;
845 * 2. boolean running;
846 * 3. java.lang.VMThread vmdata;
848 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
850 // Static offsets of the object's instance fields.
851 // TODO These offsets need to be checked on VM startup.
852 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
853 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
854 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
857 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
858 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
861 java_handle_t* get_thread() const;
862 threadobject* get_vmdata() const;
865 void set_thread(java_handle_t* value);
866 void set_vmdata(threadobject* value);
870 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
877 inline java_handle_t* java_lang_VMThread::get_thread() const
879 return get<java_handle_t*>(_handle, offset_thread);
882 inline threadobject* java_lang_VMThread::get_vmdata() const
884 return get<threadobject*>(_handle, offset_vmdata);
888 inline void java_lang_VMThread::set_thread(java_handle_t* value)
890 set(_handle, offset_thread, value);
893 inline void java_lang_VMThread::set_vmdata(threadobject* value)
895 set(_handle, offset_vmdata, value);
900 * GNU Classpath java/lang/Throwable
905 * 1. java.lang.String detailMessage;
906 * 2. java.lang.Throwable cause;
907 * 3. java.lang.StackTraceElement[] stackTrace;
908 * 4. java.lang.VMThrowable vmState;
910 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
912 // Static offsets of the object's instance fields.
913 // TODO These offsets need to be checked on VM startup.
914 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
915 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
916 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
917 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
920 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
923 java_handle_t* get_detailMessage() const;
924 java_handle_t* get_cause () const;
925 java_handle_t* get_vmState () const;
929 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
931 return get<java_handle_t*>(_handle, offset_detailMessage);
934 inline java_handle_t* java_lang_Throwable::get_cause() const
936 return get<java_handle_t*>(_handle, offset_cause);
939 inline java_handle_t* java_lang_Throwable::get_vmState() const
941 return get<java_handle_t*>(_handle, offset_vmState);
946 * GNU Classpath java/lang/VMThrowable
951 * 1. java.lang.Object vmdata;
953 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
955 // Static offsets of the object's instance fields.
956 // TODO These offsets need to be checked on VM startup.
957 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
960 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
962 java_handle_bytearray_t* get_vmdata() const;
963 void set_vmdata(java_handle_bytearray_t* value);
967 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
969 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
972 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
974 set(_handle, offset_vmdata, value);
979 * GNU Classpath java/lang/reflect/VMConstructor
984 * 1. java.lang.Class clazz;
986 * 3. byte[] annotations;
987 * 4. byte[] parameterAnnotations;
988 * 5. java.util.Map declaredAnnotations;
989 * 6. java.lang.reflect.Constructor cons;
991 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
993 // Static offsets of the object's instance fields.
994 // TODO These offsets need to be checked on VM startup.
995 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
996 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
997 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
998 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
999 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1000 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1003 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
1004 java_lang_reflect_VMConstructor(methodinfo* m);
1007 classinfo* get_clazz () const;
1008 int32_t get_slot () const;
1009 java_handle_bytearray_t* get_annotations () const;
1010 java_handle_bytearray_t* get_parameterAnnotations() const;
1011 java_handle_t* get_declaredAnnotations () const;
1012 java_handle_t* get_cons () const;
1015 void set_clazz (classinfo* value);
1016 void set_slot (int32_t value);
1017 void set_annotations (java_handle_bytearray_t* value);
1018 void set_parameterAnnotations(java_handle_bytearray_t* value);
1019 void set_declaredAnnotations (java_handle_t* value);
1020 void set_cons (java_handle_t* value);
1022 // Convenience functions.
1023 methodinfo* get_method();
1027 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
1029 _handle = builtin_new(class_java_lang_reflect_VMConstructor);
1034 int slot = m - m->clazz->methods;
1035 java_handle_bytearray_t* annotations = method_get_annotations(m);
1036 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1038 set_clazz(m->clazz);
1040 set_annotations(annotations);
1041 set_parameterAnnotations(parameterAnnotations);
1045 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1047 return get<classinfo*>(_handle, offset_clazz);
1050 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1052 return get<int32_t>(_handle, offset_slot);
1055 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1057 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1060 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1062 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1065 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1067 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1070 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1072 return get<java_handle_t*>(_handle, offset_cons);
1075 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1077 set(_handle, offset_clazz, value);
1080 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1082 set(_handle, offset_slot, value);
1085 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1087 set(_handle, offset_annotations, value);
1090 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1092 set(_handle, offset_parameterAnnotations, value);
1095 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1097 set(_handle, offset_declaredAnnotations, value);
1100 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1102 set(_handle, offset_cons, value);
1105 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1107 classinfo* c = get_clazz();
1108 int32_t slot = get_slot();
1109 methodinfo* m = &(c->methods[slot]);
1115 * GNU Classpath java/lang/reflect/Constructor
1121 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1122 * 3. java.lang.reflect.VMConstructor cons;
1124 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
1126 // Static offsets of the object's instance fields.
1127 // TODO These offsets need to be checked on VM startup.
1128 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1129 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1130 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1133 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
1134 java_lang_reflect_Constructor(methodinfo* m);
1136 java_handle_t* new_instance(java_handle_objectarray_t* args);
1139 int32_t get_flag() const;
1140 java_handle_t* get_cons() const;
1143 void set_cons(java_handle_t* value);
1145 // Convenience functions.
1146 methodinfo* get_method () const;
1147 int32_t get_override() const;
1151 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
1153 java_lang_reflect_VMConstructor jlrvmc(m);
1155 if (jlrvmc.is_null())
1158 _handle = builtin_new(class_java_lang_reflect_Constructor);
1163 // Link the two Java objects.
1164 set_cons(jlrvmc.get_handle());
1165 jlrvmc.set_cons(get_handle());
1169 inline int32_t java_lang_reflect_Constructor::get_flag() const
1171 return get<int32_t>(_handle, offset_flag);
1174 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
1176 return get<java_handle_t*>(_handle, offset_cons);
1180 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
1182 set(_handle, offset_cons, value);
1186 inline methodinfo* java_lang_reflect_Constructor::get_method() const
1188 java_lang_reflect_VMConstructor jlrvmc(get_cons());
1189 return jlrvmc.get_method();
1192 inline int32_t java_lang_reflect_Constructor::get_override() const
1199 * GNU Classpath java/lang/reflect/VMField
1204 * 1. java.lang.Class clazz;
1205 * 2. java.lang.String name;
1207 * 4. byte[] annotations;
1208 * 5. java.lang.Map declaredAnnotations;
1209 * 6. java.lang.reflect.Field f;
1211 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1213 // Static offsets of the object's instance fields.
1214 // TODO These offsets need to be checked on VM startup.
1215 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1216 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1217 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1218 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1219 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1220 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1223 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1224 java_lang_reflect_VMField(fieldinfo* f);
1227 classinfo* get_clazz () const;
1228 int32_t get_slot () const;
1229 java_handle_bytearray_t* get_annotations () const;
1230 java_handle_t* get_declaredAnnotations() const;
1231 java_handle_t* get_f () const;
1234 void set_clazz (classinfo* value);
1235 void set_name (java_handle_t* value);
1236 void set_slot (int32_t value);
1237 void set_annotations (java_handle_bytearray_t* value);
1238 void set_declaredAnnotations(java_handle_t* value);
1239 void set_f (java_handle_t* value);
1241 // Convenience functions.
1242 fieldinfo* get_field() const;
1246 inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
1248 _handle = builtin_new(class_java_lang_reflect_VMField);
1253 java_handle_t* name = javastring_intern(javastring_new(f->name));
1254 int slot = f - f->clazz->fields;
1255 java_handle_bytearray_t* annotations = field_get_annotations(f);
1257 set_clazz(f->clazz);
1260 set_annotations(annotations);
1264 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1266 return get<classinfo*>(_handle, offset_clazz);
1269 inline int32_t java_lang_reflect_VMField::get_slot() const
1271 return get<int32_t>(_handle, offset_slot);
1274 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1276 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1279 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1281 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1284 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1286 return get<java_handle_t*>(_handle, offset_f);
1290 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1292 set(_handle, offset_clazz, value);
1295 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1297 set(_handle, offset_name, value);
1300 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1302 set(_handle, offset_slot, value);
1305 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1307 set(_handle, offset_annotations, value);
1310 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1312 set(_handle, offset_declaredAnnotations, value);
1315 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1317 set(_handle, offset_f, value);
1320 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1322 classinfo* c = get_clazz();
1323 int32_t slot = get_slot();
1324 fieldinfo* f = &(c->fields[slot]);
1330 * GNU Classpath java/lang/reflect/Field
1336 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1337 * 3. java.lang.reflect.VMField f;
1339 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1341 // Static offsets of the object's instance fields.
1342 // TODO These offsets need to be checked on VM startup.
1343 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1344 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1345 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1348 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1349 java_lang_reflect_Field(fieldinfo* f);
1352 int32_t get_flag() const;
1353 java_handle_t* get_f() const;
1356 void set_f(java_handle_t* value);
1358 // Convenience functions.
1359 fieldinfo* get_field() const;
1363 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
1365 java_lang_reflect_VMField jlrvmf(f);
1367 if (jlrvmf.is_null())
1370 _handle = builtin_new(class_java_lang_reflect_Field);
1375 // Link the two Java objects.
1376 set_f(jlrvmf.get_handle());
1377 jlrvmf.set_f(get_handle());
1381 inline int32_t java_lang_reflect_Field::get_flag() const
1383 return get<int32_t>(_handle, offset_flag);
1386 inline java_handle_t* java_lang_reflect_Field::get_f() const
1388 return get<java_handle_t*>(_handle, offset_f);
1392 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1394 set(_handle, offset_f, value);
1398 inline fieldinfo* java_lang_reflect_Field::get_field() const
1400 java_lang_reflect_VMField jlrvmf(get_f());
1401 return jlrvmf.get_field();
1406 * GNU Classpath java/lang/reflect/VMMethod
1411 * 1. java.lang.Class clazz;
1412 * 2. java.lang.String name;
1414 * 4. byte[] annotations;
1415 * 5. byte[] parameterAnnotations;
1416 * 6. byte[] annotationDefault;
1417 * 7. java.lang.Map declaredAnnotations;
1418 * 8. java.lang.reflect.Method m;
1420 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1422 // Static offsets of the object's instance fields.
1423 // TODO These offsets need to be checked on VM startup.
1424 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1425 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1426 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1427 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1428 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1429 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1430 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1431 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1434 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1435 java_lang_reflect_VMMethod(methodinfo* m);
1438 classinfo* get_clazz () const;
1439 int32_t get_slot () const;
1440 java_handle_bytearray_t* get_annotations () const;
1441 java_handle_bytearray_t* get_parameterAnnotations() const;
1442 java_handle_bytearray_t* get_annotationDefault () const;
1443 java_handle_t* get_declaredAnnotations () const;
1444 java_handle_t* get_m () const;
1447 void set_clazz (classinfo* value);
1448 void set_name (java_handle_t* value);
1449 void set_slot (int32_t value);
1450 void set_annotations (java_handle_bytearray_t* value);
1451 void set_parameterAnnotations(java_handle_bytearray_t* value);
1452 void set_annotationDefault (java_handle_bytearray_t* value);
1453 void set_declaredAnnotations (java_handle_t* value);
1454 void set_m (java_handle_t* value);
1456 // Convenience functions.
1457 methodinfo* get_method() const;
1461 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
1463 _handle = builtin_new(class_java_lang_reflect_VMMethod);
1468 java_handle_t* name = javastring_intern(javastring_new(m->name));
1469 int slot = m - m->clazz->methods;
1470 java_handle_bytearray_t* annotations = method_get_annotations(m);
1471 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1472 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1474 set_clazz(m->clazz);
1477 set_annotations(annotations);
1478 set_parameterAnnotations(parameterAnnotations);
1479 set_annotationDefault(annotationDefault);
1482 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1484 return get<classinfo*>(_handle, offset_clazz);
1487 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1489 return get<int32_t>(_handle, offset_slot);
1492 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1494 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1497 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1499 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1502 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1504 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1507 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1509 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1512 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1514 return get<java_handle_t*>(_handle, offset_m);
1517 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1519 set(_handle, offset_clazz, value);
1522 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1524 set(_handle, offset_name, value);
1527 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1529 set(_handle, offset_slot, value);
1532 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1534 set(_handle, offset_annotations, value);
1537 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1539 set(_handle, offset_parameterAnnotations, value);
1542 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1544 set(_handle, offset_annotationDefault, value);
1547 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1549 set(_handle, offset_declaredAnnotations, value);
1552 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1554 set(_handle, offset_m, value);
1557 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1559 classinfo* c = get_clazz();
1560 int32_t slot = get_slot();
1561 methodinfo* m = &(c->methods[slot]);
1567 * GNU Classpath java/lang/reflect/Method
1573 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1574 * 3. java.lang.reflect.VMMethod m;
1576 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1578 // Static offsets of the object's instance fields.
1579 // TODO These offsets need to be checked on VM startup.
1580 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1581 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1582 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1585 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1586 java_lang_reflect_Method(methodinfo* m);
1588 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
1591 int32_t get_flag() const;
1592 java_handle_t* get_m() const;
1595 void set_m(java_handle_t* value);
1597 // Convenience functions.
1598 methodinfo* get_method () const;
1599 int32_t get_override() const;
1603 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
1605 java_lang_reflect_VMMethod jlrvmm(m);
1607 if (jlrvmm.is_null())
1610 _handle = builtin_new(class_java_lang_reflect_Method);
1615 // Link the two Java objects.
1616 set_m(jlrvmm.get_handle());
1617 jlrvmm.set_m(get_handle());
1621 inline int32_t java_lang_reflect_Method::get_flag() const
1623 return get<int32_t>(_handle, offset_flag);
1626 inline java_handle_t* java_lang_reflect_Method::get_m() const
1628 return get<java_handle_t*>(_handle, offset_m);
1632 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1634 set(_handle, offset_m, value);
1638 inline methodinfo* java_lang_reflect_Method::get_method() const
1640 java_lang_reflect_VMMethod jlrvmm(get_m());
1641 return jlrvmm.get_method();
1644 inline int32_t java_lang_reflect_Method::get_override() const
1651 * GNU Classpath java/nio/Buffer
1660 * 5. gnu.classpath.Pointer address;
1662 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1664 // Static offsets of the object's instance fields.
1665 // TODO These offsets need to be checked on VM startup.
1666 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1667 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1668 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1669 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1670 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1673 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1676 int32_t get_cap() const;
1679 inline int32_t java_nio_Buffer::get_cap() const
1681 return get<int32_t>(_handle, offset_cap);
1686 * GNU Classpath java/nio/DirectByteBufferImpl
1695 * 5. gnu.classpath.Pointer address;
1696 * 6. java.nio.ByteOrder endian;
1697 * 7. byte[] backing_buffer;
1698 * 8. int array_offset;
1699 * 9. java.lang.Object owner;
1701 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1703 // Static offsets of the object's instance fields.
1704 // TODO These offsets need to be checked on VM startup.
1705 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1706 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1707 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1708 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1709 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1710 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1711 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1712 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1713 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1716 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1719 java_handle_t* get_address() const;
1723 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1725 return get<java_handle_t*>(_handle, offset_address);
1730 * GNU Classpath gnu/classpath/Pointer
1732 * Actually there are two classes, gnu.classpath.Pointer32 and
1733 * gnu.classpath.Pointer64, but we only define the abstract super
1734 * class and use the int/long field as void* type.
1741 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1743 // Static offsets of the object's instance fields.
1744 // TODO These offsets need to be checked on VM startup.
1745 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1748 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1749 gnu_classpath_Pointer(java_handle_t* h, void* data);
1752 void* get_data() const;
1755 void set_data(void* value);
1758 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1763 inline void* gnu_classpath_Pointer::get_data() const
1765 return get<void*>(_handle, offset_data);
1768 inline void gnu_classpath_Pointer::set_data(void* value)
1770 set(_handle, offset_data, value);
1773 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1776 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1779 * OpenJDK java/lang/AssertionStatusDirectives
1784 * 1. java.lang.String[] classes;
1785 * 2. boolean[] classEnabled;
1786 * 3. java.lang.String[] packages;
1787 * 4. boolean[] packageEnabled;
1790 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1792 // Static offsets of the object's instance fields.
1793 // TODO These offsets need to be checked on VM startup.
1794 static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1795 static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1796 static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1797 static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1798 static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1801 java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1804 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)
1806 classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1808 // FIXME Load the class at VM startup.
1812 _handle = builtin_new(c);
1817 set(_handle, offset_classes, classes);
1818 set(_handle, offset_classEnabled, classEnabled);
1819 set(_handle, offset_packages, packages);
1820 set(_handle, offset_packageEnabled, packageEnabled);
1825 * OpenJDK java/lang/ClassLoader
1830 * 1. boolean initialized
1831 * 2. java.lang.ClassLoader parent
1832 * [other fields are not used]
1834 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
1836 // Static offsets of the object's instance fields.
1837 // TODO These offsets need to be checked on VM startup.
1838 static const off_t offset_initialized = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1839 static const off_t offset_parent = MEMORY_ALIGN(offset_initialized + sizeof(int32_t), SIZEOF_VOID_P);
1842 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
1845 java_handle_t* get_parent() const;
1847 // Invocation wrappers for static methods.
1848 static java_handle_t* invoke_getSystemClassLoader();
1851 inline java_handle_t* java_lang_ClassLoader::get_parent() const
1853 return get<java_handle_t*>(_handle, offset_parent);
1858 * OpenJDK java/lang/StackTraceElement
1863 * 1. java.lang.String declaringClass;
1864 * 2. java.lang.String methodName;
1865 * 3. java.lang.String fileName;
1866 * 4. int lineNumber;
1868 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
1870 // Static offsets of the object's instance fields.
1871 // TODO These offsets need to be checked on VM startup.
1872 static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1873 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1874 static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1875 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1878 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
1879 java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1882 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1884 _handle = builtin_new(class_java_lang_StackTraceElement);
1889 set(_handle, offset_declaringClass, declaringClass);
1890 set(_handle, offset_methodName, methodName);
1891 set(_handle, offset_fileName, fileName);
1892 set(_handle, offset_lineNumber, lineNumber);
1897 * OpenJDK java/lang/String
1907 class java_lang_String : public java_lang_Object, private FieldAccess {
1909 // Static offsets of the object's instance fields.
1910 // TODO These offsets need to be checked on VM startup.
1911 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1912 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1913 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1914 static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
1917 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1918 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1921 java_handle_chararray_t* get_value () const;
1922 int32_t get_offset() const;
1923 int32_t get_count () const;
1926 void set_value (java_handle_chararray_t* value);
1927 void set_offset(int32_t value);
1928 void set_count (int32_t value);
1931 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)
1938 inline java_handle_chararray_t* java_lang_String::get_value() const
1940 return get<java_handle_chararray_t*>(_handle, offset_value);
1943 inline int32_t java_lang_String::get_offset() const
1945 return get<int32_t>(_handle, offset_offset);
1948 inline int32_t java_lang_String::get_count() const
1950 return get<int32_t>(_handle, offset_count);
1953 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1955 set(_handle, offset_value, value);
1958 inline void java_lang_String::set_offset(int32_t value)
1960 set(_handle, offset_offset, value);
1963 inline void java_lang_String::set_count(int32_t value)
1965 set(_handle, offset_count, value);
1970 * OpenJDK java/lang/Thread
1977 * 3. java_lang_Thread threadQ;
1979 * 5. boolean single_step;
1980 * 6. boolean daemon;
1981 * 7. boolean stillborn;
1982 * 8. java_lang_Runnable target;
1983 * 9. java_lang_ThreadGroup group;
1984 * 10. java_lang_ClassLoader contextClassLoader;
1985 * 11. java_security_AccessControlContext inheritedAccessControlContext;
1986 * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals;
1987 * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals;
1988 * 14. long stackSize;
1989 * 15. long nativeParkEventPointer;
1991 * 17. int threadStatus;
1992 * 18. java_lang_Object parkBlocker;
1993 * 19. sun_nio_ch_Interruptible blocker;
1994 * 20. java_lang_Object blockerLock;
1995 * 21. boolean stopBeforeStart;
1996 * 22. java_lang_Throwable throwableFromStop;
1997 * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
1999 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2001 // Static offsets of the object's instance fields.
2002 // TODO These offsets need to be checked on VM startup.
2003 static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2004 static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
2005 static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2006 static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t));
2007 static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t));
2008 static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t));
2009 static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
2010 static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2011 static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P);
2012 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
2013 static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
2014 static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P);
2015 static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P);
2016 static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t));
2017 static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t));
2018 static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t));
2019 static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t));
2020 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P);
2021 static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
2022 static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
2023 static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t));
2024 static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P);
2025 static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P);
2028 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2029 // java_lang_Thread(threadobject* t);
2032 int32_t get_priority () const;
2033 int32_t get_daemon () const;
2034 java_handle_t* get_group () const;
2035 java_handle_t* get_uncaughtExceptionHandler() const;
2038 void set_priority (int32_t value);
2039 void set_group (java_handle_t* value);
2040 void set_threadStatus(int32_t value);
2044 inline int32_t java_lang_Thread::get_priority() const
2046 return get<int32_t>(_handle, offset_priority);
2049 inline int32_t java_lang_Thread::get_daemon() const
2051 return get<int32_t>(_handle, offset_daemon);
2054 inline java_handle_t* java_lang_Thread::get_group() const
2056 return get<java_handle_t*>(_handle, offset_group);
2059 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
2061 return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
2065 inline void java_lang_Thread::set_priority(int32_t value)
2067 set(_handle, offset_priority, value);
2070 inline void java_lang_Thread::set_group(java_handle_t* value)
2072 set(_handle, offset_group, value);
2075 inline void java_lang_Thread::set_threadStatus(int32_t value)
2077 set(_handle, offset_threadStatus, value);
2083 * OpenJDK java/lang/Throwable
2088 * 1. java.lang.Object backtrace;
2089 * 2. java.lang.String detailMessage;
2090 * 3. java.lang.Throwable cause;
2091 * 4. java.lang.StackTraceElement[] stackTrace;
2093 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2095 // Static offsets of the object's instance fields.
2096 // TODO These offsets need to be checked on VM startup.
2097 static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2098 static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2099 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2100 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2103 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2104 java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
2107 java_handle_bytearray_t* get_backtrace () const;
2108 java_handle_t* get_detailMessage() const;
2109 java_handle_t* get_cause () const;
2112 void set_backtrace(java_handle_bytearray_t* value);
2116 inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
2118 set_backtrace(backtrace);
2122 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2124 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2127 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2129 return get<java_handle_t*>(_handle, offset_detailMessage);
2132 inline java_handle_t* java_lang_Throwable::get_cause() const
2134 return get<java_handle_t*>(_handle, offset_cause);
2138 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2140 set(_handle, offset_backtrace, value);
2145 * OpenJDK java/lang/reflect/Constructor
2150 * 1. boolean override;
2151 * 2. java.lang.Class clazz;
2153 * 4. java.lang.Class[] parameterTypes;
2154 * 5. java.lang.Class[] exceptionTypes;
2156 * 7. java.lang.String signature;
2157 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2158 * 9. byte[] annotations;
2159 * 10. byte[] parameterAnnotations;
2160 * 11. java.lang.Class securityCheckCache;
2161 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2162 * 13. java.lang.reflect.Constructor root;
2163 * 14. java.util.Map declaredAnnotations;
2165 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
2167 // Static offsets of the object's instance fields.
2168 // TODO These offsets need to be checked on VM startup.
2169 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2170 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2171 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2172 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2173 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2174 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2175 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2176 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2177 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2178 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2179 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2180 static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2181 static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2182 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2185 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
2186 java_lang_reflect_Constructor(methodinfo* m);
2188 java_handle_t* new_instance(java_handle_objectarray_t* args);
2191 int32_t get_override () const;
2192 classinfo* get_clazz () const;
2193 int32_t get_slot () const;
2194 java_handle_bytearray_t* get_annotations() const;
2197 void set_clazz (classinfo* value);
2198 void set_slot (int32_t value);
2199 void set_parameterTypes (java_handle_objectarray_t* value);
2200 void set_exceptionTypes (java_handle_objectarray_t* value);
2201 void set_modifiers (int32_t value);
2202 void set_signature (java_handle_t* value);
2203 void set_annotations (java_handle_bytearray_t* value);
2204 void set_parameterAnnotations(java_handle_bytearray_t* value);
2206 // Convenience functions.
2207 methodinfo* get_method();
2211 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
2213 _handle = builtin_new(class_java_lang_reflect_Constructor);
2218 int slot = m - m->clazz->methods;
2219 java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
2220 java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
2221 java_handle_bytearray_t* annotations = method_get_annotations(m);
2222 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2224 set_clazz(m->clazz);
2226 set_parameterTypes(parameterTypes);
2227 set_exceptionTypes(exceptionTypes);
2228 set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2229 set_signature(m->signature ? javastring_new(m->signature) : NULL);
2230 set_annotations(annotations);
2231 set_parameterAnnotations(parameterAnnotations);
2235 inline int32_t java_lang_reflect_Constructor::get_override() const
2237 return get<int32_t>(_handle, offset_override);
2240 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2242 return get<classinfo*>(_handle, offset_clazz);
2245 inline int32_t java_lang_reflect_Constructor::get_slot() const
2247 return get<int32_t>(_handle, offset_slot);
2250 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2252 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2256 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2258 set(_handle, offset_clazz, value);
2261 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2263 set(_handle, offset_slot, value);
2266 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2268 set(_handle, offset_parameterTypes, value);
2271 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2273 set(_handle, offset_exceptionTypes, value);
2276 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2278 set(_handle, offset_modifiers, value);
2281 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2283 set(_handle, offset_signature, value);
2286 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2288 set(_handle, offset_annotations, value);
2291 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2293 set(_handle, offset_parameterAnnotations, value);
2297 inline methodinfo* java_lang_reflect_Constructor::get_method()
2299 classinfo* c = get_clazz();
2300 int32_t slot = get_slot();
2301 methodinfo* m = &(c->methods[slot]);
2307 * OpenJDK java/lang/reflect/Field
2312 * 1. boolean override;
2313 * 2. java.lang.Class clazz;
2315 * 4. java.lang.String name;
2316 * 5. java.lang.Class type;
2318 * 7. java.lang.String signature;
2319 * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2320 * 9. byte[] annotations;
2321 * 10. sun.reflect.FieldAccessor fieldAccessor;
2322 * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2323 * 12. java.lang.reflect.Field root;
2324 * 13. java.lang.Class securityCheckCache;
2325 * 14. java.lang.Class securityCheckTargetClassCache;
2326 * 15. java.util.Map declaredAnnotations;
2328 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2330 // Static offsets of the object's instance fields.
2331 // TODO These offsets need to be checked on VM startup.
2332 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2333 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2334 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2335 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2336 static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2337 static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2338 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2339 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2340 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2341 static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2342 static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2343 static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2344 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2345 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2346 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2349 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
2350 java_lang_reflect_Field(fieldinfo* f);
2353 int32_t get_override () const;
2354 classinfo* get_clazz () const;
2355 int32_t get_slot () const;
2356 java_handle_bytearray_t* get_annotations() const;
2359 void set_clazz (classinfo* value);
2360 void set_slot (int32_t value);
2361 void set_name (java_handle_t* value);
2362 void set_type (classinfo* value);
2363 void set_modifiers (int32_t value);
2364 void set_signature (java_handle_t* value);
2365 void set_annotations(java_handle_bytearray_t* value);
2367 // Convenience functions.
2368 fieldinfo* get_field() const;
2372 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
2374 _handle = builtin_new(class_java_lang_reflect_Field);
2380 set_clazz(f->clazz);
2381 set_slot(f - f->clazz->fields);
2382 set_name(javastring_intern(javastring_new(f->name)));
2383 set_type(field_get_type(f));
2384 set_modifiers(f->flags);
2385 set_signature(f->signature ? javastring_new(f->signature) : NULL);
2386 set_annotations(field_get_annotations(f));
2390 inline int32_t java_lang_reflect_Field::get_override() const
2392 return get<int32_t>(_handle, offset_override);
2395 inline classinfo* java_lang_reflect_Field::get_clazz() const
2397 return get<classinfo*>(_handle, offset_clazz);
2400 inline int32_t java_lang_reflect_Field::get_slot() const
2402 return get<int32_t>(_handle, offset_slot);
2405 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2407 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2411 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2413 set(_handle, offset_clazz, value);
2416 inline void java_lang_reflect_Field::set_slot(int32_t value)
2418 set(_handle, offset_slot, value);
2421 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2423 set(_handle, offset_name, value);
2426 inline void java_lang_reflect_Field::set_type(classinfo* value)
2428 set(_handle, offset_type, value);
2431 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2433 set(_handle, offset_modifiers, value);
2436 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2438 set(_handle, offset_signature, value);
2441 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2443 set(_handle, offset_annotations, value);
2447 inline fieldinfo* java_lang_reflect_Field::get_field() const
2449 classinfo* c = get_clazz();
2450 int32_t slot = get_slot();
2451 fieldinfo* f = &(c->fields[slot]);
2457 * OpenJDK java/lang/reflect/Method
2462 * 1. boolean override;
2463 * 2. java.lang.Class clazz;
2465 * 4. java.lang.String name;
2466 * 5. java.lang.Class returnType;
2467 * 6. java.lang.Class[] parameterTypes;
2468 * 7. java.lang.Class[] exceptionTypes;
2470 * 9. java.lang.String signature;
2471 * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2472 * 11. byte[] annotations;
2473 * 12. byte[] parameterAnnotations;
2474 * 13. byte[] annotationDefault;
2475 * 14. sun.reflect.MethodAccessor methodAccessor;
2476 * 15. java.lang.reflect.Method root;
2477 * 16. java.lang.Class securityCheckCache;
2478 * 17. java.lang.Class securityCheckTargetClassCache;
2479 * 18. java.util.Map declaredAnnotations;
2481 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2483 // Static offsets of the object's instance fields.
2484 // TODO These offsets need to be checked on VM startup.
2485 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2486 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2487 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2488 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2489 static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2490 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2491 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2492 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2493 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2494 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2495 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2496 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2497 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2498 static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2499 static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2500 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2501 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2502 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2505 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
2506 java_lang_reflect_Method(methodinfo* m);
2508 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
2511 int32_t get_override () const;
2512 classinfo* get_clazz () const;
2513 int32_t get_slot () const;
2514 java_handle_bytearray_t* get_annotations () const;
2515 java_handle_bytearray_t* get_parameterAnnotations() const;
2516 java_handle_bytearray_t* get_annotationDefault () const;
2520 // Convenience functions.
2521 methodinfo* get_method() const;
2525 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
2527 _handle = builtin_new(class_java_lang_reflect_Method);
2532 set(_handle, offset_clazz, m->clazz);
2533 set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2534 set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
2535 set(_handle, offset_returnType, method_returntype_get(m));
2536 set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2537 set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2538 set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2539 set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
2540 set(_handle, offset_annotations, method_get_annotations(m));
2541 set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2542 set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2546 inline int32_t java_lang_reflect_Method::get_override() const
2548 return get<int32_t>(_handle, offset_override);
2551 inline classinfo* java_lang_reflect_Method::get_clazz() const
2553 return get<classinfo*>(_handle, offset_clazz);
2556 inline int32_t java_lang_reflect_Method::get_slot() const
2558 return get<int32_t>(_handle, offset_slot);
2561 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2563 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2566 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2568 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2571 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2573 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2577 inline methodinfo* java_lang_reflect_Method::get_method() const
2579 classinfo* c = get_clazz();
2580 int32_t slot = get_slot();
2581 methodinfo* m = &(c->methods[slot]);
2587 * OpenJDK java/nio/Buffer
2598 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2600 // Static offsets of the object's instance fields.
2601 // TODO These offsets need to be checked on VM startup.
2602 static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2603 static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2604 static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2605 static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2606 static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2609 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
2612 void* get_address() const;
2616 inline void* java_nio_Buffer::get_address() const
2618 return get<void*>(_handle, offset_address);
2621 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2624 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2627 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2636 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2638 // Static offsets of the object's instance fields.
2639 // TODO These offsets need to be checked on VM startup.
2640 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2641 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2642 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2645 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2646 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2647 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2650 int64_t get_pointer () const;
2651 int32_t get_position() const;
2652 int32_t get_length () const;
2655 void set_pointer (int64_t value);
2656 void set_position(int32_t value);
2657 void set_length (int32_t value);
2661 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)
2663 set_pointer(pointer);
2664 set_position(position);
2668 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)
2670 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2674 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2676 return get<int64_t>(_handle, offset_pointer);
2679 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2681 return get<int32_t>(_handle, offset_position);
2684 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2686 return get<int32_t>(_handle, offset_length);
2690 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2692 set(_handle, offset_pointer, value);
2695 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2697 set(_handle, offset_position, value);
2700 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2702 set(_handle, offset_length, value);
2707 * CLDC 1.1 java/lang/String
2716 class java_lang_String : public java_lang_Object, private FieldAccess {
2718 // Static offsets of the object's instance fields.
2719 // TODO These offsets need to be checked on VM startup.
2720 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2721 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2722 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2725 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
2726 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2729 java_handle_chararray_t* get_value () const;
2730 int32_t get_offset() const;
2731 int32_t get_count () const;
2734 void set_value (java_handle_chararray_t* value);
2735 void set_offset(int32_t value);
2736 void set_count (int32_t value);
2740 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)
2747 inline java_handle_chararray_t* java_lang_String::get_value() const
2749 return get<java_handle_chararray_t*>(_handle, offset_value);
2752 inline int32_t java_lang_String::get_offset() const
2754 return get<int32_t>(_handle, offset_offset);
2757 inline int32_t java_lang_String::get_count() const
2759 return get<int32_t>(_handle, offset_count);
2762 inline void java_lang_String::set_value(java_handle_chararray_t* value)
2764 set(_handle, offset_value, value);
2767 inline void java_lang_String::set_offset(int32_t value)
2769 set(_handle, offset_offset, value);
2772 inline void java_lang_String::set_count(int32_t value)
2774 set(_handle, offset_count, value);
2779 * CLDC 1.1 java/lang/Thread
2785 * 2. java.lang.Runnable runnable;
2786 * 3. java.lang.Object vm_thread;
2787 * 4. int is_terminated;
2788 * 5. int is_stillborn;
2791 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2793 // Static offsets of the object's instance fields.
2794 // TODO These offsets need to be checked on VM startup.
2795 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2796 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2797 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2798 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2799 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2800 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2803 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2804 // java_lang_Thread(threadobject* t);
2807 int32_t get_priority () const;
2808 threadobject* get_vm_thread() const;
2809 java_handle_chararray_t* get_name () const;
2812 void set_vm_thread(threadobject* value);
2816 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
2818 // java_lang_Thread(thread_get_object(t));
2822 inline int32_t java_lang_Thread::get_priority() const
2824 return get<int32_t>(_handle, offset_priority);
2827 inline threadobject* java_lang_Thread::get_vm_thread() const
2829 return get<threadobject*>(_handle, offset_vm_thread);
2832 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2834 return get<java_handle_chararray_t*>(_handle, offset_name);
2838 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2840 set(_handle, offset_vm_thread, value);
2845 * CLDC 1.1 java/lang/Throwable
2850 * 1. java.lang.String detailMessage;
2851 * 2. java.lang.Object backtrace;
2853 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2855 // Static offsets of the object's instance fields.
2856 // TODO These offsets need to be checked on VM startup.
2857 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2858 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2861 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2864 java_handle_t* get_detailMessage() const;
2865 java_handle_bytearray_t* get_backtrace () const;
2868 void set_backtrace(java_handle_bytearray_t* value);
2872 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2874 return get<java_handle_t*>(_handle, offset_detailMessage);
2877 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2879 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2883 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2885 set(_handle, offset_backtrace, value);
2888 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2892 #endif // _JAVAOBJECTS_HPP
2896 * These are local overrides for various environment variables in Emacs.
2897 * Please do not remove this and leave it at the end of the file, where
2898 * Emacs will automagically detect them.
2899 * ---------------------------------------------------------------------
2902 * indent-tabs-mode: t