|
Duplicate :
|
|
|
Duplicate :
|
|
|
Relates :
|
The following erroneous code compiles on JDK8:
public class Test {
final int y;
final int z = this.y;
{ y = 1; }
}
If z is instead initialized to 'y', then the appropriate error is given ("variable y might not have been initialized").
This may be related to a javac change for 7004835, whereby 'this.y' (not just 'y') is an "access" to a variable. Of course, since 'this.y' is an access, and the y variable is definitely unassigned at that point, an error is due.
|