Variable initialization within closure?

Neal Gafter neal at gafter.com
Thu Jan 15 14:00:58 PST 2009


This sounds like it should be a bug.

On Thu, Jan 15, 2009 at 1:53 PM, Kannan Goundan <kannan at cakoose.com> wrote:

> 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
> initialized
>   }.invoke();
>
>
> 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
> "http://hg.openjdk.java.net/closures/closures/langtools" and ran
> "dist/boostrap/bin/javac -source 1.7".)
>
> - Kannan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20090115/70aa009f/attachment.html 


More information about the closures-dev mailing list