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

Viewed 27304

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
6 Answers

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.

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

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

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

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 :)

In my case, I solved changing java version from 16 top 11.
Adding this line:
--illegal-access=warn
--add-opens java.base/java.lang=ALL-UNNAMED

in my case, eclipse is not enable to start. Version: 2021-03 (4.19.0) Build id: 20210312-0638

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
Related