Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-14198

Java 8 default methods not detected as bean properties

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 4.2.5
    • Fix Version/s: 4.3 RC2
    • Component/s: Core
    • Labels:
      None

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              cjbooms Conor Gallagher
              Last updater:
              Spring Issuemaster
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 40 weeks, 6 days ago