1

When I build files using gradle in intellij and run in debug mode I can set breakpoints and step by step debug application. I'm wondering how that is possible if sources are compiled into classes? In web development we have something called source maps, is it something like that in Java world?

1
  • 1
    You can decompile your Java code, either you can use some external tool like JDGUI or you can use some IDE plugin. I don't know Intellij-idea, but in Eclipse you can attach the sources while debugging. Nov 29, 2014 at 9:56

1 Answer 1

2

Two solutions:

  • attach sources to the compiled Java code; if you use a build tool like gradle or maven, your IDE will generally download the sources along with the "binary jar", so you will be able to set breakpoints even in this case; otherwise you can attach sources manually (be sure to match the source and binary versions in this case!);
  • IDEA 14.+ has a builtin decompiler if you don't have the sources; you can use the result of decompilation and set breakpoints.

IDEA can do point 1 and @Michal says Eclipse can, too; I suspect NetBeans allows this too. As to point 2 I only know about IDEA.

7
  • Thanks! Actually my question was dictated by that issue. I'm using Android Studio to debug and I'm wondering whether it already has everything for the option 2 that you specified, any idea how to check that? Nov 29, 2014 at 16:43
  • Huh, no idea... I don't do Android ;) Can't you attach sources?
    – fge
    Nov 29, 2014 at 17:05
  • Sorry, what sources? Attach here? Nov 29, 2014 at 17:11
  • 1
    Ah, sorry, then I misunderstood the problem. Are you positive that this breakpoint should be hit? Are you sure that those are the correct sources you link to?
    – fge
    Nov 29, 2014 at 17:12
  • yeah, it is definitely hit because I can see variable's values. Actually, the more interesting part starts from Update - new findings - have you read that one? Nov 29, 2014 at 17:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.