public static <T extends ConfigInstance> T getNewInstance(Class<T> type, String configId, ConfigPayload payload) {
        T instance;
        try {
            ConfigTransformer<?> transformer = new ConfigTransformer<>(type);
            ConfigInstance.Builder instanceBuilder = transformer.toConfigBuilder(payload);
            Constructor<T> constructor = type.getConstructor(instanceBuilder.getClass());
            instance = constructor.newInstance(instanceBuilder);

            // Workaround for JDK7, where compilation fails due to fields being
            // private and not accessible from T. Reference it as a
            // ConfigInstance to work around it. See
            // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7022052 for
            // more information.
            ConfigInstance i = instance;
            i.postInitialize(configId);
            setConfigId(i, configId);

        } catch (InstantiationException | InvocationTargetException | NoSuchMethodException |
                 NoSuchFieldException | IllegalAccessException e) {
            throw new IllegalArgumentException("Failed creating new instance of '" + type.getCanonicalName() +
                                               "' for config id '" + configId + "'", e);
        }
        return instance;
    }
@Test
    public void testGetNewInstanceErrorMessage() {
        ConfigPayloadBuilder payloadBuilder = new ConfigPayloadBuilder();
        try {
            ConfigInstanceUtil.getNewInstance(TestNodefsConfig.class, "id0", ConfigPayload.fromBuilder(payloadBuilder));
            assert(false);
        } catch (IllegalArgumentException e) {
            assertEquals("Failed creating new instance of 'com.yahoo.foo.TestNodefsConfig' for config id 'id0'",
                         e.getMessage());
        }
    }