FULL PRODUCT VERSION :
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Related to https://bugs.openjdk.java.net/browse/JDK-8051958
If lambda is used as part of enum entry, then bug still occur.
This same code without enum (but still with lambda) works fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just create enum with any FunctionalInterface as any of args.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error:(9, 13) java: cannot assign a value to final variable bug
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
public enum Bugs {
BUG_ONE(() -> {
final Boolean bug;
bug = true;
});
private final Runnable runnable;
Bugs(final Runnable runnable) {
this.runnable = runnable;
}
}
public static void main(final String[] nope) {
Bugs.BUG_ONE.runnable.run();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
compile it with eclipse compiler.
SUPPORT :
YES
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Related to https://bugs.openjdk.java.net/browse/JDK-8051958
If lambda is used as part of enum entry, then bug still occur.
This same code without enum (but still with lambda) works fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just create enum with any FunctionalInterface as any of args.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error:(9, 13) java: cannot assign a value to final variable bug
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
public enum Bugs {
BUG_ONE(() -> {
final Boolean bug;
bug = true;
});
private final Runnable runnable;
Bugs(final Runnable runnable) {
this.runnable = runnable;
}
}
public static void main(final String[] nope) {
Bugs.BUG_ONE.runnable.run();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
compile it with eclipse compiler.
SUPPORT :
YES
- duplicates
-
JDK-8051958 Cannot assign a value to final variable in lambda
-
- Closed
-