Title: calling unimplemented method on JyClass(IJava) returns 0, should throw exception
Type: behaviour Severity: urgent
Components: Core Versions: Jython 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: akong, cgroves, fwierzbicki, pjenvey, seanj, zyasoft
Priority: urgent Keywords:

Created on 2010-02-21.08:45:28 by seanj, last changed 2015-01-18.04:54:15 by zyasoft.

msg5544 (view) Author: seanj (seanj) Date: 2010-02-21.08:45:27
# file:

def test_unimplemented_interface():
    from java.lang import Runnable

    class RunMethodNotImplemented(Runnable):

    test_failure = "failure: should have thrown an un-implemented method exception"

        run = RunMethodNotImplemented()
        result =
        # result will be 0, should throw exception
        raise Exception(test_failure)
    except Exception, e:
        if e.message == test_failure:
            raise e

if __name__ == "__main__":
msg5664 (view) Author: Philip Jenvey (pjenvey) Date: 2010-04-11.18:18:14
this is related to #1432 and #1437
msg5745 (view) Author: Jim Baker (zyasoft) Date: 2010-04-26.01:36:13
Deferred to 2.6 - this needs the custom proxy support
msg8506 (view) Author: Jim Baker (zyasoft) Date: 2014-05-21.23:47:12
Time to revisit for 2.7
msg9024 (view) Author: Jim Baker (zyasoft) Date: 2014-09-24.03:36:21
Let's look at the output of the proxy maker for a class implementing Callable:

    public Object call() throws Exception {
        final PyObject findPython = ProxyMaker.findPython((PyProxy)this, "call");
        if (findPython != null) {
            final PyObject pyObject = findPython;
            try {
                return Py.tojava(pyObject._jcallexc((Object[])Py.EmptyObjects), (Class)Class.forName("java.lang.Object"));
            catch (Exception ex) {
                throw ex;
            catch (Throwable t) {
                return null;
        return null;

(See the decompilation example in

That last `return null` is where the problem occurs. Although this is a somewhat big change for existing code, it's an appropriate one and is likely hiding bugs. In particular:

exception NotImplementedError
This exception is derived from RuntimeError. In user defined base classes, abstract methods should raise this exception when they require derived classes to override the method.

This Python-specific exception is likely a better exception than UnsupportedOperationException; in either case, it's derived from RuntimeException
msg9031 (view) Author: Jim Baker (zyasoft) Date: 2014-09-26.04:30:49
This is a breaking change for users, so if it's going in, it has to be in for beta 4 of 2.7.0. Or wait to Jython 3.
msg9086 (view) Author: Jim Baker (zyasoft) Date: 2014-10-06.02:55:57
Related/near duplicate of #1785

Fix for beta 4
msg9327 (view) Author: Jim Baker (zyasoft) Date: 2015-01-07.06:10:56
Must fix before beta 4
msg9352 (view) Author: Jim Baker (zyasoft) Date: 2015-01-08.04:15:42
Fixed as of
Date User Action Args
2015-01-18 04:54:15zyasoftsetstatus: pending -> closed
2015-01-08 04:15:43zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg9352
2015-01-07 06:10:56zyasoftsetpriority: high -> urgent
messages: + msg9327
2014-10-06 02:55:57zyasoftsetmessages: + msg9086
2014-09-26 04:30:50zyasoftsetpriority: high
assignee: zyasoft
resolution: remind -> accepted
messages: + msg9031
2014-09-24 03:36:21zyasoftsetmessages: + msg9024
2014-05-21 23:47:12zyasoftsetmessages: + msg8506
2014-05-21 23:46:56zyasoftsetresolution: later -> remind
2013-02-19 18:45:25fwierzbickisetnosy: + fwierzbicki
versions: + Jython 2.7, - Deferred
2010-05-23 09:45:36akongsetnosy: + akong
2010-04-26 01:36:13zyasoftsetresolution: later
messages: + msg5745
nosy: + zyasoft
versions: + Deferred, - 2.5.1
2010-04-11 18:18:14pjenveysetnosy: + pjenvey
messages: + msg5664
2010-04-11 02:09:47pjenveysetnosy: + cgroves
2010-02-21 08:45:29seanjcreate