-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lombok not working with JDK 11 modules (Jigsaw) #1723
Comments
same issue here java 10, lombok 1.18.0, mvn, module info with requires lombok
|
faced the same issue looks like it also depends on maven-compiler plugin because I've seen some posts that claim that they could resolve this issue by updating the version of maven-compiler. but none of them worked for me what worked was I was using mapstruct as an annotationPocessrPath the issue was gone when I removed that |
Same problem. Only for me maven says that "org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile failed". |
Current edge release has support, according to
https://projectlombok.org/setup/javac
…On Wed, Jul 18, 2018 at 10:53 AM, FortBlox ***@***.***> wrote:
same issue here java 10, lombok 1.18.0, mvn, module info with requires
lombok
i get.
Same problem. Tried downloading the edge version, still no luck. Anybody
knows if/when Lombok will support Java modules?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1723 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKCRYYDH3szvfl1WvBE-p9Kt2U_PYz0ks5uHveggaJpZM4Ugez_>
.
--
"Don't only practice your art, but force your way into it's secrets, for it
and knowledge can raise men to the divine."
-- Ludwig von Beethoven
|
I can confirm this. I included the edge release (JDK 10, Gradle 4.9) and everything was working again as it used to with JDK 8 |
When I use the latest version (1.18.2, there was no edge release when I checked), and "requires static lombok;" in my module-info.java file, when the actual code generation stops working. It doesn't generate my getters and log fields etc. I'm using maven 3.5.2, and IntelliJ IDEA. Neither of them (idea with the lombok plugin) triggers the generation of the code. Alternatively, it's triggered but it fails silently. |
I was a bit busy, so only got to play around with it today. There is currently no edge release, looks like that release went on to become version 1.18.2. I tried using this version, added a "requires static lombok" to the module-info, unfortunately it didnt work. I am using java 10 modules with maven and intelliJ. It works ok if I just use java 10 without modularizing the project, but as soon as I add a module-info file, lombok stops generating the classes. |
Somewhere it was mentioned that Lombok isn't on the module path as it
doesn't have a module-info.java file. So whenever it is used by a
modularized project it won't work as Java searches for lombok on the module
path instead of the class path. I think that may be the issue.
…On Fri, Jul 27, 2018, 12:58 FortBlox ***@***.***> wrote:
I was a bit busy, so only got to play around with it today. There is
currently no edge release, looks like that release went on to become
version 1.18.2. I tried using this version, added a "requires static
lombok" to the module-info, unfortunately it didnt work. I am using java 10
modules with maven and intelliJ. It works ok if I just use java 10 without
modularizing the project, but as soon as I add a module-info file, lombok
stops generating the classes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1723 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFtT5tWtJ2bvS5pqPYgwmwu5TmnROpXJks5uK1TYgaJpZM4Ugez_>
.
|
same here. After create module-info the compilation not work with latest lombok version.
Hope anyone has a solution. I will look also for one if yout add follwoing to maven-compile-plugin yout got a different error:
Error
IntelliJ wil show following warning (with annotation processer in pom): But the compilation will success. |
Update from 2018-07-31 The maven compiler is calle without classpath for lombok and so the compiler not found the lombok methods:
with annotationProcesser config within pom, the -processorpath will be set to lombok. In my opinion we should tak ok at the And another look should be to the compile plugin. Why is no classpath is set like the documentation says: https://projectlombok.org/setup/javac |
The maven compiler works correct to my mind because lib with modules should be only occurred in modulepath. But the annotation processers are looked up within the the classpath. So we need the setting:
There is also a discussion with annotaion processor not used if specified in module-path: http://jigsaw-dev.1059479.n5.nabble.com/Annotation-processors-and-the-processor-module-path-td5714320.html any progress with the FilerException? |
I tried with edge version (1.18.3).
if I try Java11 and annotationProcessor Path I will get somer errer for mapstruct:
|
i have the same problem (maven 3.5.2/jdk10/intellij 2018.2 /lombok 1.18.2) plug-in lombok installed |
Another workaround is to change the compiler plugin. Because I use Groovy for testing I had limited choice what plugins to use. The groovy-eclipse-compiler does not seem to work at the moment (it worked with the lombok 1.18.0-edge). For the gmaven-plus plugin I compiled a custom hotfix to support jdk10 and uploaded it to an internal jFrog. The fixed version of gamaven-plus works perfectly fine with all lombok versions. |
I found ... not a solution but rather a hack ... to get this running with Maven and JDK 9 / 10. So first you have to add the annotation processor path, as already mentioned before:
Now I also get the "/lombok/dummy/ForceNewRound0 ... file should be on source path" error. To fix this, I analyzed which parameters Maven passes to javac and reproduced the compilation process by directly calling javac. I first found out that it works if you remove the "-sourcepath" parameter. However, that should not and cannot be done with Maven. After another day of experiments, I found out that it also works if you add "/" (I assume that's where the /lombok/dummy/ForceNewRound0.java file is written to) to the sourcepath. And that can be done with Maven ... although it's kind of hacky: You need to add to the maven-compiler-plugin the following compiler arguments:
This doesn't really replace the "-sourcepath" compiler argument, but it adds a second "-sourcepath", which overwrites the first one. As I said, this is not a clean solution, but it works and maybe it's a starting point to find a real solution. |
Unfortunately my previous hack breaks the build in IntelliJ IDEA with javac when the project contains tests:
It builds in Eclipse and in IntelliJ with the Eclipse compiler. I'll try to find a solution... |
Here's a way to get the hack running in Maven, IntelliJ and Eclipse: I define the sourcepath in a separate Maven profile "update-sourcepath-for-lombok", so it's ignored by IntelliJ:
And when running Maven on the command line, I activate that profile:
|
like @SvenWoltmann mentioned the sourcepath is the problem. But if I try it with my own Annotation processors it works also with this flag. I will have a deeper look in lombok code the days. |
@rzwitserloot The problem ist that the EmptyLombokFileObject ist created and root. So the compiler warns because the root is not in source-module-paths.
Log from lombok.javac.apt.InterceptingJavaFileManager#getJavaFileForOutput I've added:
In newer version for com.sun.tools.javac.processing.JavacFiler#createSourceOrClassFile you will find an implementation for module handling too. |
Gradle does not support modules yet: https://stackoverflow.com/questions/51917106/java-10-gradle-project-automatic-module-not-found Lombok preprocessing is causing some issues: projectlombok/lombok#1723
Tried with latest Edge Release (1.18.3 (2018-10-15 22:58:24 UTC) ) No resolution. Lombok only work in test classes in IntelliJ. Maven still fails |
I am using lombok 1.18.4 and the following still gives an error: package io.x.cloud.exception.handler.dto;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.slf4j.MDC;
import org.springframework.http.HttpStatus;
import java.time.Instant;
/**
* Contains the common details that should be returned in case of an error during a web service request.
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = ErrorDto.TYPE)
@JsonSubTypes({
@JsonSubTypes.Type(value = ErrorDto.class, name = ErrorDto.SIMPLE_TYPE),
})
@Data
@NoArgsConstructor
public class ErrorDto {
public static final String SIMPLE_TYPE = "simple";
public static final String TYPE = "type";
private String requestUid = MDC.get("X-B3-TraceId");
private long timestamp = Instant.now().toEpochMilli();
private int httpStatus;
private String message;
private String errorCode = "GeneralException";
public ErrorDto(HttpStatus httpStatus, Exception e) {
setHttpStatus(httpStatus.value());
setMessage(e.getMessage());
}
public ErrorDto(HttpStatus httpStatus, String message) {
setHttpStatus(httpStatus.value());
setMessage(message);
}
public ErrorDto(HttpStatus httpStatus, Exception e, String errorCode) {
setHttpStatus(httpStatus.value());
setMessage(e.getMessage());
setErrorCode(errorCode);
}
} System info: [mate@devmate ~]$ java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13)
OpenJDK 64-Bit Server VM (build 11.0.1+13, mixed mode)
[mate@devmate ~]$ mvn -version
Apache Maven 3.5.4 (NON-CANONICAL_2018-09-08T01:02:16+02:00_root; 2018-09-08T02:02:16+03:00)
Maven home: /opt/maven
Java version: 11.0.1, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.16-arch1-1-arch", arch: "amd64", family: "unix" module io.x.cloud.error {
requires static lombok;
requires slf4j.api;
requires hystrix.core;
requires jackson.annotations;
requires spring.web;
requires spring.context;
requires com.fasterxml.jackson.databind;
requires feign.core;
requires spring.core;
requires spring.beans;
} The build fails with the following:
Is this a known issue? If yes do we have an ETA when it will be fixed? Unfortunately it's blocking my organization to move to a modularized project structure. Cheers, |
Issue is still present with Java 11 and Lombok 1.18.4 and Gradle 4.10.2, I guess I'll check back in a year after Java 12 has been out for a while and hope it's fixed by then. Cheers. |
Hey, But on the other hand run from IntelliJ fails with error:
Should it be solved in this edge release or am I doing something wrong? pom.xml <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>lombok-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>10</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lombok.version>edge-SNAPSHOT</lombok.version>
</properties>
<repositories>
<repository>
<id>projectlombok.org</id>
<url>https://projectlombok.org/edge-releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>10</release>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version> <!-- Use newer version of ASM -->
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project> module-info.java
App.java package com.example;
import lombok.Getter;
@Getter
public class App {
private String test = "qwe";
public static void main(String[] args) {
System.out.println(new App().getTest());
}
} |
@gvart The surefire plugin works for me if I configure forkCount as zero instead of the default value of 1:
|
taking the lombok edge version i have resolved the issue. below is the config i have used |
Hello all, in my company we want migrate from java 8 to java 12. Best Regards. |
upgrade your Lombok version, try this:
v1.18.6 and above support JDK10/11 |
As I mentioned above, issue is still present with v1.18.4. Cheers. edit: the comment above originally said v1.18.4 but has since been edited to v1.18.6, however I looked through the patch notes of v1.18.6 and saw no mention of illegal reflective access being fixed. |
Testing edge-snapshot and still facing an issue with private final fields Class annotated with:
java 10.0.2 2018-07-17 |
yes,i change the version.it is ok when i upgrade to v1.18.6 |
sounds like this is fixed. |
@rzwitserloot What fixed it? Still happening???!? |
I'm facing the same issue, so it's definitely not fixed: OpenJDK 11.0.2 I'm going to delombok my project. |
Got the same issue usings jdeps (but I'm not going to delombok my project :D ).
I haven't enough knowledge of the new java module system, I just excluded the lombok jar from jdeps analysis and fortunately it uses modules probably required by other modules. My goal is to list all the modules and build a minimal jvm runtime with minimal number of modules. |
Ok so I did get it, in JDK 12 it changes as well because service loaders are no longer read from the META-INF location anymore, only from the module file what you want to do is
Then in your module-info file,
To build full JLink Images though it goes a bit further,
|
I had the same recently in 1.18.10 and JDK 11 |
same error with jdk11 and lombok 1.18.12 15:33:52 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ common ---
15:33:52 [INFO] Changes detected - recompiling the module!
15:33:54 [INFO] -------------------------------------------------------------
15:33:54 [ERROR] COMPILATION ERROR :
15:33:54 [INFO] -------------------------------------------------------------
15:33:54 [ERROR]
15:33:54 [ERROR] model/AutoCount.java:[124,30] cannot find symbol |
No I have Lombok fully supported and installed on 1.18.12 from jdk11 all the way through to jdk14. Double check your config and make sure you are referencing the Lombok annotation processor in your maven compiler config. It will not automatically pick up the annotation processor, especially from 12 and up as the meta-inf/services directory can longer be referenced at all for service discovery. |
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin> (like this)[https://projectlombok.org/setup/maven] I have been tried a lot of methods but still getting the same error |
try this
|
my bad it was not caused by lombok <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin> thanks bro |
Hello, I am also still having errors using lombok 1.18.12 from OpenJDK11. I've tried the solutions above but it still does not work.
|
Hello, I'm facing this issue on Java 15. Is there any fix? |
I have same issue with Adopt JDK11 and MVN 3.6.3, not possible to compile |
Same with Adopt 11.0.11, |
Cannot reproduce. Will remain closed without a complete reproduction formula. A zip with the lot - maven file, everything. |
I am facing the same issue while using JDK11 |
I'm using:
PS: I have requires static lombok in module-info.java and IDE does not show any error
Error courtesy: @jython234
I also have included the requires static lombok; in my module-info.java
EDIT: code can be found here: https://github.com/jython234/matrix-bridge-java
The text was updated successfully, but these errors were encountered: