1 /* src/native/vm/Field.c - java/lang/reflect/Field
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Roman Obermaiser
29 Changes: Joseph Wenninger
32 $Id: Field.c 3455 2005-10-19 22:04:36Z twisti $
42 #include "native/jni.h"
43 #include "native/native.h"
44 #include "native/include/java_lang_Boolean.h"
45 #include "native/include/java_lang_Byte.h"
46 #include "native/include/java_lang_Character.h"
47 #include "native/include/java_lang_Short.h"
48 #include "native/include/java_lang_Integer.h"
49 #include "native/include/java_lang_Long.h"
50 #include "native/include/java_lang_Float.h"
51 #include "native/include/java_lang_Double.h"
52 #include "native/include/java_lang_Object.h"
53 #include "native/include/java_lang_Class.h"
54 #include "native/include/java_lang_reflect_Field.h"
55 #include "vm/access.h"
56 #include "vm/builtin.h"
57 #include "vm/exceptions.h"
58 #include "vm/global.h"
59 #include "vm/initialize.h"
60 #include "vm/loader.h"
61 #include "vm/resolve.h"
62 #include "vm/stringlocal.h"
63 #include "vm/tables.h"
65 #include "vm/jit/stacktrace.h"
68 #define CHECKFIELDACCESS(this,fi,c,doret)
71 /* cacao_get_field_address *****************************************************
75 *******************************************************************************/
77 static void *cacao_get_field_address(classinfo *c, fieldinfo *f,
82 /* check field access */
84 if (!(f->flags & ACC_PUBLIC)) {
85 caller = cacao_callingMethod();
87 if (!access_is_accessible_member(caller->class, c, f->flags)) {
89 new_exception(string_java_lang_IllegalAccessException);
94 /* get the address of the field */
96 if (f->flags & ACC_STATIC) {
97 /* initialize class if required */
99 if (!initialize_class(c))
102 /* return value address */
107 /* obj is required for not-static fields */
110 *exceptionptr = new_nullpointerexception();
114 if (builtin_instanceof((java_objectheader *) o, c))
115 return (void *) ((ptrint) o + f->offset);
120 *exceptionptr = new_illegalargumentexception();
127 * Class: java/lang/reflect/Field
129 * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
131 JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Field_get(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
137 c = (classinfo *) this->declaringClass;
138 f = &c->fields[this->slot];
140 /* get address of the source field value */
142 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
145 switch (f->parseddesc->decltype) {
146 case PRIMITIVETYPE_BOOLEAN: {
147 java_lang_Boolean *bo;
149 /* create wrapping class */
151 if (!(bo = (java_lang_Boolean *) builtin_new(class_java_lang_Boolean)))
154 /* set the object value */
156 bo->value = *((s4 *) addr);
158 /* return the wrapped object */
160 return (java_lang_Object *) bo;
163 case PRIMITIVETYPE_BYTE: {
166 if (!(bo = (java_lang_Byte *) builtin_new(class_java_lang_Byte)))
169 bo->value = *((s4 *) addr);
171 return (java_lang_Object *) bo;
174 case PRIMITIVETYPE_CHAR: {
175 java_lang_Character *co;
177 if (!(co = (java_lang_Character *) builtin_new(class_java_lang_Character)))
180 co->value = *((s4 *) addr);
182 return (java_lang_Object *) co;
185 case PRIMITIVETYPE_SHORT: {
188 if (!(so = (java_lang_Short *) builtin_new(class_java_lang_Short)))
191 so->value = (s4) *((s4 *) addr);
193 return (java_lang_Object *) so;
196 case PRIMITIVETYPE_INT: {
197 java_lang_Integer *io;
199 if (!(io = (java_lang_Integer *) builtin_new(class_java_lang_Integer)))
202 io->value = *((s4 *) addr);
204 return (java_lang_Object *) io;
207 case PRIMITIVETYPE_LONG: {
210 if (!(lo = (java_lang_Long *) builtin_new(class_java_lang_Long)))
213 lo->value = *((s8 *) addr);
215 return (java_lang_Object *) lo;
218 case PRIMITIVETYPE_FLOAT: {
221 if (!(fo = (java_lang_Float *) builtin_new(class_java_lang_Float)))
224 fo->value = *((float *) addr);
226 return (java_lang_Object *) fo;
229 case PRIMITIVETYPE_DOUBLE: {
230 java_lang_Double *_do;
232 if (!(_do = (java_lang_Double *) builtin_new(class_java_lang_Double)))
235 _do->value = *((double *) addr);
237 return (java_lang_Object *) _do;
241 return (java_lang_Object *) *((java_objectheader **) addr);
244 /* this must not happen */
251 * Class: java/lang/reflect/Field
253 * Signature: (Ljava/lang/Object;)Z
255 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getBoolean(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
261 /* get the class and the field */
263 c = (classinfo *) this->declaringClass;
264 f = &c->fields[this->slot];
266 /* get the address of the field with an internal helper */
268 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
271 /* check the field type and return the value */
273 switch (f->parseddesc->decltype) {
274 case PRIMITIVETYPE_BOOLEAN:
275 return (s4) *((s4 *) addr);
277 *exceptionptr = new_illegalargumentexception();
284 * Class: java/lang/reflect/Field
286 * Signature: (Ljava/lang/Object;)B
288 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getByte(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
294 /* get the class and the field */
296 c = (classinfo *) this->declaringClass;
297 f = &c->fields[this->slot];
299 /* get the address of the field with an internal helper */
301 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
304 /* check the field type and return the value */
306 switch (f->parseddesc->decltype) {
307 case PRIMITIVETYPE_BYTE:
308 return (s4) *((s4 *) addr);
310 *exceptionptr = new_illegalargumentexception();
317 * Class: java/lang/reflect/Field
319 * Signature: (Ljava/lang/Object;)C
321 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getChar(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
327 /* get the class and the field */
329 c = (classinfo *) this->declaringClass;
330 f = &c->fields[this->slot];
332 /* get the address of the field with an internal helper */
334 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
337 /* check the field type and return the value */
339 switch (f->parseddesc->decltype) {
340 case PRIMITIVETYPE_CHAR:
341 return (s4) *((s4 *) addr);
343 *exceptionptr = new_illegalargumentexception();
350 * Class: java/lang/reflect/Field
352 * Signature: (Ljava/lang/Object;)S
354 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getShort(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
360 /* get the class and the field */
362 c = (classinfo *) this->declaringClass;
363 f = &c->fields[this->slot];
365 /* get the address of the field with an internal helper */
367 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
370 /* check the field type and return the value */
372 switch (f->parseddesc->decltype) {
373 case PRIMITIVETYPE_BYTE:
374 case PRIMITIVETYPE_SHORT:
375 return (s4) *((s4 *) addr);
377 *exceptionptr = new_illegalargumentexception();
384 * Class: java/lang/reflect/Field
386 * Signature: (Ljava/lang/Object;)I
388 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getInt(JNIEnv *env , java_lang_reflect_Field *this, java_lang_Object *o)
394 /* get the class and the field */
396 c = (classinfo *) this->declaringClass;
397 f = &c->fields[this->slot];
399 /* get the address of the field with an internal helper */
401 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
404 /* check the field type and return the value */
406 switch (f->parseddesc->decltype) {
407 case PRIMITIVETYPE_BYTE:
408 case PRIMITIVETYPE_CHAR:
409 case PRIMITIVETYPE_SHORT:
410 case PRIMITIVETYPE_INT:
411 return (s4) *((s4 *) addr);
413 *exceptionptr = new_illegalargumentexception();
420 * Class: java/lang/reflect/Field
422 * Signature: (Ljava/lang/Object;)J
424 JNIEXPORT s8 JNICALL Java_java_lang_reflect_Field_getLong(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
430 /* get the class and the field */
432 c = (classinfo *) this->declaringClass;
433 f = &c->fields[this->slot];
435 /* get the address of the field with an internal helper */
437 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
440 /* check the field type and return the value */
442 switch (f->parseddesc->decltype) {
443 case PRIMITIVETYPE_BYTE:
444 case PRIMITIVETYPE_CHAR:
445 case PRIMITIVETYPE_SHORT:
446 case PRIMITIVETYPE_INT:
447 return (s8) *((s4 *) addr);
448 case PRIMITIVETYPE_LONG:
449 return (s8) *((s8 *) addr);
451 *exceptionptr = new_illegalargumentexception();
458 * Class: java/lang/reflect/Field
460 * Signature: (Ljava/lang/Object;)F
462 JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o)
468 /* get the class and the field */
470 c = (classinfo *) this->declaringClass;
471 f = &c->fields[this->slot];
473 /* get the address of the field with an internal helper */
475 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
478 /* check the field type and return the value */
480 switch (f->parseddesc->decltype) {
481 case PRIMITIVETYPE_BYTE:
482 case PRIMITIVETYPE_CHAR:
483 case PRIMITIVETYPE_SHORT:
484 case PRIMITIVETYPE_INT:
485 return (float) *((s4 *) addr);
486 case PRIMITIVETYPE_LONG:
487 return (float) *((s8 *) addr);
488 case PRIMITIVETYPE_FLOAT:
489 return (float) *((float *) addr);
491 *exceptionptr = new_illegalargumentexception();
498 * Class: java/lang/reflect/Field
500 * Signature: (Ljava/lang/Object;)D
502 JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble(JNIEnv *env , java_lang_reflect_Field *this, java_lang_Object *o)
508 /* get the class and the field */
510 c = (classinfo *) this->declaringClass;
511 f = &c->fields[this->slot];
513 /* get the address of the field with an internal helper */
515 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
518 /* check the field type and return the value */
520 switch (f->parseddesc->decltype) {
521 case PRIMITIVETYPE_BYTE:
522 case PRIMITIVETYPE_CHAR:
523 case PRIMITIVETYPE_SHORT:
524 case PRIMITIVETYPE_INT:
525 return (double) *((s4 *) addr);
526 case PRIMITIVETYPE_LONG:
527 return (double) *((s8 *) addr);
528 case PRIMITIVETYPE_FLOAT:
529 return (double) *((float *) addr);
530 case PRIMITIVETYPE_DOUBLE:
531 return (double) *((double *) addr);
533 *exceptionptr = new_illegalargumentexception();
540 * Class: java/lang/reflect/Field
542 * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
544 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, java_lang_Object *value)
556 /* get the class and the field */
558 dc = (classinfo *) this->declaringClass;
559 df = &dc->fields[this->slot];
561 /* get the address of the destination field */
563 if ((faddr = cacao_get_field_address(dc, df, o)) == NULL)
571 /* get the source classinfo from the object */
573 sc = value->header.vftbl->class;
575 /* The fieldid is used to set the new value, for primitive
576 types the value has to be retrieved from the wrapping
579 switch (df->parseddesc->decltype) {
580 case PRIMITIVETYPE_BOOLEAN:
581 /* determine the field to read the value */
583 if (!(sf = class_findfield(sc, utf_value, utf_Z)))
586 switch (sf->parseddesc->decltype) {
587 case PRIMITIVETYPE_BOOLEAN:
588 ival = ((java_lang_Boolean *) value)->value;
591 *exceptionptr = new_illegalargumentexception();
595 *((s4 *) faddr) = ival;
598 case PRIMITIVETYPE_BYTE:
599 if (!(sf = class_findfield(sc, utf_value, utf_B)))
602 switch (sf->parseddesc->decltype) {
603 case PRIMITIVETYPE_BYTE:
604 ival = ((java_lang_Byte *) value)->value;
607 *exceptionptr = new_illegalargumentexception();
611 *((s4 *) faddr) = ival;
614 case PRIMITIVETYPE_CHAR:
615 if (!(sf = class_findfield(sc, utf_value, utf_C)))
618 switch (sf->parseddesc->decltype) {
619 case PRIMITIVETYPE_CHAR:
620 ival = ((java_lang_Character *) value)->value;
623 *exceptionptr = new_illegalargumentexception();
627 *((s4 *) faddr) = ival;
630 case PRIMITIVETYPE_SHORT:
631 /* get field only by name, it can be one of B, S */
633 if (!(sf = class_findfield_by_name(sc, utf_value)))
636 switch (sf->parseddesc->decltype) {
637 case PRIMITIVETYPE_BYTE:
638 ival = ((java_lang_Byte *) value)->value;
640 case PRIMITIVETYPE_SHORT:
641 ival = ((java_lang_Short *) value)->value;
644 *exceptionptr = new_illegalargumentexception();
648 *((s4 *) faddr) = ival;
651 case PRIMITIVETYPE_INT:
652 /* get field only by name, it can be one of B, S, C, I */
654 if (!(sf = class_findfield_by_name(sc, utf_value)))
657 switch (sf->parseddesc->decltype) {
658 case PRIMITIVETYPE_BYTE:
659 ival = ((java_lang_Byte *) value)->value;
661 case PRIMITIVETYPE_CHAR:
662 ival = ((java_lang_Character *) value)->value;
664 case PRIMITIVETYPE_SHORT:
665 ival = ((java_lang_Short *) value)->value;
667 case PRIMITIVETYPE_INT:
668 ival = ((java_lang_Integer *) value)->value;
671 *exceptionptr = new_illegalargumentexception();
675 *((s4 *) faddr) = ival;
678 case PRIMITIVETYPE_LONG:
679 /* get field only by name, it can be one of B, S, C, I, J */
681 if (!(sf = class_findfield_by_name(sc, utf_value)))
684 switch (sf->parseddesc->decltype) {
685 case PRIMITIVETYPE_BYTE:
686 lval = ((java_lang_Byte *) value)->value;
688 case PRIMITIVETYPE_CHAR:
689 lval = ((java_lang_Character *) value)->value;
691 case PRIMITIVETYPE_SHORT:
692 lval = ((java_lang_Short *) value)->value;
694 case PRIMITIVETYPE_INT:
695 lval = ((java_lang_Integer *) value)->value;
697 case PRIMITIVETYPE_LONG:
698 lval = ((java_lang_Long *) value)->value;
701 *exceptionptr = new_illegalargumentexception();
705 *((s8 *) faddr) = ival;
708 case PRIMITIVETYPE_FLOAT:
709 /* get field only by name, it can be one of B, S, C, I, J, F */
711 if (!(sf = class_findfield_by_name(sc, utf_value)))
714 switch (sf->parseddesc->decltype) {
715 case PRIMITIVETYPE_BYTE:
716 fval = ((java_lang_Byte *) value)->value;
718 case PRIMITIVETYPE_CHAR:
719 fval = ((java_lang_Character *) value)->value;
721 case PRIMITIVETYPE_SHORT:
722 fval = ((java_lang_Short *) value)->value;
724 case PRIMITIVETYPE_INT:
725 fval = ((java_lang_Integer *) value)->value;
727 case PRIMITIVETYPE_LONG:
728 fval = ((java_lang_Long *) value)->value;
730 case PRIMITIVETYPE_FLOAT:
731 fval = ((java_lang_Float *) value)->value;
734 *exceptionptr = new_illegalargumentexception();
738 *((float *) faddr) = fval;
741 case PRIMITIVETYPE_DOUBLE:
742 /* get field only by name, it can be one of B, S, C, I, J, F, D */
744 if (!(sf = class_findfield_by_name(sc, utf_value)))
747 switch (sf->parseddesc->decltype) {
748 case PRIMITIVETYPE_BYTE:
749 dval = ((java_lang_Byte *) value)->value;
751 case PRIMITIVETYPE_CHAR:
752 dval = ((java_lang_Character *) value)->value;
754 case PRIMITIVETYPE_SHORT:
755 dval = ((java_lang_Short *) value)->value;
757 case PRIMITIVETYPE_INT:
758 dval = ((java_lang_Integer *) value)->value;
760 case PRIMITIVETYPE_LONG:
761 dval = ((java_lang_Long *) value)->value;
763 case PRIMITIVETYPE_FLOAT:
764 dval = ((java_lang_Float *) value)->value;
766 case PRIMITIVETYPE_DOUBLE:
767 dval = ((java_lang_Double *) value)->value;
770 *exceptionptr = new_illegalargumentexception();
774 *((double *) faddr) = fval;
778 /* check if value is an instance of the destination class */
781 /* if (!builtin_instanceof((java_objectheader *) value, df->class)) */
784 *((java_lang_Object **) faddr) = value;
788 /* raise exception */
790 *exceptionptr = new_illegalargumentexception();
795 * Class: java/lang/reflect/Field
797 * Signature: (Ljava/lang/Object;Z)V
799 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
805 /* get the class and the field */
807 c = (classinfo *) this->declaringClass;
808 f = &c->fields[this->slot];
810 /* get the address of the field with an internal helper */
812 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
815 /* check the field type and set the value */
817 switch (f->parseddesc->decltype) {
818 case PRIMITIVETYPE_BOOLEAN:
819 *((s4 *) addr) = value;
822 *exceptionptr = new_illegalargumentexception();
830 * Class: java/lang/reflect/Field
832 * Signature: (Ljava/lang/Object;B)V
834 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
840 /* get the class and the field */
842 c = (classinfo *) this->declaringClass;
843 f = &c->fields[this->slot];
845 /* get the address of the field with an internal helper */
847 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
850 /* check the field type and set the value */
852 switch (f->parseddesc->decltype) {
853 case PRIMITIVETYPE_BYTE:
854 case PRIMITIVETYPE_SHORT:
855 case PRIMITIVETYPE_INT:
856 *((s4 *) addr) = value;
858 case PRIMITIVETYPE_LONG:
859 *((s8 *) addr) = value;
861 case PRIMITIVETYPE_FLOAT:
862 *((float *) addr) = value;
864 case PRIMITIVETYPE_DOUBLE:
865 *((double *) addr) = value;
868 *exceptionptr = new_illegalargumentexception();
876 * Class: java/lang/reflect/Field
878 * Signature: (Ljava/lang/Object;C)V
880 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
886 /* get the class and the field */
888 c = (classinfo *) this->declaringClass;
889 f = &c->fields[this->slot];
891 /* get the address of the field with an internal helper */
893 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
896 /* check the field type and set the value */
898 switch (f->parseddesc->decltype) {
899 case PRIMITIVETYPE_CHAR:
900 case PRIMITIVETYPE_INT:
901 *((s4 *) addr) = value;
903 case PRIMITIVETYPE_LONG:
904 *((s8 *) addr) = value;
906 case PRIMITIVETYPE_FLOAT:
907 *((float *) addr) = value;
909 case PRIMITIVETYPE_DOUBLE:
910 *((double *) addr) = value;
913 *exceptionptr = new_illegalargumentexception();
921 * Class: java/lang/reflect/Field
923 * Signature: (Ljava/lang/Object;S)V
925 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
931 /* get the class and the field */
933 c = (classinfo *) this->declaringClass;
934 f = &c->fields[this->slot];
936 /* get the address of the field with an internal helper */
938 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
941 /* check the field type and set the value */
943 switch (f->parseddesc->decltype) {
944 case PRIMITIVETYPE_SHORT:
945 case PRIMITIVETYPE_INT:
946 *((s4 *) addr) = value;
948 case PRIMITIVETYPE_LONG:
949 *((s8 *) addr) = value;
951 case PRIMITIVETYPE_FLOAT:
952 *((float *) addr) = value;
954 case PRIMITIVETYPE_DOUBLE:
955 *((double *) addr) = value;
958 *exceptionptr = new_illegalargumentexception();
966 * Class: java/lang/reflect/Field
968 * Signature: (Ljava/lang/Object;I)V
970 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s4 value)
976 /* get the class and the field */
978 c = (classinfo *) this->declaringClass;
979 f = &c->fields[this->slot];
981 /* get the address of the field with an internal helper */
983 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
986 /* check the field type and set the value */
988 switch (f->parseddesc->decltype) {
989 case PRIMITIVETYPE_INT:
990 *((s4 *) addr) = value;
992 case PRIMITIVETYPE_LONG:
993 *((s8 *) addr) = value;
995 case PRIMITIVETYPE_FLOAT:
996 *((float *) addr) = value;
998 case PRIMITIVETYPE_DOUBLE:
999 *((double *) addr) = value;
1002 *exceptionptr = new_illegalargumentexception();
1010 * Class: java/lang/reflect/Field
1012 * Signature: (Ljava/lang/Object;J)V
1014 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, s8 value)
1020 /* get the class and the field */
1022 c = (classinfo *) this->declaringClass;
1023 f = &c->fields[this->slot];
1025 /* get the address of the field with an internal helper */
1027 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
1030 /* check the field type and set the value */
1032 switch (f->parseddesc->decltype) {
1033 case PRIMITIVETYPE_LONG:
1034 *((s8 *) addr) = value;
1036 case PRIMITIVETYPE_FLOAT:
1037 *((float *) addr) = value;
1039 case PRIMITIVETYPE_DOUBLE:
1040 *((double *) addr) = value;
1043 *exceptionptr = new_illegalargumentexception();
1051 * Class: java/lang/reflect/Field
1053 * Signature: (Ljava/lang/Object;F)V
1055 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, float value)
1061 /* get the class and the field */
1063 c = (classinfo *) this->declaringClass;
1064 f = &c->fields[this->slot];
1066 /* get the address of the field with an internal helper */
1068 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
1071 /* check the field type and set the value */
1073 switch (f->parseddesc->decltype) {
1074 case PRIMITIVETYPE_FLOAT:
1075 *((float *) addr) = value;
1077 case PRIMITIVETYPE_DOUBLE:
1078 *((double *) addr) = value;
1081 *exceptionptr = new_illegalargumentexception();
1089 * Class: java/lang/reflect/Field
1091 * Signature: (Ljava/lang/Object;D)V
1093 JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o, double value)
1099 /* get the class and the field */
1101 c = (classinfo *) this->declaringClass;
1102 f = &c->fields[this->slot];
1104 /* get the address of the field with an internal helper */
1106 if ((addr = cacao_get_field_address(c, f, o)) == NULL)
1109 /* check the field type and set the value */
1111 switch (f->parseddesc->decltype) {
1112 case PRIMITIVETYPE_DOUBLE:
1113 *((double *) addr) = value;
1116 *exceptionptr = new_illegalargumentexception();
1124 * Class: java/lang/reflect/Field
1126 * Signature: ()Ljava/lang/Class;
1128 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Field_getType(JNIEnv *env, java_lang_reflect_Field *this)
1134 c = (classinfo *) this->declaringClass;
1135 desc = c->fields[this->slot].parseddesc;
1140 if (!resolve_class_from_typedesc(desc, true, false, &ret))
1143 if (!use_class_as_object(ret))
1146 return (java_lang_Class *) ret;
1151 * Class: java_lang_reflect_Field
1152 * Method: getModifiers
1155 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getModifiers(JNIEnv *env, java_lang_reflect_Field *this)
1159 c = (classinfo *) this->declaringClass;
1161 return c->fields[this->slot].flags;
1166 * These are local overrides for various environment variables in Emacs.
1167 * Please do not remove this and leave it at the end of the file, where
1168 * Emacs will automagically detect them.
1169 * ---------------------------------------------------------------------
1172 * indent-tabs-mode: t