Jython inherit from Java class
Kent Johnson
kent at kentsjohnson.com
Mon Feb 13 15:51:29 EST 2006
Mark Fink wrote:
> Hi Kent,
> many thanks for your help! In the meantime I received my "Jython
> Essentials" book and hope that I have much fewer questions in the near
> future.
> One last question for this thread. I tried to inherit from a Java class
> and override on method. I figured that this approach was nonsense
> because the method used private attributes of the Java class. Now I
> read that there is injection used in Jython. Jython uses setter and
> getter methods to do the injection, right? Unfortunately the Java class
> has no setters and getters for the private members. Is there another
> way to override the method besides rewriting the Java class or is this
> approach really doomed?
I don't know what you mean by injection in this context. But Jython has
a property "python.security.respectJavaAccessibility" which may help -
if you set it to false (on the command line or the Jython registry (see
the docs)) then Jython code can access private members of Java objects.
It seems a bit of a hack but it might help you out. Changing the Java
class to make the private members be protected seems like a better fix
if you can do it.
Kent
More information about the Python-list
mailing list