Variable initialization within closure?

Kannan Goundan kannan at
Thu Jan 15 13:53:05 PST 2009

I'm not sure if this behavior is defined by the spec or a bug in the
"javac" prototype:

   int x;
   { =>
      x = 1;
      System.out.println(x);  // javac: variable x might not have been

I realize that 'x' shouldn't be considered definitely assigned after
the closure.  But it seems unintuitive that 'x' would not be
definitely assigned inside the closure as well.

(I compiled code from
"" and ran
"dist/boostrap/bin/javac -source 1.7".)

- Kannan

More information about the closures-dev mailing list