class AttributeBytecodeGenerator {

    static void ensureFieldExists(Class<?> pojoClass, Class<?> attributeValueType, String fieldName, String attributeName) {
        try {
            // Validate that the field exists...
            while (pojoClass != null) {
                try {
                    pojoClass.getDeclaredField(fieldName);
                    return;
                } catch (NoSuchFieldException e) {
                    pojoClass = pojoClass.getSuperclass();
                }
            }
            throw new NoSuchFieldException(fieldName);
        } catch (Exception e) {
            throw new IllegalStateException(getExceptionMessage(pojoClass, attributeValueType, attributeName), e);
        }
    }

}