[ 
https://issues.apache.org/jira/browse/GROOVY-11078?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17728991#comment-17728991
 ] 

Eric Milles commented on GROOVY-11078:
--------------------------------------

The field gets null in this case.  I don't believe there are any checks for 
final field initialization.  Assign to final field is only partially handled.

We have explicit tests that declare something like "interface \{ int i \}" and 
make sure "i" gets zero.

> Compiler does not validate final assignment in constructors
> -----------------------------------------------------------
>
>                 Key: GROOVY-11078
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11078
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.12
>            Reporter: Christopher Smith
>            Priority: Minor
>
> The Groovy compiler does not seem to make any attempt to verify that final 
> fields are assigned during object construction, making possible very simple 
> bugs (I added a property but forgot the "this" assignment) that the Java 
> compiler flags. I'm aware that the richness of Groovy expressiveness may make 
> this difficult, but it's frustrating not to have that safeguard.
> {code}
> class Bug {
>     final Object o // and add an explicit constructor if you like
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to