lambda in a static method of an interface

Remi Forax forax at
Mon Apr 1 05:04:24 PDT 2013

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");

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(
     at User$$Lambda$1.firstName(Unknown Source)
     at User.main(

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, 

BTW, I use the b83 binary build, not the lastest mecurial tip.


More information about the lambda-dev mailing list