From: Robert W. B. <rb...@di...> - 2001-10-25 20:25:31
|
On Thu, 25 Oct 2001, Andres Corrada-Emmanuel wrote: > On Thu, 25 Oct 2001, Kevin Butler wrote: > > [CC's removed] > > Andres, > > You need to explicitly declare the 'outputTags' attribute as public: > > > > public String outputTags; > > > > Your existing declaration: > > > > > String outputTags; > > > > leaves it 'package-protected' ("friendly"), and subclasses could normally use it just fine, but because Jython attempts to access the attribute from its own package, the field is not visible. > > > > kb > > Okay. I got that working. But this brings me back to my original problem: > I have a Python class that subclasses a Java class in a package. How do I > tell Python that it can access that package's attributes? I was mistaken earlier about saying there's a difference between package private fields and methods. I confused myself into thinking protected attributes. Yes, package private attributes are inaccessible. I do not know of a way to "tell" jython that it can access them other than setting respectJavaAccessibility to false. > When I compile the Python class with jythonc I use the --package option > and can see that the .java file created does have the correct package > statement but I still cannot see the super's attributes. You mean just package private attributes and protected fields, right? You do have access to protected methods and everything public in the superclass. > Isn't that problematic? <opinion> Not really. If you are writing the package, you have the power to use jython-friendly permissions. If someone else wrote the package, chastise them for making users develop in the same package <g> You also have the choice to set respectJavaAccessibility to false. </opinion> -robert > Andres Corrada-Emmanuel > Senior Research Fellow > Center for Intelligent Information Retrieval > University of Massachusetts, Amherst |