A DESCRIPTION OF THE PROBLEM :
At the last paragraph of accessing local variables section, (right above the 'target typing' section), the doc says 'FirstLevel.x' is not effectively final anymore. But the assignment is done to the parameter. Also last sentence says 'myConsumer tries to access FirstLevel.x variable', this is wrong, it tries to access the parameter x.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the parameter x is not effectively final anymore
and
myConsumer tries to access parameter x
ACTUAL -
Because of this assignment statement, the variable FirstLevel.x is not effectively final anymore. As a result, the Java compiler generates an error message similar to "local variables referenced from a lambda expression must be final or effectively final" where the lambda expression myConsumer tries to access the FirstLevel.x variable:
System.out.println("x = " + x);
URL OF FAULTY DOCUMENTATION :
https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html#accessing-local-variables
At the last paragraph of accessing local variables section, (right above the 'target typing' section), the doc says 'FirstLevel.x' is not effectively final anymore. But the assignment is done to the parameter. Also last sentence says 'myConsumer tries to access FirstLevel.x variable', this is wrong, it tries to access the parameter x.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the parameter x is not effectively final anymore
and
myConsumer tries to access parameter x
ACTUAL -
Because of this assignment statement, the variable FirstLevel.x is not effectively final anymore. As a result, the Java compiler generates an error message similar to "local variables referenced from a lambda expression must be final or effectively final" where the lambda expression myConsumer tries to access the FirstLevel.x variable:
System.out.println("x = " + x);
URL OF FAULTY DOCUMENTATION :
https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html#accessing-local-variables