Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source code doesn't match byte code IntelliJ 15 while debugging

Tags:

I am facing a issue while debugging Java code in IntelliJ.

I am connected to remote server, Am using Maven to build my project and project is building properly, verified it multiple times.

Every time I insert a debug point, IntelliJ returns an error message "there is no executable code at that point". While some breakpoints are inserted, IntelliJ returns a error message while execution "source code doesn't match byte code".

Tried solution provided in various links like : using synchronize options, invalidate caches, rebuilding and others.

like image 385
Sunil Kumar Avatar asked Feb 11 '17 13:02

Sunil Kumar


People also ask

How do I change the code while debugging in IntelliJ?

From the main menu, select Run | Debugging Actions | Reload Changed Classes.

How do I show debugging in IntelliJ?

By default, the Debug tool window opens when your program hits a breakpoint and is not hidden when the session is terminated. To change this behavior, clear the Show debug window on breakpoint checkbox on the Build, Execution, Deployment | Debugger page of the IDE settings Ctrl+Alt+S .


1 Answers

You need to make absolutely sure that the source code you have in IDE corresponds to the classes loaded in the remote JVM.

It could be that you have some extra jar in the classpath with older class versions that overrides the more recent versions or the code is built without debug info, or some annotation processors/obfuscators have changed the target classes during the build process.

Using javap or a decompiler can help to detect classes that are not in sync.

As you have mentioned in the comment, the code running on the server was from the different git branch than the code you had in IDE. This could be avoided by rebuilding the project in IDE and deploying the actual code to the server.

like image 98
CrazyCoder Avatar answered Sep 22 '22 11:09

CrazyCoder