[ 
https://jira.codehaus.org/browse/MCOMPILER-228?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robert Scholte updated MCOMPILER-228:
-------------------------------------

    Attachment: MCOMPILER-228.patch

Attaching example as integration test. I've reproduces it with {{Java version: 
1.8.0, vendor: Oracle Corporation}}
I need to verify this with the most recent version of JDK8. If that still has 
the same issue, we'll report it to Oracle.

> 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