Java – Eclipse skips lines when debugging

Eclipse skips lines when debugging… here is a solution to the problem.

Eclipse skips lines when debugging

I’m new to Java and Eclipse and I’ve been trying to debug Android apps on my device. This is a small project with a jar file reference. I read similar questions but it didn’t help.

What I needed was to be able to debug the source code of the jar file, so I attached the source code (which I got using a decompiler) and I was able to get the source code of the library so I think I got it right. But I can’t successfully debug these source codes; In Debug mode, it skips breakpoints (only breakpoints in the source file attached to the jar file), and when I try to “get into code”, it jumps to random lines and skips lines while debugging.

I’m using the latest versions of Eclipse, Android SDK, and JDK. I don’t know what causes this problem, I want to know.

Thanks in advance, I hope I explained adequately.


The problem is, you can’t decompile the class file to debug it. Because the line of the decompiled file will be different from the original Java source code line (imagine: the real source code has some comments and other things that will not be compiled into class files)!

Therefore, if your Eclipse shows you the current debug line, it will only tell you that the debugger will show you the line 42of code file in the 42th class. This does not match the Java source file that you decompiled.

However, you can decompile the class file by using the option to add line numbers as comments . You can compare these line numbers in the comment with the actual stack trace line numbers. This can help you imagine the problem a little.

EDIT: Following Laurent B’s suggestion, you will be able to realign code using JD-Eclipse , see:

Comment +1! 🙂

edit2: If the class file is compiled with the flag -g:none , you will not be able to decompile with the line number. :

Do not generate any debugging information.

So, if that’s the case: try to find the original source code of your jar file!

Related Problems and Solutions