How to debug a Java application without access to the source code?

人走茶凉 提交于 2019-12-03 06:58:23

You can probably do this with the help of a combination of jd-eclipse and its extension jd-eclipse realignment fragment.

JD-Eclipse

Realignment fragment

The process for installing this is quite simple:

  • Install JD-Eclipse following the steps provided in the JD-Eclipse site (the process is quite simple)
  • Restart Eclipse
  • Download Realignment realignment.jd.ide.eclipse_1.0.2.jar
  • Copy the file to the \dropins
  • Restart Eclipse
  • Go to Windows -> Preferences
  • Navigate to General -> Editors -> File Associations
  • Select *.class in the File types section, select Realignment for JD Class File Editor in the Associated editors section and click the Default button.
  • Press OK and start debugging!

here is a possible solution:

  1. run the jar with arguments below:

java -agentlib:jdwp=transport=dt_shmem,address=XXXXX,server=y,suspend=n -jar YourJar

  1. run jdb in eclipse using Run->External Tools to connect to the running jvm

jdb -attach XXXXX

  1. set breakpoints using jdb cmd like:

stop at <TheClassName>:<ThePosition>

I will try it when I'm free, will update if it works

updates:

I've figured it out today:

  1. unzip jar file

  2. jdb -sourcepath [unzipped jar path] -classpath [your main class path]

  3. after jdb initializing, excute:

stop at <package>.<yourclass>:<linenunmber>
run <your main class, for example org.springframework.boot.loader.JarLauncher>
  1. after breakpoint triggered, you can step by step debug using jdb command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!