[
https://issues.apache.org/jira/browse/GROOVY-8978?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King resolved GROOVY-8978.
-------------------------------
Resolution: Fixed
Assignee: Paul King
Fix Version/s: 2.5.7
3.0.0-beta-1
Fixed as part of GROOVY-9007. Thanks for spotting the issue.
> 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)