Closed
Description
Conor Gallagher opened SPR-14198 and commented
As the title suggests, Spring 4.2.5.RELEASE cannot inject into Java 8 default methods via xml context files.
I have thrown together a simple example on GitHub to demonstrate how this fails:
void setSomeDate(LocalDate localDate);
default void setSomeDateInDayMonthYear(String dayMonthYear) {
setSomeDate(LocalDate.parse(dayMonthYear, DateTimeFormatter.ofPattern("dd/MM/yyyy")));
}
An egregious workaround is to reference the default method from the implementation as follows:
@Override
public void setSomeDateInDayMonthYear(String dayMonthYear) {
SomeInterface.super.setSomeDateInDayMonthYear(dayMonthYear);
}
Also referenced on SO:
http://stackoverflow.com/questions/30477367/spring-4-cannot-execute-java-8-default-methods
Affects: 4.2.5
Reference URL: https://github.com/cjbooms/spring-default-methods
Issue Links:
- @Bean on Java 8 default methods in interfaces [SPR-10919] #15547
@Bean
on Java 8 default methods in interfaces - CachedIntrospectionResults should build complete descriptor for setter/getter across interface hierarchy [SPR-16978] #21516 CachedIntrospectionResults should build complete descriptor for setter/getter across interface hierarchy
- CachedIntrospectionResults should use BeanInfoFactory when introspecting implemented interfaces [SPR-16322] #20869 CachedIntrospectionResults should use BeanInfoFactory when introspecting implemented interfaces
Referenced from: commits ce2f28d