SAM conversion of abstracted methods from java.lang.Object

Thomas Jung thomas.andreas.jung at googlemail.com
Wed Aug 25 05:54:47 PDT 2010


Hi,

the SAM type conversion for a type A that abstracts a method from
java.lang.Object

abstract class A{
	@Override public abstract boolean equals(Object object);
}

A a = #(x){true};

does not compile with:
invalid target type A for lambda conversion
		A a = #(x){true};

The analogous definition for a method that is not defined in
java.lang.Object works.

C c = #{"y"};
	
class B{
	String x(){ return "x"; }
}

abstract class C extends B{
	@Override abstract String x();
}

Thomas


More information about the lambda-dev mailing list