[ 
https://issues.apache.org/jira/browse/GROOVY-2433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17906455#comment-17906455
 ] 

Krzysztof Debski commented on GROOVY-2433:
------------------------------------------

[~emilles] 

Is it also going to be fixed for accessing private fields?

An example that fails but should work fine:
{code:java}
class ClosureWithInheritance {

    static class Parent {
        private Object object = new Object()

        void foo() {
            {
                println object
            }.run()
        }
    }

    static class Child extends Parent {

    }

    static void main(String[] args) {
        new Parent().foo() //works fine
        new Child().foo() //fails
    }
} {code}

> Closure in base class unable to call private methods when invoked from 
> derived class
> ------------------------------------------------------------------------------------
>
>                 Key: GROOVY-2433
>                 URL: https://issues.apache.org/jira/browse/GROOVY-2433
>             Project: Groovy
>          Issue Type: Sub-task
>          Components: groovy-runtime
>            Reporter: David Clark
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-1
>
>         Attachments: testcase.zip
>
>
> Closures defined in base classes are not able to access private methods in 
> the same base class, when invoked from a derived class.  Java visibility 
> rules imply that this should not happen.  When the private methods are made 
> public, the error disappears.  Also, when the closure is converted to a 
> method the problem also disappears.  Compiling and running the TestCase class 
> included (along with Base class) should reproduce the problem.  It's easier 
> to see the problem than to try and describe it.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to