Bug in javac and eclipse ??

Sam Pullara spullara at gmail.com
Tue Jan 21 14:33:14 PST 2014


I think this is similar to the same issue with instance fields, you have to fully specify them. If you use ReferenceProblem.constant (or in the case of instance fields, this.constant) it works. Not sure why the behavior is different.

Sam

On Jan 21, 2014, at 2:23 PM, Remi Forax <forax at univ-mlv.fr> wrote:

> (CC lambda-dev)
> This code do not compile neither with Eclipse nor with javac, but I think that both are wrong.
> 
> public class ReferenceProblem {
>  static class A {
>    public A(Runnable r) { }
>  }
> 
>  static final A constant = new A(() -> {
>    System.out.println(constant);
>  });
> }
> 
> javac talks about 'self reference' but there is no self reference here, a lambda is a delayed computation.
> 15.27.2 only concern local variables, so I don't think this code should be rejected.
> 
> cheers,
> Rémi
> 



More information about the lambda-dev mailing list