Class in external library shows as "Java compiled bytecode file" instead of normal class

Answered

After upgrading a dependency, I started getting complaints in the IDE that it could not longer resolve the symbol for a class in that JAR. 

When I expand the Java under External Libraries, the class is there but is shown as a “Java compiled bytecode file” instead of a normal class (see picture). 

No amount of IDE repair steps seem to correct this issue. Fortunately, the application still runs fine, but it's going to be troublesome trying to edit classes that use this misunderstood class. Does anyone know what would make this happen?

0
6 comments

Hi Kpilandjr , do you have the source package of this module? not in IntelliJ, but somewhere else like github or other repository where you download the dependencies. If yes, please check the original file and see whether the MatchMode.class is a class file or a java file.

If it's within one version of JDK, please let me know the JDK version or a complete screenshot of the JDK, and let me know the package directory, so I can check at my side, thank you.

0

I just fixed using clearing memory and chache

0

Hi Jerome Guan 

The library in question is from PrimeFaces, which is on GitHub here: https://github.com/primefaces/primefaces

From there, it is in the primefaces module. The odd class is here: https://github.com/primefaces/primefaces/blob/master/primefaces/src/main/java/org/primefaces/model/MatchMode.java

That file is a Java source file for an Enum class. 

I believe the library is available from Maven Central. 

<dependency>
  <groupId>org.primefaces</groupId>
  <artifactId>primefaces</artifactId>
  <version>14.0.7</version>
</dependency>

I should note that version is important as downgrading to 14.0.6, the library does not show this problem. I've heard that 14.0.8 may be released quite soon, so we'll see if the latest has this issue too.

I'm not sure what you're asking with “If it's within one version of JDK” - if what is within one version of what JDK?

My current IntelliJ version is IntelliJ IDEA 2023.1.2. The Boot Runtime for the IDE is 17.0.6+10-829.9-jcef (which is the bundled version).

Please let me know if there is any other information I can provide.

0
For the "Cannot resolve the symbol" issue, please clear the local maven repository (.m2/) and load the maven dependencies again from pom.xml. and see if issue persists or not.
For the "Java compiled bytecode file" issue, since the file is named "MatchMode.class", then it means this file is a compiled file, which is with bytecode format. IDEA provide decompile function, but the class file is still not editable cause it's a .class file not .java file.
0

While I did not remove the entire local maven repository, I did remove the one module in question and reloaded it via Run Maven→Reimport from the project in IntelliJ. This did not correct the issue.

I don't understand your comment about the offending file being a class file. This is a Java module/jar. Pretty much everything in that jar file is a class file. Most are interpreted properly by the IDE. I understand this is not editable. For unknown reasons the IDE shows this (and truth be told a small number of other classes) as a “Java compiled bytecode file” instead of a normal class like everything else. 

After some relatively thorough poking through the library I think I have found the commonality. The files that the IDE displays this way are all enums with a custom constructor. For example the constructor for MatchMode is:

private MatchMode(String operator) {
    this.operator = operator;
}

Is this perhaps throwing off the IDE? I guess it could be somehow related to how the JAR was built too, since the most recent prior version of this dependency is fine and the class is identical.

0

Update: I was finally able to upgrade my IDE to IDEA 2024.2.4 (using its bundled/default JDK) and the problem went away. 

Looks like the bundled JDK is now some version of JDK 21 where I was on JDK 11 before. I'll chalk this up to some combination of how the library was compiled and the older JDK that the IDE was using.

0

Please sign in to leave a comment.