java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment [duplicate]

java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment [duplicate]

Resolving java.lang.IllegalAccessError in Lombok: Upgrade to Version 1.18.22 or Higher

If you’ve encountered the following error while using Lombok:

java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment [duplicate]

The root cause is an incompatibility between the Lombok version and the Java compiler (javac) environment. The solution to this issue is to upgrade to at least version 1.18.22 of Lombok, which contains the necessary fix.

Dependency Update

To resolve this issue, update your pom.xml to use Lombok version 1.18.28. Here is the dependency configuration:

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.28</version>
</dependency>

For the latest version of Lombok, you can check the search.maven.org.

Why This Upgrade is Necessary

The java.lang.IllegalAccessError arises due to changes in the Java compiler that prevent older versions of Lombok from accessing certain internal APIs. The Lombok team addressed this issue starting with version 1.18.22. By upgrading to this version or later, you ensure compatibility with the latest Java compiler and avoid this error.

Steps to Upgrade

  1. Open your pom.xml: Locate the Lombok dependency in your project’s pom.xml file.
  2. Update the version: Change the version number to 1.18.28 as shown above.
  3. Save and Rebuild: Save the changes and rebuild your project. This ensures that Maven downloads the updated Lombok version and incorporates it into your build.

By following these steps, you will resolve the java.lang.IllegalAccessError and ensure that Lombok works smoothly with your Java environment.

For more information on Lombok and its updates, visit the official Lombok website.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *