Posts Tagged ‘Closures’

State of the Lambda

Brian Goetz, from Oracle, has posted an updated proposal for the lambda expressions : State of the Lambda
Here are some examples of closures taken from the proposal :
We can use lambda expressions to replace the heavy usage of Single Abstract Method (SAM) interfaces :

public interface CallbackHandler {
public void callback(Context c);
}
 
CallbackHandler cb = { c -> System.out.println("pippo") };

We can …

Java 7 : Add “public defender methods” to Java interfaces

At this time, we aren’t sure that the closures will be included in the Java 7 release. But these doubts have generated a new project : The “public defender methods” proposal.
This new proposal for Java 7 wants to improve the interfaces allowing to add new methods to existing interfaces. The classes implementing the interfaces doesn’t need implements these methods. The implementation of these methods …

Java 7 : Oracle pushes a first version of closures

2 days ago, Oracle pushed a first version of the closures implementation. We can see the evolving syntax in the test cases they made for the Java compiler. You can see these test cases here.
This revision supports the following features (copied from revision) :

Function types syntax
Function types subtyping
Full support for lambda expression of type 1 and 2
Inference of thrown types/return type in a lambda
Lambda …