-
Notifications
You must be signed in to change notification settings - Fork 37.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spring-context-indexer doesn't support Java records #26909
Comments
I wonder why you would want to declare a record as a Spring-managed bean to begin with? Our notion of a "managed bean" seems strongly bound to traditional object semantics, including instance identity and access to delegates. Are records ever a good fit there? Now, if you're arguing that this is a mismatch between the indexer and runtime component scanning, we should indeed align the behavior there. Even if not a recommended choice of component type, consistently detecting annotated record classes is certainly better than inconsistent runtime behavior. |
I've locally refined those checks to |
@jhoeller Thank you for the quick response. I guess Java records is rather new feature (which was declared stable only in JDK 16) so there' no so much best practices around it. |
So I will understand if you remove Java records support at all. But it looks like inconsistent behavior now. |
Spring version: 5.3.6
JDK: 16.0.1
It seems that spring-context-indexer library doesn't support Java records. If I declare a record as Spring bean:
then META-INF/spring.components doesn't contain entry for this type. And Spring fails to load it during startup. I looked into source code and the following blocks seem to responsible for that:
CandidateComponentsIndexer:
IndexedStereotypesProvider:
The text was updated successfully, but these errors were encountered: