Message5389

Author markku_hanninen
Recipients markku_hanninen
Date 2009-12-21.13:34:57
SpamBayes Score 2.69333e-10
Marked as misclassified No
Message-id <1261402499.45.0.477614349833.issue1528@psf.upfronthosting.co.za>
In-reply-to
Content
This is how to reproduce the problem:

GenJavaErr.java:

public class GenJavaErr {
    static public void genErr() throws Exception {
        Exception ex = new Exception("Exception from java");
        ex.printStackTrace();
        throw ex;
    }
}

errtest.py:

#!/usr/bin/env jython

import GenJavaErr

def err():
    GenJavaErr.genErr()

    return "Dummy return"


err()

[hmm@bombadil jythontest]$ javac GenJavaErr.java 
[hmm@bombadil jythontest]$ jython errtest.py
*sys-package-mgr*: can't create package cache dir,
'/opt/jython2.5.1/cachedir/packages'
java.lang.Exception: Exception from java
	at GenJavaErr.genErr(GenJavaErr.java:3)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:175)
	at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	at org.python.core.PyObject.__call__(PyObject.java:381)
	at org.python.core.PyObject.__call__(PyObject.java:385)
	at org.python.pycode._pyx0.err$1(errtest.py:8)
	at org.python.pycode._pyx0.call_function(errtest.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:117)
	at org.python.core.PyFunction.__call__(PyFunction.java:307)
	at org.python.pycode._pyx0.f$0(errtest.py:11)
	at org.python.pycode._pyx0.call_function(errtest.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1204)
	at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:200)
	at org.python.util.jython.run(jython.java:246)
	at org.python.util.jython.main(jython.java:129)
Traceback (most recent call last):
  File "errtest.py", line 11, in <module>
    err()
  File "errtest.py", line 6, in err
    GenJavaErr.genErr()
	at GenJavaErr.genErr(GenJavaErr.java:3)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)

java.lang.Exception: java.lang.Exception: Exception from java


Notice here how the Java-exception has line:
	at org.python.pycode._pyx0.err$1(errtest.py:8)
But the actual call is:
  File "errtest.py", line 6, in err

Actually in java the reported line is always the last line of the
method/function. This is a problem in our system which has long call
chains and the error handler doesn't have the python exception available
so we don't really know on what line the call was.
History
Date User Action Args
2009-12-21 13:34:59markku_hanninensetrecipients: + markku_hanninen
2009-12-21 13:34:59markku_hanninensetmessageid: <1261402499.45.0.477614349833.issue1528@psf.upfronthosting.co.za>
2009-12-21 13:34:59markku_hanninenlinkissue1528 messages
2009-12-21 13:34:57markku_hanninencreate