CACAO
javaobjects.hpp
Go to the documentation of this file.
1 /* src/vm/javaobjects.hpp - functions to create and access Java objects
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5  Copyright (C) 2008, 2009 Theobroma Systems Ltd.
6 
7  This file is part of CACAO.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2, or (at
12  your option) any later version.
13 
14  This program is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  02110-1301, USA.
23 
24 */
25 
26 
27 #ifndef JAVAOBJECTS_HPP_
28 #define JAVAOBJECTS_HPP_ 1
29 
30 #include "config.h"
31 
32 #include <stdint.h>
33 
34 #include "mm/memory.hpp"
35 
36 #include "native/jni.hpp" // for jclass, jsize
37 #include "native/llni.hpp"
38 
39 #include "threads/atomic.hpp"
40 
41 #include "vm/class.hpp"
42 #include "vm/field.hpp"
43 #include "vm/global.hpp"
44 #include "vm/globals.hpp"
45 #include "vm/method.hpp"
46 #include "vm/string.hpp"
47 
48 #include "vm/array.hpp"
49 
50 /**
51  * This class provides low-level functions to access Java object
52  * instance fields.
53  *
54  * These functions do NOT take care about the GC critical section!
55  * Please use FieldAccess wherever possible.
56  */
58 protected:
59  template<class T> static inline T raw_get(void* address, const off_t offset);
60  template<class T> static inline void raw_set(void* address, const off_t offset, T value);
61 };
62 
63 
64 template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
65 {
66  T* p = (T*) (((uintptr_t) address) + offset);
67  return *p;
68 }
69 
70 
71 template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
72 {
73  T* p = (T*) (((uintptr_t) address) + offset);
74  *p = value;
75 }
76 
77 
78 /**
79  * This classes provides functions to access Java object instance
80  * fields. These functions enter a critical GC section before
81  * accessing the Java object throught the handle and leave it
82  * afterwards.
83  */
84 class FieldAccess : private RawFieldAccess {
85 public:
86  // Normal field accessors.
87  template<class T> static inline T get(java_handle_t* h, const off_t offset);
88  template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
89 
90  // Volatile field accessors.
91  template<class T> static inline T get_volatile(java_handle_t* h, const off_t offset);
92  template<class T> static inline void set_volatile(java_handle_t* h, const off_t offset, T value);
93 };
94 
95 
96 template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
97 {
98  // This function is inside a critical section.
100 
101  // XXX This should be _handle->get_object();
102  java_object_t* ho = LLNI_UNWRAP(h);
103  return raw_get<T>(ho, offset);
104 }
105 
106 template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
107 {
108  // This function is inside a critical section.
110 
111  // XXX This should be _handle->get_object();
112  java_object_t* o = LLNI_UNWRAP(h);
113  java_object_t* result = raw_get<java_object_t*>(o, offset);
114  return LLNI_WRAP(result);
115 }
116 
117 
118 template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
119 {
120  // This function is inside a critical section.
122 
123  java_object_t* ho = LLNI_UNWRAP(h);
124  raw_set(ho, offset, value);
125 }
126 
127 template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
128 {
129  // This function is inside a critical section.
131 
132  // XXX This should be h->get_object();
133  java_object_t* o = LLNI_UNWRAP(h);
134  java_object_t* ovalue = LLNI_UNWRAP(value);
135  raw_set(o, offset, ovalue);
136 }
137 
138 
139 template<class T> inline T FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
140 {
141  // This function is inside a critical section.
143 
144  // XXX This should be _handle->get_object();
145  java_object_t* ho = LLNI_UNWRAP(h);
146  return raw_get<volatile T>(ho, offset);
147 }
148 
149 template<> inline java_handle_t* FieldAccess::get_volatile(java_handle_t* h, const off_t offset)
150 {
151  // This function is inside a critical section.
153 
154  // XXX This should be _handle->get_object();
155  java_object_t* o = LLNI_UNWRAP(h);
156  java_object_t* result = (java_object_t*) raw_get<volatile java_object_t*>(o, offset);
157  return LLNI_WRAP(result);
158 }
159 
160 
161 template<class T> inline void FieldAccess::set_volatile(java_handle_t* h, const off_t offset, T value)
162 {
163  // This function is inside a critical section.
165 
166  java_object_t* ho = LLNI_UNWRAP(h);
167  raw_set(ho, offset, (volatile T) value);
168 
169  // Memory barrier for the Java Memory Model.
171 }
172 
173 template<> inline void FieldAccess::set_volatile<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
174 {
175  // This function is inside a critical section.
177 
178  // XXX This should be h->get_object();
179  java_object_t* o = LLNI_UNWRAP(h);
180  java_object_t* ovalue = LLNI_UNWRAP(value);
181  raw_set(o, offset, (volatile java_object_t*) ovalue);
182 
183  // Memory barrier for the Java Memory Model.
185 }
186 
187 
188 /**
189  * java/lang/Object
190  *
191  * Object layout:
192  *
193  * 0. object header
194  */
196 protected:
197  // Handle of Java object.
199 
200 public:
203  virtual ~java_lang_Object() {}
204 
205  // Getters.
206  virtual java_handle_t* get_handle () const { return _handle; }
207  vftbl_t* get_vftbl () const;
208  classinfo* get_Class () const;
209  int32_t get_hashcode() const;
210 
211  bool is_null () const;
212  bool is_non_null() const;
213 };
214 
215 
217 {
218  // This function is inside a critical section.
220 
221  // XXX This should be h->get_object();
223  return o->vftbl;
224 }
225 
227 {
228  return get_vftbl()->clazz;
229 }
230 
231 inline int32_t java_lang_Object::get_hashcode() const
232 {
233 #if defined(ENABLE_GC_CACAO)
234  return heap_get_hashcode(_handle);
235 #else
236  // This function is inside a critical section.
238 
239  // XXX This should be h->get_object();
241  return (int32_t) (intptr_t) o;
242 #endif
243 }
244 
245 
246 inline bool java_lang_Object::is_null() const
247 {
248  return (_handle == NULL);
249 }
250 
251 inline bool java_lang_Object::is_non_null() const
252 {
253  return (_handle != NULL);
254 }
255 
256 
257 /**
258  * java/lang/Boolean
259  *
260  * Object layout:
261  *
262  * 0. object header
263  * 1. boolean value;
264  */
266 private:
267  // Static offsets of the object's instance fields.
268  // TODO These offsets need to be checked on VM startup.
269  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
270 
271 public:
273 
274  uint8_t get_value();
275  void set_value(uint8_t value);
276 };
277 
279 {
280  return get<int32_t>(_handle, offset_value);
281 }
282 
283 inline void java_lang_Boolean::set_value(uint8_t value)
284 {
285  set(_handle, offset_value, (uint32_t) value);
286 }
287 
288 
289 /**
290  * java/lang/Byte
291  *
292  * Object layout:
293  *
294  * 0. object header
295  * 1. byte value;
296  */
297 class java_lang_Byte : public java_lang_Object, private FieldAccess {
298 private:
299  // Static offsets of the object's instance fields.
300  // TODO These offsets need to be checked on VM startup.
301  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
302 
303 public:
305 
306  int8_t get_value();
307  void set_value(int8_t value);
308 };
309 
311 {
312  return get<int32_t>(_handle, offset_value);
313 }
314 
315 inline void java_lang_Byte::set_value(int8_t value)
316 {
317  set(_handle, offset_value, (int32_t) value);
318 }
319 
320 
321 /**
322  * java/lang/Character
323  *
324  * Object layout:
325  *
326  * 0. object header
327  * 1. char value;
328  */
330 private:
331  // Static offsets of the object's instance fields.
332  // TODO These offsets need to be checked on VM startup.
333  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
334 
335 public:
337 
338  uint16_t get_value();
339  void set_value(uint16_t value);
340 };
341 
343 {
344  return get<int32_t>(_handle, offset_value);
345 }
346 
347 inline void java_lang_Character::set_value(uint16_t value)
348 {
349  set(_handle, offset_value, (uint32_t) value);
350 }
351 
352 
353 /**
354  * java/lang/Short
355  *
356  * Object layout:
357  *
358  * 0. object header
359  * 1. short value;
360  */
362 private:
363  // Static offsets of the object's instance fields.
364  // TODO These offsets need to be checked on VM startup.
365  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
366 
367 public:
369 
370  int16_t get_value();
371  void set_value(int16_t value);
372 };
373 
375 {
376  return get<int32_t>(_handle, offset_value);
377 }
378 
379 inline void java_lang_Short::set_value(int16_t value)
380 {
381  set(_handle, offset_value, (int32_t) value);
382 }
383 
384 
385 /**
386  * java/lang/Integer
387  *
388  * Object layout:
389  *
390  * 0. object header
391  * 1. int value;
392  */
394 private:
395  // Static offsets of the object's instance fields.
396  // TODO These offsets need to be checked on VM startup.
397  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
398 
399 public:
401 
402  int32_t get_value();
403  void set_value(int32_t value);
404 };
405 
407 {
408  return get<int32_t>(_handle, offset_value);
409 }
410 
411 inline void java_lang_Integer::set_value(int32_t value)
412 {
413  set(_handle, offset_value, value);
414 }
415 
416 
417 /**
418  * java/lang/Long
419  *
420  * Object layout:
421  *
422  * 0. object header
423  * 1. long value;
424  */
425 class java_lang_Long : public java_lang_Object, private FieldAccess {
426 private:
427  // Static offsets of the object's instance fields.
428  // TODO These offsets need to be checked on VM startup.
429  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
430 
431 public:
433 
434  int64_t get_value();
435  void set_value(int64_t value);
436 };
437 
439 {
440  return get<int64_t>(_handle, offset_value);
441 }
442 
443 inline void java_lang_Long::set_value(int64_t value)
444 {
445  set(_handle, offset_value, value);
446 }
447 
448 
449 /**
450  * java/lang/Float
451  *
452  * Object layout:
453  *
454  * 0. object header
455  * 1. float value;
456  */
458 private:
459  // Static offsets of the object's instance fields.
460  // TODO These offsets need to be checked on VM startup.
461  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
462 
463 public:
465 
466  float get_value();
467  void set_value(float value);
468 };
469 
471 {
472  return get<float>(_handle, offset_value);
473 }
474 
475 inline void java_lang_Float::set_value(float value)
476 {
477  set(_handle, offset_value, value);
478 }
479 
480 
481 /**
482  * java/lang/Double
483  *
484  * Object layout:
485  *
486  * 0. object header
487  * 1. double value;
488  */
490 private:
491  // Static offsets of the object's instance fields.
492  // TODO These offsets need to be checked on VM startup.
493  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
494 
495 public:
497 
498  double get_value();
499  void set_value(double value);
500 };
501 
503 {
504  return get<double>(_handle, offset_value);
505 }
506 
507 inline void java_lang_Double::set_value(double value)
508 {
509  set(_handle, offset_value, value);
510 }
511 
512 
513 #if defined(ENABLE_JAVASE)
514 
515 /**
516  * java/lang/management/MemoryUsage
517  *
518  * Object layout:
519  *
520  * 0. object header
521  * [other fields are not used]
522  */
524 public:
526  java_lang_management_MemoryUsage(int64_t init, int64_t used, int64_t commited, int64_t maximum);
527 };
528 
529 
530 # if defined(ENABLE_ANNOTATIONS)
531 /**
532  * OpenJDK sun/reflect/ConstantPool
533  *
534  * Object layout:
535  *
536  * 0. object header
537  * 1. java.lang.Object constantPoolOop;
538  */
540 private:
541  // Static offsets of the object's instance fields.
542  // TODO These offsets need to be checked on VM startup.
543  static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
544 
545 public:
547  sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
548 
549  // Setters.
550  void set_constantPoolOop(classinfo* value);
551  void set_constantPoolOop(jclass value);
552 };
553 
554 
556 {
557  set_constantPoolOop(constantPoolOop);
558 }
559 
560 
562 {
564 }
565 
567 {
568  // XXX jclass is a boxed object.
570 }
571 # endif // ENABLE_ANNOTATIONS
572 
573 #endif // ENABLE_JAVASE
574 
577 
578 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
579 
580 /**
581  * GNU Classpath java/lang/Class
582  *
583  * Object layout:
584  *
585  * 0. object header
586  * 1. java.lang.Object[] signers;
587  * 2. java.security.ProtectionDomain pd;
588  * 3. java.lang.Object vmdata;
589  * 4. java.lang.reflect.Constructor constructor;
590  */
592 private:
593  // Static offsets of the object's instance fields.
594  // TODO These offsets need to be checked on VM startup.
595  static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
596  static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
597  static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
598  static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
599 
600 public:
602 
603  // Setters.
604  void set_pd(java_handle_t* value);
605 };
606 
608 {
609  set(_handle, offset_pd, value);
610 }
611 
612 
613 /**
614  * GNU Classpath java/lang/ClassLoader
615  *
616  * Object layout:
617  *
618  * 0. object header
619  * 1. java.util.HashMap definedPackages
620  * 2. java.lang.ClassLoader parent
621  * [other fields are not used]
622  */
624 private:
625  // Static offsets of the object's instance fields.
626  // TODO These offsets need to be checked on VM startup.
627  static const off_t offset_definedPackages = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
628  static const off_t offset_parent = MEMORY_ALIGN(offset_definedPackages + SIZEOF_VOID_P, SIZEOF_VOID_P);
629 
630 public:
632 
633  // Getters.
634  java_handle_t* get_parent() const;
635 
636  // Invocation wrappers for static methods.
638 };
639 
641 {
642  return get<java_handle_t*>(_handle, offset_parent);
643 }
644 
645 
646 /**
647  * GNU Classpath java/lang/StackTraceElement
648  *
649  * Object layout:
650  *
651  * 0. object header
652  * 1. java.lang.String fileName;
653  * 2. int lineNumber;
654  * 3. java.lang.String declaringClass;
655  * 4. java.lang.String methodName;
656  * 5. boolean isNative;
657  */
659 private:
660  // Static offsets of the object's instance fields.
661  // TODO These offsets need to be checked on VM startup.
662  static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
663  static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
664  static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
665  static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
666  static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
667 
668 public:
670  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);
671 };
672 
673 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative) : java_lang_Object(h)
674 {
676 
677  set(_handle, offset_fileName, fileName);
678  set(_handle, offset_lineNumber, lineNumber);
679  set(_handle, offset_declaringClass, declaringClass);
680  set(_handle, offset_methodName, methodName);
681  set(_handle, offset_isNative, isNative);
682 }
683 
684 
685 /**
686  * GNU Classpath java/lang/String
687  *
688  * Object layout:
689  *
690  * 0. object header
691  * 1. char[] value;
692  * 2. int count;
693  * 3. int cachedHashCode;
694  * 4. int offset;
695  */
697 private:
698  // Static offsets of the object's instance fields.
699  // TODO These offsets need to be checked on VM startup.
700  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
701  static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
702  static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
703  static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
704 
705 public:
707  java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
708 
709  // Getters.
711  int32_t get_count () const;
712  int32_t get_offset() const;
713 
714  // Setters.
715  void set_value (java_handle_chararray_t* value);
716  void set_count (int32_t value);
717  void set_offset(int32_t value);
718 
719  // Raw access
720  static inline void set_fields(java_handle_t *str, java_handle_chararray_t* value) {
721  set(str, offset_value, value);
722  set(str, offset_count, CharArray(value).get_length());
723  set(str, offset_offset, (int32_t) 0);
724  // cachedHashCode is assumed to be zero initialized
725  }
726 
728  return get<java_handle_chararray_t*>(str, offset_value);
729  }
730  static inline int32_t get_count(java_handle_t *str) {
731  return get<int32_t>(str, offset_count);
732  }
733  static inline int32_t get_offset(java_handle_t *str) {
734  return get<int32_t>(str, offset_offset);
735  }
736 };
737 
738 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)
739 {
740  set_value(value);
741  set_count(count);
742  set_offset(offset);
743 }
744 
746 {
747  return get<java_handle_chararray_t*>(_handle, offset_value);
748 }
749 
750 inline int32_t java_lang_String::get_count() const
751 {
752  return get<int32_t>(_handle, offset_count);
753 }
754 
755 inline int32_t java_lang_String::get_offset() const
756 {
757  return get<int32_t>(_handle, offset_offset);
758 }
759 
761 {
762  set(_handle, offset_value, value);
763 }
764 
765 inline void java_lang_String::set_count(int32_t value)
766 {
767  set(_handle, offset_count, value);
768 }
769 
770 inline void java_lang_String::set_offset(int32_t value)
771 {
772  set(_handle, offset_offset, value);
773 }
774 
775 namespace runtime_str_ops {
776 
777 inline jsize get_string_count(const java_lang_String &s)
778 {
779  return s.get_count();
780 }
781 
782 inline jsize get_string_offset(const java_lang_String &s)
783 {
784  return s.get_offset();
785 }
786 
787 }
788 
789 /**
790  * GNU Classpath java/lang/Thread
791  */
793 private:
794  // Static offsets of the object's instance fields.
795  static off_t offset_vmThread;
796  static off_t offset_group;
797  static off_t offset_name;
798  static off_t offset_daemon;
799  static off_t offset_priority;
801 
802 public:
804 
805  // Getters.
806  java_handle_t* get_vmThread () const;
807  java_handle_t* get_group () const;
808  java_handle_t* get_name () const;
809  int32_t get_daemon () const;
810  int32_t get_priority () const;
812 
813  // Setters.
814  void set_group(java_handle_t* value);
815 
816  // Offset initializers
817  static void set_vmThread_offset(int32_t off) { offset_vmThread = off; }
818  static void set_group_offset(int32_t off) { offset_group = off; }
819  static void set_name_offset(int32_t off) { offset_name = off; }
820  static void set_daemon_offset(int32_t off) { offset_daemon = off; }
821  static void set_priority_offset(int32_t off) { offset_priority = off; }
822  static void set_exceptionHandler_offset(int32_t off) { offset_exceptionHandler = off; }
823 };
824 
825 
827 {
828  return get<java_handle_t*>(_handle, offset_vmThread);
829 }
830 
832 {
833  return get<java_handle_t*>(_handle, offset_group);
834 }
835 
837 {
838  return get<java_handle_t*>(_handle, offset_name);
839 }
840 
841 inline int32_t java_lang_Thread::get_daemon() const
842 {
843  return get<int32_t>(_handle, offset_daemon);
844 }
845 
846 inline int32_t java_lang_Thread::get_priority() const
847 {
848  return get<int32_t>(_handle, offset_priority);
849 }
850 
852 {
853  return get<java_handle_t*>(_handle, offset_exceptionHandler);
854 }
855 
856 
858 {
859  set(_handle, offset_group, value);
860 }
861 
862 
863 /**
864  * GNU Classpath java/lang/VMThread
865  *
866  * Object layout:
867  *
868  * 0. object header
869  * 1. java.lang.Thread thread;
870  * 2. boolean running;
871  * 3. java.lang.VMThread vmdata;
872  */
874 private:
875  // Static offsets of the object's instance fields.
876  // TODO These offsets need to be checked on VM startup.
877  static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
878  static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
879  static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
880 
881 public:
884 
885  // Getters.
886  java_handle_t* get_thread() const;
887  threadobject* get_vmdata() const;
888 
889  // Setters.
890  void set_thread(java_handle_t* value);
891  void set_vmdata(threadobject* value);
892 };
893 
894 
896 {
897  set_thread(thread);
898  set_vmdata(vmdata);
899 }
900 
901 
903 {
904  return get<java_handle_t*>(_handle, offset_thread);
905 }
906 
908 {
909  return get<threadobject*>(_handle, offset_vmdata);
910 }
911 
912 
914 {
915  set(_handle, offset_thread, value);
916 }
917 
919 {
920  set(_handle, offset_vmdata, value);
921 }
922 
923 
924 /**
925  * GNU Classpath java/lang/Throwable
926  *
927  * Object layout:
928  *
929  * 0. object header
930  * 1. java.lang.String detailMessage;
931  * 2. java.lang.Throwable cause;
932  * 3. java.lang.StackTraceElement[] stackTrace;
933  * 4. java.lang.VMThrowable vmState;
934  */
936 private:
937  // Static offsets of the object's instance fields.
938  // TODO These offsets need to be checked on VM startup.
939  static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
940  static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
941  static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
942  static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
943 
944 public:
946 
947  // Getters.
949  java_handle_t* get_cause () const;
950  java_handle_t* get_vmState () const;
951 };
952 
953 
955 {
956  return get<java_handle_t*>(_handle, offset_detailMessage);
957 }
958 
960 {
961  return get<java_handle_t*>(_handle, offset_cause);
962 }
963 
965 {
966  return get<java_handle_t*>(_handle, offset_vmState);
967 }
968 
969 
970 /**
971  * GNU Classpath java/lang/VMThrowable
972  *
973  * Object layout:
974  *
975  * 0. object header
976  * 1. java.lang.Object vmdata;
977  */
979 private:
980  // Static offsets of the object's instance fields.
981  // TODO These offsets need to be checked on VM startup.
982  static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
983 
984 public:
986 
988  void set_vmdata(java_handle_bytearray_t* value);
989 };
990 
991 
993 {
994  return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
995 }
996 
998 {
999  set(_handle, offset_vmdata, value);
1000 }
1001 
1002 
1003 /**
1004  * GNU Classpath java/lang/reflect/VMConstructor
1005  *
1006  * Object layout:
1007  *
1008  * 0. object header
1009  * 1. java.lang.Class clazz;
1010  * 2. int slot;
1011  * 3. byte[] annotations;
1012  * 4. byte[] parameterAnnotations;
1013  * 5. java.util.Map declaredAnnotations;
1014  * 6. java.lang.reflect.Constructor cons;
1015  */
1017 private:
1018  // Static offsets of the object's instance fields.
1019  // TODO These offsets need to be checked on VM startup.
1020  static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1021  static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
1022  static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1023  static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1024  static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1025  static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1026 
1027 public:
1030 
1031  // Getters.
1032  classinfo* get_clazz () const;
1033  int32_t get_slot () const;
1037  java_handle_t* get_cons () const;
1038 
1039  // Setters.
1040  void set_clazz (classinfo* value);
1041  void set_slot (int32_t value);
1044  void set_declaredAnnotations (java_handle_t* value);
1045  void set_cons (java_handle_t* value);
1046 
1047  // Convenience functions.
1049 };
1050 
1051 
1053 {
1055 
1056  if (is_null())
1057  return;
1058 
1059  int slot = m - m->clazz->methods;
1061  java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1062 
1063  set_clazz(m->clazz);
1064  set_slot(slot);
1065  set_annotations(annotations);
1066  set_parameterAnnotations(parameterAnnotations);
1067 }
1068 
1069 
1071 {
1072  return get<classinfo*>(_handle, offset_clazz);
1073 }
1074 
1076 {
1077  return get<int32_t>(_handle, offset_slot);
1078 }
1079 
1081 {
1082  return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1083 }
1084 
1086 {
1087  return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1088 }
1089 
1091 {
1092  return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1093 }
1094 
1096 {
1097  return get<java_handle_t*>(_handle, offset_cons);
1098 }
1099 
1101 {
1102  set(_handle, offset_clazz, value);
1103 }
1104 
1106 {
1107  set(_handle, offset_slot, value);
1108 }
1109 
1111 {
1112  set(_handle, offset_annotations, value);
1113 }
1114 
1116 {
1118 }
1119 
1121 {
1123 }
1124 
1126 {
1127  set(_handle, offset_cons, value);
1128 }
1129 
1131 {
1132  classinfo* c = get_clazz();
1133  int32_t slot = get_slot();
1134  methodinfo* m = &(c->methods[slot]);
1135  return m;
1136 }
1137 
1138 
1139 /**
1140  * GNU Classpath java/lang/reflect/Constructor
1141  *
1142  * Object layout:
1143  *
1144  * 0. object header
1145  * 1. boolean flag;
1146  * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1147  * 3. java.lang.reflect.VMConstructor cons;
1148  */
1150 private:
1151  // Static offsets of the object's instance fields.
1152  // TODO These offsets need to be checked on VM startup.
1153  static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1154  static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1155  static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1156 
1157 public:
1160 
1162 
1163  // Getters.
1164  int32_t get_flag() const;
1165  java_handle_t* get_cons() const;
1166 
1167  // Setters.
1168  void set_cons(java_handle_t* value);
1169 
1170  // Convenience functions.
1171  methodinfo* get_method () const;
1172  int32_t get_override() const;
1173 };
1174 
1175 
1177 {
1179 
1180  if (jlrvmc.is_null())
1181  return;
1182 
1184 
1185  if (is_null())
1186  return;
1187 
1188  // Link the two Java objects.
1189  set_cons(jlrvmc.get_handle());
1190  jlrvmc.set_cons(get_handle());
1191 }
1192 
1193 
1195 {
1196  return get<int32_t>(_handle, offset_flag);
1197 }
1198 
1200 {
1201  return get<java_handle_t*>(_handle, offset_cons);
1202 }
1203 
1204 
1206 {
1207  set(_handle, offset_cons, value);
1208 }
1209 
1210 
1212 {
1214  return jlrvmc.get_method();
1215 }
1216 
1218 {
1219  return get_flag();
1220 }
1221 
1222 
1223 /**
1224  * GNU Classpath java/lang/reflect/VMField
1225  *
1226  * Object layout:
1227  *
1228  * 0. object header
1229  * 1. java.lang.Class clazz;
1230  * 2. java.lang.String name;
1231  * 3. int slot;
1232  * 4. byte[] annotations;
1233  * 5. java.lang.Map declaredAnnotations;
1234  * 6. java.lang.reflect.Field f;
1235  */
1237 private:
1238  // Static offsets of the object's instance fields.
1239  // TODO These offsets need to be checked on VM startup.
1240  static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1241  static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1242  static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1243  static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1244  static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1245  static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1246 
1247 public:
1250 
1251  // Getters.
1252  classinfo* get_clazz () const;
1253  int32_t get_slot () const;
1256  java_handle_t* get_f () const;
1257 
1258  // Setters.
1259  void set_clazz (classinfo* value);
1260  void set_name (java_handle_t* value);
1261  void set_slot (int32_t value);
1264  void set_f (java_handle_t* value);
1265 
1266  // Convenience functions.
1267  fieldinfo* get_field() const;
1268 };
1269 
1270 
1272 {
1274 
1275  if (is_null())
1276  return;
1277 
1279  int slot = f - f->clazz->fields;
1281 
1282  set_clazz(f->clazz);
1283  set_name(name);
1284  set_slot(slot);
1285  set_annotations(annotations);
1286 }
1287 
1288 
1290 {
1291  return get<classinfo*>(_handle, offset_clazz);
1292 }
1293 
1295 {
1296  return get<int32_t>(_handle, offset_slot);
1297 }
1298 
1300 {
1301  return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1302 }
1303 
1305 {
1306  return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1307 }
1308 
1310 {
1311  return get<java_handle_t*>(_handle, offset_f);
1312 }
1313 
1314 
1316 {
1317  set(_handle, offset_clazz, value);
1318 }
1319 
1321 {
1322  set(_handle, offset_name, value);
1323 }
1324 
1325 inline void java_lang_reflect_VMField::set_slot(int32_t value)
1326 {
1327  set(_handle, offset_slot, value);
1328 }
1329 
1331 {
1332  set(_handle, offset_annotations, value);
1333 }
1334 
1336 {
1338 }
1339 
1341 {
1342  set(_handle, offset_f, value);
1343 }
1344 
1346 {
1347  classinfo* c = get_clazz();
1348  int32_t slot = get_slot();
1349  fieldinfo* f = &(c->fields[slot]);
1350  return f;
1351 }
1352 
1353 
1354 /**
1355  * GNU Classpath java/lang/reflect/Field
1356  *
1357  * Object layout:
1358  *
1359  * 0. object header
1360  * 1. boolean flag;
1361  * 2. gnu.java.lang.reflect.FieldSignatureParser p;
1362  * 3. java.lang.reflect.VMField f;
1363  */
1365 private:
1366  // Static offsets of the object's instance fields.
1367  // TODO These offsets need to be checked on VM startup.
1368  static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1369  static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1370  static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1371 
1372 public:
1375 
1376  // Getters.
1377  int32_t get_flag() const;
1378  java_handle_t* get_f() const;
1379 
1380  // Setters.
1381  void set_f(java_handle_t* value);
1382 
1383  // Convenience functions.
1384  fieldinfo* get_field() const;
1385 };
1386 
1387 
1389 {
1390  java_lang_reflect_VMField jlrvmf(f);
1391 
1392  if (jlrvmf.is_null())
1393  return;
1394 
1396 
1397  if (is_null())
1398  return;
1399 
1400  // Link the two Java objects.
1401  set_f(jlrvmf.get_handle());
1402  jlrvmf.set_f(get_handle());
1403 }
1404 
1405 
1407 {
1408  return get<int32_t>(_handle, offset_flag);
1409 }
1410 
1412 {
1413  return get<java_handle_t*>(_handle, offset_f);
1414 }
1415 
1416 
1418 {
1419  set(_handle, offset_f, value);
1420 }
1421 
1422 
1424 {
1425  java_lang_reflect_VMField jlrvmf(get_f());
1426  return jlrvmf.get_field();
1427 }
1428 
1429 
1430 /**
1431  * GNU Classpath java/lang/reflect/VMMethod
1432  *
1433  * Object layout:
1434  *
1435  * 0. object header
1436  * 1. java.lang.Class clazz;
1437  * 2. java.lang.String name;
1438  * 3. int slot;
1439  * 4. byte[] annotations;
1440  * 5. byte[] parameterAnnotations;
1441  * 6. byte[] annotationDefault;
1442  * 7. java.lang.Map declaredAnnotations;
1443  * 8. java.lang.reflect.Method m;
1444  */
1446 private:
1447  // Static offsets of the object's instance fields.
1448  // TODO These offsets need to be checked on VM startup.
1449  static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1450  static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
1451  static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
1452  static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
1453  static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1454  static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1455  static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
1456  static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
1457 
1458 public:
1461 
1462  // Getters.
1463  classinfo* get_clazz () const;
1464  int32_t get_slot () const;
1469  java_handle_t* get_m () const;
1470 
1471  // Setters.
1472  void set_clazz (classinfo* value);
1473  void set_name (java_handle_t* value);
1474  void set_slot (int32_t value);
1478  void set_declaredAnnotations (java_handle_t* value);
1479  void set_m (java_handle_t* value);
1480 
1481  // Convenience functions.
1482  methodinfo* get_method() const;
1483 };
1484 
1485 
1487 {
1489 
1490  if (is_null())
1491  return;
1492 
1494  int slot = m - m->clazz->methods;
1496  java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
1497  java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
1498 
1499  set_clazz(m->clazz);
1500  set_name(name);
1501  set_slot(slot);
1502  set_annotations(annotations);
1503  set_parameterAnnotations(parameterAnnotations);
1504  set_annotationDefault(annotationDefault);
1505 }
1506 
1508 {
1509  return get<classinfo*>(_handle, offset_clazz);
1510 }
1511 
1513 {
1514  return get<int32_t>(_handle, offset_slot);
1515 }
1516 
1518 {
1519  return get<java_handle_bytearray_t*>(_handle, offset_annotations);
1520 }
1521 
1523 {
1524  return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
1525 }
1526 
1528 {
1529  return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
1530 }
1531 
1533 {
1534  return get<java_handle_t*>(_handle, offset_declaredAnnotations);
1535 }
1536 
1538 {
1539  return get<java_handle_t*>(_handle, offset_m);
1540 }
1541 
1543 {
1544  set(_handle, offset_clazz, value);
1545 }
1546 
1548 {
1549  set(_handle, offset_name, value);
1550 }
1551 
1552 inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
1553 {
1554  set(_handle, offset_slot, value);
1555 }
1556 
1558 {
1559  set(_handle, offset_annotations, value);
1560 }
1561 
1563 {
1565 }
1566 
1568 {
1570 }
1571 
1573 {
1575 }
1576 
1578 {
1579  set(_handle, offset_m, value);
1580 }
1581 
1583 {
1584  classinfo* c = get_clazz();
1585  int32_t slot = get_slot();
1586  methodinfo* m = &(c->methods[slot]);
1587  return m;
1588 }
1589 
1590 
1591 /**
1592  * GNU Classpath java/lang/reflect/Method
1593  *
1594  * Object layout:
1595  *
1596  * 0. object header
1597  * 1. boolean flag;
1598  * 2. gnu.java.lang.reflect.MethodSignatureParser p;
1599  * 3. java.lang.reflect.VMMethod m;
1600  */
1602 private:
1603  // Static offsets of the object's instance fields.
1604  // TODO These offsets need to be checked on VM startup.
1605  static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1606  static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
1607  static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
1608 
1609 public:
1612 
1614 
1615  // Getters.
1616  int32_t get_flag() const;
1617  java_handle_t* get_m() const;
1618 
1619  // Setters.
1620  void set_m(java_handle_t* value);
1621 
1622  // Convenience functions.
1623  methodinfo* get_method () const;
1624  int32_t get_override() const;
1625 };
1626 
1627 
1629 {
1630  java_lang_reflect_VMMethod jlrvmm(m);
1631 
1632  if (jlrvmm.is_null())
1633  return;
1634 
1636 
1637  if (is_null())
1638  return;
1639 
1640  // Link the two Java objects.
1641  set_m(jlrvmm.get_handle());
1642  jlrvmm.set_m(get_handle());
1643 }
1644 
1645 
1647 {
1648  return get<int32_t>(_handle, offset_flag);
1649 }
1650 
1652 {
1653  return get<java_handle_t*>(_handle, offset_m);
1654 }
1655 
1656 
1658 {
1659  set(_handle, offset_m, value);
1660 }
1661 
1662 
1664 {
1666  return jlrvmm.get_method();
1667 }
1668 
1670 {
1671  return get_flag();
1672 }
1673 
1674 
1675 /**
1676  * GNU Classpath java/nio/Buffer
1677  *
1678  * Object layout:
1679  *
1680  * 0. object header
1681  * 1. int cap;
1682  * 2. int limit;
1683  * 3. int pos;
1684  * 4. int mark;
1685  * 5. gnu.classpath.Pointer address;
1686  */
1688 private:
1689  // Static offsets of the object's instance fields.
1690  // TODO These offsets need to be checked on VM startup.
1691  static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1692  static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1693  static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1694  static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1695  static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1696 
1697 public:
1699 
1700  // Getters.
1701  int32_t get_cap() const;
1702 };
1703 
1704 inline int32_t java_nio_Buffer::get_cap() const
1705 {
1706  return get<int32_t>(_handle, offset_cap);
1707 }
1708 
1709 
1710 /**
1711  * GNU Classpath java/nio/DirectByteBufferImpl
1712  *
1713  * Object layout:
1714  *
1715  * 0. object header
1716  * 1. int cap;
1717  * 2. int limit;
1718  * 3. int pos;
1719  * 4. int mark;
1720  * 5. gnu.classpath.Pointer address;
1721  * 6. java.nio.ByteOrder endian;
1722  * 7. byte[] backing_buffer;
1723  * 8. int array_offset;
1724  * 9. java.lang.Object owner;
1725  */
1727 private:
1728  // Static offsets of the object's instance fields.
1729  // TODO These offsets need to be checked on VM startup.
1730  static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1731  static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
1732  static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
1733  static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
1734  static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
1735  static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
1736  static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
1737  static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
1738  static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
1739 
1740 public:
1742 
1743  // Getters.
1744  java_handle_t* get_address() const;
1745 };
1746 
1747 
1749 {
1750  return get<java_handle_t*>(_handle, offset_address);
1751 }
1752 
1753 
1754 /**
1755  * GNU Classpath gnu/classpath/Pointer
1756  *
1757  * Actually there are two classes, gnu.classpath.Pointer32 and
1758  * gnu.classpath.Pointer64, but we only define the abstract super
1759  * class and use the int/long field as void* type.
1760  *
1761  * Object layout:
1762  *
1763  * 0. object header
1764  * 1. int/long data;
1765  */
1767 private:
1768  // Static offsets of the object's instance fields.
1769  // TODO These offsets need to be checked on VM startup.
1770  static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1771 
1772 public:
1774  gnu_classpath_Pointer(java_handle_t* h, void* data);
1775 
1776  // Getters.
1777  void* get_data() const;
1778 
1779  // Setters.
1780  void set_data(void* value);
1781 };
1782 
1784 {
1785  set_data(data);
1786 }
1787 
1789 {
1790  return get<void*>(_handle, offset_data);
1791 }
1792 
1793 inline void gnu_classpath_Pointer::set_data(void* value)
1794 {
1795  set(_handle, offset_data, value);
1796 }
1797 
1798 #endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
1799 
1800 
1801 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1802 
1803 /**
1804  * OpenJDK java/lang/AssertionStatusDirectives
1805  *
1806  * Object layout:
1807  *
1808  * 0. object header
1809  * 1. java.lang.String[] classes;
1810  * 2. boolean[] classEnabled;
1811  * 3. java.lang.String[] packages;
1812  * 4. boolean[] packageEnabled;
1813  * 5. boolean deflt;
1814  */
1815 class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
1816 private:
1817  // Static offsets of the object's instance fields.
1818  // TODO These offsets need to be checked on VM startup.
1819  static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1820  static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
1821  static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
1822  static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
1823  static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
1824 
1825 public:
1826  java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
1827 };
1828 
1829 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)
1830 {
1831  classinfo* c = load_class_bootstrap(Utf8String::from_utf8("java/lang/AssertionStatusDirectives"));
1832 
1833  // FIXME Load the class at VM startup.
1834  if (c == NULL)
1835  return;
1836 
1837  _handle = builtin_new(c);
1838 
1839  if (is_null())
1840  return;
1841 
1842  set(_handle, offset_classes, classes);
1843  set(_handle, offset_classEnabled, classEnabled);
1844  set(_handle, offset_packages, packages);
1845  set(_handle, offset_packageEnabled, packageEnabled);
1846 }
1847 
1848 
1849 /**
1850  * OpenJDK java/lang/Class
1851  *
1852  * Object layout:
1853  *
1854  * 0. object header
1855  * ? java.lang.ClassLoader classLoader
1856  */
1857 class java_lang_Class : public java_lang_Object, private FieldAccess {
1858 private:
1859  // Static offsets of the object's instance fields.
1860  static off_t offset_classLoader;
1861 
1862 public:
1864 
1865  // Setters.
1866  void set_classLoader(java_handle_t* value);
1867 
1868  // Offset initializers
1869  static void set_classLoader_offset(int32_t off) { offset_classLoader = off; }
1870 };
1871 
1872 inline void java_lang_Class::set_classLoader(java_handle_t* value)
1873 {
1874  if (offset_classLoader)
1875  set(_handle, offset_classLoader, value);
1876 }
1877 
1878 /**
1879  * OpenJDK java/lang/ClassLoader
1880  *
1881  * Object layout:
1882  *
1883  * 0. object header
1884  * 1. boolean initialized
1885  * 2. java.lang.ClassLoader parent
1886  * [other fields are not used]
1887  */
1888 class java_lang_ClassLoader : public java_lang_Object, private FieldAccess {
1889 private:
1890  // Static offsets of the object's instance fields.
1891  // TODO These offsets need to be checked on VM startup.
1892  static const off_t offset_initialized = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
1893  static const off_t offset_parent = MEMORY_ALIGN(offset_initialized + sizeof(int32_t), SIZEOF_VOID_P);
1894 
1895 public:
1897 
1898  // Getters.
1899  java_handle_t* get_parent() const;
1900 
1901  // Invocation wrappers for static methods.
1903 };
1904 
1906 {
1907  return get<java_handle_t*>(_handle, offset_parent);
1908 }
1909 
1910 
1911 /**
1912  * OpenJDK java/lang/StackTraceElement
1913  *
1914  * Object layout:
1915  *
1916  * 0. object header
1917  * 1. java.lang.String declaringClass;
1918  * 2. java.lang.String methodName;
1919  * 3. java.lang.String fileName;
1920  * 4. int lineNumber;
1921  */
1923 private:
1924  // Static offsets of the object's instance fields.
1925  // TODO These offsets need to be checked on VM startup.
1926  static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1927  static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
1928  static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
1929  static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
1930 
1931 public:
1933  java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
1934 };
1935 
1936 inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
1937 {
1939 
1940  if (is_null())
1941  return;
1942 
1943  set(_handle, offset_declaringClass, declaringClass);
1944  set(_handle, offset_methodName, methodName);
1945  set(_handle, offset_fileName, fileName);
1946  set(_handle, offset_lineNumber, lineNumber);
1947 }
1948 
1949 
1950 /**
1951  * OpenJDK java/lang/String
1952  *
1953  * Object layout (JDK6):
1954  *
1955  * 0. object header
1956  * 1. char[] value;
1957  * 2. int offset;
1958  * 3. int count;
1959  * 4. int hash;
1960  *
1961  * Object layout (JDK7):
1962  *
1963  * 0. object header
1964  * 1. char[] value;
1965  * 2. int hash;
1966  */
1967 class java_lang_String : public java_lang_Object, private FieldAccess {
1968 private:
1969  // Static offsets of the object's instance fields.
1970  // TODO These offsets need to be checked on VM startup.
1971  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
1972 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
1973  static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1974  static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
1975 #else
1976  static const off_t offset_hash = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
1977 #endif
1978 
1979 public:
1981  java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
1982 
1983  // Getters.
1985 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
1986  int32_t get_offset() const;
1987  int32_t get_count () const;
1988 #endif
1989 
1990  // Setters.
1991  void set_value (java_handle_chararray_t* value);
1992 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
1993  void set_offset(int32_t value);
1994  void set_count (int32_t value);
1995 #endif
1996 
1997  // Raw access
1998  static inline void set_fields(java_handle_t *str, java_handle_chararray_t *value) {
1999  set(str, offset_value, value);
2000 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2001  set(str, offset_offset, (int32_t) 0);
2002  set(str, offset_count, CharArray(value).get_length());
2003 #endif
2004  // hash is assumed to be zero initialized
2005  }
2006 
2007  static inline java_handle_chararray_t *get_value(java_handle_t *str) {
2008  return get<java_handle_chararray_t*>(str, offset_value);
2009  }
2010 };
2011 
2012 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)
2013 {
2014  set_value(value);
2015 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2016  set_offset(offset);
2017  set_count(count);
2018 #endif
2019 }
2020 
2022 {
2023  return get<java_handle_chararray_t*>(_handle, offset_value);
2024 }
2025 
2026 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2027 inline int32_t java_lang_String::get_offset() const
2028 {
2029  return get<int32_t>(_handle, offset_offset);
2030 }
2031 
2032 inline int32_t java_lang_String::get_count() const
2033 {
2034  return get<int32_t>(_handle, offset_count);
2035 }
2036 #endif
2037 
2039 {
2040  set(_handle, offset_value, value);
2041 }
2042 
2043 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2044 inline void java_lang_String::set_offset(int32_t value)
2045 {
2046  set(_handle, offset_offset, value);
2047 }
2048 
2049 inline void java_lang_String::set_count(int32_t value)
2050 {
2051  set(_handle, offset_count, value);
2052 }
2053 #endif
2054 
2055 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2056 namespace jdk6_str_ops {
2057 
2058 inline jsize get_string_count(const java_lang_String &s)
2059 {
2060  return s.get_count();
2061 }
2062 
2063 inline jsize get_string_offset(const java_lang_String &s)
2064 {
2065  return s.get_offset();
2066 }
2067 
2068 }
2069 #endif
2070 
2071 namespace jdk7_str_ops {
2072 
2073 inline jsize get_string_count(const java_lang_String &s)
2074 {
2075  java_handle_chararray_t *value = s.get_value();
2076  return value ? CharArray(value).get_length() : 0;
2077 }
2078 
2079 inline jsize get_string_offset(const java_lang_String &s)
2080 {
2081  return 0;
2082 }
2083 
2084 }
2085 
2086 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2087 namespace runtime_str_ops = jdk6_str_ops;
2088 #else
2089 namespace runtime_str_ops = jdk7_str_ops;
2090 #endif
2091 
2092 
2093 /**
2094  * OpenJDK java/lang/Thread
2095  */
2096 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2097 private:
2098  static off_t offset_priority;
2099  static off_t offset_daemon;
2100  static off_t offset_group;
2101  static off_t offset_uncaughtExceptionHandler;
2102  static off_t offset_threadStatus;
2103 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2104  static off_t offset_me;
2105 #endif
2106 
2107 public:
2109 
2110  // Getters.
2111  int32_t get_priority () const;
2112  int32_t get_daemon () const;
2113  java_handle_t* get_group () const;
2114  java_handle_t* get_uncaughtExceptionHandler() const;
2115 
2116  // Setters.
2117  void set_priority (int32_t value);
2118  void set_group (java_handle_t* value);
2119  void set_threadStatus(int32_t value);
2120 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2121  void set_me (java_handle_t* value);
2122 #endif
2123 
2124  // Offset initializers
2125  static void set_priority_offset(int32_t off) { offset_priority = off; }
2126  static void set_daemon_offset(int32_t off) { offset_daemon = off; }
2127  static void set_group_offset(int32_t off) { offset_group = off; }
2128  static void set_uncaughtExceptionHandler_offset(int32_t off) { offset_uncaughtExceptionHandler = off; }
2129  static void set_threadStatus_offset(int32_t off) { offset_threadStatus = off; }
2130 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2131  static void set_me_offset(int32_t off) { offset_me = off; }
2132 #endif
2133 };
2134 
2135 
2136 inline int32_t java_lang_Thread::get_priority() const
2137 {
2138  return get<int32_t>(_handle, offset_priority);
2139 }
2140 
2141 inline int32_t java_lang_Thread::get_daemon() const
2142 {
2143  return get<int32_t>(_handle, offset_daemon);
2144 }
2145 
2147 {
2148  return get<java_handle_t*>(_handle, offset_group);
2149 }
2150 
2151 inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
2152 {
2153  return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
2154 }
2155 
2156 
2157 inline void java_lang_Thread::set_priority(int32_t value)
2158 {
2159  set(_handle, offset_priority, value);
2160 }
2161 
2162 inline void java_lang_Thread::set_group(java_handle_t* value)
2163 {
2164  set(_handle, offset_group, value);
2165 }
2166 
2167 inline void java_lang_Thread::set_threadStatus(int32_t value)
2168 {
2169  set(_handle, offset_threadStatus, value);
2170 }
2171 
2172 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2173 inline void java_lang_Thread::set_me(java_handle_t* value)
2174 {
2175  set(_handle, offset_me, value);
2176 }
2177 #endif
2178 
2179 
2180 /**
2181  * OpenJDK java/lang/Throwable
2182  *
2183  * Object layout:
2184  *
2185  * 0. object header
2186  * 1. java.lang.Object backtrace;
2187  * 2. java.lang.String detailMessage;
2188  * 3. java.lang.Throwable cause;
2189  * 4. java.lang.StackTraceElement[] stackTrace;
2190  */
2191 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2192 private:
2193  // Static offsets of the object's instance fields.
2194  // TODO These offsets need to be checked on VM startup.
2195  static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2196  static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
2197  static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
2198  static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
2199 
2200 public:
2203 
2204  // Getters.
2205  java_handle_bytearray_t* get_backtrace () const;
2207  java_handle_t* get_cause () const;
2208 
2209  // Setters.
2210  void set_backtrace(java_handle_bytearray_t* value);
2211 };
2212 
2213 
2215 {
2216  set_backtrace(backtrace);
2217 }
2218 
2219 
2220 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
2221 {
2222  return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
2223 }
2224 
2226 {
2227  return get<java_handle_t*>(_handle, offset_detailMessage);
2228 }
2229 
2231 {
2232  return get<java_handle_t*>(_handle, offset_cause);
2233 }
2234 
2235 
2236 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
2237 {
2238  set(_handle, offset_backtrace, value);
2239 }
2240 
2241 
2242 /**
2243  * OpenJDK java/lang/reflect/Constructor
2244  *
2245  * Object layout:
2246  *
2247  * 0. object header
2248  * 1. boolean override;
2249  * 2. java.lang.Class clazz;
2250  * 3. int slot;
2251  * 4. java.lang.Class[] parameterTypes;
2252  * 5. java.lang.Class[] exceptionTypes;
2253  * 6. int modifiers;
2254  * 7. java.lang.String signature;
2255  * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
2256  * 9. byte[] annotations;
2257  * 10. byte[] parameterAnnotations;
2258  * 11. java.lang.Class securityCheckCache;
2259  * 12. sun.reflect.ConstructorAccessor constructorAccessor;
2260  * 13. java.lang.reflect.Constructor root;
2261  * 14. java.util.Map declaredAnnotations;
2262  */
2264 private:
2265  // Static offsets of the object's instance fields.
2266  // TODO These offsets need to be checked on VM startup.
2267  static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2268 #ifdef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2269  static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2270  /* Members of the actual class java.lang.reflect.Constructor */
2271  static const off_t offset_clazz = MEMORY_ALIGN(offset_securityCheckCache + sizeof(int32_t), SIZEOF_VOID_P);
2272 #else
2273  static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2274 #endif
2275  static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2276  static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2277  static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2278  static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2279  static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2280  static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2281  static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2282  static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2283 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2284  static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2285 #endif
2286  static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2287  static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2288  static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2289 
2290 public:
2293 
2295 
2296  // Getters.
2297  int32_t get_override () const;
2298  classinfo* get_clazz () const;
2299  int32_t get_slot () const;
2300  java_handle_bytearray_t* get_annotations() const;
2301 
2302  // Setters.
2303  void set_clazz (classinfo* value);
2304  void set_slot (int32_t value);
2305  void set_parameterTypes (java_handle_objectarray_t* value);
2306  void set_exceptionTypes (java_handle_objectarray_t* value);
2307  void set_modifiers (int32_t value);
2308  void set_signature (java_handle_t* value);
2309  void set_annotations (java_handle_bytearray_t* value);
2310  void set_parameterAnnotations(java_handle_bytearray_t* value);
2311 
2312  // Convenience functions.
2314 };
2315 
2316 
2318 {
2320 
2321  if (is_null())
2322  return;
2323 
2324  int slot = m - m->clazz->methods;
2328  java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
2329 
2330  set_clazz(m->clazz);
2331  set_slot(slot);
2332  set_parameterTypes(parameterTypes);
2333  set_exceptionTypes(exceptionTypes);
2334  set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
2335  set_signature(m->signature ? JavaString::from_utf8(m->signature) : NULL);
2336  set_annotations(annotations);
2337  set_parameterAnnotations(parameterAnnotations);
2338 }
2339 
2340 
2341 inline int32_t java_lang_reflect_Constructor::get_override() const
2342 {
2343  return get<int32_t>(_handle, offset_override);
2344 }
2345 
2346 inline classinfo* java_lang_reflect_Constructor::get_clazz() const
2347 {
2348  return get<classinfo*>(_handle, offset_clazz);
2349 }
2350 
2351 inline int32_t java_lang_reflect_Constructor::get_slot() const
2352 {
2353  return get<int32_t>(_handle, offset_slot);
2354 }
2355 
2356 inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
2357 {
2358  return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2359 }
2360 
2361 
2362 inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
2363 {
2364  set(_handle, offset_clazz, value);
2365 }
2366 
2367 inline void java_lang_reflect_Constructor::set_slot(int32_t value)
2368 {
2369  set(_handle, offset_slot, value);
2370 }
2371 
2372 inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
2373 {
2374  set(_handle, offset_parameterTypes, value);
2375 }
2376 
2377 inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
2378 {
2379  set(_handle, offset_exceptionTypes, value);
2380 }
2381 
2382 inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
2383 {
2384  set(_handle, offset_modifiers, value);
2385 }
2386 
2387 inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
2388 {
2389  set(_handle, offset_signature, value);
2390 }
2391 
2392 inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
2393 {
2394  set(_handle, offset_annotations, value);
2395 }
2396 
2397 inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
2398 {
2399  set(_handle, offset_parameterAnnotations, value);
2400 }
2401 
2402 
2404 {
2405  classinfo* c = get_clazz();
2406  int32_t slot = get_slot();
2407  methodinfo* m = &(c->methods[slot]);
2408  return m;
2409 }
2410 
2411 
2412 /**
2413  * OpenJDK java/lang/reflect/Field
2414  *
2415  * Object layout:
2416  *
2417  * 0. object header
2418  * 1. boolean override;
2419  * 2. java.lang.Class clazz;
2420  * 3. int slot;
2421  * 4. java.lang.String name;
2422  * 5. java.lang.Class type;
2423  * 6. int modifiers;
2424  * 7. java.lang.String signature;
2425  * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
2426  * 9. byte[] annotations;
2427  * 10. sun.reflect.FieldAccessor fieldAccessor;
2428  * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
2429  * 12. java.lang.reflect.Field root;
2430  * 13. java.lang.Class securityCheckCache;
2431  * 14. java.lang.Class securityCheckTargetClassCache;
2432  * 15. java.util.Map declaredAnnotations;
2433  */
2434 class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
2435 private:
2436  // Static offsets of the object's instance fields.
2437  // TODO These offsets need to be checked on VM startup.
2438  /* Fields of extended class
2439  * java.lang.reflect.AccessibleObject */
2440  static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2441 #ifdef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2442  static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2443  /* Members of the actual class java.lang.reflect.Field */
2444  static const off_t offset_clazz = MEMORY_ALIGN(offset_securityCheckCache + sizeof(int32_t), SIZEOF_VOID_P);
2445 #else
2446  static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2447 #endif
2448  static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2449  static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2450  static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2451  static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
2452  static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2453  static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2454  static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2455  static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2456  static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2457  static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2458 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2459  static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2460  static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2461  static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2462 #endif
2463 
2464 public:
2467 
2468  // Getters.
2469  int32_t get_override () const;
2470  classinfo* get_clazz () const;
2471  int32_t get_slot () const;
2472  java_handle_bytearray_t* get_annotations() const;
2473 
2474  // Setters.
2475  void set_clazz (classinfo* value);
2476  void set_slot (int32_t value);
2477  void set_name (java_handle_t* value);
2478  void set_type (classinfo* value);
2479  void set_modifiers (int32_t value);
2480  void set_signature (java_handle_t* value);
2481  void set_annotations(java_handle_bytearray_t* value);
2482 
2483  // Convenience functions.
2484  fieldinfo* get_field() const;
2485 };
2486 
2487 
2489 {
2491 
2492  // OOME.
2493  if (is_null())
2494  return;
2495 
2496  set_clazz(f->clazz);
2497  set_slot(f - f->clazz->fields);
2498  set_name(JavaString::literal(f->name));
2499  set_type(field_get_type(f));
2500  set_modifiers(f->flags);
2501  set_signature(f->signature ? JavaString::from_utf8(f->signature) : NULL);
2502  set_annotations(field_get_annotations(f));
2503 }
2504 
2505 
2506 inline int32_t java_lang_reflect_Field::get_override() const
2507 {
2508  return get<int32_t>(_handle, offset_override);
2509 }
2510 
2511 inline classinfo* java_lang_reflect_Field::get_clazz() const
2512 {
2513  return get<classinfo*>(_handle, offset_clazz);
2514 }
2515 
2516 inline int32_t java_lang_reflect_Field::get_slot() const
2517 {
2518  return get<int32_t>(_handle, offset_slot);
2519 }
2520 
2521 inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
2522 {
2523  return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2524 }
2525 
2526 
2527 inline void java_lang_reflect_Field::set_clazz(classinfo* value)
2528 {
2529  set(_handle, offset_clazz, value);
2530 }
2531 
2532 inline void java_lang_reflect_Field::set_slot(int32_t value)
2533 {
2534  set(_handle, offset_slot, value);
2535 }
2536 
2537 inline void java_lang_reflect_Field::set_name(java_handle_t* value)
2538 {
2539  set(_handle, offset_name, value);
2540 }
2541 
2542 inline void java_lang_reflect_Field::set_type(classinfo* value)
2543 {
2544  set(_handle, offset_type, value);
2545 }
2546 
2547 inline void java_lang_reflect_Field::set_modifiers(int32_t value)
2548 {
2549  set(_handle, offset_modifiers, value);
2550 }
2551 
2552 inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
2553 {
2554  set(_handle, offset_signature, value);
2555 }
2556 
2557 inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
2558 {
2559  set(_handle, offset_annotations, value);
2560 }
2561 
2562 
2564 {
2565  classinfo* c = get_clazz();
2566  int32_t slot = get_slot();
2567  fieldinfo* f = &(c->fields[slot]);
2568  return f;
2569 }
2570 
2571 
2572 /**
2573  * OpenJDK java/lang/reflect/Method
2574  *
2575  * Object layout:
2576  *
2577  * 0. object header
2578  * 1. boolean override;
2579  * 2. java.lang.Class clazz;
2580  * 3. int slot;
2581  * 4. java.lang.String name;
2582  * 5. java.lang.Class returnType;
2583  * 6. java.lang.Class[] parameterTypes;
2584  * 7. java.lang.Class[] exceptionTypes;
2585  * 8. int modifiers;
2586  * 9. java.lang.String signature;
2587  * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
2588  * 11. byte[] annotations;
2589  * 12. byte[] parameterAnnotations;
2590  * 13. byte[] annotationDefault;
2591  * 14. sun.reflect.MethodAccessor methodAccessor;
2592  * 15. java.lang.reflect.Method root;
2593  * 16. java.lang.Class securityCheckCache;
2594  * 17. java.lang.Class securityCheckTargetClassCache;
2595  * 18. java.util.Map declaredAnnotations;
2596  */
2597 class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
2598 private:
2599  // Static offsets of the object's instance fields.
2600  // TODO These offsets need to be checked on VM startup.
2601  /* Fields of extended class
2602  * java.lang.reflect.AccessibleObject */
2603  static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2604 #ifdef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2605  static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2606  /* Members of the actual class java.lang.reflect.Method */
2607  static const off_t offset_clazz = MEMORY_ALIGN(offset_securityCheckCache + sizeof(int32_t), SIZEOF_VOID_P);
2608 #else
2609  static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
2610 #endif
2611  static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
2612  static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
2613  static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
2614  static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
2615  static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
2616  static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
2617  static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
2618  static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
2619  static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
2620  static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2621  static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
2622  static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
2623  static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
2624 #ifndef WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7
2625  static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
2626  static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2627  static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
2628 #endif
2629 
2630 public:
2633 
2635 
2636  // Getters.
2637  int32_t get_override () const;
2638  classinfo* get_clazz () const;
2639  int32_t get_slot () const;
2640  java_handle_bytearray_t* get_annotations () const;
2641  java_handle_bytearray_t* get_parameterAnnotations() const;
2642  java_handle_bytearray_t* get_annotationDefault () const;
2643 
2644  // Setters.
2645 
2646  // Convenience functions.
2647  methodinfo* get_method() const;
2648 };
2649 
2650 
2652 {
2654 
2655  if (is_null())
2656  return;
2657 
2658  set(_handle, offset_clazz, m->clazz);
2659  set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100).
2660  set(_handle, offset_name, JavaString::literal(m->name));
2661  set(_handle, offset_returnType, method_returntype_get(m));
2662  set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
2663  set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
2664  set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK));
2665  set(_handle, offset_signature, m->signature ? JavaString::from_utf8(m->signature) : NULL);
2666  set(_handle, offset_annotations, method_get_annotations(m));
2667  set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
2668  set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
2669 }
2670 
2671 
2672 inline int32_t java_lang_reflect_Method::get_override() const
2673 {
2674  return get<int32_t>(_handle, offset_override);
2675 }
2676 
2677 inline classinfo* java_lang_reflect_Method::get_clazz() const
2678 {
2679  return get<classinfo*>(_handle, offset_clazz);
2680 }
2681 
2682 inline int32_t java_lang_reflect_Method::get_slot() const
2683 {
2684  return get<int32_t>(_handle, offset_slot);
2685 }
2686 
2687 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
2688 {
2689  return get<java_handle_bytearray_t*>(_handle, offset_annotations);
2690 }
2691 
2692 inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
2693 {
2694  return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
2695 }
2696 
2697 inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
2698 {
2699  return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
2700 }
2701 
2702 
2704 {
2705  classinfo* c = get_clazz();
2706  int32_t slot = get_slot();
2707  methodinfo* m = &(c->methods[slot]);
2708  return m;
2709 }
2710 
2711 
2712 /**
2713  * OpenJDK java/nio/Buffer
2714  *
2715  * Object layout:
2716  *
2717  * 0. object header
2718  * 1. int mark;
2719  * 2. int position;
2720  * 3. int limit;
2721  * 4. int capacity;
2722  * 5. long address;
2723  */
2724 class java_nio_Buffer : public java_lang_Object, private FieldAccess {
2725 private:
2726  // Static offsets of the object's instance fields.
2727  // TODO These offsets need to be checked on VM startup.
2728  static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2729  static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
2730  static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2731  static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
2732  static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
2733 
2734 public:
2736 
2737  // Getters.
2738  void* get_address() const;
2739  int32_t get_capacity() const;
2740 };
2741 
2742 
2743 inline void* java_nio_Buffer::get_address() const
2744 {
2745  return get<void*>(_handle, offset_address);
2746 }
2747 
2748 inline int32_t java_nio_Buffer::get_capacity() const
2749 {
2750  return get<int32_t>(_handle, offset_capacity);
2751 }
2752 
2753 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
2754 
2755 
2756 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
2757 
2758 /**
2759  * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
2760  *
2761  * Object layout:
2762  *
2763  * 0. object header
2764  * 1. long pointer;
2765  * 2. int position;
2766  * 3. int length;
2767  */
2768 class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
2769 private:
2770  // Static offsets of the object's instance fields.
2771  // TODO These offsets need to be checked on VM startup.
2772  static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
2773  static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
2774  static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
2775 
2776 public:
2777  com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
2778  com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
2779  com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
2780 
2781  // Getters.
2782  int64_t get_pointer () const;
2783  int32_t get_position() const;
2784  int32_t get_length () const;
2785 
2786  // Setters.
2787  void set_pointer (int64_t value);
2788  void set_position(int32_t value);
2789  void set_length (int32_t value);
2790 };
2791 
2792 
2793 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)
2794 {
2795  set_pointer(pointer);
2796  set_position(position);
2797  set_length(length);
2798 }
2799 
2800 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)
2801 {
2802  com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
2803 }
2804 
2805 
2806 inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
2807 {
2808  return get<int64_t>(_handle, offset_pointer);
2809 }
2810 
2811 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
2812 {
2813  return get<int32_t>(_handle, offset_position);
2814 }
2815 
2816 inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
2817 {
2818  return get<int32_t>(_handle, offset_length);
2819 }
2820 
2821 
2822 inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
2823 {
2824  set(_handle, offset_pointer, value);
2825 }
2826 
2827 inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
2828 {
2829  set(_handle, offset_position, value);
2830 }
2831 
2832 inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
2833 {
2834  set(_handle, offset_length, value);
2835 }
2836 
2837 
2838 /**
2839  * CLDC 1.1 java/lang/String
2840  *
2841  * Object layout:
2842  *
2843  * 0. object header
2844  * 1. char[] value;
2845  * 2. int offset;
2846  * 3. int count;
2847  */
2848 class java_lang_String : public java_lang_Object, private FieldAccess {
2849 private:
2850  // Static offsets of the object's instance fields.
2851  // TODO These offsets need to be checked on VM startup.
2852  static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
2853  static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
2854  static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
2855 
2856 public:
2858  java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
2859 
2860  // Getters.
2862  int32_t get_offset() const;
2863  int32_t get_count () const;
2864 
2865  // Setters.
2866  void set_value (java_handle_chararray_t* value);
2867  void set_offset(int32_t value);
2868  void set_count (int32_t value);
2869 
2870  // Raw access
2871  static inline void set_fields(java_handle_t *str, java_handle_chararray_t* value) {
2872  set(str, offset_value, value);
2873  set(str, offset_offset, 0);
2874  set(str, offset_count, CharArray(value).get_length());
2875  }
2876 
2877  static inline java_handle_chararray_t *get_value(java_handle_t *str) {
2878  return get<java_handle_chararray_t*>(str, offset_value);
2879  }
2880  static inline int32_t get_count(java_handle_t *str) {
2881  return get<int32_t>(str, offset_count);
2882  }
2883  static inline int32_t get_offset(java_handle_t *str) {
2884  return get<int32_t>(str, offset_offset);
2885  }
2886 };
2887 
2888 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)
2889 {
2890  set_value(value);
2891  set_offset(offset);
2892  set_count(count);
2893 }
2894 
2896 {
2897  return get<java_handle_chararray_t*>(_handle, offset_value);
2898 }
2899 
2900 inline int32_t java_lang_String::get_offset() const
2901 {
2902  return get<int32_t>(_handle, offset_offset);
2903 }
2904 
2905 inline int32_t java_lang_String::get_count() const
2906 {
2907  return get<int32_t>(_handle, offset_count);
2908 }
2909 
2911 {
2912  set(_handle, offset_value, value);
2913 }
2914 
2915 inline void java_lang_String::set_offset(int32_t value)
2916 {
2917  set(_handle, offset_offset, value);
2918 }
2919 
2920 inline void java_lang_String::set_count(int32_t value)
2921 {
2922  set(_handle, offset_count, value);
2923 }
2924 
2925 
2926 /**
2927  * CLDC 1.1 java/lang/Thread
2928  *
2929  * Object layout:
2930  *
2931  * 0. object header
2932  * 1. int priority;
2933  * 2. java.lang.Runnable runnable;
2934  * 3. java.lang.Object vm_thread;
2935  * 4. int is_terminated;
2936  * 5. int is_stillborn;
2937  * 6. char[] name;
2938  */
2939 class java_lang_Thread : public java_lang_Object, private FieldAccess {
2940 private:
2941  // Static offsets of the object's instance fields.
2942  // TODO These offsets need to be checked on VM startup.
2943  static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
2944  static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
2945  static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
2946  static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
2947  static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
2948  static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
2949 
2950 public:
2952 // java_lang_Thread(threadobject* t);
2953 
2954  // Getters.
2955  int32_t get_priority () const;
2956  threadobject* get_vm_thread() const;
2958 
2959  // Setters.
2960  void set_vm_thread(threadobject* value);
2961 };
2962 
2963 
2964 inline int32_t java_lang_Thread::get_priority() const
2965 {
2966  return get<int32_t>(_handle, offset_priority);
2967 }
2968 
2969 inline threadobject* java_lang_Thread::get_vm_thread() const
2970 {
2971  return get<threadobject*>(_handle, offset_vm_thread);
2972 }
2973 
2975 {
2976  return get<java_handle_chararray_t*>(_handle, offset_name);
2977 }
2978 
2979 
2980 inline void java_lang_Thread::set_vm_thread(threadobject* value)
2981 {
2982  set(_handle, offset_vm_thread, value);
2983 }
2984 
2985 
2986 /**
2987  * CLDC 1.1 java/lang/Throwable
2988  *
2989  * Object layout:
2990  *
2991  * 0. object header
2992  * 1. java.lang.String detailMessage;
2993  * 2. java.lang.Object backtrace;
2994  */
2995 class java_lang_Throwable : public java_lang_Object, private FieldAccess {
2996 private:
2997  // Static offsets of the object's instance fields.
2998  // TODO These offsets need to be checked on VM startup.
2999  static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
3000  static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
3001 
3002 public:
3004 
3005  // Getters.
3007  java_handle_bytearray_t* get_backtrace () const;
3008 
3009  // Setters.
3010  void set_backtrace(java_handle_bytearray_t* value);
3011 };
3012 
3013 
3015 {
3016  return get<java_handle_t*>(_handle, offset_detailMessage);
3017 }
3018 
3019 inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
3020 {
3021  return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
3022 }
3023 
3024 
3025 inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
3026 {
3027  set(_handle, offset_backtrace, value);
3028 }
3029 
3030 #endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
3031 
3032 #endif // JAVAOBJECTS_HPP_
3033 
3034 
3035 /*
3036  * These are local overrides for various environment variables in Emacs.
3037  * Please do not remove this and leave it at the end of the file, where
3038  * Emacs will automagically detect them.
3039  * ---------------------------------------------------------------------
3040  * Local variables:
3041  * mode: c++
3042  * indent-tabs-mode: t
3043  * c-basic-offset: 4
3044  * tab-width: 4
3045  * End:
3046  * vim:noexpandtab:sw=4:ts=4:
3047  */
java_lang_Thread(java_handle_t *h)
java/lang/Integer
void set_data(void *value)
java_handle_t * get_address() const
Utf8String name
Definition: method.hpp:71
java_lang_reflect_Constructor(java_handle_t *h)
jlong jlong jlong jlong jint jmethodID jint slot
Definition: jvmti.h:497
int32_t get_priority() const
static const off_t offset_offset
void set_clazz(classinfo *value)
java_handle_bytearray_t * get_parameterAnnotations() const
static void set_group_offset(int32_t off)
java_lang_Short(java_handle_t *h)
static const off_t offset_f
java_lang_Object(java_handle_t *h)
void * get_data() const
void set_f(java_handle_t *value)
void set_cons(java_handle_t *value)
classinfo * class_java_lang_reflect_Field
Definition: globals.cpp:82
static off_t offset_exceptionHandler
Utf8String name
Definition: field.hpp:61
bool is_non_null() const
virtual java_handle_t * get_handle() const
java_lang_VMThrowable(java_handle_t *h)
classinfo * get_clazz() const
java_lang_management_MemoryUsage(java_handle_t *h)
void set_annotations(java_handle_bytearray_t *value)
bool is_null() const
static const off_t offset_p
GNU Classpath java/lang/VMThread.
static const off_t offset_constantPoolOop
java_lang_Integer(java_handle_t *h)
static const off_t offset_name
int32_t get_slot() const
methodinfo * methods
Definition: class.hpp:113
int32_t get_hashcode() const
java/lang/Float
static const off_t offset_value
java_lang_reflect_Method(java_handle_t *h)
static const off_t offset_cons
void set_value(int16_t value)
GNU Classpath java/nio/Buffer.
void set_constantPoolOop(classinfo *value)
int8_t get_value()
static const off_t offset_count
void set_annotations(java_handle_bytearray_t *value)
vftbl_t * get_vftbl() const
static JavaString from_utf8(Utf8String)
Definition: string.cpp:184
static const off_t offset_flag
classinfo * field_get_type(fieldinfo *f)
Definition: field.cpp:358
static const off_t offset_array_offset
static const off_t offset_f
java_handle_t * get_name() const
java_handle_t * get_vmState() const
classinfo * get_clazz() const
java_handle_chararray_t * get_value() const
OpenJDK sun/reflect/ConstantPool.
static const off_t offset_value
java_handle_t * get_declaredAnnotations() const
java_handle_bytearray_t * method_get_annotations(methodinfo *m)
Definition: method.cpp:932
static const off_t offset_parameterAnnotations
static const off_t offset_owner
static const off_t offset_annotations
static off_t offset_priority
classinfo * class_java_lang_reflect_VMMethod
Definition: globals.cpp:91
void set_slot(int32_t value)
java/lang/Boolean
GNU Classpath java/lang/reflect/VMConstructor.
void jobjects_register_dyn_offsets()
void set_vmdata(threadobject *value)
static const off_t offset_value
java_handle_bytearray_t * get_annotations() const
void set_pd(java_handle_t *value)
GNU Classpath java/lang/reflect/Field.
s4 heap_get_hashcode(java_object_t *o)
Definition: heap.c:204
void set_value(float value)
void set_value(int64_t value)
static void set_priority_offset(int32_t off)
static const off_t offset_declaredAnnotations
classinfo * get_clazz() const
static void set(java_handle_t *h, const off_t offset, T value)
static const off_t offset_clazz
classinfo * get_Class() const
classinfo * load_class_bootstrap(Utf8String name)
Definition: loader.cpp:1276
static off_t offset_vmThread
java_handle_bytearray_t * get_annotations() const
void set_m(java_handle_t *value)
void set_thread(java_handle_t *value)
static const off_t offset_detailMessage
static void set_daemon_offset(int32_t off)
void set_vmdata(java_handle_bytearray_t *value)
static const off_t offset_signers
alloc::set< EdgeType >::type & set
static const off_t offset_thread
static const off_t offset_flag
void set_count(int32_t value)
static const off_t offset_limit
GNU Classpath java/lang/StackTraceElement.
static void set_fields(java_handle_t *str, java_handle_chararray_t *value)
JNIEnv jclass jobject const char * name
Definition: jvmti.h:312
static const off_t offset_m
java_handle_objectarray_t * method_get_parametertypearray(methodinfo *m)
Definition: method.cpp:774
static T get(java_handle_t *h, const off_t offset)
Definition: javaobjects.hpp:96
static void set_vmThread_offset(int32_t off)
Utf8String signature
Definition: method.hpp:74
static const off_t offset_mark
static int32_t get_count(java_handle_t *str)
static std::set< Utf8String > & packages()
Definition: package.cpp:40
GNU Classpath java/lang/VMThrowable.
static const off_t offset_flag
int32_t get_cap() const
java_handle_t * builtin_new(classinfo *c)
Definition: builtin.cpp:816
static const off_t offset_vmState
GNU Classpath java/lang/reflect/Constructor.
java_lang_Long(java_handle_t *h)
static const off_t offset_parameterAnnotations
static void set_volatile(java_handle_t *h, const off_t offset, T value)
java_handle_t * get_parent() const
java_handle_t * get_group() const
java_lang_reflect_VMField(java_handle_t *h)
java_handle_t * invoke(java_handle_t *o, java_handle_objectarray_t *args)
Invokes the given method.
static T get_volatile(java_handle_t *h, const off_t offset)
int32_t get_daemon() const
static const off_t offset_stackTrace
fieldinfo * fields
Definition: class.hpp:110
java_handle_t * get_f() const
static const off_t offset_cause
java_handle_bytearray_t * get_annotations() const
static const off_t offset_declaredAnnotations
java/lang/management/MemoryUsage
java_handle_t * get_thread() const
#define LLNI_WRAP(obj)
Definition: llni.hpp:51
java/lang/Object
java_lang_Class(java_handle_t *h)
Critical section for the GC.
Definition: gc.hpp:42
static const off_t offset_vmdata
java_nio_DirectByteBufferImpl(java_handle_t *h)
int32_t get_length() const
Definition: array.hpp:189
This classes provides functions to access Java object instance fields.
Definition: javaobjects.hpp:84
java_lang_reflect_Field(java_handle_t *h)
fieldinfo * get_field() const
classinfo * class_java_lang_reflect_VMField
Definition: globals.cpp:90
java_lang_ClassLoader(java_handle_t *h)
static const off_t offset_cachedHashCode
static const off_t offset_declaringClass
static const off_t offset_value
static void set_name_offset(int32_t off)
methodinfo * get_method() const
classinfo * clazz
Definition: method.hpp:80
bool jobjects_run_dynoffsets_hook(classinfo *c)
static off_t offset_daemon
int32_t get_override() const
int32_t get_flag() const
static const off_t offset_name
static const off_t offset_m
void set_declaredAnnotations(java_handle_t *value)
classinfo * clazz
Definition: vftbl.hpp:100
java_handle_t * get_declaredAnnotations() const
s4 flags
Definition: field.hpp:59
java_lang_Character(java_handle_t *h)
static const off_t offset_fileName
GNU Classpath java/lang/reflect/Method.
static const off_t offset_pos
java_lang_Float(java_handle_t *h)
java/lang/Character
java_handle_bytearray_t * get_vmdata() const
java_lang_Double(java_handle_t *h)
classinfo * class_java_lang_reflect_Method
Definition: globals.cpp:83
static const off_t offset_pos
void set_value(double value)
JNIEnv jthread thread
Definition: jvmti.h:207
virtual ~java_lang_Object()
static const off_t offset_vmdata
void set_declaredAnnotations(java_handle_t *value)
static Utf8String from_utf8(const char *, size_t)
Definition: utf8.cpp:335
JNIEnv jthread jmethodID void * address
Definition: jvmti.h:264
void set_clazz(classinfo *value)
static const off_t offset_value
static const off_t offset_parent
static const off_t offset_slot
java/lang/Double
GNU Classpath java/lang/Throwable.
static const off_t offset_address
static void raw_set(void *address, const off_t offset, T value)
Definition: javaobjects.hpp:71
static const off_t offset_declaredAnnotations
classinfo * clazz
Definition: field.hpp:55
void set_value(int8_t value)
void set_cons(java_handle_t *value)
jsize get_string_offset(const java_lang_String &s)
void set_value(int32_t value)
classinfo * method_returntype_get(methodinfo *m)
Definition: method.cpp:857
java_lang_reflect_VMConstructor(java_handle_t *h)
static const off_t offset_p
static const off_t offset_definedPackages
void set_group(java_handle_t *value)
static const off_t offset_data
static java_handle_t * invoke_getSystemClassLoader()
Invokes the static Java method getSystemClassLoader().
Definition: javaobjects.cpp:51
java_lang_VMThread(java_handle_t *h)
void set_clazz(classinfo *value)
static const off_t offset_vmdata
java/lang/Long
#define LLNI_UNWRAP(hdl)
Definition: llni.hpp:52
java_lang_StackTraceElement(java_handle_t *h)
void set_value(uint16_t value)
GNU Classpath java/nio/DirectByteBufferImpl.
static const off_t offset_value
static const off_t offset_cap
void set_parameterAnnotations(java_handle_bytearray_t *value)
java_handle_bytearray_t * field_get_annotations(fieldinfo *f)
Definition: field.cpp:414
This class provides low-level functions to access Java object instance fields.
Definition: javaobjects.hpp:57
static const off_t offset_value
void set_name(java_handle_t *value)
GNU Classpath java/lang/ClassLoader.
sun_reflect_ConstantPool(java_handle_t *h)
java_handle_t * get_vmThread() const
static const off_t offset_methodName
java_handle_t * new_instance(java_handle_objectarray_t *args)
Constructs a Java object with the given java.lang.reflect.Constructor.
void set_annotations(java_handle_bytearray_t *value)
GNU Classpath java/lang/String.
java_lang_reflect_VMMethod(java_handle_t *h)
static const off_t offset_lineNumber
java_handle_bytearray_t * get_parameterAnnotations() const
void memory_barrier(void)
Definition: atomic.hpp:96
methodinfo * get_method() const
void set_name(java_handle_t *value)
int32_t get_offset() const
static const off_t offset_running
int16_t get_value()
static const off_t offset_clazz
void set_slot(int32_t value)
java_lang_Throwable(java_handle_t *h)
GNU Classpath java/lang/reflect/VMMethod.
java_handle_bytearray_t * get_annotationDefault() const
void set_value(java_handle_chararray_t *value)
void set_declaredAnnotations(java_handle_t *value)
static const off_t offset_isNative
int32_t get_flag() const
java_handle_t * get_declaredAnnotations() const
void set_offset(int32_t value)
java_lang_Boolean(java_handle_t *h)
static const off_t offset_cap
#define MEMORY_ALIGN(pos, size)
Definition: memory.hpp:37
static off_t offset_group
methodinfo * get_method() const
java_handle_t * _handle
java_handle_t * get_cause() const
java_handle_bytearray_t * method_get_annotationdefault(methodinfo *m)
Definition: method.cpp:1021
java_handle_t * get_f() const
void set_f(java_handle_t *value)
threadobject * get_vmdata() const
java_handle_t * get_detailMessage() const
GNU Classpath java/lang/Thread.
static const off_t offset_annotations
fieldinfo * get_field() const
void set_value(uint8_t value)
java_handle_t * get_exceptionHandler() const
java_handle_t * get_cons() const
classinfo * class_java_lang_reflect_VMConstructor
Definition: globals.cpp:89
jsize get_string_count(const java_lang_String &s)
#define LLNI_classinfo_unwrap(clazz)
Definition: llni.hpp:113
java/lang/Byte
classinfo * class_java_lang_StackTraceElement
Definition: globals.cpp:80
static const off_t offset_mark
java/lang/Short
#define str(x)
static const off_t offset_value
s4 flags
Definition: method.hpp:70
static const off_t offset_limit
static T raw_get(void *address, const off_t offset)
Definition: javaobjects.hpp:64
java_handle_t * get_m() const
GNU Classpath java/lang/Class.
Utf8String signature
Definition: field.hpp:63
classinfo * class_java_lang_reflect_Constructor
Definition: globals.cpp:81
void set_parameterAnnotations(java_handle_bytearray_t *value)
java_handle_objectarray_t * method_get_exceptionarray(methodinfo *m)
Definition: method.cpp:824
static JavaString literal(Utf8String)
Definition: string.cpp:257
static const off_t offset_constructor
vftbl_t * vftbl
Definition: global.hpp:264
static const off_t offset_pd
java_handle_t * get_m() const
static const off_t offset_slot
java_nio_Buffer(java_handle_t *h)
static const off_t offset_endian
const char const void jint length
Definition: jvmti.h:352
void set_annotationDefault(java_handle_bytearray_t *value)
int64_t get_value()
static const off_t offset_backing_buffer
static const off_t offset_annotations
static off_t offset_name
static const off_t offset_address
java_handle_bytearray_t * method_get_parameterannotations(methodinfo *m)
Definition: method.cpp:976
GNU Classpath java/lang/reflect/VMField.
GNU Classpath gnu/classpath/Pointer.
static int32_t get_offset(java_handle_t *str)
void set_m(java_handle_t *value)
int32_t get_count() const
java_lang_String(java_handle_t *h)
java_lang_Byte(java_handle_t *h)
gnu_classpath_Pointer(java_handle_t *h)
static void set_exceptionHandler_offset(int32_t off)
static java_handle_chararray_t * get_value(java_handle_t *str)
static const off_t offset_value
java_handle_t * get_cons() const
static const off_t offset_annotationDefault