704 * Sets the field represented by this {@code Field} object on the
705 * specified object argument to the specified new value. The new
706 * value is automatically unwrapped if the underlying field has a
707 * primitive type.
708 *
709 * <p>The operation proceeds as follows:
710 *
711 * <p>If the underlying field is static, the {@code obj} argument is
712 * ignored; it may be null.
713 *
714 * <p>Otherwise the underlying field is an instance field. If the
715 * specified object argument is null, the method throws a
716 * {@code NullPointerException}. If the specified object argument is not
717 * an instance of the class or interface declaring the underlying
718 * field, the method throws an {@code IllegalArgumentException}.
719 *
720 * <p>If this {@code Field} object is enforcing Java language access control, and
721 * the underlying field is inaccessible, the method throws an
722 * {@code IllegalAccessException}.
723 *
724 * <p>If the underlying field is final, the method throws an
725 * {@code IllegalAccessException} unless {@code setAccessible(true)}
726 * has succeeded for this {@code Field} object
727 * and the field is non-static. Setting a final field in this way
728 * is meaningful only during deserialization or reconstruction of
729 * instances of classes with blank final fields, before they are
730 * made available for access by other parts of a program. Use in
731 * any other context may have unpredictable effects, including cases
732 * in which other parts of a program continue to use the original
733 * value of this field.
734 *
735 * <p>If the underlying field is of a primitive type, an unwrapping
736 * conversion is attempted to convert the new value to a value of
737 * a primitive type. If this attempt fails, the method throws an
738 * {@code IllegalArgumentException}.
739 *
740 * <p>If, after possible unwrapping, the new value cannot be
741 * converted to the type of the underlying field by an identity or
742 * widening conversion, the method throws an
743 * {@code IllegalArgumentException}.
744 *
745 * <p>If the underlying field is static, the class that declared the
746 * field is initialized if it has not already been initialized.
747 *
748 * <p>The field is set to the possibly unwrapped and widened new value.
749 *
750 * <p>If the field is hidden in the type of {@code obj},
751 * the field's value is set according to the preceding rules.
752 *
753 * @param obj the object whose field should be modified
754 * @param value the new value for the field of {@code obj}
755 * being modified
756 *
757 * @throws IllegalAccessException if this {@code Field} object
758 * is enforcing Java language access control and the underlying
759 * field is either inaccessible or final.
760 * @throws IllegalArgumentException if the specified object is not an
761 * instance of the class or interface declaring the underlying
762 * field (or a subclass or implementor thereof),
763 * or if an unwrapping conversion fails.
764 * @throws NullPointerException if the specified object is null
765 * and the field is an instance field.
766 * @throws ExceptionInInitializerError if the initialization provoked
767 * by this method fails.
768 */
769 @CallerSensitive
770 @ForceInline // to ensure Reflection.getCallerClass optimization
771 public void set(Object obj, Object value)
772 throws IllegalArgumentException, IllegalAccessException
773 {
774 if (!override) {
775 Class<?> caller = Reflection.getCallerClass();
776 checkAccess(caller, obj);
777 }
778 getFieldAccessor(obj).set(obj, value);
779 }
780
781 /**
782 * Sets the value of a field as a {@code boolean} on the specified object.
783 * This method is equivalent to
784 * {@code set(obj, zObj)},
785 * where {@code zObj} is a {@code Boolean} object and
786 * {@code zObj.booleanValue() == z}.
787 *
788 * @param obj the object whose field should be modified
789 * @param z the new value for the field of {@code obj}
790 * being modified
791 *
792 * @throws IllegalAccessException if this {@code Field} object
793 * is enforcing Java language access control and the underlying
794 * field is either inaccessible or final.
795 * @throws IllegalArgumentException if the specified object is not an
796 * instance of the class or interface declaring the underlying
797 * field (or a subclass or implementor thereof),
798 * or if an unwrapping conversion fails.
799 * @throws NullPointerException if the specified object is null
800 * and the field is an instance field.
801 * @throws ExceptionInInitializerError if the initialization provoked
802 * by this method fails.
803 * @see Field#set
804 */
805 @CallerSensitive
806 @ForceInline // to ensure Reflection.getCallerClass optimization
807 public void setBoolean(Object obj, boolean z)
808 throws IllegalArgumentException, IllegalAccessException
809 {
810 if (!override) {
811 Class<?> caller = Reflection.getCallerClass();
812 checkAccess(caller, obj);
813 }
814 getFieldAccessor(obj).setBoolean(obj, z);
815 }
816
817 /**
818 * Sets the value of a field as a {@code byte} on the specified object.
819 * This method is equivalent to
820 * {@code set(obj, bObj)},
821 * where {@code bObj} is a {@code Byte} object and
822 * {@code bObj.byteValue() == b}.
823 *
824 * @param obj the object whose field should be modified
825 * @param b the new value for the field of {@code obj}
826 * being modified
827 *
828 * @throws IllegalAccessException if this {@code Field} object
829 * is enforcing Java language access control and the underlying
830 * field is either inaccessible or final.
831 * @throws IllegalArgumentException if the specified object is not an
832 * instance of the class or interface declaring the underlying
833 * field (or a subclass or implementor thereof),
834 * or if an unwrapping conversion fails.
835 * @throws NullPointerException if the specified object is null
836 * and the field is an instance field.
837 * @throws ExceptionInInitializerError if the initialization provoked
838 * by this method fails.
839 * @see Field#set
840 */
841 @CallerSensitive
842 @ForceInline // to ensure Reflection.getCallerClass optimization
843 public void setByte(Object obj, byte b)
844 throws IllegalArgumentException, IllegalAccessException
845 {
846 if (!override) {
847 Class<?> caller = Reflection.getCallerClass();
848 checkAccess(caller, obj);
849 }
850 getFieldAccessor(obj).setByte(obj, b);
851 }
852
853 /**
854 * Sets the value of a field as a {@code char} on the specified object.
855 * This method is equivalent to
856 * {@code set(obj, cObj)},
857 * where {@code cObj} is a {@code Character} object and
858 * {@code cObj.charValue() == c}.
859 *
860 * @param obj the object whose field should be modified
861 * @param c the new value for the field of {@code obj}
862 * being modified
863 *
864 * @throws IllegalAccessException if this {@code Field} object
865 * is enforcing Java language access control and the underlying
866 * field is either inaccessible or final.
867 * @throws IllegalArgumentException if the specified object is not an
868 * instance of the class or interface declaring the underlying
869 * field (or a subclass or implementor thereof),
870 * or if an unwrapping conversion fails.
871 * @throws NullPointerException if the specified object is null
872 * and the field is an instance field.
873 * @throws ExceptionInInitializerError if the initialization provoked
874 * by this method fails.
875 * @see Field#set
876 */
877 @CallerSensitive
878 @ForceInline // to ensure Reflection.getCallerClass optimization
879 public void setChar(Object obj, char c)
880 throws IllegalArgumentException, IllegalAccessException
881 {
882 if (!override) {
883 Class<?> caller = Reflection.getCallerClass();
884 checkAccess(caller, obj);
885 }
886 getFieldAccessor(obj).setChar(obj, c);
887 }
888
889 /**
890 * Sets the value of a field as a {@code short} on the specified object.
891 * This method is equivalent to
892 * {@code set(obj, sObj)},
893 * where {@code sObj} is a {@code Short} object and
894 * {@code sObj.shortValue() == s}.
895 *
896 * @param obj the object whose field should be modified
897 * @param s the new value for the field of {@code obj}
898 * being modified
899 *
900 * @throws IllegalAccessException if this {@code Field} object
901 * is enforcing Java language access control and the underlying
902 * field is either inaccessible or final.
903 * @throws IllegalArgumentException if the specified object is not an
904 * instance of the class or interface declaring the underlying
905 * field (or a subclass or implementor thereof),
906 * or if an unwrapping conversion fails.
907 * @throws NullPointerException if the specified object is null
908 * and the field is an instance field.
909 * @throws ExceptionInInitializerError if the initialization provoked
910 * by this method fails.
911 * @see Field#set
912 */
913 @CallerSensitive
914 @ForceInline // to ensure Reflection.getCallerClass optimization
915 public void setShort(Object obj, short s)
916 throws IllegalArgumentException, IllegalAccessException
917 {
918 if (!override) {
919 Class<?> caller = Reflection.getCallerClass();
920 checkAccess(caller, obj);
921 }
922 getFieldAccessor(obj).setShort(obj, s);
923 }
924
925 /**
926 * Sets the value of a field as an {@code int} on the specified object.
927 * This method is equivalent to
928 * {@code set(obj, iObj)},
929 * where {@code iObj} is an {@code Integer} object and
930 * {@code iObj.intValue() == i}.
931 *
932 * @param obj the object whose field should be modified
933 * @param i the new value for the field of {@code obj}
934 * being modified
935 *
936 * @throws IllegalAccessException if this {@code Field} object
937 * is enforcing Java language access control and the underlying
938 * field is either inaccessible or final.
939 * @throws IllegalArgumentException if the specified object is not an
940 * instance of the class or interface declaring the underlying
941 * field (or a subclass or implementor thereof),
942 * or if an unwrapping conversion fails.
943 * @throws NullPointerException if the specified object is null
944 * and the field is an instance field.
945 * @throws ExceptionInInitializerError if the initialization provoked
946 * by this method fails.
947 * @see Field#set
948 */
949 @CallerSensitive
950 @ForceInline // to ensure Reflection.getCallerClass optimization
951 public void setInt(Object obj, int i)
952 throws IllegalArgumentException, IllegalAccessException
953 {
954 if (!override) {
955 Class<?> caller = Reflection.getCallerClass();
956 checkAccess(caller, obj);
957 }
958 getFieldAccessor(obj).setInt(obj, i);
959 }
960
961 /**
962 * Sets the value of a field as a {@code long} on the specified object.
963 * This method is equivalent to
964 * {@code set(obj, lObj)},
965 * where {@code lObj} is a {@code Long} object and
966 * {@code lObj.longValue() == l}.
967 *
968 * @param obj the object whose field should be modified
969 * @param l the new value for the field of {@code obj}
970 * being modified
971 *
972 * @throws IllegalAccessException if this {@code Field} object
973 * is enforcing Java language access control and the underlying
974 * field is either inaccessible or final.
975 * @throws IllegalArgumentException if the specified object is not an
976 * instance of the class or interface declaring the underlying
977 * field (or a subclass or implementor thereof),
978 * or if an unwrapping conversion fails.
979 * @throws NullPointerException if the specified object is null
980 * and the field is an instance field.
981 * @throws ExceptionInInitializerError if the initialization provoked
982 * by this method fails.
983 * @see Field#set
984 */
985 @CallerSensitive
986 @ForceInline // to ensure Reflection.getCallerClass optimization
987 public void setLong(Object obj, long l)
988 throws IllegalArgumentException, IllegalAccessException
989 {
990 if (!override) {
991 Class<?> caller = Reflection.getCallerClass();
992 checkAccess(caller, obj);
993 }
994 getFieldAccessor(obj).setLong(obj, l);
995 }
996
997 /**
998 * Sets the value of a field as a {@code float} on the specified object.
999 * This method is equivalent to
1000 * {@code set(obj, fObj)},
1001 * where {@code fObj} is a {@code Float} object and
1002 * {@code fObj.floatValue() == f}.
1003 *
1004 * @param obj the object whose field should be modified
1005 * @param f the new value for the field of {@code obj}
1006 * being modified
1007 *
1008 * @throws IllegalAccessException if this {@code Field} object
1009 * is enforcing Java language access control and the underlying
1010 * field is either inaccessible or final.
1011 * @throws IllegalArgumentException if the specified object is not an
1012 * instance of the class or interface declaring the underlying
1013 * field (or a subclass or implementor thereof),
1014 * or if an unwrapping conversion fails.
1015 * @throws NullPointerException if the specified object is null
1016 * and the field is an instance field.
1017 * @throws ExceptionInInitializerError if the initialization provoked
1018 * by this method fails.
1019 * @see Field#set
1020 */
1021 @CallerSensitive
1022 @ForceInline // to ensure Reflection.getCallerClass optimization
1023 public void setFloat(Object obj, float f)
1024 throws IllegalArgumentException, IllegalAccessException
1025 {
1026 if (!override) {
1027 Class<?> caller = Reflection.getCallerClass();
1028 checkAccess(caller, obj);
1029 }
1030 getFieldAccessor(obj).setFloat(obj, f);
1031 }
1032
1033 /**
1034 * Sets the value of a field as a {@code double} on the specified object.
1035 * This method is equivalent to
1036 * {@code set(obj, dObj)},
1037 * where {@code dObj} is a {@code Double} object and
1038 * {@code dObj.doubleValue() == d}.
1039 *
1040 * @param obj the object whose field should be modified
1041 * @param d the new value for the field of {@code obj}
1042 * being modified
1043 *
1044 * @throws IllegalAccessException if this {@code Field} object
1045 * is enforcing Java language access control and the underlying
1046 * field is either inaccessible or final.
1047 * @throws IllegalArgumentException if the specified object is not an
1048 * instance of the class or interface declaring the underlying
1049 * field (or a subclass or implementor thereof),
1050 * or if an unwrapping conversion fails.
1051 * @throws NullPointerException if the specified object is null
1052 * and the field is an instance field.
1053 * @throws ExceptionInInitializerError if the initialization provoked
1054 * by this method fails.
1055 * @see Field#set
1056 */
1057 @CallerSensitive
1058 @ForceInline // to ensure Reflection.getCallerClass optimization
1059 public void setDouble(Object obj, double d)
1060 throws IllegalArgumentException, IllegalAccessException
1061 {
1062 if (!override) {
1063 Class<?> caller = Reflection.getCallerClass();
1064 checkAccess(caller, obj);
1065 }
1066 getFieldAccessor(obj).setDouble(obj, d);
|
704 * Sets the field represented by this {@code Field} object on the
705 * specified object argument to the specified new value. The new
706 * value is automatically unwrapped if the underlying field has a
707 * primitive type.
708 *
709 * <p>The operation proceeds as follows:
710 *
711 * <p>If the underlying field is static, the {@code obj} argument is
712 * ignored; it may be null.
713 *
714 * <p>Otherwise the underlying field is an instance field. If the
715 * specified object argument is null, the method throws a
716 * {@code NullPointerException}. If the specified object argument is not
717 * an instance of the class or interface declaring the underlying
718 * field, the method throws an {@code IllegalArgumentException}.
719 *
720 * <p>If this {@code Field} object is enforcing Java language access control, and
721 * the underlying field is inaccessible, the method throws an
722 * {@code IllegalAccessException}.
723 *
724 * <p>If the underlying field is final, this {@code Field} object has
725 * <em>write</em> access if and only if the following conditions are met:
726 * <ul>
727 * <li>{@link #setAccessible(boolean) setAccessible(true)} has succeeded for
728 * this {@code Field} object;</li>
729 * <li>the field is non-static; and</li>
730 * <li>the field's declaring class is not a {@linkplain Class#isHiddenClass()
731 * hidden class}.</li>
732 * </ul>
733 * If any of the above checks is not met, this method throws an
734 * {@code IllegalAccessException}.
735 *
736 * <p> Setting a final field in this way
737 * is meaningful only during deserialization or reconstruction of
738 * instances of classes with blank final fields, before they are
739 * made available for access by other parts of a program. Use in
740 * any other context may have unpredictable effects, including cases
741 * in which other parts of a program continue to use the original
742 * value of this field.
743 *
744 * <p>If the underlying field is of a primitive type, an unwrapping
745 * conversion is attempted to convert the new value to a value of
746 * a primitive type. If this attempt fails, the method throws an
747 * {@code IllegalArgumentException}.
748 *
749 * <p>If, after possible unwrapping, the new value cannot be
750 * converted to the type of the underlying field by an identity or
751 * widening conversion, the method throws an
752 * {@code IllegalArgumentException}.
753 *
754 * <p>If the underlying field is static, the class that declared the
755 * field is initialized if it has not already been initialized.
756 *
757 * <p>The field is set to the possibly unwrapped and widened new value.
758 *
759 * <p>If the field is hidden in the type of {@code obj},
760 * the field's value is set according to the preceding rules.
761 *
762 * @param obj the object whose field should be modified
763 * @param value the new value for the field of {@code obj}
764 * being modified
765 *
766 * @throws IllegalAccessException if this {@code Field} object
767 * is enforcing Java language access control and the underlying
768 * field is inaccessible or final;
769 * or if this {@code Field} object has no write access.
770 * @throws IllegalArgumentException if the specified object is not an
771 * instance of the class or interface declaring the underlying
772 * field (or a subclass or implementor thereof),
773 * or if an unwrapping conversion fails.
774 * @throws NullPointerException if the specified object is null
775 * and the field is an instance field.
776 * @throws ExceptionInInitializerError if the initialization provoked
777 * by this method fails.
778 */
779 @CallerSensitive
780 @ForceInline // to ensure Reflection.getCallerClass optimization
781 public void set(Object obj, Object value)
782 throws IllegalArgumentException, IllegalAccessException
783 {
784 if (!override) {
785 Class<?> caller = Reflection.getCallerClass();
786 checkAccess(caller, obj);
787 }
788 getFieldAccessor(obj).set(obj, value);
789 }
790
791 /**
792 * Sets the value of a field as a {@code boolean} on the specified object.
793 * This method is equivalent to
794 * {@code set(obj, zObj)},
795 * where {@code zObj} is a {@code Boolean} object and
796 * {@code zObj.booleanValue() == z}.
797 *
798 * @param obj the object whose field should be modified
799 * @param z the new value for the field of {@code obj}
800 * being modified
801 *
802 * @throws IllegalAccessException if this {@code Field} object
803 * is enforcing Java language access control and the underlying
804 * field is either inaccessible or final;
805 * or if this {@code Field} object has no write access.
806 * @throws IllegalArgumentException if the specified object is not an
807 * instance of the class or interface declaring the underlying
808 * field (or a subclass or implementor thereof),
809 * or if an unwrapping conversion fails.
810 * @throws NullPointerException if the specified object is null
811 * and the field is an instance field.
812 * @throws ExceptionInInitializerError if the initialization provoked
813 * by this method fails.
814 * @see Field#set
815 */
816 @CallerSensitive
817 @ForceInline // to ensure Reflection.getCallerClass optimization
818 public void setBoolean(Object obj, boolean z)
819 throws IllegalArgumentException, IllegalAccessException
820 {
821 if (!override) {
822 Class<?> caller = Reflection.getCallerClass();
823 checkAccess(caller, obj);
824 }
825 getFieldAccessor(obj).setBoolean(obj, z);
826 }
827
828 /**
829 * Sets the value of a field as a {@code byte} on the specified object.
830 * This method is equivalent to
831 * {@code set(obj, bObj)},
832 * where {@code bObj} is a {@code Byte} object and
833 * {@code bObj.byteValue() == b}.
834 *
835 * @param obj the object whose field should be modified
836 * @param b the new value for the field of {@code obj}
837 * being modified
838 *
839 * @throws IllegalAccessException if this {@code Field} object
840 * is enforcing Java language access control and the underlying
841 * field is either inaccessible or final;
842 * or if this {@code Field} object has no write access.
843 * @throws IllegalArgumentException if the specified object is not an
844 * instance of the class or interface declaring the underlying
845 * field (or a subclass or implementor thereof),
846 * or if an unwrapping conversion fails.
847 * @throws NullPointerException if the specified object is null
848 * and the field is an instance field.
849 * @throws ExceptionInInitializerError if the initialization provoked
850 * by this method fails.
851 * @see Field#set
852 */
853 @CallerSensitive
854 @ForceInline // to ensure Reflection.getCallerClass optimization
855 public void setByte(Object obj, byte b)
856 throws IllegalArgumentException, IllegalAccessException
857 {
858 if (!override) {
859 Class<?> caller = Reflection.getCallerClass();
860 checkAccess(caller, obj);
861 }
862 getFieldAccessor(obj).setByte(obj, b);
863 }
864
865 /**
866 * Sets the value of a field as a {@code char} on the specified object.
867 * This method is equivalent to
868 * {@code set(obj, cObj)},
869 * where {@code cObj} is a {@code Character} object and
870 * {@code cObj.charValue() == c}.
871 *
872 * @param obj the object whose field should be modified
873 * @param c the new value for the field of {@code obj}
874 * being modified
875 *
876 * @throws IllegalAccessException if this {@code Field} object
877 * is enforcing Java language access control and the underlying
878 * field is either inaccessible or final;
879 * or if this {@code Field} object has no write access.
880 * @throws IllegalArgumentException if the specified object is not an
881 * instance of the class or interface declaring the underlying
882 * field (or a subclass or implementor thereof),
883 * or if an unwrapping conversion fails.
884 * @throws NullPointerException if the specified object is null
885 * and the field is an instance field.
886 * @throws ExceptionInInitializerError if the initialization provoked
887 * by this method fails.
888 * @see Field#set
889 */
890 @CallerSensitive
891 @ForceInline // to ensure Reflection.getCallerClass optimization
892 public void setChar(Object obj, char c)
893 throws IllegalArgumentException, IllegalAccessException
894 {
895 if (!override) {
896 Class<?> caller = Reflection.getCallerClass();
897 checkAccess(caller, obj);
898 }
899 getFieldAccessor(obj).setChar(obj, c);
900 }
901
902 /**
903 * Sets the value of a field as a {@code short} on the specified object.
904 * This method is equivalent to
905 * {@code set(obj, sObj)},
906 * where {@code sObj} is a {@code Short} object and
907 * {@code sObj.shortValue() == s}.
908 *
909 * @param obj the object whose field should be modified
910 * @param s the new value for the field of {@code obj}
911 * being modified
912 *
913 * @throws IllegalAccessException if this {@code Field} object
914 * is enforcing Java language access control and the underlying
915 * field is either inaccessible or final;
916 * or if this {@code Field} object has no write access.
917 * @throws IllegalArgumentException if the specified object is not an
918 * instance of the class or interface declaring the underlying
919 * field (or a subclass or implementor thereof),
920 * or if an unwrapping conversion fails.
921 * @throws NullPointerException if the specified object is null
922 * and the field is an instance field.
923 * @throws ExceptionInInitializerError if the initialization provoked
924 * by this method fails.
925 * @see Field#set
926 */
927 @CallerSensitive
928 @ForceInline // to ensure Reflection.getCallerClass optimization
929 public void setShort(Object obj, short s)
930 throws IllegalArgumentException, IllegalAccessException
931 {
932 if (!override) {
933 Class<?> caller = Reflection.getCallerClass();
934 checkAccess(caller, obj);
935 }
936 getFieldAccessor(obj).setShort(obj, s);
937 }
938
939 /**
940 * Sets the value of a field as an {@code int} on the specified object.
941 * This method is equivalent to
942 * {@code set(obj, iObj)},
943 * where {@code iObj} is an {@code Integer} object and
944 * {@code iObj.intValue() == i}.
945 *
946 * @param obj the object whose field should be modified
947 * @param i the new value for the field of {@code obj}
948 * being modified
949 *
950 * @throws IllegalAccessException if this {@code Field} object
951 * is enforcing Java language access control and the underlying
952 * field is either inaccessible or final;
953 * or if this {@code Field} object has no write access.
954 * @throws IllegalArgumentException if the specified object is not an
955 * instance of the class or interface declaring the underlying
956 * field (or a subclass or implementor thereof),
957 * or if an unwrapping conversion fails.
958 * @throws NullPointerException if the specified object is null
959 * and the field is an instance field.
960 * @throws ExceptionInInitializerError if the initialization provoked
961 * by this method fails.
962 * @see Field#set
963 */
964 @CallerSensitive
965 @ForceInline // to ensure Reflection.getCallerClass optimization
966 public void setInt(Object obj, int i)
967 throws IllegalArgumentException, IllegalAccessException
968 {
969 if (!override) {
970 Class<?> caller = Reflection.getCallerClass();
971 checkAccess(caller, obj);
972 }
973 getFieldAccessor(obj).setInt(obj, i);
974 }
975
976 /**
977 * Sets the value of a field as a {@code long} on the specified object.
978 * This method is equivalent to
979 * {@code set(obj, lObj)},
980 * where {@code lObj} is a {@code Long} object and
981 * {@code lObj.longValue() == l}.
982 *
983 * @param obj the object whose field should be modified
984 * @param l the new value for the field of {@code obj}
985 * being modified
986 *
987 * @throws IllegalAccessException if this {@code Field} object
988 * is enforcing Java language access control and the underlying
989 * field is either inaccessible or final;
990 * or if this {@code Field} object has no write access.
991 * @throws IllegalArgumentException if the specified object is not an
992 * instance of the class or interface declaring the underlying
993 * field (or a subclass or implementor thereof),
994 * or if an unwrapping conversion fails.
995 * @throws NullPointerException if the specified object is null
996 * and the field is an instance field.
997 * @throws ExceptionInInitializerError if the initialization provoked
998 * by this method fails.
999 * @see Field#set
1000 */
1001 @CallerSensitive
1002 @ForceInline // to ensure Reflection.getCallerClass optimization
1003 public void setLong(Object obj, long l)
1004 throws IllegalArgumentException, IllegalAccessException
1005 {
1006 if (!override) {
1007 Class<?> caller = Reflection.getCallerClass();
1008 checkAccess(caller, obj);
1009 }
1010 getFieldAccessor(obj).setLong(obj, l);
1011 }
1012
1013 /**
1014 * Sets the value of a field as a {@code float} on the specified object.
1015 * This method is equivalent to
1016 * {@code set(obj, fObj)},
1017 * where {@code fObj} is a {@code Float} object and
1018 * {@code fObj.floatValue() == f}.
1019 *
1020 * @param obj the object whose field should be modified
1021 * @param f the new value for the field of {@code obj}
1022 * being modified
1023 *
1024 * @throws IllegalAccessException if this {@code Field} object
1025 * is enforcing Java language access control and the underlying
1026 * field is either inaccessible or final;
1027 * or if this {@code Field} object has no write access.
1028 * @throws IllegalArgumentException if the specified object is not an
1029 * instance of the class or interface declaring the underlying
1030 * field (or a subclass or implementor thereof),
1031 * or if an unwrapping conversion fails.
1032 * @throws NullPointerException if the specified object is null
1033 * and the field is an instance field.
1034 * @throws ExceptionInInitializerError if the initialization provoked
1035 * by this method fails.
1036 * @see Field#set
1037 */
1038 @CallerSensitive
1039 @ForceInline // to ensure Reflection.getCallerClass optimization
1040 public void setFloat(Object obj, float f)
1041 throws IllegalArgumentException, IllegalAccessException
1042 {
1043 if (!override) {
1044 Class<?> caller = Reflection.getCallerClass();
1045 checkAccess(caller, obj);
1046 }
1047 getFieldAccessor(obj).setFloat(obj, f);
1048 }
1049
1050 /**
1051 * Sets the value of a field as a {@code double} on the specified object.
1052 * This method is equivalent to
1053 * {@code set(obj, dObj)},
1054 * where {@code dObj} is a {@code Double} object and
1055 * {@code dObj.doubleValue() == d}.
1056 *
1057 * @param obj the object whose field should be modified
1058 * @param d the new value for the field of {@code obj}
1059 * being modified
1060 *
1061 * @throws IllegalAccessException if this {@code Field} object
1062 * is enforcing Java language access control and the underlying
1063 * field is either inaccessible or final;
1064 * or if this {@code Field} object has no write access.
1065 * @throws IllegalArgumentException if the specified object is not an
1066 * instance of the class or interface declaring the underlying
1067 * field (or a subclass or implementor thereof),
1068 * or if an unwrapping conversion fails.
1069 * @throws NullPointerException if the specified object is null
1070 * and the field is an instance field.
1071 * @throws ExceptionInInitializerError if the initialization provoked
1072 * by this method fails.
1073 * @see Field#set
1074 */
1075 @CallerSensitive
1076 @ForceInline // to ensure Reflection.getCallerClass optimization
1077 public void setDouble(Object obj, double d)
1078 throws IllegalArgumentException, IllegalAccessException
1079 {
1080 if (!override) {
1081 Class<?> caller = Reflection.getCallerClass();
1082 checkAccess(caller, obj);
1083 }
1084 getFieldAccessor(obj).setDouble(obj, d);
|