[ https://jira.codehaus.org/browse/MCOMPILER-228?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robert Scholte updated MCOMPILER-228: ------------------------------------- Description: Code example compiles in Eclipse, but not with Maven Compiler Plugin. Code is like below (inside a lamda expression) {code} final x; if (some condition) x = a; else if (some other condition) x = b; else x = c; {code} See attached example source. {noformat} [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 {noformat} The workaround is to remove final for the variable and just ensure that the value is assigned in each code path. was: 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. > cannot assign a value to final variable in lamda > ------------------------------------------------ > > Key: MCOMPILER-228 > URL: https://jira.codehaus.org/browse/MCOMPILER-228 > Project: Maven Compiler Plugin > Issue Type: Bug > Affects Versions: 3.1 > Environment: Windows 7 64 bit, Maven 3.2.2, JDK 64 bit 8u5 > Reporter: Robert Kish > Priority: Minor > Attachments: FinalExample.java > > > Code example compiles in Eclipse, but not with Maven Compiler Plugin. Code is > like below (inside a lamda expression) > {code} > final x; > if (some condition) > x = a; > else if (some other condition) > x = b; > else > x = c; > {code} > See attached example source. > {noformat} > [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 > {noformat} > The workaround is to remove final for the variable and just ensure that the > value is assigned in each code path. -- This message was sent by Atlassian JIRA (v6.1.6#6162)