Closed
Description
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:
@Component
public record ServiceManager() {}
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:
private static final Set<ElementKind> TYPE_KINDS =
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS, ElementKind.INTERFACE));
IndexedStereotypesProvider:
@Override
public Set<String> getStereotypes(Element element) {
Set<String> stereotypes = new LinkedHashSet<>();
ElementKind kind = element.getKind();
if (kind != ElementKind.CLASS && kind != ElementKind.INTERFACE) {
return stereotypes;
}