[ https://issues.apache.org/jira/browse/GROOVY-7686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-7686. --------------------------------- Fix Version/s: 4.0.0-alpha-3 Resolution: Fixed > 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 > Fix For: 4.0.0-alpha-3 > > Time Spent: 0.5h > Remaining Estimate: 0h > > 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)