-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Minas Manthos opened SPR-9233 and commented
Since 3.1.1 the AbstractRecursiveAnnotationVisitor logs a warning when annotation class could not be loaded (see AbstractRecursiveAnnotationVisitor#logNonFatalException). Until 3.1.0 any Exception was catched without any message. I agree to log this but IMO this should be a debug log message. Annotations (even if RetentionPolicy.RUNTIME) may or may not be available at run-time. See also Java Language Specification:
9.6.1.2 Retention
Annotations may be present only in the source code, or they may be present in the binary form of a class or interface. An annotation that is present in the binary may or may not be available at run-time via the reflective libraries of the Java platform.
...
So there is nothing wrong about getting a ClassNotFoundException regarding annotations.
I suggest to change the log level to debug or (IMO better) to catch ClassNotFoundException -> logger.debug(...) because it's legitimate and any other Exception -> logger.warn(...).
Background: We currently use jsr305 with @javax
.annotation.Nonnull and @javax
.annotation.Nullable doing some code analyses during builds. At run-time these annotations are no longer available/needed and we get tons of warnings ??"Failed to classload type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable."??. Of course, it's not a problem to workaround this: we can include jsr305 or change log level in config of this logger but IMO I should not get a warning when everything is like expected and JLS-compliant.
Affects: 3.1.1
Sub-tasks:
- Backport "Reduce log level for message re: missing annotation" [SPR-9447] #14082 Backport "Reduce log level for message re: missing annotation"
Issue Links:
- @ComponentScan with includeFilters on @Import-ed context does not work [SPR-9031] #13670
@ComponentScan
with includeFilters on@Import-ed
context does not work
Referenced from: commits c25a1bc, f55a4a1
6 votes, 7 watchers