public static ServiceConfiguration convertFrom(PulsarConfiguration conf, boolean ignoreNonExistMember)
            throws RuntimeException {
        try {
            final ServiceConfiguration convertedConf = ServiceConfiguration.class
                    .getDeclaredConstructor().newInstance();
            Field[] confFields = conf.getClass().getDeclaredFields();
            Properties sourceProperties = conf.getProperties();
            Properties targetProperties = convertedConf.getProperties();
            Arrays.stream(confFields).forEach(confField -> {
                try {
                    confField.setAccessible(true);
                    Field convertedConfField = ServiceConfiguration.class.getDeclaredField(confField.getName());
                    if (!Modifier.isStatic(convertedConfField.getModifiers())
                            && convertedConfField.getDeclaredAnnotation(FieldContext.class) != null) {
                        convertedConfField.setAccessible(true);
                        convertedConfField.set(convertedConf, confField.get(conf));
                    }
                } catch (NoSuchFieldException e) {
                    if (!ignoreNonExistMember) {
                        throw new IllegalArgumentException(
                                "Exception caused while converting configuration: " + e.getMessage());
                    }
                    // add unknown fields to properties
                    try {
                        String propertyName = confField.getName();
                        if (!sourceProperties.containsKey(propertyName) && confField.get(conf) != null) {
                            targetProperties.put(propertyName, confField.get(conf));
                        }
                    } catch (Exception ignoreException) {
                        // should not happen
                    }
                } catch (IllegalAccessException e) {
                    throw new RuntimeException("Exception caused while converting configuration: " + e.getMessage());
                }
            });
            // Put the rest of properties to new config
            targetProperties.putAll(sourceProperties);
            return convertedConf;
        } catch (InstantiationException | IllegalAccessException
                | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Exception caused while converting configuration: " + e.getMessage());
        }
    }
@Test
    public void testConfigurationConverting_checkNonExistMember() {
        assertThrows(IllegalArgumentException.class,
                () -> PulsarConfigurationLoader.convertFrom(new MockConfiguration(), false));
    }