[ 
https://jira.codehaus.org/browse/MCOMPILER-228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=351332#comment-351332
 ] 

Robert Scholte commented on MCOMPILER-228:
------------------------------------------

[JDK9 ea b26|https://jdk9.java.net/download/] can be downloaded. I've confirmed 
that it contains the fix for this issue.

> 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, MCOMPILER-228.patch
>
>
> 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)

Reply via email to