IllegalAccessError on JDK8

2,459 views
Skip to first unread message

hossameldeen

unread,
Nov 16, 2016, 2:23:05 AM11/16/16
to Project Lombok
Hi,

Background:
- Building using maven.
- Using lombok 1.6.10 as a maven build plugin.
- The source and target versions are 1.8.
- Using Oracle JDK.
- The machine is Ubuntu 16.04.
- The problem occurs on my machine, but doesn't occur on colleagues' machines.

Problem:
- When using mvn clean compile, this exception is thrown:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project dummy-name-for-privacy: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x1e4c6583) 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 @0x1e4c6583 -> [Help 1]

Steps:
- Was using Oracle JDK9.
- The code was compiling fine.
- After some changes in the code, all of a sudden, it started throwing this exception.
- Switched to Oracle JDK8 (because of this issue) but the problem still persists. I have both JDK9&8 installed, but switched using update-alternatives. Can confirm the switch by using `java -version` and `javac -version` which prints something like javac 1.8.0_111

Also, tried deleting ~/.m2/repository/org/projectlombok and then compiling but the problem didn't go away.

My guess: There're cached files of some library/project somewhere that were compiled Oracle JDK9 and the problem would go away by deleting them.

So, any help on how to solve that problem?

Thanks!

hossameldeen

unread,
Nov 16, 2016, 2:40:46 AM11/16/16
to Project Lombok
Also, deleted the contents of ~/.m2/repository but no luck :(

hossameldeen

unread,
Nov 21, 2016, 2:03:47 AM11/21/16
to Project Lombok
The solution in case anyone faces the same problem:

Probably, mvn doesn't use the javac you'd get by writing `javac` in your terminal. It uses the one in $JAVA_HOME variable. You can check which one it uses by writing `mvn -version`. To use the JDK8 version, change $JAVA_HOME variable (e.g., by writing `JAVA_HOME='/usr/lib/jvm/java-8-oracle'` in an Ubuntu terminal, if that was the path to JDK8 on your machine).


On Wednesday, November 16, 2016 at 9:23:05 AM UTC+2, hossameldeen wrote:
Reply all
Reply to author
Forward
0 new messages