Created
May 5, 2014 00:49
-
-
Save brunoborges/67d6195bbe76f6d68b00 to your computer and use it in GitHub Desktop.
JDK 8 compiler fails if referenced final variable is not being called with "this."
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author bruno.borges@oracle.com | |
*/ | |
public class FooBar { | |
private final String foobar; | |
public FooBar() { | |
foobar = "foobar"; | |
} | |
private final java.util.function.Function ds = n -> { | |
System.out.println(this.foobar); // compiles successfuly | |
System.out.println(foobar); // throws compilation error: "variable foobar might not have been initialized" | |
return foobar; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment