[Ype Kingma]
>In Jython, when subclassing from a Java class, the protected
>attributes of the Java class are not available.
Protected fields are not made available.
Protected methods are normally available from within python subclasses.
One exception exist: final protected methods are not available with the
Class.method syntax, but can be accessed as self.super__method.
>This is different in a Java subclass.
>Why?
Mostly because the actual need haven't been so high. There are also some
technical issues that have to be solved first. The access to a protected
field must occur from with the subclass. In jython that means from the
generated proxy class.
>In case this actually should be changed: which code in the Jython
>source is providing this feature?
For the methods, look at org.python.compiler.JavaMaker.addMethod which
are selecting which method from the java superclass should be available
in the proxy.
For protected fields we would have to create public getter/setter
methods in the proxy class for each field. That must be done in a way
that does not interfere with any existing getter/setter methods.
>I know about the registry entry for accessing protected and private
>attributes, but that is doing too much as I don't need private
>fields.
>
>(I tried to access the protected pySystemState in PythonInterpreter.java
>in a Jython subclass, which didn't work.
>I worked around it by temporarily changing
>the current system's argv while invoking the interpreter.)
Subclassing PythonInterpreter from python? Kinda funny way of using
jython IMHO.
If you wanted to assign some value to sys.argv from PythonInterpreter,
you can call PySystemState.initialize(Properties, Properties, String[])
method. The values in the last string array are assigned to sys.argv.
However, this call will be ignore once the jython runtime is
initialized.
(Perhaps we should consider adding a PythonInterpreter.initialize(..)
method that just calls one of the PySystemState.initialize methods. That
way the initialization methods becomes more visible.)
regards,
finn
|