You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/05/20 07:32:11 UTC

[jira] [Closed] (GROOVY-8978) NPE when accessing protected method from subclass clone

     [ https://issues.apache.org/jira/browse/GROOVY-8978?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-8978.
-----------------------------

> NPE when accessing protected method from subclass clone
> -------------------------------------------------------
>
>                 Key: GROOVY-8978
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8978
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.6
>            Reporter: paolo di tommaso
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 3.0.0-beta-1, 2.5.7
>
>
> I'm getting a NPE when running this snippet: 
> {code}
> @groovy.transform.CompileStatic
> class LazyMap implements Map<String,Object> {
>     @Delegate protected Map<String,Object> target
>     LazyMap() {
>         target = new HashMap<>()
>     }
> }
> @groovy.transform.CompileStatic
> class TaskConfig extends LazyMap implements Cloneable {
>     TaskConfig() {  }
>     TaskConfig clone() {
>         def copy = (TaskConfig)super.clone()
>         copy.target = new HashMap<>(this.target)
>         return copy
>     }
> }
> {code}
> The problem is that `this.target` in the clone method is evaluated to `null`. It works fine if the classes are not declared CompileStatic. It was also working fine with groovy version prior to 2.5.6. 
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)