2

I'm looking for a tool for debugging and stepping through Java Bytecode, with visualizing of the basic JVM state, including the operand stack and the local variables array, merely for educational purposes and JVM learning (for myself, and hopefully for others as well). Is there such a tool at hand?

I came across the Bytecode Visualizer Eclipse plugin by Dr. Garbage, which allows breaking on and stepping through Bytecode, but it doesn't visualize the JVM state:

http://www.drgarbage.com/bytecode-visualizer

The following related questions (quite old) mention a few tools, some of which allow stepping through Bytecode, but none with JVM state visualization:

Is there such a tool at hand, that is capable of debugging simple Java programs? Or even a simple JVM simulator?

Thanks!

6
  • JC decompile plug-in for eclipse may be of helpful..Nut i don't think it will provide visualization of JVM state Commented Jun 1, 2017 at 13:28
  • Thanks @pragadez - the JVM state visualization is really the piece I'm missing. Cheers Commented Jun 1, 2017 at 14:15
  • The debug interface of an ordinary JVM doesn’t support reading the operand stack. Commented Jun 1, 2017 at 17:44
  • Thanks @Holger, that's good affirmation... I guess it means that some form of simulation of the operand stack is needed, for visualizing it. Commented Jun 1, 2017 at 17:54
  • FYI, there's a new project on Github called MiniSpot, that aims to be an educational JVM based on HotSpot VM, and uses JNI (it seems in very early development). Seems very interesting but not quite what I'm after, although it may be a good place to implement operand stack modeling etc. Commented Jun 3, 2017 at 8:45

1 Answer 1

3

I've adapted the PyJVM to do what you are after. It shows a simple gui for each thread of the Java program (they have to be compiled for Java7).

The only issue with this tool is that it doesn't have a GC, since garbage collection is handled by Python itself. Therefore, the Thread 1 (daemon) (the reference handler) will not ever do anything. Finalize method also won't trigger.

Source is available on https://github.com/MatevzFa/pyjvm (warning: the source code isn't very nice to look at), you can also install it with pip (pip2 actually, since PyJVM is written in Python2).

Install:

pip install pyjvmgui

Upgrade:

pip install pyjvmgui --upgrade --no-deps

I stil have to write a good README for it.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Matevž, it sounds great, but unfortunately I wasn't able to run it. pip2 install pyjvmgui resulted with: ImportError: No module named pyjvm_util.globals, and trying to run pava from cloned sources failed since java.py is missing.
Hello, I have patched the install script. If you want to run from sources, run the pyjvmgui.py script.
Thank you Matevž, it is working now. Just what I was looking for!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.