Notes/Discussion/Decisions on having PySequence implement java.util.List...

Topics


Topic: InitModule BR Anchor(initmodule) ClarkUpdike Feb 26 2005 BR PySequence excerpt:

/**
 * The abstract superclass of PyObjects that implements a Sequence.
 * Minimize the work in creating such objects.
 *
 * Method names are designed to make it possible for PySequence to
 * implement java.util.List interface when JDK 1.2 is ubiquitous.
 *
 * All subclasses must declare that they implement the ClassDictInit
 * interface, and provide an classDictInit() method that calls
 * PySequence.classDictInit().
 *
 * Subclasses must also implement get, getslice, and repeat methods.
 *
 * Subclasses that are mutable should also implement: set, setslice, del,
 * and delRange.
 */

// this class doesn't "implement InitModule" because otherwise
// PyJavaClass.init() would try to instantiate it.  That fails because this
// class is abstract.  TBD: is there a way to test for whether a class is
// abstract?
abstract public class PySequence extends PyObject {
    /**
     * This constructor is used by PyJavaClass.init()
     */
    public PySequence() {}

Sure there's a way to do it using reflection, and looking at public PyObject __call__(PyObject[] args, String[] keywords) shows that there is already implemented and that an error is reported if called on an abstract class. Does this mean PySequence should now implement InitModule, or actually ClassDictInit since InitModule is deprecated?

Then, consider the comment that says "All subclasses must declare they implement ClassDictInit interface and provide an classDistInit() method that calls PySequence.classDictInit()". If you look at PyList, it doesn't implement ClassDictInit, but it does have a public static void classDictInit(PyObject dict) method. However, it is an empty method that doesn't call PySequence.classDictInit().

Either: