# Fix "IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment"

Yes. An agent raises Lombok to a release built for your JDK, removes --add-opens workarounds, and compiles on each JDK you target to show getters still exist.

[Run this on Rush](https://cloud.getrush.ai/run/fix-lombok-illegalaccesserror/lombok/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

Lombok works by reaching into the Java compiler's internals. From JDK 16 those internals are closed to outside code by default, and a Lombok release older than the JDK it runs on fails at the first annotation it processes: `java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module`. The project's own code is untouched and compiled yesterday. What changed is the JDK on the build machine, on a new laptop or in a CI image.

braindevoiler/design-patterns is a typical victim. Its `pom.xml` sets `<lombok.version>1.18.12</lombok.version>`, declares Lombok with `provided` scope, and compiles with `maven.compiler.source` and `target` at `1.8`. Only two source files use Lombok, both through `@Getter`: `creational/builder/Computer.java` and `structural/proxy/GumballMachine.java`. Nothing about that looks fragile, and on a Java 8 or 11 toolchain it builds. On JDK 17 the same `mvn compile` stops with the error above, because the source level in the POM controls the language accepted, not which compiler binary runs the annotation processor.

The agent's fix is one property, chosen by test instead of by guess. It installs the JDKs the team builds with, then compiles under each with candidate Lombok versions. The reason for testing more than one JDK is that this error has a successor. A Lombok new enough for JDK 17 can still fail on JDK 21 with `java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid'`, a different message with the same cause: the Lombok release predates that compiler. Picking the newest Lombok and compiling on the newest JDK in use settles both at once, and the agent records which pairs passed and which failed.

It then checks that the upgrade changed nothing the rest of the code depends on. Other classes in that repository call `computer.getCpu()`, `computer.isGraphicsCardEnabled()` and `gumballMachine.getCount()`, methods that exist only because Lombok generates them. The agent runs `javap` on the compiled classes before and after and compares the method lists, which catches a renamed boolean getter or a missing accessor without needing a test for each. It also searches the build files for workarounds people paste to get past this error, such as `--add-opens` or `--add-exports` flags for `jdk.compiler` in `maven-compiler-plugin` arguments, `MAVEN_OPTS` or `.mvn/jvm.config`, and removes them once the build passes without them. That project's one test, `AppTest`, asserts `true`, so the compile and the `javap` comparison are the real evidence, and the agent says so.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "The build fails on a newer JDK with \"java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module\". Find where Lombok's version is set (pom.xml properties, dependencyManagement, a parent POM, build.gradle, a version catalog) and every place the build passes flags to open JDK internals: --add-opens or --add-exports for jdk.compiler in compiler arguments, MAVEN_OPTS, .mvn/jvm.config, gradle.properties or CI files. Determine which JDKs this project is built with from the build files, toolchain config, CI workflows and Dockerfiles; if they name only an old one, also test the current long-term-support releases. Install those JDKs. On the oldest JDK that still compiles the project, build it and save the output of javap -p for every class that uses a Lombok annotation. Then raise Lombok to the newest release, build on every JDK in your list, and save the same javap output. Report a table of JDK by Lombok version with pass or the first error line. Compare the javap output before and after and list any method that appeared, disappeared or changed signature. Remove the internal-access flags you found and confirm the build still passes on every JDK without them. If the project configures annotationProcessorPaths, update Lombok's version there too. Do not change source or target levels, do not rewrite Lombok annotations by hand, and do not upgrade unrelated dependencies; list any that block the newer JDK separately. Run the test suite on each JDK. Open a pull request with the table and the comparison.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that is usually one changed line: the Lombok version. When workaround flags existed, their removal is a second, separate commit so it can be reverted alone. The description contains the compatibility table, with one row per JDK and one column per Lombok version tried, each cell either a pass or the first line of the failure.

Under the table is the `javap` comparison for every class that carries a Lombok annotation. An empty difference is the result a reviewer wants: the same accessors, constructors and builders, produced by a newer processor. A non-empty one is listed method by method with the callers the agent found, since a changed generated signature is the one way a Lombok upgrade can break code that compiled before.

The description ends with what the newer JDK still objects to outside Lombok, if anything: another dependency that uses removed APIs, a plugin version too old for the compiler, a source level the JDK warns about. Those are named with their error text and left out of this change.

## Run it on every repository on an old Lombok

A JDK upgrade reaches every Java service in the organisation in the same quarter, so this is a sweep more than an incident. From your own script, list the repositories whose build files pin Lombok and send the request once for each, with that repository as the `resources` URL. Give every request a `request_id` that is a new UUID kept beside the repository name, so re-running the script after a network error returns the runs already started.

You do not need to pace the script. An API key runs at most its `max_concurrent` runs at once, 4 by default and never more than your plan allows, and a request past that limit is still accepted: its run is created `queued` and starts when an earlier one finishes. If the key has a `webhook_url`, each finished run posts `run.completed` or `run.failed` there, and the script's second half can read each session from the event's `session_url` to collect the pull request links.

## Why run it on Rush?

The evidence is a matrix, and a laptop has one JDK on its path. Proving that a single Lombok version compiles on 11, 17 and 21 means installing all three and running the build under each, then doing it again without the workaround flags. The agent's sandbox is empty at the start and disposable at the end, so it can hold every JDK in the table at once, and each compile's output is kept with the session for anyone who doubts a cell.

It also removes the temptation to stop at the flag. Adding `--add-opens` to the compiler arguments makes this error disappear in a minute and leaves a build that depends on JDK internals staying reachable. Because the run already has the upgraded build passing on every JDK, deleting those flags is a checked step, not a risk someone has to take on a Friday.

## Frequently asked questions

### Which Lombok version do I need for my JDK?

One released after that JDK. Two boundaries to go by: 1.18.12 fails on JDK 17 with this error and 1.18.20 compiles; 1.18.20 and 1.18.28 fail on JDK 21 with the `JCImport` error and 1.18.30 compiles. The simplest rule is to take the newest Lombok and let the run confirm it on every JDK you build with, the oldest included.

### My pom.xml says source and target 1.8. Why does the JDK version matter?

Those settings choose the language level and bytecode version. The annotation processor still runs inside whichever `javac` Maven launches, and that is the installed JDK. Lombok 1.18.12 running inside a JDK 17 compiler fails regardless of the level it is asked to emit.

### Will upgrading Lombok change my generated code?

For common annotations such as `@Getter`, `@Setter` and `@Builder`, the generated members keep their names and signatures across patch releases. The run does not rely on that: it compares `javap` output for every annotated class before and after and reports any difference with the code that calls it.

### Is adding --add-opens a valid fix?

It can get a build through today. It ties the build to compiler internals that each JDK release may change, and it does not help with the JDK 21 failure, which is a missing field and not an access check. Upgrading Lombok removes the cause, and then the flags can go.

### Does this apply to Gradle projects?

Yes. The same error appears when the Gradle daemon's JDK is newer than the Lombok on `annotationProcessor`. The agent updates the version where the build defines it, including a version catalog or a Lombok Gradle plugin, and runs the same matrix with `./gradlew compileJava`.

## More jobs like this: Upgrade dependencies weekly

- [Fix --compilers Is DEPRECATED and No Longer Supported After a Mocha Upgrade](https://getrush.ai/run/fix-mocha-compilers-is-deprecated-and-no-longer-supported/mocha/)
- [Fix "Module 'networkx' Has No Attribute 'from_numpy_matrix'" After a NetworkX 3 Upgrade](https://getrush.ai/run/fix-networkx-from-numpy-matrix-attribute-error/networkx/)
- [Fix "No module named 'distutils'" on Python 3.12](https://getrush.ai/run/fix-no-module-named-distutils/distutils/)
- [Fix npm "ERESOLVE unable to resolve dependency tree" Without legacy-peer-deps](https://getrush.ai/run/fix-npm-eresolve-peer-conflicts/npm/)
- [Fix OneHotEncoder Unexpected Keyword Argument sparse After a scikit-learn Upgrade](https://getrush.ai/run/fix-onehotencoder-unexpected-keyword-argument-sparse/scikit-learn/)
- [Fix page.waitForTimeout Is Not a Function After a Puppeteer Upgrade](https://getrush.ai/run/fix-page-waitfortimeout-is-not-a-function/puppeteer/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
