Neal Gafter has written a prototype closures implementation for Java 6. According to Gafter,
This is binary-licensed under the JRL, but if a JSR is created I expect to license it under GPLv2. There are a few small test cases included.
This prototype supports
- the BGGA function type syntax
- closure literals
- the closure conversion
- the null type, disjunctive types, and exception transparency
- definite assignment
- Unreachable and completion transparency.
- Catching multiple exceptions at once like catch(X1|X2 ex) { ...
[not closely related to closures but the implementation was simple once closures are there]This prototype does not yet support
- a closure using a mutated variable from the enclosing scope
- nonlocal control-flow (break, return, and continue)
- the control invocation statement and loop abstractions
I'm intentionally distributing it before these features are available. The idea is that people can try this version, and compare it to the next version with these features working.