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)
97 // XXX This should be _handle->get_object();
98 java_object_t* ho = LLNI_UNWRAP(h);
99 T result = raw_get<T>(ho, offset);
101 GC::critical_leave();
106 template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
108 GC::critical_enter();
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 java_handle_t* hresult = LLNI_WRAP(result);
115 GC::critical_leave();
121 template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
123 GC::critical_enter();
125 java_object_t* ho = LLNI_UNWRAP(h);
126 raw_set(ho, offset, value);
128 GC::critical_leave();
131 template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
133 GC::critical_enter();
135 // XXX This should be h->get_object();
136 java_object_t* o = LLNI_UNWRAP(h);
137 java_object_t* ovalue = LLNI_UNWRAP(value);
139 raw_set(o, offset, ovalue);
141 GC::critical_leave();
145 template<class T> inline T FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
147 GC::critical_enter();
149 // XXX This should be _handle->get_object();
150 java_object_t* ho = LLNI_UNWRAP(h);
151 T result = raw_get<volatile T>(ho, offset);
153 GC::critical_leave();
158 template<> inline java_handle_t* FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
160 GC::critical_enter();
162 // XXX This should be _handle->get_object();
163 java_object_t* o = LLNI_UNWRAP(h);
164 java_object_t* result = (java_object_t*) raw_get<volatile java_object_t*>(o, offset);
165 java_handle_t* hresult = LLNI_WRAP(result);
167 GC::critical_leave();
173 template<class T> inline void FieldAccess::set_volatile(java_handle_t* h, const off_t offset, T value)
175 GC::critical_enter();
177 java_object_t* ho = LLNI_UNWRAP(h);
178 raw_set(ho, offset, (volatile T) value);
180 // Memory barrier for the Java Memory Model.
181 Atomic::memory_barrier();
183 GC::critical_leave();
186 template<> inline void FieldAccess::set_volatile<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
188 GC::critical_enter();
190 // XXX This should be h->get_object();
191 java_object_t* o = LLNI_UNWRAP(h);
192 java_object_t* ovalue = LLNI_UNWRAP(value);
193 raw_set(o, offset, (volatile java_object_t*) ovalue);
195 // Memory barrier for the Java Memory Model.
196 Atomic::memory_barrier();
198 GC::critical_leave();
209 class java_lang_Object {
211 // Handle of Java object.
212 java_handle_t* _handle;
215 java_lang_Object() : _handle(NULL) {}
216 java_lang_Object(java_handle_t* h) : _handle(h) {}
217 virtual ~java_lang_Object() {}
220 virtual inline java_handle_t* get_handle () const { return _handle; }
221 inline vftbl_t* get_vftbl () const;
222 inline classinfo* get_Class () const;
223 inline int32_t get_hashcode() const;
225 inline bool is_null () const;
226 inline bool is_non_null() const;
230 inline vftbl_t* java_lang_Object::get_vftbl() const
232 GC::critical_enter();
234 // XXX This should be h->get_object();
235 java_object_t* o = LLNI_UNWRAP(_handle);
236 vftbl_t* vftbl = o->vftbl;
238 GC::critical_leave();
243 inline classinfo* java_lang_Object::get_Class() const
245 return get_vftbl()->clazz;
248 inline int32_t java_lang_Object::get_hashcode() const
250 #if defined(ENABLE_GC_CACAO)
251 return heap_get_hashcode(_handle);
256 GC::critical_enter();
258 // XXX This should be h->get_object();
259 o = LLNI_UNWRAP(_handle);
261 hashcode = (int32_t)(intptr_t) o;
263 GC::critical_leave();
270 inline bool java_lang_Object::is_null() const
272 return (_handle == NULL);
275 inline bool java_lang_Object::is_non_null() const
277 return (_handle != NULL);
289 class java_lang_Boolean : public java_lang_Object, private FieldAccess {
291 // Static offsets of the object's instance fields.
292 // TODO These offsets need to be checked on VM startup.
293 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
296 java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {}
298 inline uint8_t get_value();
299 inline void set_value(uint8_t value);
302 inline uint8_t java_lang_Boolean::get_value()
304 return get<int32_t>(_handle, offset_value);
307 inline void java_lang_Boolean::set_value(uint8_t value)
309 set(_handle, offset_value, (uint32_t) value);
321 class java_lang_Byte : public java_lang_Object, private FieldAccess {
323 // Static offsets of the object's instance fields.
324 // TODO These offsets need to be checked on VM startup.
325 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
328 java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {}
330 inline int8_t get_value();
331 inline void set_value(int8_t value);
334 inline int8_t java_lang_Byte::get_value()
336 return get<int32_t>(_handle, offset_value);
339 inline void java_lang_Byte::set_value(int8_t value)
341 set(_handle, offset_value, (int32_t) value);
346 * java/lang/Character
353 class java_lang_Character : public java_lang_Object, private FieldAccess {
355 // Static offsets of the object's instance fields.
356 // TODO These offsets need to be checked on VM startup.
357 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
360 java_lang_Character(java_handle_t* h) : java_lang_Object(h) {}
362 inline uint16_t get_value();
363 inline void set_value(uint16_t value);
366 inline uint16_t java_lang_Character::get_value()
368 return get<int32_t>(_handle, offset_value);
371 inline void java_lang_Character::set_value(uint16_t value)
373 set(_handle, offset_value, (uint32_t) value);
385 class java_lang_Short : public java_lang_Object, private FieldAccess {
387 // Static offsets of the object's instance fields.
388 // TODO These offsets need to be checked on VM startup.
389 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
392 java_lang_Short(java_handle_t* h) : java_lang_Object(h) {}
394 inline int16_t get_value();
395 inline void set_value(int16_t value);
398 inline int16_t java_lang_Short::get_value()
400 return get<int32_t>(_handle, offset_value);
403 inline void java_lang_Short::set_value(int16_t value)
405 set(_handle, offset_value, (int32_t) value);
417 class java_lang_Integer : public java_lang_Object, private FieldAccess {
419 // Static offsets of the object's instance fields.
420 // TODO These offsets need to be checked on VM startup.
421 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
424 java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
426 inline int32_t get_value();
427 inline void set_value(int32_t value);
430 inline int32_t java_lang_Integer::get_value()
432 return get<int32_t>(_handle, offset_value);
435 inline void java_lang_Integer::set_value(int32_t value)
437 set(_handle, offset_value, value);
449 class java_lang_Long : public java_lang_Object, private FieldAccess {
451 // Static offsets of the object's instance fields.
452 // TODO These offsets need to be checked on VM startup.
453 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
456 java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
458 inline int64_t get_value();
459 inline void set_value(int64_t value);
462 inline int64_t java_lang_Long::get_value()
464 return get<int64_t>(_handle, offset_value);
467 inline void java_lang_Long::set_value(int64_t value)
469 set(_handle, offset_value, value);
481 class java_lang_Float : public java_lang_Object, private FieldAccess {
483 // Static offsets of the object's instance fields.
484 // TODO These offsets need to be checked on VM startup.
485 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
488 java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
490 inline float get_value();
491 inline void set_value(float value);
494 inline float java_lang_Float::get_value()
496 return get<float>(_handle, offset_value);
499 inline void java_lang_Float::set_value(float value)
501 set(_handle, offset_value, value);
513 class java_lang_Double : public java_lang_Object, private FieldAccess {
515 // Static offsets of the object's instance fields.
516 // TODO These offsets need to be checked on VM startup.
517 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
520 java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
522 inline double get_value();
523 inline void set_value(double value);
526 inline double java_lang_Double::get_value()
528 return get<double>(_handle, offset_value);
531 inline void java_lang_Double::set_value(double value)
533 set(_handle, offset_value, value);
537 #if defined(ENABLE_JAVASE)
539 # if defined(ENABLE_ANNOTATIONS)
541 * OpenJDK sun/reflect/ConstantPool
546 * 1. java.lang.Object constantPoolOop;
548 class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
550 // Static offsets of the object's instance fields.
551 // TODO These offsets need to be checked on VM startup.
552 static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
555 sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
556 sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
559 inline void set_constantPoolOop(classinfo* value);
560 inline void set_constantPoolOop(jclass value);
564 inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
566 set_constantPoolOop(constantPoolOop);
570 inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
572 set(_handle, offset_constantPoolOop, value);
575 inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
577 // XXX jclass is a boxed object.
578 set_constantPoolOop(LLNI_classinfo_unwrap(value));
580 # endif // ENABLE_ANNOTATIONS
582 #endif // ENABLE_JAVASE
585 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
588 * GNU Classpath java/lang/Class
593 * 1. java.lang.Object[] signers;
594 * 2. java.security.ProtectionDomain pd;
595 * 3. java.lang.Object vmdata;
596 * 4. java.lang.reflect.Constructor constructor;
598 class java_lang_Class : public java_lang_Object, private FieldAccess {
600 // Static offsets of the object's instance fields.
601 // TODO These offsets need to be checked on VM startup.
602 static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
603 static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
604 static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
605 static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
608 java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
611 inline void set_pd(java_handle_t* value);
614 inline void java_lang_Class::set_pd(java_handle_t* value)
616 set(_handle, offset_pd, value);
621 * GNU Classpath java/lang/StackTraceElement
626 * 1. java.lang.String fileName;
628 * 3. java.lang.String declaringClass;
629 * 4. java.lang.String methodName;
630 * 5. boolean isNative;
632 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
634 // Static offsets of the object's instance fields.
635 // TODO These offsets need to be checked on VM startup.
636 static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
637 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
638 static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
639 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
640 static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
643 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
644 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);
647 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)
649 java_lang_StackTraceElement((java_handle_t*) h);
651 set(_handle, offset_fileName, fileName);
652 set(_handle, offset_lineNumber, lineNumber);
653 set(_handle, offset_declaringClass, declaringClass);
654 set(_handle, offset_methodName, methodName);
655 set(_handle, offset_isNative, isNative);
660 * GNU Classpath java/lang/String
667 * 3. int cachedHashCode;
670 class java_lang_String : public java_lang_Object, private FieldAccess {
672 // Static offsets of the object's instance fields.
673 // TODO These offsets need to be checked on VM startup.
674 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
675 static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
676 static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
677 static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
680 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
681 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
684 inline java_handle_chararray_t* get_value () const;
685 inline int32_t get_count () const;
686 inline int32_t get_offset() const;
689 inline void set_value (java_handle_chararray_t* value);
690 inline void set_count (int32_t value);
691 inline void set_offset(int32_t value);
694 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)
701 inline java_handle_chararray_t* java_lang_String::get_value() const
703 return get<java_handle_chararray_t*>(_handle, offset_value);
706 inline int32_t java_lang_String::get_count() const
708 return get<int32_t>(_handle, offset_count);
711 inline int32_t java_lang_String::get_offset() const
713 return get<int32_t>(_handle, offset_offset);
716 inline void java_lang_String::set_value(java_handle_chararray_t* value)
718 set(_handle, offset_value, value);
721 inline void java_lang_String::set_count(int32_t value)
723 set(_handle, offset_count, value);
726 inline void java_lang_String::set_offset(int32_t value)
728 set(_handle, offset_offset, value);
733 * GNU Classpath java/lang/Thread
738 * 1. java.lang.VMThread vmThread;
739 * 2. java.lang.ThreadGroup group;
740 * 3. java.lang.Runnable runnable;
741 * 4. java.lang.String name;
745 * 8. java.lang.Throwable stillborn;
746 * 9. java.lang.ClassLoader contextClassLoader;
747 * 10. boolean contextClassLoaderIsSystemClassLoader;
749 * 12. java.lang.Object parkBlocker;
750 * 13. gnu.java.util.WeakIdentityHashMap locals;
751 * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
753 class java_lang_Thread : public java_lang_Object, private FieldAccess {
755 // Static offsets of the object's instance fields.
756 // TODO These offsets need to be checked on VM startup.
757 static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
758 static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
759 static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
760 static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
761 static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
762 static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
763 static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
764 static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
765 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
766 static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
767 static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
768 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
769 static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
770 static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
773 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
774 // java_lang_Thread(threadobject* t);
777 inline java_handle_t* get_vmThread () const;
778 inline java_handle_t* get_group () const;
779 inline java_handle_t* get_name () const;
780 inline int32_t get_daemon () const;
781 inline int32_t get_priority () const;
782 inline java_handle_t* get_exceptionHandler() const;
785 inline void set_group(java_handle_t* value);
789 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
791 // java_lang_Thread(thread_get_object(t));
795 inline java_handle_t* java_lang_Thread::get_vmThread() const
797 return get<java_handle_t*>(_handle, offset_vmThread);
800 inline java_handle_t* java_lang_Thread::get_group() const
802 return get<java_handle_t*>(_handle, offset_group);
805 inline java_handle_t* java_lang_Thread::get_name() const
807 return get<java_handle_t*>(_handle, offset_name);
810 inline int32_t java_lang_Thread::get_daemon() const
812 return get<int32_t>(_handle, offset_daemon);
815 inline int32_t java_lang_Thread::get_priority() const
817 return get<int32_t>(_handle, offset_priority);
820 inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
822 return get<java_handle_t*>(_handle, offset_exceptionHandler);
826 inline void java_lang_Thread::set_group(java_handle_t* value)
828 set(_handle, offset_group, value);
833 * GNU Classpath java/lang/VMThread
838 * 1. java.lang.Thread thread;
839 * 2. boolean running;
840 * 3. java.lang.VMThread vmdata;
842 class java_lang_VMThread : public java_lang_Object, private FieldAccess {
844 // Static offsets of the object's instance fields.
845 // TODO These offsets need to be checked on VM startup.
846 static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
847 static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
848 static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
851 java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
852 java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
855 inline java_handle_t* get_thread() const;
856 inline threadobject* get_vmdata() const;
859 inline void set_thread(java_handle_t* value);
860 inline void set_vmdata(threadobject* value);
864 inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
871 inline java_handle_t* java_lang_VMThread::get_thread() const
873 return get<java_handle_t*>(_handle, offset_thread);
876 inline threadobject* java_lang_VMThread::get_vmdata() const
878 return get<threadobject*>(_handle, offset_vmdata);
882 inline void java_lang_VMThread::set_thread(java_handle_t* value)
884 set(_handle, offset_thread, value);
887 inline void java_lang_VMThread::set_vmdata(threadobject* value)
889 set(_handle, offset_vmdata, value);
894 * GNU Classpath java/lang/Throwable
899 * 1. java.lang.String detailMessage;
900 * 2. java.lang.Throwable cause;
901 * 3. java.lang.StackTraceElement[] stackTrace;
902 * 4. java.lang.VMThrowable vmState;
904 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
906 // Static offsets of the object's instance fields.
907 // TODO These offsets need to be checked on VM startup.
908 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
909 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
910 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
911 static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
914 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
917 inline java_handle_t* get_detailMessage() const;
918 inline java_handle_t* get_cause () const;
919 inline java_handle_t* get_vmState () const;
923 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
925 return get<java_handle_t*>(_handle, offset_detailMessage);
928 inline java_handle_t* java_lang_Throwable::get_cause() const
930 return get<java_handle_t*>(_handle, offset_cause);
933 inline java_handle_t* java_lang_Throwable::get_vmState() const
935 return get<java_handle_t*>(_handle, offset_vmState);
940 * GNU Classpath java/lang/VMThrowable
945 * 1. java.lang.Object vmdata;
947 class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
949 // Static offsets of the object's instance fields.
950 // TODO These offsets need to be checked on VM startup.
951 static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
954 java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
956 inline java_handle_bytearray_t* get_vmdata() const;
957 inline void set_vmdata(java_handle_bytearray_t* value);
961 inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
963 return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
966 inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
968 set(_handle, offset_vmdata, value);
973 * GNU Classpath java/lang/reflect/VMConstructor
978 * 1. java.lang.Class clazz;
980 * 3. byte[] annotations;
981 * 4. byte[] parameterAnnotations;
982 * 5. java.util.Map declaredAnnotations;
983 * 6. java.lang.reflect.Constructor cons;
985 class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
987 // Static offsets of the object's instance fields.
988 // TODO These offsets need to be checked on VM startup.
989 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
990 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
991 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
992 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
993 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
994 static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
997 java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
998 java_lang_reflect_VMConstructor(methodinfo* m);
1001 inline classinfo* get_clazz () const;
1002 inline int32_t get_slot () const;
1003 inline java_handle_bytearray_t* get_annotations () const;
1004 inline java_handle_bytearray_t* get_parameterAnnotations() const;
1005 inline java_handle_t* get_declaredAnnotations () const;
1006 inline java_handle_t* get_cons () const;
1009 inline void set_clazz (classinfo* value);
1010 inline void set_slot (int32_t value);
1011 inline void set_annotations (java_handle_bytearray_t* value);
1012 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
1013 inline void set_declaredAnnotations (java_handle_t* value);
1014 inline void set_cons (java_handle_t* value);
1016 // Convenience functions.
1017 inline methodinfo* get_method();
1021 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
1023 _handle = builtin_new(class_java_lang_reflect_VMConstructor);
1028 int slot = m - m->clazz->methods;
1029 java_handle_bytearray_t* annotations = method_get_annotations(m);
1030 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1032 set_clazz(m->clazz);
1034 set_annotations(annotations);
1035 set_parameterAnnotations(parameterAnnotations);
1039 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
1041 return get<classinfo*>(_handle, offset_clazz);
1044 inline int32_t java_lang_reflect_VMConstructor::get_slot() const
1046 return get<int32_t>(_handle, offset_slot);
1049 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
1051 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1054 inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
1056 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1059 inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
1061 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1064 inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
1066 return get<java_handle_t*>(_handle, offset_cons);
1069 inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
1071 set(_handle, offset_clazz, value);
1074 inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
1076 set(_handle, offset_slot, value);
1079 inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
1081 set(_handle, offset_annotations, value);
1084 inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
1086 set(_handle, offset_parameterAnnotations, value);
1089 inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
1091 set(_handle, offset_declaredAnnotations, value);
1094 inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
1096 set(_handle, offset_cons, value);
1099 inline methodinfo* java_lang_reflect_VMConstructor::get_method()
1101 classinfo* c = get_clazz();
1102 int32_t slot = get_slot();
1103 methodinfo* m = &(c->methods[slot]);
1109 * GNU Classpath java/lang/reflect/Constructor
1115 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1116 * 3. java.lang.reflect.VMConstructor cons;
1118 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
1120 // Static offsets of the object's instance fields.
1121 // TODO These offsets need to be checked on VM startup.
1122 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1123 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1124 static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1127 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
1128 java_lang_reflect_Constructor(methodinfo* m);
1130 java_handle_t* new_instance(java_handle_objectarray_t* args);
1133 inline int32_t get_flag() const;
1134 inline java_handle_t* get_cons() const;
1137 inline void set_cons(java_handle_t* value);
1139 // Convenience functions.
1140 inline methodinfo* get_method () const;
1141 inline int32_t get_override() const;
1145 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
1147 java_lang_reflect_VMConstructor jlrvmc(m);
1149 if (jlrvmc.is_null())
1152 _handle = builtin_new(class_java_lang_reflect_Constructor);
1157 // Link the two Java objects.
1158 set_cons(jlrvmc.get_handle());
1159 jlrvmc.set_cons(get_handle());
1163 inline int32_t java_lang_reflect_Constructor::get_flag() const
1165 return get<int32_t>(_handle, offset_flag);
1168 inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
1170 return get<java_handle_t*>(_handle, offset_cons);
1174 inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
1176 set(_handle, offset_cons, value);
1180 inline methodinfo* java_lang_reflect_Constructor::get_method() const
1182 java_lang_reflect_VMConstructor jlrvmc(get_cons());
1183 return jlrvmc.get_method();
1186 inline int32_t java_lang_reflect_Constructor::get_override() const
1193 * GNU Classpath java/lang/reflect/VMField
1198 * 1. java.lang.Class clazz;
1199 * 2. java.lang.String name;
1201 * 4. byte[] annotations;
1202 * 5. java.lang.Map declaredAnnotations;
1203 * 6. java.lang.reflect.Field f;
1205 class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
1207 // Static offsets of the object's instance fields.
1208 // TODO These offsets need to be checked on VM startup.
1209 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1210 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1211 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1212 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1213 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1214 static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1217 java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
1218 java_lang_reflect_VMField(fieldinfo* f);
1221 inline classinfo* get_clazz () const;
1222 inline int32_t get_slot () const;
1223 inline java_handle_bytearray_t* get_annotations () const;
1224 inline java_handle_t* get_declaredAnnotations() const;
1225 inline java_handle_t* get_f () const;
1228 inline void set_clazz (classinfo* value);
1229 inline void set_name (java_handle_t* value);
1230 inline void set_slot (int32_t value);
1231 inline void set_annotations (java_handle_bytearray_t* value);
1232 inline void set_declaredAnnotations(java_handle_t* value);
1233 inline void set_f (java_handle_t* value);
1235 // Convenience functions.
1236 inline fieldinfo* get_field() const;
1240 inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
1242 _handle = builtin_new(class_java_lang_reflect_VMField);
1247 java_handle_t* name = javastring_intern(javastring_new(f->name));
1248 int slot = f - f->clazz->fields;
1249 java_handle_bytearray_t* annotations = field_get_annotations(f);
1251 set_clazz(f->clazz);
1254 set_annotations(annotations);
1258 inline classinfo* java_lang_reflect_VMField::get_clazz() const
1260 return get<classinfo*>(_handle, offset_clazz);
1263 inline int32_t java_lang_reflect_VMField::get_slot() const
1265 return get<int32_t>(_handle, offset_slot);
1268 inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
1270 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1273 inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
1275 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1278 inline java_handle_t* java_lang_reflect_VMField::get_f() const
1280 return get<java_handle_t*>(_handle, offset_f);
1284 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
1286 set(_handle, offset_clazz, value);
1289 inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
1291 set(_handle, offset_name, value);
1294 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1296 set(_handle, offset_slot, value);
1299 inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
1301 set(_handle, offset_annotations, value);
1304 inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
1306 set(_handle, offset_declaredAnnotations, value);
1309 inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
1311 set(_handle, offset_f, value);
1314 inline fieldinfo* java_lang_reflect_VMField::get_field() const
1316 classinfo* c = get_clazz();
1317 int32_t slot = get_slot();
1318 fieldinfo* f = &(c->fields[slot]);
1324 * GNU Classpath java/lang/reflect/Field
1330 * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1331 * 3. java.lang.reflect.VMField f;
1333 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
1335 // Static offsets of the object's instance fields.
1336 // TODO These offsets need to be checked on VM startup.
1337 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1338 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1339 static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1342 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
1343 java_lang_reflect_Field(fieldinfo* f);
1346 inline int32_t get_flag() const;
1347 inline java_handle_t* get_f() const;
1350 inline void set_f(java_handle_t* value);
1352 // Convenience functions.
1353 inline fieldinfo* get_field() const;
1357 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
1359 java_lang_reflect_VMField jlrvmf(f);
1361 if (jlrvmf.is_null())
1364 _handle = builtin_new(class_java_lang_reflect_Field);
1369 // Link the two Java objects.
1370 set_f(jlrvmf.get_handle());
1371 jlrvmf.set_f(get_handle());
1375 inline int32_t java_lang_reflect_Field::get_flag() const
1377 return get<int32_t>(_handle, offset_flag);
1380 inline java_handle_t* java_lang_reflect_Field::get_f() const
1382 return get<java_handle_t*>(_handle, offset_f);
1386 inline void java_lang_reflect_Field::set_f(java_handle_t* value)
1388 set(_handle, offset_f, value);
1392 inline fieldinfo* java_lang_reflect_Field::get_field() const
1394 java_lang_reflect_VMField jlrvmf(get_f());
1395 return jlrvmf.get_field();
1400 * GNU Classpath java/lang/reflect/VMMethod
1405 * 1. java.lang.Class clazz;
1406 * 2. java.lang.String name;
1408 * 4. byte[] annotations;
1409 * 5. byte[] parameterAnnotations;
1410 * 6. byte[] annotationDefault;
1411 * 7. java.lang.Map declaredAnnotations;
1412 * 8. java.lang.reflect.Method m;
1414 class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
1416 // Static offsets of the object's instance fields.
1417 // TODO These offsets need to be checked on VM startup.
1418 static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1419 static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1420 static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1421 static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1422 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1423 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1424 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1425 static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1428 java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
1429 java_lang_reflect_VMMethod(methodinfo* m);
1432 inline classinfo* get_clazz () const;
1433 inline int32_t get_slot () const;
1434 inline java_handle_bytearray_t* get_annotations () const;
1435 inline java_handle_bytearray_t* get_parameterAnnotations() const;
1436 inline java_handle_bytearray_t* get_annotationDefault () const;
1437 inline java_handle_t* get_declaredAnnotations () const;
1438 inline java_handle_t* get_m () const;
1441 inline void set_clazz (classinfo* value);
1442 inline void set_name (java_handle_t* value);
1443 inline void set_slot (int32_t value);
1444 inline void set_annotations (java_handle_bytearray_t* value);
1445 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
1446 inline void set_annotationDefault (java_handle_bytearray_t* value);
1447 inline void set_declaredAnnotations (java_handle_t* value);
1448 inline void set_m (java_handle_t* value);
1450 // Convenience functions.
1451 inline methodinfo* get_method() const;
1455 inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
1457 _handle = builtin_new(class_java_lang_reflect_VMMethod);
1462 java_handle_t* name = javastring_intern(javastring_new(m->name));
1463 int slot = m - m->clazz->methods;
1464 java_handle_bytearray_t* annotations = method_get_annotations(m);
1465 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1466 java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1468 set_clazz(m->clazz);
1471 set_annotations(annotations);
1472 set_parameterAnnotations(parameterAnnotations);
1473 set_annotationDefault(annotationDefault);
1476 inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
1478 return get<classinfo*>(_handle, offset_clazz);
1481 inline int32_t java_lang_reflect_VMMethod::get_slot() const
1483 return get<int32_t>(_handle, offset_slot);
1486 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
1488 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1491 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
1493 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1496 inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
1498 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1501 inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
1503 return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1506 inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
1508 return get<java_handle_t*>(_handle, offset_m);
1511 inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
1513 set(_handle, offset_clazz, value);
1516 inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
1518 set(_handle, offset_name, value);
1521 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1523 set(_handle, offset_slot, value);
1526 inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
1528 set(_handle, offset_annotations, value);
1531 inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
1533 set(_handle, offset_parameterAnnotations, value);
1536 inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
1538 set(_handle, offset_annotationDefault, value);
1541 inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
1543 set(_handle, offset_declaredAnnotations, value);
1546 inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
1548 set(_handle, offset_m, value);
1551 inline methodinfo* java_lang_reflect_VMMethod::get_method() const
1553 classinfo* c = get_clazz();
1554 int32_t slot = get_slot();
1555 methodinfo* m = &(c->methods[slot]);
1561 * GNU Classpath java/lang/reflect/Method
1567 * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1568 * 3. java.lang.reflect.VMMethod m;
1570 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
1572 // Static offsets of the object's instance fields.
1573 // TODO These offsets need to be checked on VM startup.
1574 static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1575 static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1576 static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1579 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
1580 java_lang_reflect_Method(methodinfo* m);
1582 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
1585 inline int32_t get_flag() const;
1586 inline java_handle_t* get_m() const;
1589 inline void set_m(java_handle_t* value);
1591 // Convenience functions.
1592 inline methodinfo* get_method () const;
1593 inline int32_t get_override() const;
1597 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
1599 java_lang_reflect_VMMethod jlrvmm(m);
1601 if (jlrvmm.is_null())
1604 _handle = builtin_new(class_java_lang_reflect_Method);
1609 // Link the two Java objects.
1610 set_m(jlrvmm.get_handle());
1611 jlrvmm.set_m(get_handle());
1615 inline int32_t java_lang_reflect_Method::get_flag() const
1617 return get<int32_t>(_handle, offset_flag);
1620 inline java_handle_t* java_lang_reflect_Method::get_m() const
1622 return get<java_handle_t*>(_handle, offset_m);
1626 inline void java_lang_reflect_Method::set_m(java_handle_t* value)
1628 set(_handle, offset_m, value);
1632 inline methodinfo* java_lang_reflect_Method::get_method() const
1634 java_lang_reflect_VMMethod jlrvmm(get_m());
1635 return jlrvmm.get_method();
1638 inline int32_t java_lang_reflect_Method::get_override() const
1645 * GNU Classpath java/nio/Buffer
1654 * 5. gnu.classpath.Pointer address;
1656 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
1658 // Static offsets of the object's instance fields.
1659 // TODO These offsets need to be checked on VM startup.
1660 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1661 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1662 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1663 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1664 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1667 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
1670 inline int32_t get_cap() const;
1673 inline int32_t java_nio_Buffer::get_cap() const
1675 return get<int32_t>(_handle, offset_cap);
1680 * GNU Classpath java/nio/DirectByteBufferImpl
1689 * 5. gnu.classpath.Pointer address;
1690 * 6. java.nio.ByteOrder endian;
1691 * 7. byte[] backing_buffer;
1692 * 8. int array_offset;
1693 * 9. java.lang.Object owner;
1695 class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
1697 // Static offsets of the object's instance fields.
1698 // TODO These offsets need to be checked on VM startup.
1699 static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1700 static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1701 static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1702 static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1703 static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1704 static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1705 static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1706 static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1707 static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1710 java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
1713 inline java_handle_t* get_address() const;
1717 inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
1719 return get<java_handle_t*>(_handle, offset_address);
1724 * GNU Classpath gnu/classpath/Pointer
1726 * Actually there are two classes, gnu.classpath.Pointer32 and
1727 * gnu.classpath.Pointer64, but we only define the abstract super
1728 * class and use the int/long field as void* type.
1735 class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
1737 // Static offsets of the object's instance fields.
1738 // TODO These offsets need to be checked on VM startup.
1739 static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1742 gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
1743 gnu_classpath_Pointer(java_handle_t* h, void* data);
1746 inline void* get_data() const;
1749 inline void set_data(void* value);
1752 inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
1757 inline void* gnu_classpath_Pointer::get_data() const
1759 return get<void*>(_handle, offset_data);
1762 inline void gnu_classpath_Pointer::set_data(void* value)
1764 set(_handle, offset_data, value);
1767 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1770 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1773 * OpenJDK java/lang/AssertionStatusDirectives
1778 * 1. java.lang.String[] classes;
1779 * 2. boolean[] classEnabled;
1780 * 3. java.lang.String[] packages;
1781 * 4. boolean[] packageEnabled;
1784 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1786 // Static offsets of the object's instance fields.
1787 // TODO These offsets need to be checked on VM startup.
1788 static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1789 static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1790 static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1791 static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1792 static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1795 java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1798 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)
1800 classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
1802 // FIXME Load the class at VM startup.
1806 _handle = builtin_new(c);
1811 set(_handle, offset_classes, classes);
1812 set(_handle, offset_classEnabled, classEnabled);
1813 set(_handle, offset_packages, packages);
1814 set(_handle, offset_packageEnabled, packageEnabled);
1819 * OpenJDK java/lang/StackTraceElement
1824 * 1. java.lang.String declaringClass;
1825 * 2. java.lang.String methodName;
1826 * 3. java.lang.String fileName;
1827 * 4. int lineNumber;
1829 class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
1831 // Static offsets of the object's instance fields.
1832 // TODO These offsets need to be checked on VM startup.
1833 static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1834 static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1835 static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1836 static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1839 java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
1840 java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1843 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1845 _handle = builtin_new(class_java_lang_StackTraceElement);
1850 set(_handle, offset_declaringClass, declaringClass);
1851 set(_handle, offset_methodName, methodName);
1852 set(_handle, offset_fileName, fileName);
1853 set(_handle, offset_lineNumber, lineNumber);
1858 * OpenJDK java/lang/String
1868 class java_lang_String : public java_lang_Object, private FieldAccess {
1870 // Static offsets of the object's instance fields.
1871 // TODO These offsets need to be checked on VM startup.
1872 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1873 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1874 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1875 static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
1878 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
1879 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1882 inline java_handle_chararray_t* get_value () const;
1883 inline int32_t get_offset() const;
1884 inline int32_t get_count () const;
1887 inline void set_value (java_handle_chararray_t* value);
1888 inline void set_offset(int32_t value);
1889 inline void set_count (int32_t value);
1892 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)
1899 inline java_handle_chararray_t* java_lang_String::get_value() const
1901 return get<java_handle_chararray_t*>(_handle, offset_value);
1904 inline int32_t java_lang_String::get_offset() const
1906 return get<int32_t>(_handle, offset_offset);
1909 inline int32_t java_lang_String::get_count() const
1911 return get<int32_t>(_handle, offset_count);
1914 inline void java_lang_String::set_value(java_handle_chararray_t* value)
1916 set(_handle, offset_value, value);
1919 inline void java_lang_String::set_offset(int32_t value)
1921 set(_handle, offset_offset, value);
1924 inline void java_lang_String::set_count(int32_t value)
1926 set(_handle, offset_count, value);
1931 * OpenJDK java/lang/Thread
1938 * 3. java_lang_Thread threadQ;
1940 * 5. boolean single_step;
1941 * 6. boolean daemon;
1942 * 7. boolean stillborn;
1943 * 8. java_lang_Runnable target;
1944 * 9. java_lang_ThreadGroup group;
1945 * 10. java_lang_ClassLoader contextClassLoader;
1946 * 11. java_security_AccessControlContext inheritedAccessControlContext;
1947 * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals;
1948 * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals;
1949 * 14. long stackSize;
1950 * 15. long nativeParkEventPointer;
1952 * 17. int threadStatus;
1953 * 18. java_lang_Object parkBlocker;
1954 * 19. sun_nio_ch_Interruptible blocker;
1955 * 20. java_lang_Object blockerLock;
1956 * 21. boolean stopBeforeStart;
1957 * 22. java_lang_Throwable throwableFromStop;
1958 * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
1960 class java_lang_Thread : public java_lang_Object, private FieldAccess {
1962 // Static offsets of the object's instance fields.
1963 // TODO These offsets need to be checked on VM startup.
1964 static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1965 static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1966 static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
1967 static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t));
1968 static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t));
1969 static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t));
1970 static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
1971 static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
1972 static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P);
1973 static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
1974 static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
1975 static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P);
1976 static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P);
1977 static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t));
1978 static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t));
1979 static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t));
1980 static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t));
1981 static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P);
1982 static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
1983 static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
1984 static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t));
1985 static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P);
1986 static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P);
1989 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
1990 // java_lang_Thread(threadobject* t);
1993 inline int32_t get_priority () const;
1994 inline int32_t get_daemon () const;
1995 inline java_handle_t* get_group () const;
1996 inline java_handle_t* get_uncaughtExceptionHandler() const;
1999 inline void set_priority(int32_t value);
2000 inline void set_group (java_handle_t* value);
2004 inline int32_t java_lang_Thread::get_priority() const
2006 return get<int32_t>(_handle, offset_priority);
2009 inline int32_t java_lang_Thread::get_daemon() const
2011 return get<int32_t>(_handle, offset_daemon);
2014 inline java_handle_t* java_lang_Thread::get_group() const
2016 return get<java_handle_t*>(_handle, offset_group);
2019 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
2021 return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
2025 inline void java_lang_Thread::set_priority(int32_t value)
2027 set(_handle, offset_priority, value);
2030 inline void java_lang_Thread::set_group(java_handle_t* value)
2032 set(_handle, offset_group, value);
2038 * OpenJDK java/lang/Throwable
2043 * 1. java.lang.Object backtrace;
2044 * 2. java.lang.String detailMessage;
2045 * 3. java.lang.Throwable cause;
2046 * 4. java.lang.StackTraceElement[] stackTrace;
2048 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2050 // Static offsets of the object's instance fields.
2051 // TODO These offsets need to be checked on VM startup.
2052 static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2053 static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2054 static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2055 static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2058 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2059 java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace);
2062 inline java_handle_bytearray_t* get_backtrace () const;
2063 inline java_handle_t* get_detailMessage() const;
2064 inline java_handle_t* get_cause () const;
2067 inline void set_backtrace(java_handle_bytearray_t* value);
2071 inline java_lang_Throwable::java_lang_Throwable(java_handle_t* h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
2073 set_backtrace(backtrace);
2077 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2079 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2082 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2084 return get<java_handle_t*>(_handle, offset_detailMessage);
2087 inline java_handle_t* java_lang_Throwable::get_cause() const
2089 return get<java_handle_t*>(_handle, offset_cause);
2093 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2095 set(_handle, offset_backtrace, value);
2100 * OpenJDK java/lang/reflect/Constructor
2105 * 1. boolean override;
2106 * 2. java.lang.Class clazz;
2108 * 4. java.lang.Class[] parameterTypes;
2109 * 5. java.lang.Class[] exceptionTypes;
2111 * 7. java.lang.String signature;
2112 * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2113 * 9. byte[] annotations;
2114 * 10. byte[] parameterAnnotations;
2115 * 11. java.lang.Class securityCheckCache;
2116 * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2117 * 13. java.lang.reflect.Constructor root;
2118 * 14. java.util.Map declaredAnnotations;
2120 class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
2122 // Static offsets of the object's instance fields.
2123 // TODO These offsets need to be checked on VM startup.
2124 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2125 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2126 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2127 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2128 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2129 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2130 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2131 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2132 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2133 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2134 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2135 static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2136 static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2137 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2140 java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
2141 java_lang_reflect_Constructor(methodinfo* m);
2143 java_handle_t* new_instance(java_handle_objectarray_t* args);
2146 inline int32_t get_override () const;
2147 inline classinfo* get_clazz () const;
2148 inline int32_t get_slot () const;
2149 inline java_handle_bytearray_t* get_annotations() const;
2152 inline void set_clazz (classinfo* value);
2153 inline void set_slot (int32_t value);
2154 inline void set_parameterTypes (java_handle_objectarray_t* value);
2155 inline void set_exceptionTypes (java_handle_objectarray_t* value);
2156 inline void set_modifiers (int32_t value);
2157 inline void set_signature (java_handle_t* value);
2158 inline void set_annotations (java_handle_bytearray_t* value);
2159 inline void set_parameterAnnotations(java_handle_bytearray_t* value);
2161 // Convenience functions.
2162 inline methodinfo* get_method();
2166 inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
2168 _handle = builtin_new(class_java_lang_reflect_Constructor);
2173 int slot = m - m->clazz->methods;
2174 java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
2175 java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
2176 java_handle_bytearray_t* annotations = method_get_annotations(m);
2177 java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2179 set_clazz(m->clazz);
2181 set_parameterTypes(parameterTypes);
2182 set_exceptionTypes(exceptionTypes);
2183 set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2184 set_signature(m->signature ? javastring_new(m->signature) : NULL);
2185 set_annotations(annotations);
2186 set_parameterAnnotations(parameterAnnotations);
2190 inline int32_t java_lang_reflect_Constructor::get_override() const
2192 return get<int32_t>(_handle, offset_override);
2195 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2197 return get<classinfo*>(_handle, offset_clazz);
2200 inline int32_t java_lang_reflect_Constructor::get_slot() const
2202 return get<int32_t>(_handle, offset_slot);
2205 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2207 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2211 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2213 set(_handle, offset_clazz, value);
2216 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2218 set(_handle, offset_slot, value);
2221 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2223 set(_handle, offset_parameterTypes, value);
2226 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2228 set(_handle, offset_exceptionTypes, value);
2231 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2233 set(_handle, offset_modifiers, value);
2236 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2238 set(_handle, offset_signature, value);
2241 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2243 set(_handle, offset_annotations, value);
2246 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2248 set(_handle, offset_parameterAnnotations, value);
2252 inline methodinfo* java_lang_reflect_Constructor::get_method()
2254 classinfo* c = get_clazz();
2255 int32_t slot = get_slot();
2256 methodinfo* m = &(c->methods[slot]);
2262 * OpenJDK java/lang/reflect/Field
2267 * 1. boolean override;
2268 * 2. java.lang.Class clazz;
2270 * 4. java.lang.String name;
2271 * 5. java.lang.Class type;
2273 * 7. java.lang.String signature;
2274 * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2275 * 9. byte[] annotations;
2276 * 10. sun.reflect.FieldAccessor fieldAccessor;
2277 * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2278 * 12. java.lang.reflect.Field root;
2279 * 13. java.lang.Class securityCheckCache;
2280 * 14. java.lang.Class securityCheckTargetClassCache;
2281 * 15. java.util.Map declaredAnnotations;
2283 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2285 // Static offsets of the object's instance fields.
2286 // TODO These offsets need to be checked on VM startup.
2287 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2288 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2289 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2290 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2291 static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2292 static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2293 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2294 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2295 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2296 static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2297 static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2298 static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2299 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2300 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2301 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2304 java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
2305 java_lang_reflect_Field(fieldinfo* f);
2308 inline int32_t get_override () const;
2309 inline classinfo* get_clazz () const;
2310 inline int32_t get_slot () const;
2311 inline java_handle_bytearray_t* get_annotations() const;
2314 inline void set_clazz (classinfo* value);
2315 inline void set_slot (int32_t value);
2316 inline void set_name (java_handle_t* value);
2317 inline void set_type (classinfo* value);
2318 inline void set_modifiers (int32_t value);
2319 inline void set_signature (java_handle_t* value);
2320 inline void set_annotations(java_handle_bytearray_t* value);
2322 // Convenience functions.
2323 inline fieldinfo* get_field() const;
2327 inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
2329 _handle = builtin_new(class_java_lang_reflect_Field);
2335 set_clazz(f->clazz);
2336 set_slot(f - f->clazz->fields);
2337 set_name(javastring_intern(javastring_new(f->name)));
2338 set_type(field_get_type(f));
2339 set_modifiers(f->flags);
2340 set_signature(f->signature ? javastring_new(f->signature) : NULL);
2341 set_annotations(field_get_annotations(f));
2345 inline int32_t java_lang_reflect_Field::get_override() const
2347 return get<int32_t>(_handle, offset_override);
2350 inline classinfo* java_lang_reflect_Field::get_clazz() const
2352 return get<classinfo*>(_handle, offset_clazz);
2355 inline int32_t java_lang_reflect_Field::get_slot() const
2357 return get<int32_t>(_handle, offset_slot);
2360 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2362 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2366 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2368 set(_handle, offset_clazz, value);
2371 inline void java_lang_reflect_Field::set_slot(int32_t value)
2373 set(_handle, offset_slot, value);
2376 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2378 set(_handle, offset_name, value);
2381 inline void java_lang_reflect_Field::set_type(classinfo* value)
2383 set(_handle, offset_type, value);
2386 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2388 set(_handle, offset_modifiers, value);
2391 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2393 set(_handle, offset_signature, value);
2396 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2398 set(_handle, offset_annotations, value);
2402 inline fieldinfo* java_lang_reflect_Field::get_field() const
2404 classinfo* c = get_clazz();
2405 int32_t slot = get_slot();
2406 fieldinfo* f = &(c->fields[slot]);
2412 * OpenJDK java/lang/reflect/Method
2417 * 1. boolean override;
2418 * 2. java.lang.Class clazz;
2420 * 4. java.lang.String name;
2421 * 5. java.lang.Class returnType;
2422 * 6. java.lang.Class[] parameterTypes;
2423 * 7. java.lang.Class[] exceptionTypes;
2425 * 9. java.lang.String signature;
2426 * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2427 * 11. byte[] annotations;
2428 * 12. byte[] parameterAnnotations;
2429 * 13. byte[] annotationDefault;
2430 * 14. sun.reflect.MethodAccessor methodAccessor;
2431 * 15. java.lang.reflect.Method root;
2432 * 16. java.lang.Class securityCheckCache;
2433 * 17. java.lang.Class securityCheckTargetClassCache;
2434 * 18. java.util.Map declaredAnnotations;
2436 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2438 // Static offsets of the object's instance fields.
2439 // TODO These offsets need to be checked on VM startup.
2440 static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2441 static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2442 static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2443 static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2444 static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2445 static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2446 static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2447 static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2448 static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2449 static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2450 static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2451 static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2452 static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2453 static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2454 static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2455 static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2456 static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2457 static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2460 java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
2461 java_lang_reflect_Method(methodinfo* m);
2463 java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
2466 inline int32_t get_override () const;
2467 inline classinfo* get_clazz () const;
2468 inline int32_t get_slot () const;
2469 inline java_handle_bytearray_t* get_annotations () const;
2470 inline java_handle_bytearray_t* get_parameterAnnotations() const;
2471 inline java_handle_bytearray_t* get_annotationDefault () const;
2475 // Convenience functions.
2476 inline methodinfo* get_method() const;
2480 inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
2482 _handle = builtin_new(class_java_lang_reflect_Method);
2487 set(_handle, offset_clazz, m->clazz);
2488 set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2489 set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
2490 set(_handle, offset_returnType, method_returntype_get(m));
2491 set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2492 set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2493 set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2494 set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
2495 set(_handle, offset_annotations, method_get_annotations(m));
2496 set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2497 set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2501 inline int32_t java_lang_reflect_Method::get_override() const
2503 return get<int32_t>(_handle, offset_override);
2506 inline classinfo* java_lang_reflect_Method::get_clazz() const
2508 return get<classinfo*>(_handle, offset_clazz);
2511 inline int32_t java_lang_reflect_Method::get_slot() const
2513 return get<int32_t>(_handle, offset_slot);
2516 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2518 return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2521 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2523 return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2526 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2528 return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2532 inline methodinfo* java_lang_reflect_Method::get_method() const
2534 classinfo* c = get_clazz();
2535 int32_t slot = get_slot();
2536 methodinfo* m = &(c->methods[slot]);
2542 * OpenJDK java/nio/Buffer
2553 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2555 // Static offsets of the object's instance fields.
2556 // TODO These offsets need to be checked on VM startup.
2557 static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2558 static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2559 static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2560 static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2561 static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2564 java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
2567 inline void* get_address() const;
2571 inline void* java_nio_Buffer::get_address() const
2573 return get<void*>(_handle, offset_address);
2576 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2579 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2582 * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2591 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2593 // Static offsets of the object's instance fields.
2594 // TODO These offsets need to be checked on VM startup.
2595 static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2596 static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2597 static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2600 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2601 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2602 com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2605 inline int64_t get_pointer () const;
2606 inline int32_t get_position() const;
2607 inline int32_t get_length () const;
2610 inline void set_pointer (int64_t value);
2611 inline void set_position(int32_t value);
2612 inline void set_length (int32_t value);
2616 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)
2618 set_pointer(pointer);
2619 set_position(position);
2623 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)
2625 com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2629 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2631 return get<int64_t>(_handle, offset_pointer);
2634 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2636 return get<int32_t>(_handle, offset_position);
2639 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2641 return get<int32_t>(_handle, offset_length);
2645 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2647 set(_handle, offset_pointer, value);
2650 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2652 set(_handle, offset_position, value);
2655 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2657 set(_handle, offset_length, value);
2662 * CLDC 1.1 java/lang/String
2671 class java_lang_String : public java_lang_Object, private FieldAccess {
2673 // Static offsets of the object's instance fields.
2674 // TODO These offsets need to be checked on VM startup.
2675 static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2676 static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2677 static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2680 java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
2681 java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2684 inline java_handle_chararray_t* get_value () const;
2685 inline int32_t get_offset() const;
2686 inline int32_t get_count () const;
2689 inline void set_value (java_handle_chararray_t* value);
2690 inline void set_offset(int32_t value);
2691 inline void set_count (int32_t value);
2695 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)
2702 inline java_handle_chararray_t* java_lang_String::get_value() const
2704 return get<java_handle_chararray_t*>(_handle, offset_value);
2707 inline int32_t java_lang_String::get_offset() const
2709 return get<int32_t>(_handle, offset_offset);
2712 inline int32_t java_lang_String::get_count() const
2714 return get<int32_t>(_handle, offset_count);
2717 inline void java_lang_String::set_value(java_handle_chararray_t* value)
2719 set(_handle, offset_value, value);
2722 inline void java_lang_String::set_offset(int32_t value)
2724 set(_handle, offset_offset, value);
2727 inline void java_lang_String::set_count(int32_t value)
2729 set(_handle, offset_count, value);
2734 * CLDC 1.1 java/lang/Thread
2740 * 2. java.lang.Runnable runnable;
2741 * 3. java.lang.Object vm_thread;
2742 * 4. int is_terminated;
2743 * 5. int is_stillborn;
2746 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2748 // Static offsets of the object's instance fields.
2749 // TODO These offsets need to be checked on VM startup.
2750 static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2751 static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2752 static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2753 static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2754 static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2755 static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2758 java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
2759 // java_lang_Thread(threadobject* t);
2762 inline int32_t get_priority () const;
2763 inline threadobject* get_vm_thread() const;
2764 inline java_handle_chararray_t* get_name () const;
2767 inline void set_vm_thread(threadobject* value);
2771 // inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
2773 // java_lang_Thread(thread_get_object(t));
2777 inline int32_t java_lang_Thread::get_priority() const
2779 return get<int32_t>(_handle, offset_priority);
2782 inline threadobject* java_lang_Thread::get_vm_thread() const
2784 return get<threadobject*>(_handle, offset_vm_thread);
2787 inline java_handle_chararray_t* java_lang_Thread::get_name() const
2789 return get<java_handle_chararray_t*>(_handle, offset_name);
2793 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2795 set(_handle, offset_vm_thread, value);
2800 * CLDC 1.1 java/lang/Throwable
2805 * 1. java.lang.String detailMessage;
2806 * 2. java.lang.Object backtrace;
2808 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2810 // Static offsets of the object's instance fields.
2811 // TODO These offsets need to be checked on VM startup.
2812 static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2813 static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2816 java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
2819 inline java_handle_t* get_detailMessage() const;
2820 inline java_handle_bytearray_t* get_backtrace () const;
2823 inline void set_backtrace(java_handle_bytearray_t* value);
2827 inline java_handle_t* java_lang_Throwable::get_detailMessage() const
2829 return get<java_handle_t*>(_handle, offset_detailMessage);
2832 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2834 return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2838 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2840 set(_handle, offset_backtrace, value);
2843 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
2847 // Legacy C interface.
2848 java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m);
2849 java_handle_t* java_lang_reflect_Field_create(fieldinfo* f);
2850 java_handle_t* java_lang_reflect_Method_create(methodinfo* m);
2854 #endif // _JAVAOBJECTS_HPP
2858 * These are local overrides for various environment variables in Emacs.
2859 * Please do not remove this and leave it at the end of the file, where
2860 * Emacs will automagically detect them.
2861 * ---------------------------------------------------------------------
2864 * indent-tabs-mode: t