AOT plugin does not recognize static inner classes #671
Comments
Do you mean this is a pattern recognized by the regular |
I haven't yet verified which of the components is the root cause here. Let me try the context indexer standalone. |
There's some interesting observations, I think: In general, it looks like the AOT plugin skips the creation of a |
Isn't it created in for example We should ideally use the same algorithm but due to the AP nature of |
Actually, I prefer what Spring AOT does. Mostly because it's running later than the APT based content indexer and thus can see the class files after a post-processing step (ByteBuddy based adding of annotations in my case). I wonder if Spring AOT should just always create a |
For the original request, it looks like the creation only considers nested classes if they are Spring components, but not any other stereotypes like JPA entities, embeddables etc. |
few things to comment on. Early versions of synthesizing Sebastien and I have talked about turning it ON always. But I honestly am not sure who wins the race condition between having one already existing in your current project and the one Spring Native would generate. It needs checking. If there is an issue, I suppose a temporary substitution on the existing indexer to ask "is spring native around? If so I won't do anything" would avoid that because spring.components is never manually maintained. We can easily extend the model to catch other things, if you can describe to me what they are. That code you linked to Ollie is separate to the code that does the synthesis. And again, written in a way to 'get something going', definitely open to improve for covering more scenarios. |
Great feedback, Andy, thanks. The main difference I found was In the end I'd like to be able to keep I really like that the AOT indexer produces a more complete set of components as – as mentioned above – it allows me to add the annotations it's looking for through byte code manipulation, so that the original code can stay free of technical annotations but the code would still be treated correctly by the infrastructure. I was kind of hoping / assuming that the AOT functionality would – at some point in the future – end up in the Spring Boot build plugin anyway and |
That's my hope as well, I am totally in favor of getting more consistency across the build-time transformations we do but I guess that's a Spring Framework 6 / Spring Boot 3 discussion we need to have with @jhoeller and the wider team. |
Sounds like the simple enhancement first is to get inner classes treated properly. Then we should raise an issue that really evaluates always synthesizing it and working through potential clashes with any existing index. |
I think the code you linked is actually the problem area here, not the synthesis. The synthesis is working, build your project then:
it will contain the inner classes just fine (at least my testcase does...) So it is more about where you linked making decisions about what to do with that afterwards, which is separate to creating the list. |
I don't see this working for RESTBucks. Steps to reproduce:
The annotations on the inner class get added via the Maven ByteBuddy plugin. The log output of that should document the annotations being added. Note how the When I run the build using |
Debugging this closer, you have a point that the code I point to is not the cause for the entries being removed. |
Yep, i do see the rogue call but it doesn't affect my output so clearly something a little more subtle going on, let me dig into it. thanks for the real example code to kick around. |
Refreshing my memory! The reason the removal was occurring is that we don't really wanted nested configuration classes listed. That is because the outer may have conditions on that mean we don't want to process the inner. When processing configurations we dive into the inner after successfully handling the outer. Of course, this was all done before Spring Data was considered. That's why it is breaking down now. So I've modified it so that the filtering only occurs for configuration classes. This allows That's the first part of things. |
hey @odrotbohm how can I test this is doing what you need? I think they are no longer discarded - but I can't build restbucks reliably (even without native-image). I can't get a runnable jar (via |
I think we're fine here. I've upgraded the I think we can definitely resolve this ticket here. Sorry for the confusion about the branches. I guess you have tried the |
In this arrangement, the static inner class is not ending up in the
spring.components
file:Moving the
MyEmbeddable
type into a dedicated file makes it appear.The text was updated successfully, but these errors were encountered: