Description
Andy Wilkinson opened SPR-11874 and commented
We've hit this problem quite a few times recently with Boot's @ConditionalOnClass
, @ConditionalOnMissingClass
, @ConditionalOnBean
, and @ConditionalOnMissingBean
. They can all take a Class.
If Spring introspects a class or method with one of these annotations and the class that's referenced by the Annotation cannot be loaded it fails with java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
and no information at all about what class could not be loaded. I don't think Spring can do anything about the lack of information about the class, but it could provide clearer information about which class/method was being introspected at the time of the failure.
We (the Boot team) have wondered if Spring should be using ASM-based annotation detection to avoid this problem altogether. An argument against this is that something else in the stack may well fail ungracefully even if Spring doesn't. In the case of the Boot conditions the problem's isolated to @Configuration
classes. Could that reduce the chance of something else failing in a similar way and make it worthwhile to change Spring's behaviour?
Affects: 4.0.5
Reference URL: spring-projects/spring-boot#1065
Issue Links:
- java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy exception when annotation config not found needs to specify what class is not found [SPR-10441] #15074 java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy exception when annotation config not found needs to specify what class is not found
- Regression: Commons Logging setup in AnnotationUtils causes early initialization of logging system [SPR-12329] #16934 Regression: Commons Logging setup in AnnotationUtils causes early initialization of logging system
- Useless exception message when annotations can't be parsed [SPR-12507] #17112 Useless exception message when annotations can't be parsed
- AnnotationUtils provides poor diagnostics if getDeclaredAnnotations throws an exception [SPR-12325] #16930 AnnotationUtils provides poor diagnostics if getDeclaredAnnotations throws an exception