3

I'm using Jython to write tests for a Java project. It works well, but I can't figure how to get access to a java public nested class.

package mypackage;
public class NyClass {
 public class MyNestedClass {
 ...
 }
}

Does somebody knows how to do this?

asked Oct 31, 2008 at 11:08

1 Answer 1

4

I'm not entirely sure by what you mean by access, but if you after creating instances of the MyNestedClass it's no problem in jython.

In this case, since MyNestedClass is a non-static nested class every instance of it needs a reference to an instance of MyClass. To do this in jython:

import mypackage.MyClass
import mypackage.MyClass.MyNestedClass
outer = mypackage.MyClass()
inner = mypackage.MyClass.MyNestedClass(outer)
answered Oct 31, 2008 at 11:30
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.