Message808

Author leouserz
Recipients
Date 2007-01-16.16:28:57
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
It seems that the problem is that the proxy has not been initialised/set yet on the javaproxy.  When a method is accessed in this state, it accesses jgetattr in Py:
    public static PyObject jgetattr(PyProxy proxy, String name) {

        PyInstance o = proxy._getPyInstance();

        PyObject ret = null;

        if (o != null) {

            ret = o.__jfindattr__(name);

        }

        if (ret == null)

            throw Py.AttributeError("abstract method \""+name+

                                    "\" not implemented");

        // Set the current system state to match proxy -- usually this is a

        // waste of time :-(

        Py.setSystemState(proxy._getPySystemState());

        return ret;

    }


Since o, will be null at this point it bombs.  Initialisation happens after the super class constructors have been invoked.  But, in jgetattr's sister method, jfindattr it appears to recognise this as a reality and enforces suitable counter measures:
    public static PyObject jfindattr(PyProxy proxy, String name) {

        PyInstance o = proxy._getPyInstance();

        if (o == null) {

            proxy.__initProxy__(new Object[0]);

            o = proxy._getPyInstance();

        }

        PyObject ret = o.__jfindattr__(name);

        if (ret == null)

            return null;



        // Set the current system state to match proxy -- usually

        // this is a waste of time :-(

        Py.setSystemState(proxy._getPySystemState());

        return ret;

    }


jgetattr is only invoked it appears when the superclass is abstract.  The code generated in ProxyMaker.addMethod.  The patch I am putting together will follow jfindattr in initilising the proxy if its instance is null.  From looking at the test case this allows the method to work in the abstract class.  Also, testing in a class that does not override the abstract method results in the AttributeError(as it should).  Maybe sometime in a future VM spec, having to call the constructor right off the bat will no longer be the rule and we can initialise the proxies first....

leouser
History
Date User Action Args
2008-02-20 17:17:13adminlinkissue663592 messages
2008-02-20 17:17:13admincreate