Source code doesn't match byte code IntelliJ 15 while debugging
Asked Answered
I

2

6

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.

Intervalometer answered 11/2, 2017 at 13:46 Comment(4)
Are you 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 or obfucsators have changed the target classes during the build process.Sasser
Sometimes it happens when you have newer version of your project in maven, but local version is outdated. Try Settings->Maven->Reimport project and see what happens.Ronnie
Anton, I tried what you mentioned and though I didn't see an option Reimport project, enabled the option Always update snapshot. But there was no success. Earlier I had opened multiple projects built in same repo in a single window of IntelliJ, now I tried to open single project, no success as well.Intervalometer
@CrazyCoder, I went through what you suggested and decompiled jar in my JVM and compared it with my source code. I found that there was a mismatch and then i checked the git branch of the source code and code present in JVM, it was of different git branches of same repo.Intervalometer
S
4

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.

Sasser answered 14/2, 2017 at 9:43 Comment(2)
Is it possible to get byte code from the server debugging on remote with IntelliJ IDEA?Herr
@Herr no, it's not possible.Sasser
G
0

I was just able to solve a problem involving that error message (where the debugger and the code view had wildly different line numbers and so my application was impossible to debug) by switching my SDK in "Project Structure" / "Project Settings" (specifically, from standard "11" to Amazon Corretto 11), then cleaning and recompiling. I do not know why this worked, but since this question is a likely search result for that error message, I am posting this here to help those who find it in the future.

Grandfatherly answered 24/7 at 13:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.