private static void typeCheckFieldSet ( Field field , Class < ? > valueType , Object value ) throws IllegalAccessException { if ( ! isPrimitive ( valueType ) ) { //Call the version of this method that considers autoboxing typeCheckFieldSet ( field , value ) ; } else { //Value type is primitive. // Note: In this case value was a primitive value that became boxed, so it can't be null. Class < ? > fieldType = field . getType ( ) ; if ( ! Utils . isConvertableFrom ( fieldType , valueType ) ) { throw Exceptions . illegalSetFieldTypeException ( field , valueType , value ) ; } } }
Perform a dynamic type check needed when setting a field value onto a field . Raises the appropriate exception when the check fails and returns normally otherwise .