Overview
While working on #36586, we noticed that we use ClassUtils.resolveClassName() in TypeMappedAnnotation.adapt(...) which throws an IllegalStateException or IllegalArgumentException if a type referenced by an annotation attribute cannot be loaded. I also noticed that we have similar behavior in MergedAnnotationReadingVisitor and ClassFileAnnotationDelegate.
However, if such an error occurs while using the JDK's reflection APIs, a TypeNotPresentException is thrown instead.
We should therefore align with the standard behavior of the JDK and throw a TypeNotPresentException in such scenarios.
Related Issues