14

Upgrading to the last Eclipse version, now I am getting the following error:

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 @5d01b0d8

I tried changing JDK under preferences with no luck.

devwebcl
  • 2,396
  • 3
  • 24
  • 41
  • 3
    If you are using Lombok, it's probably this issue: https://twitter.com/howlger/status/1407316561803763716 (changing the JDK under preferences, does not change the Java used to run Eclipse). Or a similar issue of a plugin you have installed. – howlger Jun 24 '21 at 17:47

3 Answers3

25

Thanks, @howlger it was Lombok plug-in when using JDK 16. That tweet gave me the reasons: https://github.com/projectlombok/lombok/issues/2810

A workaround :

  • Use Java 15 to start Eclipse or
  • add --illegal-access=warn and --add-opens java.base/java.lang=ALL-UNNAMED to your eclipse.ini
  • or install a pre-built version (1.18.21)

In my situation I had to change eclipse.ini VM path:

-vm
C:\bin\jdk-15.0.2\bin
devwebcl
  • 2,396
  • 3
  • 24
  • 41
3

An easy way is to change the Java Version used to run Eclipse. There for you have to change the eclipse.ini.

  1. Set the vm location at the start of the file to a prior Java 16 JDK e.g. JDK 14
  2. Under MacOSX eclipse.ini is typically located in /Applications/Eclipse.app/Contents/Eclipse/
  3. The reason is an incompatibility of the lombock plugin

This a working example of the eclipse.ini file:

-vm
/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home/bin/java
-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.6.200.v20210416-2027.jar
--launcher.library
../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.2.200.v20210527-0259
-product
org.eclipse.epp.package.java.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-javaagent:/Applications/Eclipse.app/Contents/Eclipse/lombok.jar
-Dosgi.requiredJavaVersion=11
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-Dsun.java.command=Eclipse
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Dosgi.dataAreaRequiresExplicitInit=true
-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true
-Xms256m
-Xmx2048m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
Mirko Ebert
  • 1,221
  • 1
  • 20
  • 36
  • There are some duplicate lines: `--add-modules=ALL-SYSTEM` `-XstartOnFirstThread` `-Dorg.eclipse.swt.internal.carbon.smallFonts` `-Dosgi.requiredJavaVersion=11` I suppose this is not on purpose? – WarpEnterprises Oct 14 '21 at 15:09
2

Latest version of lombok 1.18.22 has fixed this issue. Install this version of lombok into your eclipse. Then this issue will get resolved.

Jobin John
  • 21
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 20 '21 at 07:08
  • thanks, this fixed it for me on eclipse 2021-12/4.22 with java 17 – dan carter Jan 09 '22 at 22:24