Unable to instantiate a local class within a closure literal

Neal Gafter neal at gafter.com
Wed Jun 18 15:24:55 PDT 2008


Thanks for the report!  This is an interesting one.  I'll look at it
when I resume development.

On Wed, Jun 18, 2008 at 2:06 PM, Mark Mahieu
<mark at twistedbanana.demon.co.uk> wrote:
> Attempting to declare and then instantiate a local class within a closure
> literal fails to compile if that closure literal is not in a static method
> or block:
>
>
> class NotEnclosingClass {
>
>        {=> void} block1 = {=> class Local {}; new Local(); };
>
>        static {
>                // fine here
>                {=> void} block2 = {=> class Local {}; new Local(); };
>        }
> }
>
>
> NotEnclosingClass.java:3: not an enclosing class: <anonymous
> NotEnclosingClass$1>
>        {=> void} block1 = {=> class Local {}; new Local(); };
>                                               ^
> 1 error
>
>
> Regards,
>
> Mark
>



More information about the closures-dev mailing list