public <T> T getInstance(Class<T> type) {
        T instance = type.cast(instances.get(type));
        if (instance == null) {
            instance = cacheNewInstance(type);
        }
        return instance;
    }
@Test
    void shouldThrowForNonZeroArgPublicConstructors() {
        CucumberException exception = assertThrows(CucumberException.class,
            () -> factory.getInstance(NoAccessibleConstructor.class));

        assertThat(exception.getMessage(), is("" +
                "class io.cucumber.core.backend.DefaultObjectFactoryTest$NoAccessibleConstructor does not have a public zero-argument constructor.\n"
                +
                "\n" +
                "To use dependency injection add an other ObjectFactory implementation such as:\n" +
                " * cucumber-picocontainer\n" +
                " * cucumber-spring\n" +
                " * cucumber-jakarta-cdi\n" +
                " * ...etc\n"));
    }