mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-15 21:05:11 +00:00
15 lines
574 B
Java
15 lines
574 B
Java
/*
|
|
* @test /nodynamiccopyright/
|
|
* @summary Verify for() loop variable not effectively final even if loop never increments
|
|
* @bug 8294461
|
|
* @compile/fail/ref=EffectivelyFinalLoopIncrement.out -XDrawDiagnostics EffectivelyFinalLoopIncrement.java
|
|
*/
|
|
class EffectivelyFinalLoopIncrement {
|
|
EffectivelyFinalLoopIncrement() {
|
|
for (int i = 0; i < 10; i++) {
|
|
Runnable r = () -> System.out.println(i); // variable i is NOT effectively final
|
|
break; // even though "i++" is never reached
|
|
}
|
|
}
|
|
}
|