Eclipse提示:Unable to make protected final java.lang.Class java.lang.ClassLoader

如果你的eclipse提示这样的错

Errors occurred during the build.
Errors running builder 'Java Builder' on project 'demo'.
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 @5a8dcfbb

恰巧你用安装了lombok.jar

Eclipse提示:Unable to make protected final java.lang.Class java.lang.ClassLoader_第1张图片

你可以打开eclipse安装目录下的eclipse.ini


#添加下面两行

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

完整的设置为:注意lombok.jar的路径

-startup
plugins/org.eclipse.equinox.launcher_1.6.300.v20210813-1054.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.2.300.v20210828-0802
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_16.0.2.v20210721-1149/jre/bin
-vmargs
-Dosgi.requiredJavaVersion=11
[email protected]/eclipse-workspace
-Dsun.java.command=Eclipse
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true
-Xms256m
-Xmx5048m
--add-modules=ALL-SYSTEM
--illegal-access=warn
--add-opens java.base/java.lang=ALL-UNNAMED
-javaagent:D:\jee-2021-09\plugins\org.projectlombok.agent_1.18.22/lombok.jar

重新打开eclipse,完美解决

你可能感兴趣的:(码农避坑,eclipse,java)