public static void setFieldValue(final Field field, final Object instance, final Object value) throws CoreException {

        try {
            // store current visibility
            final boolean accessible = field.isAccessible();

            // let it accessible anyway
            field.setAccessible(true);

            // Call this method with right parameters
            field.set(instance, value);

            // Reset default visibility
            field.setAccessible(accessible);

        } catch (IllegalAccessException | IllegalArgumentException e) {
            throw new CoreException(e);
        }
    }
public static void setFieldValue ( final Field field , final Object instance , final Object value ) throws CoreException { try { final boolean accessible = field . isAccessible ( ) ; field . setAccessible ( true ) ; field . set ( instance , value ) ; field . setAccessible ( accessible ) ; } catch ( IllegalAccessException | IllegalArgumentException e ) { throw new CoreException ( e ) ; } }
Update an object field even if it has a private or protected visibility.

@param field the field to update
@param instance the object instance that hold this field
@param value the value to set into this field

@throws CoreException if the new value cannot be set