We still need to figure it out but it looks like the nested class detection can be faulty. This can be reproduced by running BindableRuntimeHintsRegistrar against RabbitProperties, there is no metadata for org.springframework.boot.autoconfigure.amqp.RabbitProperties$SimpleContainer.

Comment From: omercelikceng

@snicoll. Hello, thank you very much for your development. A truly useful and important development. However, there are some points I don't understand. I'm a newbie at this and I'm trying to learn. The documents I read may not be up to date or I may have misunderstood. Please excuse me. Please help me understand.

Your development solves the problem of the classes we register using the BindableRuntimeHintsRegistrar class. However, when I reviewed the RabbitProperties class, it was not registered using the BindableRuntimeHintsRegistrar class. The annotations that enable the RabbitProperties class to be registered are @ConfigurationProperties and @EnableConfigurationProperties.

Then I read the spring documentation. I read that configuration classes are automatically saved in reflection hints.(@ConfigurationProperties) But nested configurations cannot be registered for configuration classes. In order to register nested classes, we need to add the @NestedConfigurationProperty annotation.

Documentation Link : https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-hints

Documentation Photo : NestedProperty

In other words, nested classes of the RabbitProperties class are not saved in hints. However, I looked into the RabbitProperties class. It does not contain any nested classes. It contains only inner class. Therefore, there is no hints registration problem for the RabbitProperties class.

But I have a question for you. Suppose the RabbitProperties class contains a nested class.Then we would have to add the @NestedConfigurationProperty annotation, right? Or we should have registered using the BindableRuntimeHintsRegistrar class, right? I ask my questions to understand the subject. Please excuse me.

Comment From: snicoll

However, when I reviewed the RabbitProperties class, it was not registered using the BindableRuntimeHintsRegistrar class.

It is. See ConfigurationPropertiesBeanFactoryInitializationAotProcessor.

Suppose the RabbitProperties class contains a nested class.

It does have many.

Then we would have to add the @NestedConfigurationProperty annotation, right?

No. That's the whole point of BindableRuntimeHintsRegistrar, it understands the configuration properties semantic and is able to crawl to the right sub-type the same way the binder does.

In short, you're mistaken and configuration properties are handled by BindableRuntimeHintsRegistrar. Going forward, you can ask that sort of questions on Gitter as we prefer to leave the issue tracker for bugs and request for new features only.

Comment From: omercelikceng

@snicoll I reviewed class ConfigurationPropertiesBeanFactoryInitializationAotProcessor. And I understood what you said. Thank you. But then isn't the document wrong?

The Spring documentation says: . Nested configuration properties which are not inner classes, however, must be annotated with @NestedConfigurationProperty, otherwise they won't be detected and will not be bindable. (@ConfigurationProperties)

But with the update you made, nested configurations are automatically registered. If what I think is true, should I open an issue to update the document? Or should I discuss it in gitter?

Comment From: snicoll

The documentation states the exact same thing. Those are inner classes don’t they?

Comment From: omercelikceng

@snicoll I understand that thanks to your development, nested configuration properties which are not inner classes will be registered automatically.((@ConfigurationProperties)) Thanks to your development, we will not need to add the @NestedConfigurationProperty annotation.

However, the documentation says "nested configuration properties which are not inner classes cannot be detected , so you must add the @NestedConfigurationProperty annotation for nested configuration properties which are not inner classes.." Please excuse me for keeping you busy.

I reviewed your test. Let's say we update your test in your commit as in the example below. Then, would these classes(Simple, ListenerRetry, Retry) be registered to hint automatically? (Without @NestedConfigurationProperty annotation) Or do I have to add the @NestedConfigurationProperty annotation for my example below so that it automatically registers with the hint?

public class ComplexNestedProperties {
    private Simple simple = new Simple();
    public Simple getSimple() {
        return this.simple;
    }

}

public class ListenerRetry extends Retry {
    private boolean stateless;
    public boolean isStateless() {
        return this.stateless;
    }
    public void setStateless(boolean stateless) {
        this.stateless = stateless;
    }
}

public abstract class Retry {
    private int count = 5;
    public int getCount() {
        return this.count;
    }
    public void setCount(int count) {
        this.count = count;
    }
}
public class Simple {
    private ListenerRetry retry = new ListenerRetry();
    public ListenerRetry getRetry() {
        return this.retry;
    }
}

Which of the following did your commit solve for automatic registration to hint? I want to understand this situation. 1- Inner classes registration 2- Nested configuration properties which are not inner classes(Example above) 3- Both