Skip to content

Java 8 default methods not detected as bean properties [SPR-14198] #18772

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits ce2f28d

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions