Debugging Jython that's executed within a Java application

Answered

This may be a dumb question, and it may be more of a programming language issue than an IDEA issue, but here goes:

I have a Java servlet that executes some Jython code, and I want to be able to set breakpoints both in the calling Java code and in my Python code. IDEA is happy to stop at my Java language breakpoints, but it does not stop at the breakpoints in my Jython code.

My question is: Is there any hope of making this work? Or must I resign myself to the idea that I'll just need to write and debug my Python code in isolation, plugging it into my servlet when all my unit tests pass.

My understanding is that when I instantiate a Jython interpreter, load my file and execute it, that the Python code gets JIT'ed into JVM bytecode. I'm guessing that the debugger would need some extra information to be able to associate this bytecode with my dynamically-loaded Python source code.

My thanks in advance to anyone who has information or an opinion.

8 comments
Comment actions Permalink

Hello Trent,

I'm not sure if Jython produces enough debugging information for this to
work. If it does, this can be made to work with special support from the
Python plugin (the recent versions of the Ruby plugin do support a similar
debugging experience with JRuby). However, we haven't yet investigated whether
this is actually possible, and I don't think that would fit in our near-term
plans.

This may be a dumb question, and it may be more of a programming
language issue than an IDEA issue, but here goes:

I have a Java servlet that executes some Jython code, and I want to be
able to set breakpoints both in the calling Java code and in my Python
code. IDEA is happy to stop at my Java language breakpoints, but it
does not stop at the breakpoints in my Jython code.

My question is: Is there any hope of making this work? Or must I
resign myself to the idea that I'll just need to write and debug my
Python code in isolation, plugging it into my servlet when all my unit
tests pass.

My understanding is that when I instantiate a Jython interpreter, load
my file and execute it, that the Python code gets JIT'ed into JVM
bytecode. I'm guessing that the debugger would need some extra
information to be able to associate this bytecode with my
dynamically-loaded Python source code.

My thanks in advance to anyone who has information or an opinion.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Dear Support: I'd like to pick this question up again now that it's 2014. I'm using Intellij IDEA 13.0 and wonder if I can have a top-level Java program that invokes Jython code and stop at breakpoints set within the Jython code. -Thanks! -Eric

0
Comment actions Permalink

Dear support,

I was surprised that this did not work, esp. since it lets you set the breakpoint and list it as a python breakpoint. I therefore second the request to improve the situation.

Are there any known alternative methods (like remote debugging with pydevd) that are known to work?

0
Comment actions Permalink

I'm also interested in this.

With PyDev+Ecipse it works like a charm.  This is the only use of Eclipse: debug Jython code.

 

1
Comment actions Permalink

Same here. For my current project, being able to debug Jython is very valuable. Switching to Eclipse just for that is a nuisance. 

0
Comment actions Permalink

@David Perez I have tried to debug a java project which call a jython file with PyDev+Eclipse and it doesn't work like a charm. In fact it seems that pydev remote debuger can not correlate the debug info with the write file. So evev if debugger stop and executes normally the jython program line by line, editor does not highlight the lines neither informs debugger about breakpoints in order to make the execution stop to the breakpoints

0
Comment actions Permalink

Hi! We don't support it at the moment, but this problem requires some investigation. Please create a feature request in our issue tracker: https://youtrack.jetbrains.com/issues/PY

0
Comment actions Permalink

This would be a very useful feature as python is often used as a scripting language within java applications.

 

0

Please sign in to leave a comment.