Overriding an @Bean method with a narrowed return type is working fine with Spring 3.2.8 on legacy JDKs (6 and 7). However, it's breaking with Spring 3.2.8 on JDK 8. Spring 4.0 on JDK 8 fixes this already, as part of general @Bean overload support. For Spring 3.2.9, we should do a minimal fix for the regression on JDK 8, even if we're not allowing overloaded @Bean methods in the same class yet.
#15653 ConfigurationClass.validate() should allow for overloading in general or not at all
#16341 Metadata reading should never use ASM for java.* and javax.* types (in particular on JDK 8)
It turns out that it's generally worthwhile to ignore bridge methods in our annotation method detection algorithms. As of JDK 8, bridge methods carry the same annotations as the corresponding original methods. However, we always want to operate on original methods anyway, exposing each annotated method just once that way (even on JDK 8).
In Spring Framework 4.x, we allow overloaded @Bean methods in general, simply picking the closest match at runtime. This works fine with the same method registered multiple times, as in our JDK 8 case here. Nevertheless, we should actively exclude bridge methods there as well since it doesn't serve any purpose to consider them, and may lead to subtle runtime differences between JDKs.
I'll apply this bridge method exclusion fix to master and 4.0.x as well since it's a generally worthwhile optimization.
We're also explicitly skipping introspection on java.* classes since we'll never find @Bean annotations there anyway. Previously, we optimized their introspection through always using reflection instead of ASM. However, it's actually pointless to even go that far since we'll never find Spring annotations there in the first place.