1 /* src/vm/javaobjects.hpp - functions to create and access Java objects
3 Copyright (C) 2008 Theobroma Systems Ltd.
5 This file is part of CACAO.
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #ifndef _JAVAOBJECTS_HPP
26 #define _JAVAOBJECTS_HPP
32 #include "mm/memory.h"
34 #include "native/llni.h"
36 #include "threads/atomic.hpp"
39 #include "vm/field.hpp"
40 #include "vm/global.h"
41 #include "vm/globals.hpp"
42 #include "vm/method.h"
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 inline java_handle_t* get_handle () const { return _handle; }
204 inline vftbl_t* get_vftbl () const;
205 inline classinfo* get_Class () const;
206 inline int32_t get_hashcode() const;
208 inline bool is_null () const;
209 inline 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) {}
271 inline uint8_t get_value();
272 inline 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) {}
303 inline int8_t get_value();
304 inline 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 inline uint16_t get_value();
336 inline 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) {}
367 inline int16_t get_value();
368 inline 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) {}
399 inline int32_t get_value();
400 inline 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) {}
431 inline int64_t get_value();
432 inline 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) {}
463 inline float get_value();
464 inline 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) {}
495 inline double get_value();
496 inline 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 inline void set_constantPoolOop(classinfo* value);
533 inline 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 inline 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/StackTraceElement
599 * 1. java.lang.String fileName;
601 * 3. java.lang.String declaringClass;
602 * 4. java.lang.String methodName;
603 * 5. boolean isNative;
605 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
607 // Static offsets of the object's instance fields.
608 // TODO These offsets need to be checked on VM startup.
609 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
610 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
611 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
612 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
613 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
616 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
617 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);
620 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)
622 java_lang_StackTraceElement((java_handle_t*) h);
624 set(_handle, offset_fileName, fileName);
625 set(_handle, offset_lineNumber, lineNumber);
626 set(_handle, offset_declaringClass, declaringClass);
627 set(_handle, offset_methodName, methodName);
628 set(_handle, offset_isNative, isNative);
633 * GNU Classpath java/lang/String
640 * 3. int cachedHashCode;
643 class java_lang_String : public java_lang_Object, private FieldAccess {
645 // Static offsets of the object's instance fields.
646 // TODO These offsets need to be checked on VM startup.
647 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
648 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
649 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
650 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
653 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
654 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
657 inline java_handle_chararray_t* get_value () const;
658 inline int32_t get_count () const;
659 inline int32_t get_offset() const;
662 inline void set_value (java_handle_chararray_t* value);
663 inline void set_count (int32_t value);
664 inline void set_offset(int32_t value);
667 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)
674 inline java_handle_chararray_t* java_lang_String::get_value() const
676 return get<java_handle_chararray_t*>(_handle, offset_value);
679 inline int32_t java_lang_String::get_count() const
681 return get<int32_t>(_handle, offset_count);
684 inline int32_t java_lang_String::get_offset() const
686 return get<int32_t>(_handle, offset_offset);
689 inline void java_lang_String::set_value(java_handle_chararray_t* value)
691 set(_handle, offset_value, value);
694 inline void java_lang_String::set_count(int32_t value)
696 set(_handle, offset_count, value);
699 inline void java_lang_String::set_offset(int32_t value)
701 set(_handle, offset_offset, value);
706 * GNU Classpath java/lang/Thread
711 * 1. java.lang.VMThread vmThread;
712 * 2. java.lang.ThreadGroup group;
713 * 3. java.lang.Runnable runnable;
714 * 4. java.lang.String name;
718 * 8. java.lang.Throwable stillborn;
719 * 9. java.lang.ClassLoader contextClassLoader;
720 * 10. boolean contextClassLoaderIsSystemClassLoader;
722 * 12. java.lang.Object parkBlocker;
723 * 13. gnu.java.util.WeakIdentityHashMap locals;
724 * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
726 class java_lang_Thread : public java_lang_Object, private FieldAccess {
728 // Static offsets of the object's instance fields.
729 // TODO These offsets need to be checked on VM startup.
730 static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
731 static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
732 static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
733 static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
734 static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
735 static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
736 static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
737 static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
738 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
739 static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
740 static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
741 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
742 static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
743 static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
746 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
747 // java_lang_Thread(threadobject* t);
750 inline java_handle_t* get_vmThread () const;
751 inline java_handle_t* get_group () const;
752 inline java_handle_t* get_name () const;
753 inline int32_t get_daemon () const;
754 inline int32_t get_priority () const;
755 inline java_handle_t* get_exceptionHandler() const;
758 inline void set_group(java_handle_t* value);
762 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
764 // java_lang_Thread(thread_get_object(t));
768 inline java_handle_t* java_lang_Thread::get_vmThread() const
770 return get<java_handle_t*>(_handle, offset_vmThread);
773 inline java_handle_t* java_lang_Thread::get_group() const
775 return get<java_handle_t*>(_handle, offset_group);
778 inline java_handle_t* java_lang_Thread::get_name() const
780 return get<java_handle_t*>(_handle, offset_name);
783 inline int32_t java_lang_Thread::get_daemon() const
785 return get<int32_t>(_handle, offset_daemon);
788 inline int32_t java_lang_Thread::get_priority() const
790 return get<int32_t>(_handle, offset_priority);
793 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
795 return get<java_handle_t*>(_handle, offset_exceptionHandler);
799 inline void java_lang_Thread::set_group(java_handle_t* value)
801 set(_handle, offset_group, value);
806 * GNU Classpath java/lang/VMThread
811 * 1. java.lang.Thread thread;
812 * 2. boolean running;
813 * 3. java.lang.VMThread vmdata;
815 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
817 // Static offsets of the object's instance fields.
818 // TODO These offsets need to be checked on VM startup.
819 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
820 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
821 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
824 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
825 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
828 inline java_handle_t* get_thread() const;
829 inline threadobject* get_vmdata() const;
832 inline void set_thread(java_handle_t* value);
833 inline void set_vmdata(threadobject* value);
837 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
844 inline java_handle_t* java_lang_VMThread::get_thread() const
846 return get<java_handle_t*>(_handle, offset_thread);
849 inline threadobject* java_lang_VMThread::get_vmdata() const
851 return get<threadobject*>(_handle, offset_vmdata);
855 inline void java_lang_VMThread::set_thread(java_handle_t* value)
857 set(_handle, offset_thread, value);
860 inline void java_lang_VMThread::set_vmdata(threadobject* value)
862 set(_handle, offset_vmdata, value);
867 * GNU Classpath java/lang/Throwable
872 * 1. java.lang.String detailMessage;
873 * 2. java.lang.Throwable cause;
874 * 3. java.lang.StackTraceElement[] stackTrace;
875 * 4. java.lang.VMThrowable vmState;
877 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
879 // Static offsets of the object's instance fields.
880 // TODO These offsets need to be checked on VM startup.
881 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
882 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
883 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
884 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
887 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
890 inline java_handle_t* get_detailMessage() const;
891 inline java_handle_t* get_cause () const;
892 inline java_handle_t* get_vmState () const;
896 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
898 return get<java_handle_t*>(_handle, offset_detailMessage);
901 inline java_handle_t* java_lang_Throwable::get_cause() const
903 return get<java_handle_t*>(_handle, offset_cause);
906 inline java_handle_t* java_lang_Throwable::get_vmState() const
908 return get<java_handle_t*>(_handle, offset_vmState);
913 * GNU Classpath java/lang/VMThrowable
918 * 1. java.lang.Object vmdata;
920 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
922 // Static offsets of the object's instance fields.
923 // TODO These offsets need to be checked on VM startup.
924 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
927 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
929 inline java_handle_bytearray_t* get_vmdata() const;
930 inline void set_vmdata(java_handle_bytearray_t* value);
934 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
936 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
939 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
941 set(_handle, offset_vmdata, value);
946 * GNU Classpath java/lang/reflect/VMConstructor
951 * 1. java.lang.Class clazz;
953 * 3. byte[] annotations;
954 * 4. byte[] parameterAnnotations;
955 * 5. java.util.Map declaredAnnotations;
956 * 6. java.lang.reflect.Constructor cons;
958 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
960 // Static offsets of the object's instance fields.
961 // TODO These offsets need to be checked on VM startup.
962 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
963 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
964 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
965 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
966 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
967 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
970 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
971 java_lang_reflect_VMConstructor(methodinfo* m);
974 inline classinfo* get_clazz () const;
975 inline int32_t get_slot () const;
976 inline java_handle_bytearray_t* get_annotations () const;
977 inline java_handle_bytearray_t* get_parameterAnnotations() const;
978 inline java_handle_t* get_declaredAnnotations () const;
979 inline java_handle_t* get_cons () const;
982 inline void set_clazz (classinfo* value);
983 inline void set_slot (int32_t value);
984 inline void set_annotations (java_handle_bytearray_t* value);
985 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
986 inline void set_declaredAnnotations (java_handle_t* value);
987 inline void set_cons (java_handle_t* value);
989 // Convenience functions.
990 inline methodinfo* get_method();
994 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
996 _handle = builtin_new(class_java_lang_reflect_VMConstructor);
1001 int slot = m - m->clazz->methods;
1002 java_handle_bytearray_t* annotations = method_get_annotations(m);
1003 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1005 set_clazz(m->clazz);
1007 set_annotations(annotations);
1008 set_parameterAnnotations(parameterAnnotations);
1012 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1014 return get<classinfo*>(_handle, offset_clazz);
1017 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1019 return get<int32_t>(_handle, offset_slot);
1022 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1024 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1027 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1029 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1032 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1034 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1037 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1039 return get<java_handle_t*>(_handle, offset_cons);
1042 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1044 set(_handle, offset_clazz, value);
1047 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1049 set(_handle, offset_slot, value);
1052 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1054 set(_handle, offset_annotations, value);
1057 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1059 set(_handle, offset_parameterAnnotations, value);
1062 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1064 set(_handle, offset_declaredAnnotations, value);
1067 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1069 set(_handle, offset_cons, value);
1072 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1074 classinfo* c = get_clazz();
1075 int32_t slot = get_slot();
1076 methodinfo* m = &(c->methods[slot]);
1082 * GNU Classpath java/lang/reflect/Constructor
1088 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1089 * 3. java.lang.reflect.VMConstructor cons;
1091 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
1093 // Static offsets of the object's instance fields.
1094 // TODO These offsets need to be checked on VM startup.
1095 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1096 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1097 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1100 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
1101 java_lang_reflect_Constructor(methodinfo* m);
1103 java_handle_t* new_instance(java_handle_objectarray_t* args);
1106 inline int32_t get_flag() const;
1107 inline java_handle_t* get_cons() const;
1110 inline void set_cons(java_handle_t* value);
1112 // Convenience functions.
1113 inline methodinfo* get_method () const;
1114 inline int32_t get_override() const;
1118 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
1120 java_lang_reflect_VMConstructor jlrvmc(m);
1122 if (jlrvmc.is_null())
1125 _handle = builtin_new(class_java_lang_reflect_Constructor);
1130 // Link the two Java objects.
1131 set_cons(jlrvmc.get_handle());
1132 jlrvmc.set_cons(get_handle());
1136 inline int32_t java_lang_reflect_Constructor::get_flag() const
1138 return get<int32_t>(_handle, offset_flag);
1141 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
1143 return get<java_handle_t*>(_handle, offset_cons);
1147 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
1149 set(_handle, offset_cons, value);
1153 inline methodinfo* java_lang_reflect_Constructor::get_method() const
1155 java_lang_reflect_VMConstructor jlrvmc(get_cons());
1156 return jlrvmc.get_method();
1159 inline int32_t java_lang_reflect_Constructor::get_override() const
1166 * GNU Classpath java/lang/reflect/VMField
1171 * 1. java.lang.Class clazz;
1172 * 2. java.lang.String name;
1174 * 4. byte[] annotations;
1175 * 5. java.lang.Map declaredAnnotations;
1176 * 6. java.lang.reflect.Field f;
1178 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1180 // Static offsets of the object's instance fields.
1181 // TODO These offsets need to be checked on VM startup.
1182 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1183 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1184 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1185 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1186 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1187 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1190 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1191 java_lang_reflect_VMField(fieldinfo* f);
1194 inline classinfo* get_clazz () const;
1195 inline int32_t get_slot () const;
1196 inline java_handle_bytearray_t* get_annotations () const;
1197 inline java_handle_t* get_declaredAnnotations() const;
1198 inline java_handle_t* get_f () const;
1201 inline void set_clazz (classinfo* value);
1202 inline void set_name (java_handle_t* value);
1203 inline void set_slot (int32_t value);
1204 inline void set_annotations (java_handle_bytearray_t* value);
1205 inline void set_declaredAnnotations(java_handle_t* value);
1206 inline void set_f (java_handle_t* value);
1208 // Convenience functions.
1209 inline fieldinfo* get_field() const;
1213 inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
1215 _handle = builtin_new(class_java_lang_reflect_VMField);
1220 java_handle_t* name = javastring_intern(javastring_new(f->name));
1221 int slot = f - f->clazz->fields;
1222 java_handle_bytearray_t* annotations = field_get_annotations(f);
1224 set_clazz(f->clazz);
1227 set_annotations(annotations);
1231 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1233 return get<classinfo*>(_handle, offset_clazz);
1236 inline int32_t java_lang_reflect_VMField::get_slot() const
1238 return get<int32_t>(_handle, offset_slot);
1241 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1243 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1246 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1248 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1251 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1253 return get<java_handle_t*>(_handle, offset_f);
1257 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1259 set(_handle, offset_clazz, value);
1262 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1264 set(_handle, offset_name, value);
1267 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1269 set(_handle, offset_slot, value);
1272 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1274 set(_handle, offset_annotations, value);
1277 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1279 set(_handle, offset_declaredAnnotations, value);
1282 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1284 set(_handle, offset_f, value);
1287 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1289 classinfo* c = get_clazz();
1290 int32_t slot = get_slot();
1291 fieldinfo* f = &(c->fields[slot]);
1297 * GNU Classpath java/lang/reflect/Field
1303 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1304 * 3. java.lang.reflect.VMField f;
1306 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1308 // Static offsets of the object's instance fields.
1309 // TODO These offsets need to be checked on VM startup.
1310 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1311 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1312 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1315 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1316 java_lang_reflect_Field(fieldinfo* f);
1319 inline int32_t get_flag() const;
1320 inline java_handle_t* get_f() const;
1323 inline void set_f(java_handle_t* value);
1325 // Convenience functions.
1326 inline fieldinfo* get_field() const;
1330 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
1332 java_lang_reflect_VMField jlrvmf(f);
1334 if (jlrvmf.is_null())
1337 _handle = builtin_new(class_java_lang_reflect_Field);
1342 // Link the two Java objects.
1343 set_f(jlrvmf.get_handle());
1344 jlrvmf.set_f(get_handle());
1348 inline int32_t java_lang_reflect_Field::get_flag() const
1350 return get<int32_t>(_handle, offset_flag);
1353 inline java_handle_t* java_lang_reflect_Field::get_f() const
1355 return get<java_handle_t*>(_handle, offset_f);
1359 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1361 set(_handle, offset_f, value);
1365 inline fieldinfo* java_lang_reflect_Field::get_field() const
1367 java_lang_reflect_VMField jlrvmf(get_f());
1368 return jlrvmf.get_field();
1373 * GNU Classpath java/lang/reflect/VMMethod
1378 * 1. java.lang.Class clazz;
1379 * 2. java.lang.String name;
1381 * 4. byte[] annotations;
1382 * 5. byte[] parameterAnnotations;
1383 * 6. byte[] annotationDefault;
1384 * 7. java.lang.Map declaredAnnotations;
1385 * 8. java.lang.reflect.Method m;
1387 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1389 // Static offsets of the object's instance fields.
1390 // TODO These offsets need to be checked on VM startup.
1391 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1392 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1393 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1394 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1395 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1396 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1397 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1398 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1401 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1402 java_lang_reflect_VMMethod(methodinfo* m);
1405 inline classinfo* get_clazz () const;
1406 inline int32_t get_slot () const;
1407 inline java_handle_bytearray_t* get_annotations () const;
1408 inline java_handle_bytearray_t* get_parameterAnnotations() const;
1409 inline java_handle_bytearray_t* get_annotationDefault () const;
1410 inline java_handle_t* get_declaredAnnotations () const;
1411 inline java_handle_t* get_m () const;
1414 inline void set_clazz (classinfo* value);
1415 inline void set_name (java_handle_t* value);
1416 inline void set_slot (int32_t value);
1417 inline void set_annotations (java_handle_bytearray_t* value);
1418 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
1419 inline void set_annotationDefault (java_handle_bytearray_t* value);
1420 inline void set_declaredAnnotations (java_handle_t* value);
1421 inline void set_m (java_handle_t* value);
1423 // Convenience functions.
1424 inline methodinfo* get_method() const;
1428 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
1430 _handle = builtin_new(class_java_lang_reflect_VMMethod);
1435 java_handle_t* name = javastring_intern(javastring_new(m->name));
1436 int slot = m - m->clazz->methods;
1437 java_handle_bytearray_t* annotations = method_get_annotations(m);
1438 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1439 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1441 set_clazz(m->clazz);
1444 set_annotations(annotations);
1445 set_parameterAnnotations(parameterAnnotations);
1446 set_annotationDefault(annotationDefault);
1449 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1451 return get<classinfo*>(_handle, offset_clazz);
1454 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1456 return get<int32_t>(_handle, offset_slot);
1459 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1461 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1464 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1466 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1469 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1471 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1474 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1476 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1479 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1481 return get<java_handle_t*>(_handle, offset_m);
1484 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1486 set(_handle, offset_clazz, value);
1489 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1491 set(_handle, offset_name, value);
1494 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1496 set(_handle, offset_slot, value);
1499 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1501 set(_handle, offset_annotations, value);
1504 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1506 set(_handle, offset_parameterAnnotations, value);
1509 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1511 set(_handle, offset_annotationDefault, value);
1514 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1516 set(_handle, offset_declaredAnnotations, value);
1519 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1521 set(_handle, offset_m, value);
1524 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1526 classinfo* c = get_clazz();
1527 int32_t slot = get_slot();
1528 methodinfo* m = &(c->methods[slot]);
1534 * GNU Classpath java/lang/reflect/Method
1540 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1541 * 3. java.lang.reflect.VMMethod m;
1543 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1545 // Static offsets of the object's instance fields.
1546 // TODO These offsets need to be checked on VM startup.
1547 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1548 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1549 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1552 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1553 java_lang_reflect_Method(methodinfo* m);
1555 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
1558 inline int32_t get_flag() const;
1559 inline java_handle_t* get_m() const;
1562 inline void set_m(java_handle_t* value);
1564 // Convenience functions.
1565 inline methodinfo* get_method () const;
1566 inline int32_t get_override() const;
1570 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
1572 java_lang_reflect_VMMethod jlrvmm(m);
1574 if (jlrvmm.is_null())
1577 _handle = builtin_new(class_java_lang_reflect_Method);
1582 // Link the two Java objects.
1583 set_m(jlrvmm.get_handle());
1584 jlrvmm.set_m(get_handle());
1588 inline int32_t java_lang_reflect_Method::get_flag() const
1590 return get<int32_t>(_handle, offset_flag);
1593 inline java_handle_t* java_lang_reflect_Method::get_m() const
1595 return get<java_handle_t*>(_handle, offset_m);
1599 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1601 set(_handle, offset_m, value);
1605 inline methodinfo* java_lang_reflect_Method::get_method() const
1607 java_lang_reflect_VMMethod jlrvmm(get_m());
1608 return jlrvmm.get_method();
1611 inline int32_t java_lang_reflect_Method::get_override() const
1618 * GNU Classpath java/nio/Buffer
1627 * 5. gnu.classpath.Pointer address;
1629 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1631 // Static offsets of the object's instance fields.
1632 // TODO These offsets need to be checked on VM startup.
1633 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1634 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1635 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1636 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1637 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1640 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1643 inline int32_t get_cap() const;
1646 inline int32_t java_nio_Buffer::get_cap() const
1648 return get<int32_t>(_handle, offset_cap);
1653 * GNU Classpath java/nio/DirectByteBufferImpl
1662 * 5. gnu.classpath.Pointer address;
1663 * 6. java.nio.ByteOrder endian;
1664 * 7. byte[] backing_buffer;
1665 * 8. int array_offset;
1666 * 9. java.lang.Object owner;
1668 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1670 // Static offsets of the object's instance fields.
1671 // TODO These offsets need to be checked on VM startup.
1672 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1673 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1674 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1675 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1676 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1677 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1678 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1679 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1680 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1683 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1686 inline java_handle_t* get_address() const;
1690 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1692 return get<java_handle_t*>(_handle, offset_address);
1697 * GNU Classpath gnu/classpath/Pointer
1699 * Actually there are two classes, gnu.classpath.Pointer32 and
1700 * gnu.classpath.Pointer64, but we only define the abstract super
1701 * class and use the int/long field as void* type.
1708 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1710 // Static offsets of the object's instance fields.
1711 // TODO These offsets need to be checked on VM startup.
1712 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1715 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1716 gnu_classpath_Pointer(java_handle_t* h, void* data);
1719 inline void* get_data() const;
1722 inline void set_data(void* value);
1725 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1730 inline void* gnu_classpath_Pointer::get_data() const
1732 return get<void*>(_handle, offset_data);
1735 inline void gnu_classpath_Pointer::set_data(void* value)
1737 set(_handle, offset_data, value);
1740 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1743 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1746 * OpenJDK java/lang/AssertionStatusDirectives
1751 * 1. java.lang.String[] classes;
1752 * 2. boolean[] classEnabled;
1753 * 3. java.lang.String[] packages;
1754 * 4. boolean[] packageEnabled;
1757 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1759 // Static offsets of the object's instance fields.
1760 // TODO These offsets need to be checked on VM startup.
1761 static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1762 static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1763 static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1764 static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1765 static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1768 java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1771 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)
1773 classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1775 // FIXME Load the class at VM startup.
1779 _handle = builtin_new(c);
1784 set(_handle, offset_classes, classes);
1785 set(_handle, offset_classEnabled, classEnabled);
1786 set(_handle, offset_packages, packages);
1787 set(_handle, offset_packageEnabled, packageEnabled);
1792 * OpenJDK java/lang/StackTraceElement
1797 * 1. java.lang.String declaringClass;
1798 * 2. java.lang.String methodName;
1799 * 3. java.lang.String fileName;
1800 * 4. int lineNumber;
1802 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
1804 // Static offsets of the object's instance fields.
1805 // TODO These offsets need to be checked on VM startup.
1806 static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1807 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1808 static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1809 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1812 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
1813 java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1816 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1818 _handle = builtin_new(class_java_lang_StackTraceElement);
1823 set(_handle, offset_declaringClass, declaringClass);
1824 set(_handle, offset_methodName, methodName);
1825 set(_handle, offset_fileName, fileName);
1826 set(_handle, offset_lineNumber, lineNumber);
1831 * OpenJDK java/lang/String
1841 class java_lang_String : public java_lang_Object, private FieldAccess {
1843 // Static offsets of the object's instance fields.
1844 // TODO These offsets need to be checked on VM startup.
1845 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1846 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1847 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1848 static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
1851 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1852 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1855 inline java_handle_chararray_t* get_value () const;
1856 inline int32_t get_offset() const;
1857 inline int32_t get_count () const;
1860 inline void set_value (java_handle_chararray_t* value);
1861 inline void set_offset(int32_t value);
1862 inline void set_count (int32_t value);
1865 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)
1872 inline java_handle_chararray_t* java_lang_String::get_value() const
1874 return get<java_handle_chararray_t*>(_handle, offset_value);
1877 inline int32_t java_lang_String::get_offset() const
1879 return get<int32_t>(_handle, offset_offset);
1882 inline int32_t java_lang_String::get_count() const
1884 return get<int32_t>(_handle, offset_count);
1887 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1889 set(_handle, offset_value, value);
1892 inline void java_lang_String::set_offset(int32_t value)
1894 set(_handle, offset_offset, value);
1897 inline void java_lang_String::set_count(int32_t value)
1899 set(_handle, offset_count, value);
1904 * OpenJDK java/lang/Thread
1911 * 3. java_lang_Thread threadQ;
1913 * 5. boolean single_step;
1914 * 6. boolean daemon;
1915 * 7. boolean stillborn;
1916 * 8. java_lang_Runnable target;
1917 * 9. java_lang_ThreadGroup group;
1918 * 10. java_lang_ClassLoader contextClassLoader;
1919 * 11. java_security_AccessControlContext inheritedAccessControlContext;
1920 * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals;
1921 * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals;
1922 * 14. long stackSize;
1923 * 15. long nativeParkEventPointer;
1925 * 17. int threadStatus;
1926 * 18. java_lang_Object parkBlocker;
1927 * 19. sun_nio_ch_Interruptible blocker;
1928 * 20. java_lang_Object blockerLock;
1929 * 21. boolean stopBeforeStart;
1930 * 22. java_lang_Throwable throwableFromStop;
1931 * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
1933 class java_lang_Thread : public java_lang_Object, private FieldAccess {
1935 // Static offsets of the object's instance fields.
1936 // TODO These offsets need to be checked on VM startup.
1937 static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1938 static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1939 static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
1940 static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t));
1941 static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t));
1942 static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t));
1943 static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
1944 static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
1945 static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P);
1946 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
1947 static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
1948 static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P);
1949 static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P);
1950 static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t));
1951 static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t));
1952 static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t));
1953 static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t));
1954 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P);
1955 static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
1956 static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
1957 static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t));
1958 static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P);
1959 static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P);
1962 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
1963 // java_lang_Thread(threadobject* t);
1966 inline int32_t get_priority () const;
1967 inline int32_t get_daemon () const;
1968 inline java_handle_t* get_group () const;
1969 inline java_handle_t* get_uncaughtExceptionHandler() const;
1972 inline void set_priority(int32_t value);
1973 inline void set_group (java_handle_t* value);
1977 inline int32_t java_lang_Thread::get_priority() const
1979 return get<int32_t>(_handle, offset_priority);
1982 inline int32_t java_lang_Thread::get_daemon() const
1984 return get<int32_t>(_handle, offset_daemon);
1987 inline java_handle_t* java_lang_Thread::get_group() const
1989 return get<java_handle_t*>(_handle, offset_group);
1992 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
1994 return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
1998 inline void java_lang_Thread::set_priority(int32_t value)
2000 set(_handle, offset_priority, value);
2003 inline void java_lang_Thread::set_group(java_handle_t* value)
2005 set(_handle, offset_group, value);
2011 * OpenJDK java/lang/Throwable
2016 * 1. java.lang.Object backtrace;
2017 * 2. java.lang.String detailMessage;
2018 * 3. java.lang.Throwable cause;
2019 * 4. java.lang.StackTraceElement[] stackTrace;
2021 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2023 // Static offsets of the object's instance fields.
2024 // TODO These offsets need to be checked on VM startup.
2025 static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2026 static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2027 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2028 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2031 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2032 java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
2035 inline java_handle_bytearray_t* get_backtrace () const;
2036 inline java_handle_t* get_detailMessage() const;
2037 inline java_handle_t* get_cause () const;
2040 inline void set_backtrace(java_handle_bytearray_t* value);
2044 inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
2046 set_backtrace(backtrace);
2050 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2052 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2055 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2057 return get<java_handle_t*>(_handle, offset_detailMessage);
2060 inline java_handle_t* java_lang_Throwable::get_cause() const
2062 return get<java_handle_t*>(_handle, offset_cause);
2066 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2068 set(_handle, offset_backtrace, value);
2073 * OpenJDK java/lang/reflect/Constructor
2078 * 1. boolean override;
2079 * 2. java.lang.Class clazz;
2081 * 4. java.lang.Class[] parameterTypes;
2082 * 5. java.lang.Class[] exceptionTypes;
2084 * 7. java.lang.String signature;
2085 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2086 * 9. byte[] annotations;
2087 * 10. byte[] parameterAnnotations;
2088 * 11. java.lang.Class securityCheckCache;
2089 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2090 * 13. java.lang.reflect.Constructor root;
2091 * 14. java.util.Map declaredAnnotations;
2093 class java_lang_reflect_Constructor : 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_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2098 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2099 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2100 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2101 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2102 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2103 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2104 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2105 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2106 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2107 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2108 static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2109 static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2110 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2113 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
2114 java_lang_reflect_Constructor(methodinfo* m);
2116 java_handle_t* new_instance(java_handle_objectarray_t* args);
2119 inline int32_t get_override () const;
2120 inline classinfo* get_clazz () const;
2121 inline int32_t get_slot () const;
2122 inline java_handle_bytearray_t* get_annotations() const;
2125 inline void set_clazz (classinfo* value);
2126 inline void set_slot (int32_t value);
2127 inline void set_parameterTypes (java_handle_objectarray_t* value);
2128 inline void set_exceptionTypes (java_handle_objectarray_t* value);
2129 inline void set_modifiers (int32_t value);
2130 inline void set_signature (java_handle_t* value);
2131 inline void set_annotations (java_handle_bytearray_t* value);
2132 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
2134 // Convenience functions.
2135 inline methodinfo* get_method();
2139 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
2141 _handle = builtin_new(class_java_lang_reflect_Constructor);
2146 int slot = m - m->clazz->methods;
2147 java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
2148 java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
2149 java_handle_bytearray_t* annotations = method_get_annotations(m);
2150 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2152 set_clazz(m->clazz);
2154 set_parameterTypes(parameterTypes);
2155 set_exceptionTypes(exceptionTypes);
2156 set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2157 set_signature(m->signature ? javastring_new(m->signature) : NULL);
2158 set_annotations(annotations);
2159 set_parameterAnnotations(parameterAnnotations);
2163 inline int32_t java_lang_reflect_Constructor::get_override() const
2165 return get<int32_t>(_handle, offset_override);
2168 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2170 return get<classinfo*>(_handle, offset_clazz);
2173 inline int32_t java_lang_reflect_Constructor::get_slot() const
2175 return get<int32_t>(_handle, offset_slot);
2178 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2180 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2184 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2186 set(_handle, offset_clazz, value);
2189 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2191 set(_handle, offset_slot, value);
2194 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2196 set(_handle, offset_parameterTypes, value);
2199 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2201 set(_handle, offset_exceptionTypes, value);
2204 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2206 set(_handle, offset_modifiers, value);
2209 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2211 set(_handle, offset_signature, value);
2214 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2216 set(_handle, offset_annotations, value);
2219 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2221 set(_handle, offset_parameterAnnotations, value);
2225 inline methodinfo* java_lang_reflect_Constructor::get_method()
2227 classinfo* c = get_clazz();
2228 int32_t slot = get_slot();
2229 methodinfo* m = &(c->methods[slot]);
2235 * OpenJDK java/lang/reflect/Field
2240 * 1. boolean override;
2241 * 2. java.lang.Class clazz;
2243 * 4. java.lang.String name;
2244 * 5. java.lang.Class type;
2246 * 7. java.lang.String signature;
2247 * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2248 * 9. byte[] annotations;
2249 * 10. sun.reflect.FieldAccessor fieldAccessor;
2250 * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2251 * 12. java.lang.reflect.Field root;
2252 * 13. java.lang.Class securityCheckCache;
2253 * 14. java.lang.Class securityCheckTargetClassCache;
2254 * 15. java.util.Map declaredAnnotations;
2256 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2258 // Static offsets of the object's instance fields.
2259 // TODO These offsets need to be checked on VM startup.
2260 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2261 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2262 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2263 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2264 static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2265 static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2266 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2267 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2268 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2269 static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2270 static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2271 static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2272 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2273 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2274 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2277 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
2278 java_lang_reflect_Field(fieldinfo* f);
2281 inline int32_t get_override () const;
2282 inline classinfo* get_clazz () const;
2283 inline int32_t get_slot () const;
2284 inline java_handle_bytearray_t* get_annotations() const;
2287 inline void set_clazz (classinfo* value);
2288 inline void set_slot (int32_t value);
2289 inline void set_name (java_handle_t* value);
2290 inline void set_type (classinfo* value);
2291 inline void set_modifiers (int32_t value);
2292 inline void set_signature (java_handle_t* value);
2293 inline void set_annotations(java_handle_bytearray_t* value);
2295 // Convenience functions.
2296 inline fieldinfo* get_field() const;
2300 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
2302 _handle = builtin_new(class_java_lang_reflect_Field);
2308 set_clazz(f->clazz);
2309 set_slot(f - f->clazz->fields);
2310 set_name(javastring_intern(javastring_new(f->name)));
2311 set_type(field_get_type(f));
2312 set_modifiers(f->flags);
2313 set_signature(f->signature ? javastring_new(f->signature) : NULL);
2314 set_annotations(field_get_annotations(f));
2318 inline int32_t java_lang_reflect_Field::get_override() const
2320 return get<int32_t>(_handle, offset_override);
2323 inline classinfo* java_lang_reflect_Field::get_clazz() const
2325 return get<classinfo*>(_handle, offset_clazz);
2328 inline int32_t java_lang_reflect_Field::get_slot() const
2330 return get<int32_t>(_handle, offset_slot);
2333 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2335 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2339 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2341 set(_handle, offset_clazz, value);
2344 inline void java_lang_reflect_Field::set_slot(int32_t value)
2346 set(_handle, offset_slot, value);
2349 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2351 set(_handle, offset_name, value);
2354 inline void java_lang_reflect_Field::set_type(classinfo* value)
2356 set(_handle, offset_type, value);
2359 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2361 set(_handle, offset_modifiers, value);
2364 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2366 set(_handle, offset_signature, value);
2369 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2371 set(_handle, offset_annotations, value);
2375 inline fieldinfo* java_lang_reflect_Field::get_field() const
2377 classinfo* c = get_clazz();
2378 int32_t slot = get_slot();
2379 fieldinfo* f = &(c->fields[slot]);
2385 * OpenJDK java/lang/reflect/Method
2390 * 1. boolean override;
2391 * 2. java.lang.Class clazz;
2393 * 4. java.lang.String name;
2394 * 5. java.lang.Class returnType;
2395 * 6. java.lang.Class[] parameterTypes;
2396 * 7. java.lang.Class[] exceptionTypes;
2398 * 9. java.lang.String signature;
2399 * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2400 * 11. byte[] annotations;
2401 * 12. byte[] parameterAnnotations;
2402 * 13. byte[] annotationDefault;
2403 * 14. sun.reflect.MethodAccessor methodAccessor;
2404 * 15. java.lang.reflect.Method root;
2405 * 16. java.lang.Class securityCheckCache;
2406 * 17. java.lang.Class securityCheckTargetClassCache;
2407 * 18. java.util.Map declaredAnnotations;
2409 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2411 // Static offsets of the object's instance fields.
2412 // TODO These offsets need to be checked on VM startup.
2413 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2414 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2415 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2416 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2417 static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2418 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2419 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2420 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2421 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2422 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2423 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2424 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2425 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2426 static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2427 static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2428 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2429 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2430 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2433 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
2434 java_lang_reflect_Method(methodinfo* m);
2436 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
2439 inline int32_t get_override () const;
2440 inline classinfo* get_clazz () const;
2441 inline int32_t get_slot () const;
2442 inline java_handle_bytearray_t* get_annotations () const;
2443 inline java_handle_bytearray_t* get_parameterAnnotations() const;
2444 inline java_handle_bytearray_t* get_annotationDefault () const;
2448 // Convenience functions.
2449 inline methodinfo* get_method() const;
2453 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
2455 _handle = builtin_new(class_java_lang_reflect_Method);
2460 set(_handle, offset_clazz, m->clazz);
2461 set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2462 set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
2463 set(_handle, offset_returnType, method_returntype_get(m));
2464 set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2465 set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2466 set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2467 set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
2468 set(_handle, offset_annotations, method_get_annotations(m));
2469 set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2470 set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2474 inline int32_t java_lang_reflect_Method::get_override() const
2476 return get<int32_t>(_handle, offset_override);
2479 inline classinfo* java_lang_reflect_Method::get_clazz() const
2481 return get<classinfo*>(_handle, offset_clazz);
2484 inline int32_t java_lang_reflect_Method::get_slot() const
2486 return get<int32_t>(_handle, offset_slot);
2489 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2491 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2494 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2496 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2499 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2501 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2505 inline methodinfo* java_lang_reflect_Method::get_method() const
2507 classinfo* c = get_clazz();
2508 int32_t slot = get_slot();
2509 methodinfo* m = &(c->methods[slot]);
2515 * OpenJDK java/nio/Buffer
2526 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2528 // Static offsets of the object's instance fields.
2529 // TODO These offsets need to be checked on VM startup.
2530 static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2531 static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2532 static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2533 static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2534 static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2537 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
2540 inline void* get_address() const;
2544 inline void* java_nio_Buffer::get_address() const
2546 return get<void*>(_handle, offset_address);
2549 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2552 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2555 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2564 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2566 // Static offsets of the object's instance fields.
2567 // TODO These offsets need to be checked on VM startup.
2568 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2569 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2570 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2573 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2574 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2575 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2578 inline int64_t get_pointer () const;
2579 inline int32_t get_position() const;
2580 inline int32_t get_length () const;
2583 inline void set_pointer (int64_t value);
2584 inline void set_position(int32_t value);
2585 inline void set_length (int32_t value);
2589 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)
2591 set_pointer(pointer);
2592 set_position(position);
2596 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)
2598 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2602 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2604 return get<int64_t>(_handle, offset_pointer);
2607 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2609 return get<int32_t>(_handle, offset_position);
2612 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2614 return get<int32_t>(_handle, offset_length);
2618 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2620 set(_handle, offset_pointer, value);
2623 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2625 set(_handle, offset_position, value);
2628 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2630 set(_handle, offset_length, value);
2635 * CLDC 1.1 java/lang/String
2644 class java_lang_String : public java_lang_Object, private FieldAccess {
2646 // Static offsets of the object's instance fields.
2647 // TODO These offsets need to be checked on VM startup.
2648 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2649 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2650 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2653 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
2654 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2657 inline java_handle_chararray_t* get_value () const;
2658 inline int32_t get_offset() const;
2659 inline int32_t get_count () const;
2662 inline void set_value (java_handle_chararray_t* value);
2663 inline void set_offset(int32_t value);
2664 inline void set_count (int32_t value);
2668 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)
2675 inline java_handle_chararray_t* java_lang_String::get_value() const
2677 return get<java_handle_chararray_t*>(_handle, offset_value);
2680 inline int32_t java_lang_String::get_offset() const
2682 return get<int32_t>(_handle, offset_offset);
2685 inline int32_t java_lang_String::get_count() const
2687 return get<int32_t>(_handle, offset_count);
2690 inline void java_lang_String::set_value(java_handle_chararray_t* value)
2692 set(_handle, offset_value, value);
2695 inline void java_lang_String::set_offset(int32_t value)
2697 set(_handle, offset_offset, value);
2700 inline void java_lang_String::set_count(int32_t value)
2702 set(_handle, offset_count, value);
2707 * CLDC 1.1 java/lang/Thread
2713 * 2. java.lang.Runnable runnable;
2714 * 3. java.lang.Object vm_thread;
2715 * 4. int is_terminated;
2716 * 5. int is_stillborn;
2719 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2721 // Static offsets of the object's instance fields.
2722 // TODO These offsets need to be checked on VM startup.
2723 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2724 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2725 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2726 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2727 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2728 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2731 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2732 // java_lang_Thread(threadobject* t);
2735 inline int32_t get_priority () const;
2736 inline threadobject* get_vm_thread() const;
2737 inline java_handle_chararray_t* get_name () const;
2740 inline void set_vm_thread(threadobject* value);
2744 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
2746 // java_lang_Thread(thread_get_object(t));
2750 inline int32_t java_lang_Thread::get_priority() const
2752 return get<int32_t>(_handle, offset_priority);
2755 inline threadobject* java_lang_Thread::get_vm_thread() const
2757 return get<threadobject*>(_handle, offset_vm_thread);
2760 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2762 return get<java_handle_chararray_t*>(_handle, offset_name);
2766 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2768 set(_handle, offset_vm_thread, value);
2773 * CLDC 1.1 java/lang/Throwable
2778 * 1. java.lang.String detailMessage;
2779 * 2. java.lang.Object backtrace;
2781 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2783 // Static offsets of the object's instance fields.
2784 // TODO These offsets need to be checked on VM startup.
2785 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2786 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2789 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2792 inline java_handle_t* get_detailMessage() const;
2793 inline java_handle_bytearray_t* get_backtrace () const;
2796 inline void set_backtrace(java_handle_bytearray_t* value);
2800 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2802 return get<java_handle_t*>(_handle, offset_detailMessage);
2805 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2807 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2811 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2813 set(_handle, offset_backtrace, value);
2816 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2820 // Legacy C interface.
2821 java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m);
2822 java_handle_t* java_lang_reflect_Field_create(fieldinfo* f);
2823 java_handle_t* java_lang_reflect_Method_create(methodinfo* m);
2827 #endif // _JAVAOBJECTS_HPP
2831 * These are local overrides for various environment variables in Emacs.
2832 * Please do not remove this and leave it at the end of the file, where
2833 * Emacs will automagically detect them.
2834 * ---------------------------------------------------------------------
2837 * indent-tabs-mode: t