1 /* src/vm/javaobjects.hpp - functions to create and access Java objects
3 Copyright (C) 1996-2011
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 Copyright (C) 2008, 2009 Theobroma Systems Ltd.
7 This file is part of CACAO.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2, or (at
12 your option) any later version.
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 #ifndef _JAVAOBJECTS_HPP
28 #define _JAVAOBJECTS_HPP
34 #include "mm/memory.hpp"
36 #include "native/llni.h"
38 #include "threads/atomic.hpp"
40 #include "vm/class.hpp"
41 #include "vm/field.hpp"
42 #include "vm/global.h"
43 #include "vm/globals.hpp"
44 #include "vm/method.hpp"
50 * This class provides low-level functions to access Java object
53 * These functions do NOT take care about the GC critical section!
54 * Please use FieldAccess wherever possible.
56 class RawFieldAccess {
58 template<class T> static inline T raw_get(void* address, const off_t offset);
59 template<class T> static inline void raw_set(void* address, const off_t offset, T value);
63 template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
65 T* p = (T*) (((uintptr_t) address) + offset);
70 template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
72 T* p = (T*) (((uintptr_t) address) + offset);
78 * This classes provides functions to access Java object instance
79 * fields. These functions enter a critical GC section before
80 * accessing the Java object throught the handle and leave it
83 class FieldAccess : private RawFieldAccess {
85 // Normal field accessors.
86 template<class T> static inline T get(java_handle_t* h, const off_t offset);
87 template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
89 // Volatile field accessors.
90 template<class T> static inline T get_volatile(java_handle_t* h, const off_t offset);
91 template<class T> static inline void set_volatile(java_handle_t* h, const off_t offset, T value);
95 template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
97 // This function is inside a critical section.
100 // XXX This should be _handle->get_object();
101 java_object_t* ho = LLNI_UNWRAP(h);
102 return raw_get<T>(ho, offset);
105 template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
107 // This function is inside a critical section.
108 GCCriticalSection cs;
110 // XXX This should be _handle->get_object();
111 java_object_t* o = LLNI_UNWRAP(h);
112 java_object_t* result = raw_get<java_object_t*>(o, offset);
113 return LLNI_WRAP(result);
117 template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
119 // This function is inside a critical section.
120 GCCriticalSection cs;
122 java_object_t* ho = LLNI_UNWRAP(h);
123 raw_set(ho, offset, value);
126 template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
128 // This function is inside a critical section.
129 GCCriticalSection cs;
131 // XXX This should be h->get_object();
132 java_object_t* o = LLNI_UNWRAP(h);
133 java_object_t* ovalue = LLNI_UNWRAP(value);
134 raw_set(o, offset, ovalue);
138 template<class T> inline T FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
140 // This function is inside a critical section.
141 GCCriticalSection cs;
143 // XXX This should be _handle->get_object();
144 java_object_t* ho = LLNI_UNWRAP(h);
145 return raw_get<volatile T>(ho, offset);
148 template<> inline java_handle_t* FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
150 // This function is inside a critical section.
151 GCCriticalSection cs;
153 // XXX This should be _handle->get_object();
154 java_object_t* o = LLNI_UNWRAP(h);
155 java_object_t* result = (java_object_t*) raw_get<volatile java_object_t*>(o, offset);
156 return LLNI_WRAP(result);
160 template<class T> inline void FieldAccess::set_volatile(java_handle_t* h, const off_t offset, T value)
162 // This function is inside a critical section.
163 GCCriticalSection cs;
165 java_object_t* ho = LLNI_UNWRAP(h);
166 raw_set(ho, offset, (volatile T) value);
168 // Memory barrier for the Java Memory Model.
169 Atomic::memory_barrier();
172 template<> inline void FieldAccess::set_volatile<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
174 // This function is inside a critical section.
175 GCCriticalSection cs;
177 // XXX This should be h->get_object();
178 java_object_t* o = LLNI_UNWRAP(h);
179 java_object_t* ovalue = LLNI_UNWRAP(value);
180 raw_set(o, offset, (volatile java_object_t*) ovalue);
182 // Memory barrier for the Java Memory Model.
183 Atomic::memory_barrier();
194 class java_lang_Object {
196 // Handle of Java object.
197 java_handle_t* _handle;
200 java_lang_Object() : _handle(NULL) {}
201 java_lang_Object(java_handle_t* h) : _handle(h) {}
202 virtual ~java_lang_Object() {}
205 virtual java_handle_t* get_handle () const { return _handle; }
206 vftbl_t* get_vftbl () const;
207 classinfo* get_Class () const;
208 int32_t get_hashcode() const;
210 bool is_null () const;
211 bool is_non_null() const;
215 inline vftbl_t* java_lang_Object::get_vftbl() const
217 // This function is inside a critical section.
218 GCCriticalSection cs;
220 // XXX This should be h->get_object();
221 java_object_t* o = LLNI_UNWRAP(_handle);
225 inline classinfo* java_lang_Object::get_Class() const
227 return get_vftbl()->clazz;
230 inline int32_t java_lang_Object::get_hashcode() const
232 #if defined(ENABLE_GC_CACAO)
233 return heap_get_hashcode(_handle);
235 // This function is inside a critical section.
236 GCCriticalSection cs;
238 // XXX This should be h->get_object();
239 java_object_t* o = LLNI_UNWRAP(_handle);
240 return (int32_t) (intptr_t) o;
245 inline bool java_lang_Object::is_null() const
247 return (_handle == NULL);
250 inline bool java_lang_Object::is_non_null() const
252 return (_handle != NULL);
264 class java_lang_Boolean : public java_lang_Object, private FieldAccess {
266 // Static offsets of the object's instance fields.
267 // TODO These offsets need to be checked on VM startup.
268 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
271 java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {}
274 void set_value(uint8_t value);
277 inline uint8_t java_lang_Boolean::get_value()
279 return get<int32_t>(_handle, offset_value);
282 inline void java_lang_Boolean::set_value(uint8_t value)
284 set(_handle, offset_value, (uint32_t) value);
296 class java_lang_Byte : public java_lang_Object, private FieldAccess {
298 // Static offsets of the object's instance fields.
299 // TODO These offsets need to be checked on VM startup.
300 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
303 java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {}
306 void set_value(int8_t value);
309 inline int8_t java_lang_Byte::get_value()
311 return get<int32_t>(_handle, offset_value);
314 inline void java_lang_Byte::set_value(int8_t value)
316 set(_handle, offset_value, (int32_t) value);
321 * java/lang/Character
328 class java_lang_Character : public java_lang_Object, private FieldAccess {
330 // Static offsets of the object's instance fields.
331 // TODO These offsets need to be checked on VM startup.
332 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
335 java_lang_Character(java_handle_t* h) : java_lang_Object(h) {}
337 uint16_t get_value();
338 void set_value(uint16_t value);
341 inline uint16_t java_lang_Character::get_value()
343 return get<int32_t>(_handle, offset_value);
346 inline void java_lang_Character::set_value(uint16_t value)
348 set(_handle, offset_value, (uint32_t) value);
360 class java_lang_Short : public java_lang_Object, private FieldAccess {
362 // Static offsets of the object's instance fields.
363 // TODO These offsets need to be checked on VM startup.
364 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
367 java_lang_Short(java_handle_t* h) : java_lang_Object(h) {}
370 void set_value(int16_t value);
373 inline int16_t java_lang_Short::get_value()
375 return get<int32_t>(_handle, offset_value);
378 inline void java_lang_Short::set_value(int16_t value)
380 set(_handle, offset_value, (int32_t) value);
392 class java_lang_Integer : public java_lang_Object, private FieldAccess {
394 // Static offsets of the object's instance fields.
395 // TODO These offsets need to be checked on VM startup.
396 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
399 java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
402 void set_value(int32_t value);
405 inline int32_t java_lang_Integer::get_value()
407 return get<int32_t>(_handle, offset_value);
410 inline void java_lang_Integer::set_value(int32_t value)
412 set(_handle, offset_value, value);
424 class java_lang_Long : public java_lang_Object, private FieldAccess {
426 // Static offsets of the object's instance fields.
427 // TODO These offsets need to be checked on VM startup.
428 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
431 java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
434 void set_value(int64_t value);
437 inline int64_t java_lang_Long::get_value()
439 return get<int64_t>(_handle, offset_value);
442 inline void java_lang_Long::set_value(int64_t value)
444 set(_handle, offset_value, value);
456 class java_lang_Float : public java_lang_Object, private FieldAccess {
458 // Static offsets of the object's instance fields.
459 // TODO These offsets need to be checked on VM startup.
460 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
463 java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
466 void set_value(float value);
469 inline float java_lang_Float::get_value()
471 return get<float>(_handle, offset_value);
474 inline void java_lang_Float::set_value(float value)
476 set(_handle, offset_value, value);
488 class java_lang_Double : public java_lang_Object, private FieldAccess {
490 // Static offsets of the object's instance fields.
491 // TODO These offsets need to be checked on VM startup.
492 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
495 java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
498 void set_value(double value);
501 inline double java_lang_Double::get_value()
503 return get<double>(_handle, offset_value);
506 inline void java_lang_Double::set_value(double value)
508 set(_handle, offset_value, value);
512 #if defined(ENABLE_JAVASE)
515 * java/lang/management/MemoryUsage
520 * [other fields are not used]
522 class java_lang_management_MemoryUsage : public java_lang_Object, private FieldAccess {
524 java_lang_management_MemoryUsage(java_handle_t* h) : java_lang_Object(h) {}
525 java_lang_management_MemoryUsage(int64_t init, int64_t used, int64_t commited, int64_t maximum);
529 # if defined(ENABLE_ANNOTATIONS)
531 * OpenJDK sun/reflect/ConstantPool
536 * 1. java.lang.Object constantPoolOop;
538 class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
540 // Static offsets of the object's instance fields.
541 // TODO These offsets need to be checked on VM startup.
542 static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
545 sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
546 sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
549 void set_constantPoolOop(classinfo* value);
550 void set_constantPoolOop(jclass value);
554 inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
556 set_constantPoolOop(constantPoolOop);
560 inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
562 set(_handle, offset_constantPoolOop, value);
565 inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
567 // XXX jclass is a boxed object.
568 set_constantPoolOop(LLNI_classinfo_unwrap(value));
570 # endif // ENABLE_ANNOTATIONS
572 #endif // ENABLE_JAVASE
574 void jobjects_register_dyn_offsets();
575 bool jobjects_run_dynoffsets_hook(classinfo *c);
577 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
580 * GNU Classpath java/lang/Class
585 * 1. java.lang.Object[] signers;
586 * 2. java.security.ProtectionDomain pd;
587 * 3. java.lang.Object vmdata;
588 * 4. java.lang.reflect.Constructor constructor;
590 class java_lang_Class : public java_lang_Object, private FieldAccess {
592 // Static offsets of the object's instance fields.
593 // TODO These offsets need to be checked on VM startup.
594 static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
595 static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
596 static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
597 static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
600 java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
603 void set_pd(java_handle_t* value);
606 inline void java_lang_Class::set_pd(java_handle_t* value)
608 set(_handle, offset_pd, value);
613 * GNU Classpath java/lang/ClassLoader
618 * 1. java.util.HashMap definedPackages
619 * 2. java.lang.ClassLoader parent
620 * [other fields are not used]
622 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
624 // Static offsets of the object's instance fields.
625 // TODO These offsets need to be checked on VM startup.
626 static const off_t offset_definedPackages = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
627 static const off_t offset_parent = MEMORY_ALIGN(offset_definedPackages + SIZEOF_VOID_P, SIZEOF_VOID_P);
630 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
633 java_handle_t* get_parent() const;
635 // Invocation wrappers for static methods.
636 static java_handle_t* invoke_getSystemClassLoader();
639 inline java_handle_t* java_lang_ClassLoader::get_parent() const
641 return get<java_handle_t*>(_handle, offset_parent);
646 * GNU Classpath java/lang/StackTraceElement
651 * 1. java.lang.String fileName;
653 * 3. java.lang.String declaringClass;
654 * 4. java.lang.String methodName;
655 * 5. boolean isNative;
657 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
659 // Static offsets of the object's instance fields.
660 // TODO These offsets need to be checked on VM startup.
661 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
662 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
663 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
664 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
665 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
668 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
669 java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative);
672 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative) : java_lang_Object(h)
674 java_lang_StackTraceElement((java_handle_t*) h);
676 set(_handle, offset_fileName, fileName);
677 set(_handle, offset_lineNumber, lineNumber);
678 set(_handle, offset_declaringClass, declaringClass);
679 set(_handle, offset_methodName, methodName);
680 set(_handle, offset_isNative, isNative);
685 * GNU Classpath java/lang/String
692 * 3. int cachedHashCode;
695 class java_lang_String : public java_lang_Object, private FieldAccess {
697 // Static offsets of the object's instance fields.
698 // TODO These offsets need to be checked on VM startup.
699 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
700 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
701 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
702 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
705 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
706 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
709 java_handle_chararray_t* get_value () const;
710 int32_t get_count () const;
711 int32_t get_offset() const;
714 void set_value (java_handle_chararray_t* value);
715 void set_count (int32_t value);
716 void set_offset(int32_t value);
719 inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
726 inline java_handle_chararray_t* java_lang_String::get_value() const
728 return get<java_handle_chararray_t*>(_handle, offset_value);
731 inline int32_t java_lang_String::get_count() const
733 return get<int32_t>(_handle, offset_count);
736 inline int32_t java_lang_String::get_offset() const
738 return get<int32_t>(_handle, offset_offset);
741 inline void java_lang_String::set_value(java_handle_chararray_t* value)
743 set(_handle, offset_value, value);
746 inline void java_lang_String::set_count(int32_t value)
748 set(_handle, offset_count, value);
751 inline void java_lang_String::set_offset(int32_t value)
753 set(_handle, offset_offset, value);
758 * GNU Classpath java/lang/Thread
760 class java_lang_Thread : public java_lang_Object, private FieldAccess {
762 // Static offsets of the object's instance fields.
763 static off_t offset_vmThread;
764 static off_t offset_group;
765 static off_t offset_name;
766 static off_t offset_daemon;
767 static off_t offset_priority;
768 static off_t offset_exceptionHandler;
771 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
774 java_handle_t* get_vmThread () const;
775 java_handle_t* get_group () const;
776 java_handle_t* get_name () const;
777 int32_t get_daemon () const;
778 int32_t get_priority () const;
779 java_handle_t* get_exceptionHandler() const;
782 void set_group(java_handle_t* value);
784 // Offset initializers
785 static void set_vmThread_offset(int32_t off) { offset_vmThread = off; }
786 static void set_group_offset(int32_t off) { offset_group = off; }
787 static void set_name_offset(int32_t off) { offset_name = off; }
788 static void set_daemon_offset(int32_t off) { offset_daemon = off; }
789 static void set_priority_offset(int32_t off) { offset_priority = off; }
790 static void set_exceptionHandler_offset(int32_t off) { offset_exceptionHandler = off; }
794 inline java_handle_t* java_lang_Thread::get_vmThread() const
796 return get<java_handle_t*>(_handle, offset_vmThread);
799 inline java_handle_t* java_lang_Thread::get_group() const
801 return get<java_handle_t*>(_handle, offset_group);
804 inline java_handle_t* java_lang_Thread::get_name() const
806 return get<java_handle_t*>(_handle, offset_name);
809 inline int32_t java_lang_Thread::get_daemon() const
811 return get<int32_t>(_handle, offset_daemon);
814 inline int32_t java_lang_Thread::get_priority() const
816 return get<int32_t>(_handle, offset_priority);
819 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
821 return get<java_handle_t*>(_handle, offset_exceptionHandler);
825 inline void java_lang_Thread::set_group(java_handle_t* value)
827 set(_handle, offset_group, value);
832 * GNU Classpath java/lang/VMThread
837 * 1. java.lang.Thread thread;
838 * 2. boolean running;
839 * 3. java.lang.VMThread vmdata;
841 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
843 // Static offsets of the object's instance fields.
844 // TODO These offsets need to be checked on VM startup.
845 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
846 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
847 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
850 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
851 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
854 java_handle_t* get_thread() const;
855 threadobject* get_vmdata() const;
858 void set_thread(java_handle_t* value);
859 void set_vmdata(threadobject* value);
863 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
870 inline java_handle_t* java_lang_VMThread::get_thread() const
872 return get<java_handle_t*>(_handle, offset_thread);
875 inline threadobject* java_lang_VMThread::get_vmdata() const
877 return get<threadobject*>(_handle, offset_vmdata);
881 inline void java_lang_VMThread::set_thread(java_handle_t* value)
883 set(_handle, offset_thread, value);
886 inline void java_lang_VMThread::set_vmdata(threadobject* value)
888 set(_handle, offset_vmdata, value);
893 * GNU Classpath java/lang/Throwable
898 * 1. java.lang.String detailMessage;
899 * 2. java.lang.Throwable cause;
900 * 3. java.lang.StackTraceElement[] stackTrace;
901 * 4. java.lang.VMThrowable vmState;
903 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
905 // Static offsets of the object's instance fields.
906 // TODO These offsets need to be checked on VM startup.
907 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
908 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
909 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
910 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
913 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
916 java_handle_t* get_detailMessage() const;
917 java_handle_t* get_cause () const;
918 java_handle_t* get_vmState () const;
922 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
924 return get<java_handle_t*>(_handle, offset_detailMessage);
927 inline java_handle_t* java_lang_Throwable::get_cause() const
929 return get<java_handle_t*>(_handle, offset_cause);
932 inline java_handle_t* java_lang_Throwable::get_vmState() const
934 return get<java_handle_t*>(_handle, offset_vmState);
939 * GNU Classpath java/lang/VMThrowable
944 * 1. java.lang.Object vmdata;
946 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
948 // Static offsets of the object's instance fields.
949 // TODO These offsets need to be checked on VM startup.
950 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
953 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
955 java_handle_bytearray_t* get_vmdata() const;
956 void set_vmdata(java_handle_bytearray_t* value);
960 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
962 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
965 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
967 set(_handle, offset_vmdata, value);
972 * GNU Classpath java/lang/reflect/VMConstructor
977 * 1. java.lang.Class clazz;
979 * 3. byte[] annotations;
980 * 4. byte[] parameterAnnotations;
981 * 5. java.util.Map declaredAnnotations;
982 * 6. java.lang.reflect.Constructor cons;
984 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
986 // Static offsets of the object's instance fields.
987 // TODO These offsets need to be checked on VM startup.
988 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
989 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
990 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
991 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
992 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
993 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
996 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
997 java_lang_reflect_VMConstructor(methodinfo* m);
1000 classinfo* get_clazz () const;
1001 int32_t get_slot () const;
1002 java_handle_bytearray_t* get_annotations () const;
1003 java_handle_bytearray_t* get_parameterAnnotations() const;
1004 java_handle_t* get_declaredAnnotations () const;
1005 java_handle_t* get_cons () const;
1008 void set_clazz (classinfo* value);
1009 void set_slot (int32_t value);
1010 void set_annotations (java_handle_bytearray_t* value);
1011 void set_parameterAnnotations(java_handle_bytearray_t* value);
1012 void set_declaredAnnotations (java_handle_t* value);
1013 void set_cons (java_handle_t* value);
1015 // Convenience functions.
1016 methodinfo* get_method();
1020 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
1022 _handle = builtin_new(class_java_lang_reflect_VMConstructor);
1027 int slot = m - m->clazz->methods;
1028 java_handle_bytearray_t* annotations = method_get_annotations(m);
1029 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1031 set_clazz(m->clazz);
1033 set_annotations(annotations);
1034 set_parameterAnnotations(parameterAnnotations);
1038 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1040 return get<classinfo*>(_handle, offset_clazz);
1043 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1045 return get<int32_t>(_handle, offset_slot);
1048 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1050 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1053 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1055 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1058 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1060 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1063 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1065 return get<java_handle_t*>(_handle, offset_cons);
1068 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1070 set(_handle, offset_clazz, value);
1073 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1075 set(_handle, offset_slot, value);
1078 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1080 set(_handle, offset_annotations, value);
1083 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1085 set(_handle, offset_parameterAnnotations, value);
1088 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1090 set(_handle, offset_declaredAnnotations, value);
1093 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1095 set(_handle, offset_cons, value);
1098 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1100 classinfo* c = get_clazz();
1101 int32_t slot = get_slot();
1102 methodinfo* m = &(c->methods[slot]);
1108 * GNU Classpath java/lang/reflect/Constructor
1114 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1115 * 3. java.lang.reflect.VMConstructor cons;
1117 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
1119 // Static offsets of the object's instance fields.
1120 // TODO These offsets need to be checked on VM startup.
1121 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1122 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1123 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1126 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
1127 java_lang_reflect_Constructor(methodinfo* m);
1129 java_handle_t* new_instance(java_handle_objectarray_t* args);
1132 int32_t get_flag() const;
1133 java_handle_t* get_cons() const;
1136 void set_cons(java_handle_t* value);
1138 // Convenience functions.
1139 methodinfo* get_method () const;
1140 int32_t get_override() const;
1144 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
1146 java_lang_reflect_VMConstructor jlrvmc(m);
1148 if (jlrvmc.is_null())
1151 _handle = builtin_new(class_java_lang_reflect_Constructor);
1156 // Link the two Java objects.
1157 set_cons(jlrvmc.get_handle());
1158 jlrvmc.set_cons(get_handle());
1162 inline int32_t java_lang_reflect_Constructor::get_flag() const
1164 return get<int32_t>(_handle, offset_flag);
1167 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
1169 return get<java_handle_t*>(_handle, offset_cons);
1173 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
1175 set(_handle, offset_cons, value);
1179 inline methodinfo* java_lang_reflect_Constructor::get_method() const
1181 java_lang_reflect_VMConstructor jlrvmc(get_cons());
1182 return jlrvmc.get_method();
1185 inline int32_t java_lang_reflect_Constructor::get_override() const
1192 * GNU Classpath java/lang/reflect/VMField
1197 * 1. java.lang.Class clazz;
1198 * 2. java.lang.String name;
1200 * 4. byte[] annotations;
1201 * 5. java.lang.Map declaredAnnotations;
1202 * 6. java.lang.reflect.Field f;
1204 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1206 // Static offsets of the object's instance fields.
1207 // TODO These offsets need to be checked on VM startup.
1208 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1209 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1210 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1211 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1212 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1213 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1216 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1217 java_lang_reflect_VMField(fieldinfo* f);
1220 classinfo* get_clazz () const;
1221 int32_t get_slot () const;
1222 java_handle_bytearray_t* get_annotations () const;
1223 java_handle_t* get_declaredAnnotations() const;
1224 java_handle_t* get_f () const;
1227 void set_clazz (classinfo* value);
1228 void set_name (java_handle_t* value);
1229 void set_slot (int32_t value);
1230 void set_annotations (java_handle_bytearray_t* value);
1231 void set_declaredAnnotations(java_handle_t* value);
1232 void set_f (java_handle_t* value);
1234 // Convenience functions.
1235 fieldinfo* get_field() const;
1239 inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
1241 _handle = builtin_new(class_java_lang_reflect_VMField);
1246 java_handle_t* name = javastring_intern(javastring_new(f->name));
1247 int slot = f - f->clazz->fields;
1248 java_handle_bytearray_t* annotations = field_get_annotations(f);
1250 set_clazz(f->clazz);
1253 set_annotations(annotations);
1257 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1259 return get<classinfo*>(_handle, offset_clazz);
1262 inline int32_t java_lang_reflect_VMField::get_slot() const
1264 return get<int32_t>(_handle, offset_slot);
1267 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1269 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1272 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1274 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1277 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1279 return get<java_handle_t*>(_handle, offset_f);
1283 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1285 set(_handle, offset_clazz, value);
1288 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1290 set(_handle, offset_name, value);
1293 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1295 set(_handle, offset_slot, value);
1298 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1300 set(_handle, offset_annotations, value);
1303 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1305 set(_handle, offset_declaredAnnotations, value);
1308 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1310 set(_handle, offset_f, value);
1313 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1315 classinfo* c = get_clazz();
1316 int32_t slot = get_slot();
1317 fieldinfo* f = &(c->fields[slot]);
1323 * GNU Classpath java/lang/reflect/Field
1329 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1330 * 3. java.lang.reflect.VMField f;
1332 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1334 // Static offsets of the object's instance fields.
1335 // TODO These offsets need to be checked on VM startup.
1336 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1337 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1338 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1341 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1342 java_lang_reflect_Field(fieldinfo* f);
1345 int32_t get_flag() const;
1346 java_handle_t* get_f() const;
1349 void set_f(java_handle_t* value);
1351 // Convenience functions.
1352 fieldinfo* get_field() const;
1356 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
1358 java_lang_reflect_VMField jlrvmf(f);
1360 if (jlrvmf.is_null())
1363 _handle = builtin_new(class_java_lang_reflect_Field);
1368 // Link the two Java objects.
1369 set_f(jlrvmf.get_handle());
1370 jlrvmf.set_f(get_handle());
1374 inline int32_t java_lang_reflect_Field::get_flag() const
1376 return get<int32_t>(_handle, offset_flag);
1379 inline java_handle_t* java_lang_reflect_Field::get_f() const
1381 return get<java_handle_t*>(_handle, offset_f);
1385 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1387 set(_handle, offset_f, value);
1391 inline fieldinfo* java_lang_reflect_Field::get_field() const
1393 java_lang_reflect_VMField jlrvmf(get_f());
1394 return jlrvmf.get_field();
1399 * GNU Classpath java/lang/reflect/VMMethod
1404 * 1. java.lang.Class clazz;
1405 * 2. java.lang.String name;
1407 * 4. byte[] annotations;
1408 * 5. byte[] parameterAnnotations;
1409 * 6. byte[] annotationDefault;
1410 * 7. java.lang.Map declaredAnnotations;
1411 * 8. java.lang.reflect.Method m;
1413 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1415 // Static offsets of the object's instance fields.
1416 // TODO These offsets need to be checked on VM startup.
1417 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1418 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1419 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1420 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1421 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1422 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1423 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1424 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1427 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1428 java_lang_reflect_VMMethod(methodinfo* m);
1431 classinfo* get_clazz () const;
1432 int32_t get_slot () const;
1433 java_handle_bytearray_t* get_annotations () const;
1434 java_handle_bytearray_t* get_parameterAnnotations() const;
1435 java_handle_bytearray_t* get_annotationDefault () const;
1436 java_handle_t* get_declaredAnnotations () const;
1437 java_handle_t* get_m () const;
1440 void set_clazz (classinfo* value);
1441 void set_name (java_handle_t* value);
1442 void set_slot (int32_t value);
1443 void set_annotations (java_handle_bytearray_t* value);
1444 void set_parameterAnnotations(java_handle_bytearray_t* value);
1445 void set_annotationDefault (java_handle_bytearray_t* value);
1446 void set_declaredAnnotations (java_handle_t* value);
1447 void set_m (java_handle_t* value);
1449 // Convenience functions.
1450 methodinfo* get_method() const;
1454 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
1456 _handle = builtin_new(class_java_lang_reflect_VMMethod);
1461 java_handle_t* name = javastring_intern(javastring_new(m->name));
1462 int slot = m - m->clazz->methods;
1463 java_handle_bytearray_t* annotations = method_get_annotations(m);
1464 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1465 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1467 set_clazz(m->clazz);
1470 set_annotations(annotations);
1471 set_parameterAnnotations(parameterAnnotations);
1472 set_annotationDefault(annotationDefault);
1475 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1477 return get<classinfo*>(_handle, offset_clazz);
1480 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1482 return get<int32_t>(_handle, offset_slot);
1485 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1487 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1490 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1492 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1495 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1497 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1500 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1502 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1505 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1507 return get<java_handle_t*>(_handle, offset_m);
1510 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1512 set(_handle, offset_clazz, value);
1515 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1517 set(_handle, offset_name, value);
1520 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1522 set(_handle, offset_slot, value);
1525 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1527 set(_handle, offset_annotations, value);
1530 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1532 set(_handle, offset_parameterAnnotations, value);
1535 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1537 set(_handle, offset_annotationDefault, value);
1540 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1542 set(_handle, offset_declaredAnnotations, value);
1545 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1547 set(_handle, offset_m, value);
1550 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1552 classinfo* c = get_clazz();
1553 int32_t slot = get_slot();
1554 methodinfo* m = &(c->methods[slot]);
1560 * GNU Classpath java/lang/reflect/Method
1566 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1567 * 3. java.lang.reflect.VMMethod m;
1569 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1571 // Static offsets of the object's instance fields.
1572 // TODO These offsets need to be checked on VM startup.
1573 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1574 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1575 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1578 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1579 java_lang_reflect_Method(methodinfo* m);
1581 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
1584 int32_t get_flag() const;
1585 java_handle_t* get_m() const;
1588 void set_m(java_handle_t* value);
1590 // Convenience functions.
1591 methodinfo* get_method () const;
1592 int32_t get_override() const;
1596 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
1598 java_lang_reflect_VMMethod jlrvmm(m);
1600 if (jlrvmm.is_null())
1603 _handle = builtin_new(class_java_lang_reflect_Method);
1608 // Link the two Java objects.
1609 set_m(jlrvmm.get_handle());
1610 jlrvmm.set_m(get_handle());
1614 inline int32_t java_lang_reflect_Method::get_flag() const
1616 return get<int32_t>(_handle, offset_flag);
1619 inline java_handle_t* java_lang_reflect_Method::get_m() const
1621 return get<java_handle_t*>(_handle, offset_m);
1625 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1627 set(_handle, offset_m, value);
1631 inline methodinfo* java_lang_reflect_Method::get_method() const
1633 java_lang_reflect_VMMethod jlrvmm(get_m());
1634 return jlrvmm.get_method();
1637 inline int32_t java_lang_reflect_Method::get_override() const
1644 * GNU Classpath java/nio/Buffer
1653 * 5. gnu.classpath.Pointer address;
1655 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1657 // Static offsets of the object's instance fields.
1658 // TODO These offsets need to be checked on VM startup.
1659 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1660 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1661 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1662 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1663 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1666 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1669 int32_t get_cap() const;
1672 inline int32_t java_nio_Buffer::get_cap() const
1674 return get<int32_t>(_handle, offset_cap);
1679 * GNU Classpath java/nio/DirectByteBufferImpl
1688 * 5. gnu.classpath.Pointer address;
1689 * 6. java.nio.ByteOrder endian;
1690 * 7. byte[] backing_buffer;
1691 * 8. int array_offset;
1692 * 9. java.lang.Object owner;
1694 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1696 // Static offsets of the object's instance fields.
1697 // TODO These offsets need to be checked on VM startup.
1698 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1699 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1700 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1701 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1702 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1703 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1704 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1705 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1706 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1709 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1712 java_handle_t* get_address() const;
1716 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1718 return get<java_handle_t*>(_handle, offset_address);
1723 * GNU Classpath gnu/classpath/Pointer
1725 * Actually there are two classes, gnu.classpath.Pointer32 and
1726 * gnu.classpath.Pointer64, but we only define the abstract super
1727 * class and use the int/long field as void* type.
1734 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1736 // Static offsets of the object's instance fields.
1737 // TODO These offsets need to be checked on VM startup.
1738 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1741 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1742 gnu_classpath_Pointer(java_handle_t* h, void* data);
1745 void* get_data() const;
1748 void set_data(void* value);
1751 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1756 inline void* gnu_classpath_Pointer::get_data() const
1758 return get<void*>(_handle, offset_data);
1761 inline void gnu_classpath_Pointer::set_data(void* value)
1763 set(_handle, offset_data, value);
1766 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1769 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1772 * OpenJDK java/lang/AssertionStatusDirectives
1777 * 1. java.lang.String[] classes;
1778 * 2. boolean[] classEnabled;
1779 * 3. java.lang.String[] packages;
1780 * 4. boolean[] packageEnabled;
1783 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1785 // Static offsets of the object's instance fields.
1786 // TODO These offsets need to be checked on VM startup.
1787 static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1788 static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1789 static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1790 static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1791 static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1794 java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1797 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)
1799 classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1801 // FIXME Load the class at VM startup.
1805 _handle = builtin_new(c);
1810 set(_handle, offset_classes, classes);
1811 set(_handle, offset_classEnabled, classEnabled);
1812 set(_handle, offset_packages, packages);
1813 set(_handle, offset_packageEnabled, packageEnabled);
1818 * OpenJDK java/lang/ClassLoader
1823 * 1. boolean initialized
1824 * 2. java.lang.ClassLoader parent
1825 * [other fields are not used]
1827 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
1829 // Static offsets of the object's instance fields.
1830 // TODO These offsets need to be checked on VM startup.
1831 static const off_t offset_initialized = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1832 static const off_t offset_parent = MEMORY_ALIGN(offset_initialized + sizeof(int32_t), SIZEOF_VOID_P);
1835 java_lang_ClassLoader(java_handle_t* h) : java_lang_Object(h) {}
1838 java_handle_t* get_parent() const;
1840 // Invocation wrappers for static methods.
1841 static java_handle_t* invoke_getSystemClassLoader();
1844 inline java_handle_t* java_lang_ClassLoader::get_parent() const
1846 return get<java_handle_t*>(_handle, offset_parent);
1851 * OpenJDK java/lang/StackTraceElement
1856 * 1. java.lang.String declaringClass;
1857 * 2. java.lang.String methodName;
1858 * 3. java.lang.String fileName;
1859 * 4. int lineNumber;
1861 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
1863 // Static offsets of the object's instance fields.
1864 // TODO These offsets need to be checked on VM startup.
1865 static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1866 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1867 static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1868 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1871 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
1872 java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1875 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1877 _handle = builtin_new(class_java_lang_StackTraceElement);
1882 set(_handle, offset_declaringClass, declaringClass);
1883 set(_handle, offset_methodName, methodName);
1884 set(_handle, offset_fileName, fileName);
1885 set(_handle, offset_lineNumber, lineNumber);
1890 * OpenJDK java/lang/String
1900 class java_lang_String : public java_lang_Object, private FieldAccess {
1902 // Static offsets of the object's instance fields.
1903 // TODO These offsets need to be checked on VM startup.
1904 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1905 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1906 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1907 static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
1910 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1911 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1914 java_handle_chararray_t* get_value () const;
1915 int32_t get_offset() const;
1916 int32_t get_count () const;
1919 void set_value (java_handle_chararray_t* value);
1920 void set_offset(int32_t value);
1921 void set_count (int32_t value);
1924 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)
1931 inline java_handle_chararray_t* java_lang_String::get_value() const
1933 return get<java_handle_chararray_t*>(_handle, offset_value);
1936 inline int32_t java_lang_String::get_offset() const
1938 return get<int32_t>(_handle, offset_offset);
1941 inline int32_t java_lang_String::get_count() const
1943 return get<int32_t>(_handle, offset_count);
1946 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1948 set(_handle, offset_value, value);
1951 inline void java_lang_String::set_offset(int32_t value)
1953 set(_handle, offset_offset, value);
1956 inline void java_lang_String::set_count(int32_t value)
1958 set(_handle, offset_count, value);
1963 * OpenJDK java/lang/Thread
1965 class java_lang_Thread : public java_lang_Object, private FieldAccess {
1967 static off_t offset_priority;
1968 static off_t offset_daemon;
1969 static off_t offset_group;
1970 static off_t offset_uncaughtExceptionHandler;
1971 static off_t offset_threadStatus;
1972 static off_t offset_me;
1975 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
1978 int32_t get_priority () const;
1979 int32_t get_daemon () const;
1980 java_handle_t* get_group () const;
1981 java_handle_t* get_uncaughtExceptionHandler() const;
1984 void set_priority (int32_t value);
1985 void set_group (java_handle_t* value);
1986 void set_threadStatus(int32_t value);
1987 void set_me (java_handle_t* value);
1989 // Offset initializers
1990 static void set_priority_offset(int32_t off) { offset_priority = off; }
1991 static void set_daemon_offset(int32_t off) { offset_daemon = off; }
1992 static void set_group_offset(int32_t off) { offset_group = off; }
1993 static void set_uncaughtExceptionHandler_offset(int32_t off) { offset_uncaughtExceptionHandler = off; }
1994 static void set_threadStatus_offset(int32_t off) { offset_threadStatus = off; }
1995 static void set_me_offset(int32_t off) { offset_me = off; }
1999 inline int32_t java_lang_Thread::get_priority() const
2001 return get<int32_t>(_handle, offset_priority);
2004 inline int32_t java_lang_Thread::get_daemon() const
2006 return get<int32_t>(_handle, offset_daemon);
2009 inline java_handle_t* java_lang_Thread::get_group() const
2011 return get<java_handle_t*>(_handle, offset_group);
2014 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
2016 return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
2020 inline void java_lang_Thread::set_priority(int32_t value)
2022 set(_handle, offset_priority, value);
2025 inline void java_lang_Thread::set_group(java_handle_t* value)
2027 set(_handle, offset_group, value);
2030 inline void java_lang_Thread::set_threadStatus(int32_t value)
2032 set(_handle, offset_threadStatus, value);
2035 inline void java_lang_Thread::set_me(java_handle_t* value)
2037 set(_handle, offset_me, value);
2043 * OpenJDK java/lang/Throwable
2048 * 1. java.lang.Object backtrace;
2049 * 2. java.lang.String detailMessage;
2050 * 3. java.lang.Throwable cause;
2051 * 4. java.lang.StackTraceElement[] stackTrace;
2053 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2055 // Static offsets of the object's instance fields.
2056 // TODO These offsets need to be checked on VM startup.
2057 static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2058 static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2059 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2060 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2063 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2064 java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
2067 java_handle_bytearray_t* get_backtrace () const;
2068 java_handle_t* get_detailMessage() const;
2069 java_handle_t* get_cause () const;
2072 void set_backtrace(java_handle_bytearray_t* value);
2076 inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
2078 set_backtrace(backtrace);
2082 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2084 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2087 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2089 return get<java_handle_t*>(_handle, offset_detailMessage);
2092 inline java_handle_t* java_lang_Throwable::get_cause() const
2094 return get<java_handle_t*>(_handle, offset_cause);
2098 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2100 set(_handle, offset_backtrace, value);
2105 * OpenJDK java/lang/reflect/Constructor
2110 * 1. boolean override;
2111 * 2. java.lang.Class clazz;
2113 * 4. java.lang.Class[] parameterTypes;
2114 * 5. java.lang.Class[] exceptionTypes;
2116 * 7. java.lang.String signature;
2117 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2118 * 9. byte[] annotations;
2119 * 10. byte[] parameterAnnotations;
2120 * 11. java.lang.Class securityCheckCache;
2121 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2122 * 13. java.lang.reflect.Constructor root;
2123 * 14. java.util.Map declaredAnnotations;
2125 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
2127 // Static offsets of the object's instance fields.
2128 // TODO These offsets need to be checked on VM startup.
2129 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2130 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2131 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2132 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2133 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2134 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2135 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2136 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2137 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2138 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2139 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2140 static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2141 static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2142 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2145 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
2146 java_lang_reflect_Constructor(methodinfo* m);
2148 java_handle_t* new_instance(java_handle_objectarray_t* args);
2151 int32_t get_override () const;
2152 classinfo* get_clazz () const;
2153 int32_t get_slot () const;
2154 java_handle_bytearray_t* get_annotations() const;
2157 void set_clazz (classinfo* value);
2158 void set_slot (int32_t value);
2159 void set_parameterTypes (java_handle_objectarray_t* value);
2160 void set_exceptionTypes (java_handle_objectarray_t* value);
2161 void set_modifiers (int32_t value);
2162 void set_signature (java_handle_t* value);
2163 void set_annotations (java_handle_bytearray_t* value);
2164 void set_parameterAnnotations(java_handle_bytearray_t* value);
2166 // Convenience functions.
2167 methodinfo* get_method();
2171 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
2173 _handle = builtin_new(class_java_lang_reflect_Constructor);
2178 int slot = m - m->clazz->methods;
2179 java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
2180 java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
2181 java_handle_bytearray_t* annotations = method_get_annotations(m);
2182 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2184 set_clazz(m->clazz);
2186 set_parameterTypes(parameterTypes);
2187 set_exceptionTypes(exceptionTypes);
2188 set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2189 set_signature(m->signature ? javastring_new(m->signature) : NULL);
2190 set_annotations(annotations);
2191 set_parameterAnnotations(parameterAnnotations);
2195 inline int32_t java_lang_reflect_Constructor::get_override() const
2197 return get<int32_t>(_handle, offset_override);
2200 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2202 return get<classinfo*>(_handle, offset_clazz);
2205 inline int32_t java_lang_reflect_Constructor::get_slot() const
2207 return get<int32_t>(_handle, offset_slot);
2210 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2212 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2216 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2218 set(_handle, offset_clazz, value);
2221 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2223 set(_handle, offset_slot, value);
2226 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2228 set(_handle, offset_parameterTypes, value);
2231 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2233 set(_handle, offset_exceptionTypes, value);
2236 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2238 set(_handle, offset_modifiers, value);
2241 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2243 set(_handle, offset_signature, value);
2246 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2248 set(_handle, offset_annotations, value);
2251 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2253 set(_handle, offset_parameterAnnotations, value);
2257 inline methodinfo* java_lang_reflect_Constructor::get_method()
2259 classinfo* c = get_clazz();
2260 int32_t slot = get_slot();
2261 methodinfo* m = &(c->methods[slot]);
2267 * OpenJDK java/lang/reflect/Field
2272 * 1. boolean override;
2273 * 2. java.lang.Class clazz;
2275 * 4. java.lang.String name;
2276 * 5. java.lang.Class type;
2278 * 7. java.lang.String signature;
2279 * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2280 * 9. byte[] annotations;
2281 * 10. sun.reflect.FieldAccessor fieldAccessor;
2282 * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2283 * 12. java.lang.reflect.Field root;
2284 * 13. java.lang.Class securityCheckCache;
2285 * 14. java.lang.Class securityCheckTargetClassCache;
2286 * 15. java.util.Map declaredAnnotations;
2288 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2290 // Static offsets of the object's instance fields.
2291 // TODO These offsets need to be checked on VM startup.
2292 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2293 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2294 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2295 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2296 static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2297 static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2298 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2299 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2300 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2301 static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2302 static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2303 static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2304 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2305 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2306 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2309 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
2310 java_lang_reflect_Field(fieldinfo* f);
2313 int32_t get_override () const;
2314 classinfo* get_clazz () const;
2315 int32_t get_slot () const;
2316 java_handle_bytearray_t* get_annotations() const;
2319 void set_clazz (classinfo* value);
2320 void set_slot (int32_t value);
2321 void set_name (java_handle_t* value);
2322 void set_type (classinfo* value);
2323 void set_modifiers (int32_t value);
2324 void set_signature (java_handle_t* value);
2325 void set_annotations(java_handle_bytearray_t* value);
2327 // Convenience functions.
2328 fieldinfo* get_field() const;
2332 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
2334 _handle = builtin_new(class_java_lang_reflect_Field);
2340 set_clazz(f->clazz);
2341 set_slot(f - f->clazz->fields);
2342 set_name(javastring_intern(javastring_new(f->name)));
2343 set_type(field_get_type(f));
2344 set_modifiers(f->flags);
2345 set_signature(f->signature ? javastring_new(f->signature) : NULL);
2346 set_annotations(field_get_annotations(f));
2350 inline int32_t java_lang_reflect_Field::get_override() const
2352 return get<int32_t>(_handle, offset_override);
2355 inline classinfo* java_lang_reflect_Field::get_clazz() const
2357 return get<classinfo*>(_handle, offset_clazz);
2360 inline int32_t java_lang_reflect_Field::get_slot() const
2362 return get<int32_t>(_handle, offset_slot);
2365 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2367 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2371 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2373 set(_handle, offset_clazz, value);
2376 inline void java_lang_reflect_Field::set_slot(int32_t value)
2378 set(_handle, offset_slot, value);
2381 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2383 set(_handle, offset_name, value);
2386 inline void java_lang_reflect_Field::set_type(classinfo* value)
2388 set(_handle, offset_type, value);
2391 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2393 set(_handle, offset_modifiers, value);
2396 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2398 set(_handle, offset_signature, value);
2401 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2403 set(_handle, offset_annotations, value);
2407 inline fieldinfo* java_lang_reflect_Field::get_field() const
2409 classinfo* c = get_clazz();
2410 int32_t slot = get_slot();
2411 fieldinfo* f = &(c->fields[slot]);
2417 * OpenJDK java/lang/reflect/Method
2422 * 1. boolean override;
2423 * 2. java.lang.Class clazz;
2425 * 4. java.lang.String name;
2426 * 5. java.lang.Class returnType;
2427 * 6. java.lang.Class[] parameterTypes;
2428 * 7. java.lang.Class[] exceptionTypes;
2430 * 9. java.lang.String signature;
2431 * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2432 * 11. byte[] annotations;
2433 * 12. byte[] parameterAnnotations;
2434 * 13. byte[] annotationDefault;
2435 * 14. sun.reflect.MethodAccessor methodAccessor;
2436 * 15. java.lang.reflect.Method root;
2437 * 16. java.lang.Class securityCheckCache;
2438 * 17. java.lang.Class securityCheckTargetClassCache;
2439 * 18. java.util.Map declaredAnnotations;
2441 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2443 // Static offsets of the object's instance fields.
2444 // TODO These offsets need to be checked on VM startup.
2445 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2446 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2447 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2448 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2449 static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2450 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2451 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2452 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2453 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2454 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2455 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2456 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2457 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2458 static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2459 static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2460 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2461 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2462 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2465 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
2466 java_lang_reflect_Method(methodinfo* m);
2468 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
2471 int32_t get_override () const;
2472 classinfo* get_clazz () const;
2473 int32_t get_slot () const;
2474 java_handle_bytearray_t* get_annotations () const;
2475 java_handle_bytearray_t* get_parameterAnnotations() const;
2476 java_handle_bytearray_t* get_annotationDefault () const;
2480 // Convenience functions.
2481 methodinfo* get_method() const;
2485 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
2487 _handle = builtin_new(class_java_lang_reflect_Method);
2492 set(_handle, offset_clazz, m->clazz);
2493 set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2494 set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
2495 set(_handle, offset_returnType, method_returntype_get(m));
2496 set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2497 set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2498 set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2499 set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
2500 set(_handle, offset_annotations, method_get_annotations(m));
2501 set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2502 set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2506 inline int32_t java_lang_reflect_Method::get_override() const
2508 return get<int32_t>(_handle, offset_override);
2511 inline classinfo* java_lang_reflect_Method::get_clazz() const
2513 return get<classinfo*>(_handle, offset_clazz);
2516 inline int32_t java_lang_reflect_Method::get_slot() const
2518 return get<int32_t>(_handle, offset_slot);
2521 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2523 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2526 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2528 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2531 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2533 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2537 inline methodinfo* java_lang_reflect_Method::get_method() const
2539 classinfo* c = get_clazz();
2540 int32_t slot = get_slot();
2541 methodinfo* m = &(c->methods[slot]);
2547 * OpenJDK java/nio/Buffer
2558 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2560 // Static offsets of the object's instance fields.
2561 // TODO These offsets need to be checked on VM startup.
2562 static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2563 static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2564 static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2565 static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2566 static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2569 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
2572 void* get_address() const;
2576 inline void* java_nio_Buffer::get_address() const
2578 return get<void*>(_handle, offset_address);
2581 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2584 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2587 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2596 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2598 // Static offsets of the object's instance fields.
2599 // TODO These offsets need to be checked on VM startup.
2600 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2601 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2602 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2605 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2606 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2607 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2610 int64_t get_pointer () const;
2611 int32_t get_position() const;
2612 int32_t get_length () const;
2615 void set_pointer (int64_t value);
2616 void set_position(int32_t value);
2617 void set_length (int32_t value);
2621 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)
2623 set_pointer(pointer);
2624 set_position(position);
2628 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)
2630 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2634 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2636 return get<int64_t>(_handle, offset_pointer);
2639 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2641 return get<int32_t>(_handle, offset_position);
2644 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2646 return get<int32_t>(_handle, offset_length);
2650 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2652 set(_handle, offset_pointer, value);
2655 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2657 set(_handle, offset_position, value);
2660 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2662 set(_handle, offset_length, value);
2667 * CLDC 1.1 java/lang/String
2676 class java_lang_String : public java_lang_Object, private FieldAccess {
2678 // Static offsets of the object's instance fields.
2679 // TODO These offsets need to be checked on VM startup.
2680 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2681 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2682 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2685 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
2686 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2689 java_handle_chararray_t* get_value () const;
2690 int32_t get_offset() const;
2691 int32_t get_count () const;
2694 void set_value (java_handle_chararray_t* value);
2695 void set_offset(int32_t value);
2696 void set_count (int32_t value);
2700 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)
2707 inline java_handle_chararray_t* java_lang_String::get_value() const
2709 return get<java_handle_chararray_t*>(_handle, offset_value);
2712 inline int32_t java_lang_String::get_offset() const
2714 return get<int32_t>(_handle, offset_offset);
2717 inline int32_t java_lang_String::get_count() const
2719 return get<int32_t>(_handle, offset_count);
2722 inline void java_lang_String::set_value(java_handle_chararray_t* value)
2724 set(_handle, offset_value, value);
2727 inline void java_lang_String::set_offset(int32_t value)
2729 set(_handle, offset_offset, value);
2732 inline void java_lang_String::set_count(int32_t value)
2734 set(_handle, offset_count, value);
2739 * CLDC 1.1 java/lang/Thread
2745 * 2. java.lang.Runnable runnable;
2746 * 3. java.lang.Object vm_thread;
2747 * 4. int is_terminated;
2748 * 5. int is_stillborn;
2751 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2753 // Static offsets of the object's instance fields.
2754 // TODO These offsets need to be checked on VM startup.
2755 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2756 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2757 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2758 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2759 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2760 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2763 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2764 // java_lang_Thread(threadobject* t);
2767 int32_t get_priority () const;
2768 threadobject* get_vm_thread() const;
2769 java_handle_chararray_t* get_name () const;
2772 void set_vm_thread(threadobject* value);
2776 inline int32_t java_lang_Thread::get_priority() const
2778 return get<int32_t>(_handle, offset_priority);
2781 inline threadobject* java_lang_Thread::get_vm_thread() const
2783 return get<threadobject*>(_handle, offset_vm_thread);
2786 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2788 return get<java_handle_chararray_t*>(_handle, offset_name);
2792 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2794 set(_handle, offset_vm_thread, value);
2799 * CLDC 1.1 java/lang/Throwable
2804 * 1. java.lang.String detailMessage;
2805 * 2. java.lang.Object backtrace;
2807 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2809 // Static offsets of the object's instance fields.
2810 // TODO These offsets need to be checked on VM startup.
2811 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2812 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2815 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2818 java_handle_t* get_detailMessage() const;
2819 java_handle_bytearray_t* get_backtrace () const;
2822 void set_backtrace(java_handle_bytearray_t* value);
2826 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2828 return get<java_handle_t*>(_handle, offset_detailMessage);
2831 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2833 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2837 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2839 set(_handle, offset_backtrace, value);
2842 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2846 #endif // _JAVAOBJECTS_HPP
2850 * These are local overrides for various environment variables in Emacs.
2851 * Please do not remove this and leave it at the end of the file, where
2852 * Emacs will automagically detect them.
2853 * ---------------------------------------------------------------------
2856 * indent-tabs-mode: t
2860 * vim:noexpandtab:sw=4:ts=4: