Although other answers prove the requirement, they don’t explain why the requirement exists.
The JLS mentions why in ยง15.27.2:
The restriction to effectively final variables prohibits access to dynamically-changing local variables, whose capture would likely introduce concurrency problems.
To lower risk of bugs, they decided to ensure captured variables are never mutated.
This also applies for anonymous inner classes