Skip to content

Align with JDK behavior by throwing TypeNotPresentException during annotation processing #36593

@sbrannen

Description

@sbrannen

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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions