Compilation error in editor only: Cannot access java.lang.Record

Answered

Hello,

I've encountered an issue in IntelliJ Editor where 'Cannot access java.lang.Record' compilation error occurs (highlighted with a red underline). But this error only appears in the editor and not during Gradle or IntelliJ builds, both of which run successfully.

The project is built using Java 11, while the library triggering this error is built using a newer version of Java. Strangely, the Gradle build is unaffected otherwise. Another notable point is that I'm unable to open the source file containing the 'Record' statement in the editor at all. Clicking on this file in 'External Dependencies' within the Project window yields no response.

I found this Stack Overflow ticket (link: https://stackoverflow.com/questions/38549649/java-cannot-access-class-class-file-not-found), but it didn't help. I can temporarily solve the issue by manually duplicating the incriminated JAR file and placing it above the one that triggers the issue, but the problem returns after reloading the Gradle project.

Invalidating the intelliJ cache didn't help either.

Project bytecode version in IDE is set to Same as language level.

Thank you.

 

IntelliJ IDEA 2024.1 (Community Edition)
Build #IC-241.14494.240, built on March 28, 2024
Runtime version: 17.0.10+8-b1207.12 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 4
Non-Bundled Plugins:
 com.jetbrains.space (241.14494.150)
 Lombook Plugin (241.14494.240)
Kotlin: 241.14494.240-IJ

 

0
6 comments

Hello,

Is it reproducible with some sample project? Also you may try to delete all IDE related data (.iml file and .idea folder) and reimport project again.

1

Thank you for the reply.

Deleting the .idea folder and reimporting the project again didn't help.

I tried to create a sample Java 11 project with this dependency, and the problem partially disappeared. There are no compilation errors in the editor (no red underlines) anymore, but it is still not possible to open the source file from within the Project window where the Record statement is used.

0

Is it possible to share sample project to check the issue on our side?

0

I'm afraid I can't share the library. I tried some public libraries too, and they seemed to be okay. So the problem only concerns my private library.

Nevertheless, I tried to click on the 'Open in Right Split' option in the context menu in the Project Window, and it surprisingly opened. It showed that the bytecode version of the source file was Java 11, which was probably strange because it was compiled with Java 17. But the opened window with the record statement froze. I couldn't even close the whole IntelliJ window. The right window was frozen, while the left window seemed to be responding okay.

I add that the record statement is probably not the cause of the issue. I've noticed that I can't open any regular Java source class files either.

I attached the log file: https://raw.githubusercontent.com/Armstrong4444/data/main/idea.log

0

Could you please report issue on YouTrack (https://youtrack.jetbrains.com/issues/IDEA) attaching full logs folder zipped for further investigation?

1

Please sign in to leave a comment.