Issue1528

classification
Title: Stack traces have incorrect line numbers when viewed inside java
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, markku_hanninen, zyasoft
Priority: normal Keywords:

Created on 2009-12-21.13:34:59 by markku_hanninen, last changed 2013-02-26.19:00:58 by fwierzbicki.

Messages
msg5389 (view) Author: Markku Hänninen (markku_hanninen) Date: 2009-12-21.13:34:57
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
2013-02-26 19:00:58fwierzbickisetpriority: normal
2013-02-26 19:00:47fwierzbickisetnosy: + fwierzbicki
2013-02-20 18:58:57fwierzbickisetversions: + Jython 2.5, - 2.5.1
2010-08-15 14:49:10zyasoftsetnosy: + zyasoft
2009-12-21 13:34:59markku_hanninencreate