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:
Referenced from: commits 74c878e, 2c0c081, fd809cd
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.TypeNotPresentExceptionProxyand 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
@Configurationclasses. 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:
Referenced from: commits 74c878e, 2c0c081, fd809cd