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 2021/03/17 03:36:00 UTC

[jira] [Assigned] (GROOVY-7686) Can not see local variable from overriden method called from the constructor of an anonymous class instance

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

Eric Milles reassigned GROOVY-7686:
-----------------------------------

    Assignee: Eric Milles

> Can not see local variable from overriden method called from the constructor of an anonymous class instance
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7686
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7686
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, groovy-runtime
>    Affects Versions: 2.4.5
>         Environment: Linux
>            Reporter: Roman Saveljev
>            Assignee: Eric Milles
>            Priority: Major
>
> Reduced code showing the problem: https://gist.github.com/RomanSaveljev/71ed29b0df3eb306485c
> In the runtime it fails with:
> {noformat}
> Caught: java.lang.NullPointerException
> java.lang.NullPointerException
> 	at bug$1.func(bug.groovy:14)
> 	at A.<init>(bug.groovy:3)
> 	at bug$1.<init>(bug.groovy)
> 	at bug.func(bug.groovy:11)
> 	at bug.run(bug.groovy:22)
> {noformat}
> It happens, because inside the overriden method it tries to access locally defined {{t}}. I have translated the same code to Java (see the gist) and it works as expected.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)