let's play TDD, tackles closures in java

tom.hawtin at oracle.com tom.hawtin at oracle.com
Wed Dec 15 10:20:20 PST 2010

On 15/12/2010 17:46, Llewellyn Falco wrote:
> Not sure if you guys are paying attention to James Shore's "Let's play TDD"
> series, but the other day he handled closures in a very common scenario of
> swing.
> again, ran into the issue of "final local variables"
> http://jamesshore.com/Blog/Lets-Play/Episode-67.html

(At 10:50 in the video.)

Generally you would use a general purpose java.lang.reflect.Proxy 
solution (perhaps from some random mocking/test library).

The long, special-purpose way around, using anonymous inner classes (or 
local classes), is actually rather easy.

     new XyzListener() {
         private boolean fired;
         public void event(XyzEvent event) {
             fired = true;


More information about the lambda-dev mailing list