I have a project with several .java
files that I can view the source of perfectly in IntelliJ, except for one.
That file is a .java
file like the others, but IntelliJ labels it a "Decompiled .class file" and the source is completely empty. If I open the file in a text editor, I can see the source just fine. Ant builds also work fine with this file.
These are not JDK sources that are missing, where you might expect to see decompiled code. And this is not a compiled .class
file I'm opening, either.
Deleting the file from the project and updating from source control to restore it doesn't seem to help.
Here is what it looks like when I try to open the file in IntelliJ:
What might cause this behavior in IntelliJ and what can I do to fix it?
A Java Decompiler is a special type of decompiler which takes a class file as input and produces Java source code as output. The decompilation is exactly the reverse process of compilation. Thus, decompiler does not produce a replica of the source code.
zip to IntelliJ IDEA. 2.2 Platform Settings -> SDKs -> Select Sourcepath -> plus icon -> select src. zip from the JDK installed path. 2.3 Done.
I did end up solving my issue.
Somehow, I inadvertently added that individual file's name to the Java Class File Types
list, and so that file was associated as a decompiled .class files in the same way an actual .class file is.
The fix is going to Settings (Ctrl+Alt+S)
⇒ Editor
⇒ File Types
, scrolling down to Java Class in the list of Recognized File Types
, selecting the file name in the list of Registered Patterns
, and clicking the Remove
button.
I did not figure out how it was automatically added to that list. One guess is that I may have accepted a suggestion pop-up or selected the wrong Intention Action, and so the name of the open or active file was added to the .class type list.
If the same class (comparing fully qualified name) is both existing in your project and simultaneously coming from a 3rd party dependency at times IntelliJ will get confused.
This happens also for dependencies if you have the decompiled class open in a editor window and press "Download Sources" action. This results in another editor window opening the just downloaded source code for the same class and IntelliJ navigation going bonkers (Ctrl + Left click
jump and other actions).
The only solution I know of is to restart IntelliJ and hope that it works. You can also try File > Invalidate Caches and Restart
which will force IntelliJ to re-index the world.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With