Message5766

Author babelmania
Recipients babelmania
Date 2010-05-11.15:57:33
SpamBayes Score 2.8438363e-13
Marked as misclassified No
Message-id <1273593455.03.0.0712737573788.issue1610@psf.upfronthosting.co.za>
In-reply-to
Content
Tested with 2.5.1.  See also issue 1467.

bash$ CLASSPATH=bin jython parameter.py 
Traceback (most recent call last):
  File "parameter.py", line 3, in <module>
    xxx = ParameterImpl(valueType = String)
AttributeError: read-only attr: valueType
---
$ cat parameter.py 
from foo import ParameterImpl
from java.lang import String
xxx = ParameterImpl(valueType = String)
---

This is a result of a base class implementing methods which a derived class inherits at the same time that the derived class implements an interface which has a method with exactly the same name.

---
// *** src/foo/Parameter.java ***
package foo;
public interface Parameter {
    public Class<?> getValueType();
}
// *** src/foo/BareBase.java ***
package foo;

/**
 * This is a baseclass which does NOT implement Parameter
 * @author jbakker
 *
 */
public class BareBase  {

    private Class<?> _valueType;

    public void setValueType(Class<?> type) throws NullPointerException {
        _valueType = type;
    }

    public Class<?> getValueType() {
        return _valueType;
    }

}// *** src/foo/ParameterImpl.java ***
package foo;
public class ParameterImpl extends BareBase implements Parameter {
}
---

workaround:
public abstract class BareBase implements Parameter

(but this is not always possible and I believe the original construct is correct. Also note that it worked under Jython 2.1 and we are not always allowed to change the code)

---

workaround: making the baseclass abstract and  'implements interface'
History
Date User Action Args
2010-05-11 15:57:35babelmaniasetrecipients: + babelmania
2010-05-11 15:57:35babelmaniasetmessageid: <1273593455.03.0.0712737573788.issue1610@psf.upfronthosting.co.za>
2010-05-11 15:57:34babelmanialinkissue1610 messages
2010-05-11 15:57:33babelmaniacreate