Community
Participate
Working Groups
interface Func1<T1, R> { R apply(T1 v1); void other(); } @FunctionalInterface // spurious error: F1<T, R> is not a functional interface interface F1<T1, R> extends Func1<T1, R> { default void other() {} } or more simply: @FunctionalInterface // spurious error: F2<T, R> is not a functional interface interface F2<T1, R> extends Func1<T1, R> { R apply(T1 v1); default void other() {} } Tested with: Version: Kepler Service Release 1 Build id: 20130919-0819 Eclipse Java Development Tools Patch for Java 8 Support (BETA) 1.0.0.v20140312-1826 org.eclipse.jdt.java8patch.feature.group Eclipse.org
Sorry, my second "more simply" example is misleading. In the straight forward case: @FunctionalInterface interface F3<T1, T2, R> { R apply(T1 v1, T2 v2); default void other() {} } no error is issued. The bug is limited to the case where a default method overrides an abstract method from a super-interface.
I think this is a duplicate of https://bugs.eclipse.org/bugs/show_bug.cgi?id=423467. But I'm not sure how to tell if the fix for that bug, https://github.com/eclipse/eclipse.jdt.core/commit/02ca7d63ca, is included in v20140312-1826.
I've just figured out, from http://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/commit/?id=7aa0f79a30d3f0cc859460c8280e2fb2fbd9665a, that my build does contain the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=423467. The test case from that ticket works okay in my installation. However, this report is slightly different: the abstract method and the overiden default methods are not overloaded. In summary: package scala.runtime.test; // Okay, fixed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=423467 interface I1 { int foo(String s); } @FunctionalInterface interface A1 extends I1 { @Override default int foo(String s) { return -1; } int foo(java.io.Serializable s); } // Spurious "A2 is not a functional interface" // pending https://bugs.eclipse.org/bugs/show_bug.cgi?id=430310 // Okay, fixed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=423467 interface I2 { int foo(String s); } @FunctionalInterface interface A2 extends I2 { @Override default int foo(String s) { return -1; } int bar(java.io.Serializable s); }
I'll take a look. Thanks.
Jason, thanks for the defect report - this is not a recent regression, but a problem that has existed for ever - one can say the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=423467 was incomplete and did not handle all cases it should have handled. I am evaluating a fix.
Changed the title to reflect the real problem. It is not that default methods get counted - the problem stems from the incorrect handling of a non-functional super interface type - we incorrectly conclude subtypes cannot be functional either - which is wrong.
Created attachment 240885 [details] Patch under consideration
All tests are green. Jay is doing some additional testing ...
Thanks for the fast turnaround time, Srikanth! Much appreciated. BTW, the context for this bug is our efforts at Typesafe to create a set of functional interfaces deriving from `scala.FunctionN`. Example usage: https://github.com/retronym/java-8-function1/blob/master/src/test/java/scala/runtime/test/Test.java I temporarily worked around this bug by changing the functional interfaces to a form recognised JDT, and found that everything else is working perfectly, including lambda type parameter inference in arguments to the overloaded `func` method. Well done!
(In reply to Jason Zaugg from comment #9) > Thanks for the fast turnaround time, Srikanth! Much appreciated. > > BTW, the context for this bug is our efforts at Typesafe to create a set of > functional interfaces deriving from `scala.FunctionN`. Example usage: > https://github.com/retronym/java-8-function1/blob/master/src/test/java/scala/ > runtime/test/Test.java Sound interesting. > I temporarily worked around this bug by changing the functional interfaces > to a form recognised JDT, and found that everything else is working > perfectly, including lambda type parameter inference in arguments to the > overloaded `func` method. Well done! Thanks a lot for the feedback - much appreciated.
Pushed the fix via: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=a1df1743aeff71de75237f6e50af470ebbed4600