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?
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.