private static Field field(final Class<?> clazz, final String fieldName, final Class<?> expectedType) {
        Field field;
        try {
            field = clazz.getDeclaredField(fieldName);
            field.setAccessible(true);
            if (!field.getType().equals(expectedType)) {
                return null;
            }
        } catch (final Throwable t) {
            // Failed to access the fields.
            field = null;
        }
        return field;
    }
Gets the field with the given name within the class, or
{@code null} if not found. If found, the field is made accessible.
jraft-core/src/main/java/com/alipay/sofa/jraft/util/internal/UnsafeUtil.java