If you (accidentally in this case) pass an anonymous class to registerType it fails with
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "org.springframework.aot.hint.AbstractTypeReference.getCanonicalName()" is null
at org.springframework.aot.hint.AbstractTypeReference.equals(AbstractTypeReference.java:93)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1214)
at org.springframework.aot.hint.ReflectionHints.registerType(ReflectionHints.java:85)
at org.springframework.aot.hint.ReflectionHints.registerType(ReflectionHints.java:98)
at org.springframework.aot.hint.ReflectionHints.registerType(ReflectionHints.java:120)
This happened to us when trying to use
for (var c : reflections.getSubTypesOf(Converter.class)) {
reflection.registerType(c, memberCategories);
}
and so it happens that Converter contains
public interface Converter<PRESENTATION, MODEL> extends Serializable {
...
static <P, M> Converter<P, M> from(
SerializableFunction<P, Result<M>> toModel,
SerializableFunction<M, P> toPresentation) {
return new Converter<P, M>() {
...
Seems like the org.reflections library returns Converter$2 as one of the sub types, which then fails when passed to registerType.
If you (accidentally in this case) pass an anonymous class to
registerTypeit fails withThis happened to us when trying to use
and so it happens that
ConvertercontainsSeems like the
org.reflectionslibrary returnsConverter$2as one of the sub types, which then fails when passed toregisterType.