'Eclipse not able to open java files -> Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass

Getting the following error, after adding Lombok lib

An error has occurred. See error log for more details.
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1d1c37d5


Solution 1:[1]

Add the below lines to the end of the eclipse.ini file

--illegal-access=warn
--add-opens java.base/java.lang=ALL-UNNAMED

Solution 2:[2]

Updating to Lombok 1.18.22 plugin resulted in this issue going away for me. I did try adding the --add-opens flag, but the eclipse launcher balked at that. IMHO this is simply a result of incompatibility between Java 17 and the Lombok Eclipse IDE plugin.

Solution 3:[3]

The only thing that worked for me was downloading the lombok directly from lombok website instead of using the one available on maven folder.

Solution 4:[4]

Itseems problem with the lombok plugin. I have removed it from the eclipse.ini file and it resolved the issue.

Removed below line:

-javaagent:C:\<location>\eclipse-jee-2022-03-R-win32-x86_64\lombok.jar

Solution 5:[5]

For my case nothing above work for a specific project.

  1. Import existing maven project or create a maven project
  2. Goto project explorer and Right click on your pom.xm then select Run As maven install.
  3. and then what you want.

Hope it will serve your purpose. You can download a sample spring boot project from sample spring boot project

Or you can run a maven project from terminal or cmd. Just goto project root folder and then run a maven task like maven clean install . Happy Coding :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thirumal
Solution 2 Tod Harter
Solution 3 Gledson
Solution 4 Sreedhar GS
Solution 5 Basharat Ali