Open bhawana99 opened 2 years ago
The error message happenstance because java 17 enforces strong encapsulation. Lombok can handle that if you upgrade to 1.18.22+. Please double check that you really use that version for your build.
@Rawi01 But doesn't the above issue is fixed in the 1.18.22 version?
Yes, it is fixed. That's why I'm pretty sure that you use an older version for your build.
Hello @bhawana99,
You are right they solved the issue, but I think it was only for "direct" dependency. I just had a similar problem, using 1.18.24 and JDK 16, in a multi-module project. Maybe yours is multi-module too? If yes, I solved the solution by making lombok non transitive ->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<optional>true</optional>
</dependency>
If you want to play with a project that has a solution:
Anyway, I am not sure to understand why the issue still exists when Lombok is an indirect dependency, I will investigate maybe it is an unsolved bug, or maybe it is expected?
@JulienElkaim Thanks for sharing the reproducer. The recommended scope for Lombok is provided
because it is only required at runtime. I changed the scope and it works too. That actually explains why their is only a small subset of people who faces this problem because it requires a wrong configuration.
If you are unable to change the included dependency it is also possible to exclude the dependency using <exclusions>
.
To be honest I have no idea why this happens and it is clearly not intended.
Hello @bhawana99,
You are right they solved the issue, but I think it was only for "direct" dependency. I just had a similar problem, using 1.18.24 and JDK 16, in a multi-module project. Maybe yours is multi-module too? If yes, I solved the solution by making lombok non transitive ->
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.24</version> <optional>true</optional> </dependency>
If you want to play with a project that has a solution:
- git clone my project from the commit in this link, and try to mvn install from the root module bulo-project 1/ with the optional true, 2/ without it. in 2/ you will see runs-orchestrator module fail at compilation, and it has dependency to swagger-starter module which has dependency to lombok
Anyway, I am not sure to understand why the issue still exists when Lombok is an indirect dependency, I will investigate maybe it is an unsolved bug, or maybe it is expected?
You, my friend, are brilliant
@bhawana99 I also experienced this situation,Replacing jdk1.8 can solve the problem
Thank you @JulienElkaim. Adding the above dependency in my projects pom.xml solved the exception.
Hello @bhawana99, You are right they solved the issue, but I think it was only for "direct" dependency. I just had a similar problem, using 1.18.24 and JDK 16, in a multi-module project. Maybe yours is multi-module too? If yes, I solved the solution by making lombok non transitive ->
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.24</version> <optional>true</optional> </dependency>
If you want to play with a project that has a solution:
- git clone my project from the commit in this link, and try to mvn install from the root module bulo-project 1/ with the optional true, 2/ without it. in 2/ you will see runs-orchestrator module fail at compilation, and it has dependency to swagger-starter module which has dependency to lombok
Anyway, I am not sure to understand why the issue still exists when Lombok is an indirect dependency, I will investigate maybe it is an unsolved bug, or maybe it is expected?
You, my friend, are brilliant
It worked for me. Gr8
I'm still having this issue
Execution failed for task ':compileJava'.
> java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x34ce9fe1) 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 @0x34ce9fe1
With Gradle
* What went wrong:
Execution failed for task ':compileJava'.
> java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x76c7b88e) 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 @0x76c7b88e
Please update you Lombok first, we did do some changes regarding the packaging of the embedded ASM.
I've tried with the latest too 1.18.30
In Java 17 we try to automatically take care of all the necessary add-opens problems. In Java 22, this no loners works. Could it be that you're accidentally using Java 22.
In any case, in the repo you can find all the necessary add-open statements in the docker directory.
FYI: for Java 22 and up we will use a different solution.
May I ask if the new version of lombok (>=JDK17) no longer relies on the jdk.compiler module for implementation? If you don't use JDK. compiler, what AST editing technique did you use?
Resolved by adding the following in sourceset.gradle
lombokVersion = '1.18.30'
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
Upgrading the Lombok library version to 1.18.20 fixed the issue. In POM.xml update the version to 1.18.20
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
I ran into same problem and I solve this after noticed that my project were Java 11 and I was executing ./gradlew build on him with Java 17 on my java -version so just have changed java version to 11 worked
Issue during Java build using JDK 17 and Lombok 1.18.22:
Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x363d3958) 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 @0x363d395**
I am compiling my java source code in java 1.8, while running the project on JRE17. As per the other bug thread, I have upgraded the lombok version to 22 as it suports lombok reflection issue. But still we are getting this issue. What could be the possible issue.
NOTE: The problem causing library is an external library, in main project we are using lombok version 1.18.12.