private static void typeCheckFieldSet ( Field field , Object value ) throws IllegalAccessException { Class < ? > fieldType = field . getType ( ) ; if ( value == null ) { if ( fieldType . isPrimitive ( ) ) { throw Exceptions . illegalSetFieldTypeException ( field , null , value ) ; } } else { if ( fieldType . isPrimitive ( ) ) { fieldType = boxTypeFor ( fieldType ) ; } Class < ? > valueType = value . getClass ( ) ; 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 . This method should only be called for object types . For primitive types call the three parameter variant instead .