As discussed in https://github.com/oracle/graal/issues/5073, our session-jdbc AOT smoke test sample currently registers reflection entry for org.springframework.jdbc.datasource.embedded.EmbeddedDatabase#shutdown instead of org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory$EmbeddedDataSourceProxy#shutdown.

It comes from EmbeddedDataSourceConfiguration and the inference is done here. The reflection registration on the class instance is needed to make it work on GraalVM 22.3 (we are not sure why that does not break on 22.2).

By design, we can't know the concrete type of the EmbeddedDatabase without instantiating the bean which is not possible at AOT stage I think. So for this case, Spring Boot should probably register reflection hints for EmbeddedDatabaseFactory$EmbeddedDataSourceProxy#shutdown when EmbeddedDataSourceConfiguration is involved.

Comment From: wilkinsona

Boot's calling EmbeddedDatabaseBuilder and its use of EmbeddedDatabaseFactory is an implementation detail. EmbeddedDataSourceProxy is then a private class that's an implementation detail of EmbeddedDatabaseFactory. Given that it's private API and Boot's two levels of abstraction away from EmbeddedDataSourceProxy, I don't think it's the right place to be registering the hint or perhaps a change could be made so that the hint isn't needed at all.

If we go down the hint route, I think it should either happen directly in Framework (although it may not be possible to determine that an EmbeddedDatabase built by EmbeddedDatabaseBuilder is going to be exposed as a bean and require reflective access to its shutdown method) or Framework should provide an API to register the hint that Boot can call so that it's not hardcoding details of Framework's internals.

If we want to avoid the hint route, I wonder if EmbeddedDatabase could be changed to implement DisposableBean so that the reflection-based adapter that calls shutdown would not be necessary.

Comment From: sdeleuze

I think you are right, we should be able to support this on Spring Framework side, I will have a deeper look on which option is better.