You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2019/04/30 16:51:00 UTC
[jira] [Commented] (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:comment-tabpanel&focusedCommentId=16830461#comment-16830461 ]
Eric Milles commented on GROOVY-8978:
-------------------------------------
GROOVY-7996 affected the meaning of "this" for classes within the same module.
> 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
> Priority: Major
>
> 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)