Community
Participate
Working Groups
interface FIOther<T> { <M> FIOther<T> run (M x); } public class TestOther { FIOther<String> fi1 = new FIOther<String>() {public <M> FIOther<String> run(M x) {return null;}}; } Convert the error free code to lambda expression with quick fix. See the syntax error message : Illegal lambda expression: Method run of type FIOther<String> is generic TestOther.java /_pasted_code_/src line 6 Java Problem
Here is another example: I.java // -- package p1; public interface I { void foo() throws packagePrivateException; } class packagePrivateException extends RuntimeException { } // X.java import p1.I; public class X { public static void main(String[] args) { I i = new I() { @Override public void foo() { } }; } } // conversion results in: "The type packagePrivateException from the descriptor computed for the target context is not visible "
Here is another case where conversion results in loss of information leading to breakage: import java.util.List; interface I<T> { void goo(List<T> i); } public class X { public static void main(String[] args) { I i = new I<String>() { @Override public void goo(List<String> k) { String s = k.get(0); } }; } }
Annotations are lost in this example: // -- interface I { void goo(String ... strings); } public class X { public static void main(String[] args) { I i = new I() { @Override public void goo(@T String ... k) { } }; } } @interface T { }
All the comments here represent different bugs resulting in incorrect conversion to lambda. I will create separate bug reports for each.
Closing as separate bug reports are created for the issues mentioned here.