How do I debug bytecode enhanced classes?
I have a project which used DataNucleus. DataNucleus requires that certain classes used with it implement certain interfaces. Since the implementations of these interfaces are boilerplate, DataNucleus offers a bytecode enhancer that can be ran as part of the build process.
I am currently attempting to track down a bug that appears to originate from a pair of methods the enhancer added. However, I cannot step into them in the debugger. It uses my original source file and just puts the cursor at the top of my class.
I tried using the "View->Show Decompiled Class" action, but this does not exist for project files, only for library files. The "View->Show Bytecode" Does correctly find the enhanced bytecode, but I do not know enough about JVM bytecode in order to utilize this.
Also, I tried the "View->Show Decompiled Class" on the .class file from the build output, but Intellij refused to decompile the enhanced classes. Unenhanced class could were decompiled and showed the "Powered by FernFlower Decompiler" comment, but enhanced classes had the "Implementation of methods is not available" comment and, as the comment indicates, no method implementations. This is does not make sense since building FernFlower from source and running from the command line yields properly decompiled sources.
To reiterate, the classes in question are not library classes. They are my own classes that have been modified during compilation such that the original source code is no longer a faithful representation. I have looked into solutions such as attaching FernFlower's decompiled source code while debugging, but everything I've found assumes that the class is part of a library and listed as such in the modules.
Please sign in to leave a comment.
Hi,
please vote https://youtrack.jetbrains.com/issue/IDEA-83442. This is the general case.
In your case IDEA prefers sources over the bytecode because source files are available in the project. You may try adding decompiled sources into a separate module and set it in debug configuration as "use classpath of module" to take sources from there. Also if there are more than one class file with the same class visible in the project, debugger will ask what source to use (alternative source). So you may also try adding your class files again as a jar lib (for example)