groovy call private method in Java super class

Posted by Jeff Storey on Stack Overflow See other posts from Stack Overflow or by Jeff Storey
Published on 2010-05-14T14:03:44Z Indexed on 2010/05/14 16:24 UTC
Read the original article Hit count: 348

Filed under:
|
|
|

I have an abstract Java class MyAbstractClass with a private method. There is a concrete implementation MyConcreteClass.

public class MyAbstractClass {
    private void somePrivateMethod();
}

public class MyConcreteClass extends MyAbstractClass {
      // implementation details
}

In my groovy test class I have

class MyAbstractClassTest {

    void myTestMethod() {
        MyAbstractClass mac = new MyConcreteClass()
        mac.somePrivateMethod()
    }
}

I get an error that there is no such method signature for somePrivateMethod. I know groovy can call private methods but I'm guessing the problem is that the private method is in the super class, not MyConcreteClass. Is there a way to invoke a private method in the super class like this (other than using something like PrivateAccessor)?

thanks Jeff

© Stack Overflow or respective owner

Related posts about java

Related posts about groovy