Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Not A Problem
-
3.1
-
None
-
None
-
Windows 7 64 bit, Maven 3.2.2, JDK 64 bit 8u5
Description
Code example compiles in Eclipse, but not with Maven Compiler Plugin. Code is like below (inside a lamda expression)
final x; if (some condition) x = a; else if (some other condition) x = b; else x = c;
See attached example source.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project MediaIndexer: Compilation failure: Compilation failure: [ERROR] /C:/MAPS/MediaIndexer/src/main/java/example/FinalExample.java:[11,13] cannot assign a value to final variable compareTo [ERROR] /C:/MAPS/MediaIndexer/src/main/java/example/FinalExample.java:[14,13] cannot assign a value to final variable compareTo [ERROR] /C:/MAPS/MediaIndexer/src/main/java/example/FinalExample.java:[17,13] cannot assign a value to final variable compareTo
The workaround is to remove final for the variable and just ensure that the value is assigned in each code path.
Attachments
Attachments
Issue Links
- is related to
-
MNG-5551 check that everything compile and run fine with Java 8
- Closed