lambda in a static method of an interface (original) (raw)
Brian Goetz brian.goetz at oracle.com
Mon Apr 1 10:07:43 PDT 2013
- Previous message: lambda in a static method of an interface
- Next message: Javac error
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Yes, we're working on this.
On 4/1/2013 12:49 PM, Mike Duigou wrote:
Also present in Mercurial tip unless very recently fixed.
Mike On Apr 1 2013, at 05:04 , Remi Forax wrote:
This code currently compiles but doesn't work at runtime
public interface User { public default String firstName() { return transform(0); } public default String lastName() { return transform(1); } public abstract String transform(int index); public static User User(String firstName, String lastName) { return ref -> (ref == 0)? firstName: lastName; } public static void main(String[] args) { User bob = User("Bob", "Vance"); System.out.println(bob.firstName()); System.out.println(bob.lastName()); } } Exception in thread "main" java.lang.IncompatibleClassChangeError: Class java.lang.String does not implement the requested interface User at User$$Lambda$1.transform(Unknown Source) at User.firstName(User.java:3) at User$$Lambda$1.firstName(Unknown Source) at User.main(User.java:18) I believe it's a bug in javac, the desugared method is not declared static but should: public java.lang.String lambda$0(java.lang.String, java.lang.String, int); BTW, I use the b83 binary build, not the lastest mecurial tip. cheers, Rémi
- Previous message: lambda in a static method of an interface
- Next message: Javac error
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]