Skip to content
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

Closed
arana198 opened this issue Jun 8, 2018 · 44 comments

Comments

@arana198
Copy link

@arana198 arana198 commented Jun 8, 2018

I'm using:

  • Java 11
  • Lombok 1.18.4 (also tried 1.18.5 edge)
  • Gradle 5.0 (also tried with 4.9)

PS: I have requires static lombok in module-info.java and IDE does not show any error

Error courtesy: @jython234

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building matrix-bridge-java 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ matrix-bridge-java ---
[INFO] Deleting /home/alejzeis/IdeaProjects/matrix-bridge-java/target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ matrix-bridge-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ matrix-bridge-java ---
[WARNING] ********************************************************************************************************************
[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *
[WARNING] ********************************************************************************************************************
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /home/alejzeis/IdeaProjects/matrix-bridge-java/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/alejzeis/IdeaProjects/matrix-bridge-java/src/main/java/io/github/jython234/matrix/bridge/MatrixBridgeEventHandler.java:[29,32] cannot find symbol
  symbol:   method getLogger()
  location: variable bridge of type io.github.jython234.matrix.bridge.MatrixBridge
[ERROR] /home/alejzeis/IdeaProjects/matrix-bridge-java/src/main/java/io/github/jython234/matrix/bridge/MatrixBridgeEventHandler.java:[30,32] cannot find symbol
  symbol:   method getLogger()
  location: variable bridge of type io.github.jython234.matrix.bridge.MatrixBridge
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.826 s
[INFO] Finished at: 2018-05-29T22:11:26-05:00
[INFO] Final Memory: 21M/74M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project matrix-bridge-java: Compilation failure: Compilation failure:
[ERROR] /home/alejzeis/IdeaProjects/matrix-bridge-java/src/main/java/io/github/jython234/matrix/bridge/MatrixBridgeEventHandler.java:[29,32] cannot find symbol
[ERROR] symbol:   method getLogger()
[ERROR] location: variable bridge of type io.github.jython234.matrix.bridge.MatrixBridge
[ERROR] /home/alejzeis/IdeaProjects/matrix-bridge-java/src/main/java/io/github/jython234/matrix/bridge/MatrixBridgeEventHandler.java:[30,32] cannot find symbol
[ERROR] symbol:   method getLogger()
[ERROR] location: variable bridge of type io.github.jython234.matrix.bridge.MatrixBridge
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

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

@arana198 arana198 changed the title Lombok not working JDK 10 modules Lombok not working with JDK 10 modules Jun 8, 2018
@dasAnderl

This comment has been minimized.

Copy link

@dasAnderl dasAnderl commented Jul 3, 2018

same issue here java 10, lombok 1.18.0, mvn, module info with requires lombok
i get.

/Users/dasanderl/dev/workspaces/idea/MOD-TEST/MOD-Config/src/main/java/module-info.java:[2,18] module not found: lombok

@mahit777

This comment has been minimized.

Copy link

@mahit777 mahit777 commented Jul 14, 2018

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

@FortBlox

This comment has been minimized.

Copy link

@FortBlox FortBlox commented Jul 18, 2018

same issue here java 10, lombok 1.18.0, mvn, module info with requires lombok
i get.

Same problem. Only for me maven says that "org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile failed".
Tried downloading the edge version, still no luck. Anybody knows if/when Lombok will support Java modules?

@randakar

This comment has been minimized.

Copy link

@randakar randakar commented Jul 18, 2018

@schoettner

This comment has been minimized.

Copy link

@schoettner schoettner commented Jul 23, 2018

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

@markusjevringgoeuro

This comment has been minimized.

Copy link

@markusjevringgoeuro markusjevringgoeuro commented Jul 26, 2018

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.

@FortBlox

This comment has been minimized.

Copy link

@FortBlox FortBlox commented Jul 27, 2018

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.

@jython234

This comment has been minimized.

Copy link

@jython234 jython234 commented Jul 27, 2018

@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Jul 29, 2018

same here. After create module-info the compilation not work with latest lombok version.
simple example: https://github.com/MCMicS/simple-lombok

  • branches with annotationprocessor, non-modulized

Hope anyone has a solution. I will look also for one

if yout add follwoing to maven-compile-plugin yout got a different error:

                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>${lombok.version}</version>
                            </path>
                        </annotationProcessorPaths>

Error

javax.annotation.processing.FilerException: Cannot write to the given module.
        at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.checkOrInferModule(JavacFiler.java:471)
        at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.createSourceFile(JavacFiler.java:425)
        at lombok.javac.apt.LombokProcessor.forceNewRound(LombokProcessor.java:370)
        at lombok.javac.apt.LombokProcessor.process(LombokProcessor.java:357)
        at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:155)
        at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:205)
        at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(AnnotationProcessor.java:99)
        at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:964)
        at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:881)
        at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2100(JavacProcessingEnvironment.java:110)
        at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1202)
        at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1311)

IntelliJ wil show following warning (with annotation processer in pom):
Warning:java: Can't force a new processing round. Lombok won't work.

But the compilation will success.

@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Jul 31, 2018

Update from 2018-07-31
I tried to compile by hand and compare with maven build.
If you use javac -cp lombok.jar -p lombok.jar <source> you will get the exception wiht javax.annotation.processing.FilerException: Cannot write to the given module.

The maven compiler is calle without classpath for lombok and so the compiler not found the lombok methods:

Application.java:11: error: cannot find symbol
log.info("Sample Title: " + sample.getTitle());

with annotationProcesser config within pom, the -processorpath will be set to lombok.

In my opinion we should tak ok at the javax.annotation.processing.FilerException which is raise from lombok module.

And another look should be to the compile plugin. Why is no classpath is set like the documentation says: https://projectlombok.org/setup/javac

@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Aug 7, 2018

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:

<annotationProcessorPaths>
   <path>
     <groupId>org.projectlombok</groupId>
     <artifactId>lombok</artifactId>
     <version>${lombok.version}</version>
   </path>
</annotationProcessorPaths> 

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?
Maybe related Bug:
#1572

@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Aug 22, 2018

I tried with edge version (1.18.3).
But now I get an additional compile error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project simple-lombok: Compilation failure
[ERROR] /lombok/dummy/ForceNewRound0.java:[1,1] file should be on source path, or on patch path for module

if I try Java11 and annotationProcessor Path I will get somer errer for mapstruct:

jdk-11\bin\javac --processor-module-path .\lib\lombok-1.18.3-edge.jar -processor lombok.launch.AnnotationProcessorHider.AnnotationProcessor --module-path .\lib\lombok-1.18.3-edge.jar -d .\javac -g --release 10 javac .conf
An exception has occurred in the compiler (11-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and
the following diagnostic in your report. Thank you.
java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi
at java.base/java.lang.module.Resolver.resolveFail(Resolver.java:885)
at java.base/java.lang.module.Resolver.checkExportSuppliers(Resolver.java:760)
at java.base/java.lang.module.Resolver.finish(Resolver.java:362)
at java.base/java.lang.module.Configuration.(Configuration.java:130)
at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:484)
at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:288)
at j

@gestshb

This comment has been minimized.

Copy link

@gestshb gestshb commented Aug 24, 2018

i have the same problem (maven 3.5.2/jdk10/intellij 2018.2 /lombok 1.18.2) plug-in lombok installed
any solution ?

@schoettner

This comment has been minimized.

Copy link

@schoettner schoettner commented Aug 24, 2018

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.

@SvenWoltmann

This comment has been minimized.

Copy link

@SvenWoltmann SvenWoltmann commented Aug 28, 2018

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:

<annotationProcessorPaths>
   <path>
     <groupId>org.projectlombok</groupId>
     <artifactId>lombok</artifactId>
     <version>${lombok.version}</version>
   </path>
</annotationProcessorPaths> 

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:

<compilerArgs>
	<arg>-sourcepath</arg>
	<arg>${project.basedir}/src/main/java${path.separator}${project.basedir}/target/generated-sources/annotations${path.separator}/</arg>
</compilerArgs>

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.

@SvenWoltmann

This comment has been minimized.

Copy link

@SvenWoltmann SvenWoltmann commented Aug 29, 2018

Unfortunately my previous hack breaks the build in IntelliJ IDEA with javac when the project contains tests:

  • "module not found" error for each module referenced from module-info.java
  • "file should be on source path" error for each of my tests

It builds in Eclipse and in IntelliJ with the Eclipse compiler. I'll try to find a solution...

@SvenWoltmann

This comment has been minimized.

Copy link

@SvenWoltmann SvenWoltmann commented Aug 29, 2018

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:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.8.0</version>

      <configuration>
        <annotationProcessorPaths>
          <path>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
          </path>
        </annotationProcessorPaths>
      </configuration>
    </plugin>
  </plugins>
</build>

<profiles>
  <profile>
    <id>update-sourcepath-for-lombok</id>
    <build>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>

          <configuration>
            <compilerArgs>
              <arg>-sourcepath</arg>
              <arg>${project.basedir}/src/main/java${path.separator}${project.basedir}/target/generated-sources/annotations${path.separator}/</arg>
            </compilerArgs>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

And when running Maven on the command line, I activate that profile:

mvn -Pupdate-sourcepath-for-lombok clean package
@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Sep 3, 2018

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.

@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Sep 10, 2018

@rzwitserloot The problem ist that the EmptyLombokFileObject ist created and root. So the compiler warns because the root is not in source-module-paths.
Why not use the target or temp folder for ForceNewRound files?
Or maybe one of them ideas:

  • add some logic in Javac9BaseFileObjectWrapper
  • use some kind of SourceMemoryJavaFileObject

Log from lombok.javac.apt.InterceptingJavaFileManager#getJavaFileForOutput I've added:

warning: getJavaFileForOutput javaFileObject: /lombok/dummy/ForceNewRound0.java
warning: getJavaFileForOutput javaFileObject: file:///lombok/dummy/ForceNewRound0.java

In newer version for com.sun.tools.javac.processing.JavacFiler#createSourceOrClassFile you will find an implementation for module handling too.

@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Oct 17, 2018

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

@matelang

This comment has been minimized.

Copy link

@matelang matelang commented Nov 1, 2018

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:

[INFO] 7 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.010 s
[INFO] Finished at: 2018-11-01T12:48:30+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project x-error: Compilation failure: Compilation failure: 
[ERROR] /home/mate/work/x-cloud/x-error/src/main/java/io/x/cloud/exception/handler/dto/ErrorDto.java:[36,9] cannot find symbol
[ERROR]   symbol:   method setHttpStatus(int)
[ERROR]   location: class io.x.cloud.exception.handler.dto.ErrorDto
[ERROR] /home/mate/work/x-cloud/x-error/src/main/java/io/x/cloud/exception/handler/dto/ErrorDto.java:[37,9] cannot find symbol
[ERROR]   symbol:   method setMessage(java.lang.String)
[ERROR]   location: class io.x.cloud.exception.handler.dto.ErrorDto
[ERROR] /home/mate/work/x-cloud/x-error/src/main/java/io/x/cloud/exception/handler/dto/ErrorDto.java:[41,9] cannot find symbol
[ERROR]   symbol:   method setHttpStatus(int)
[ERROR]   location: class io.x.cloud.exception.handler.dto.ErrorDto
[ERROR] /home/mate/work/x-cloud/x-error/src/main/java/io/x/cloud/exception/handler/dto/ErrorDto.java:[42,9] cannot find symbol
[ERROR]   symbol:   method setMessage(java.lang.String)
[ERROR]   location: class io.x.cloud.exception.handler.dto.ErrorDto
[ERROR] /home/mate/work/x-cloud/x-error/src/main/java/io/x/cloud/exception/handler/dto/ErrorDto.java:[46,9] cannot find symbol
[ERROR]   symbol:   method setHttpStatus(int)
[ERROR]   location: class io.x.cloud.exception.handler.dto.ErrorDto
[ERROR] /home/mate/work/x-cloud/x-error/src/main/java/io/x/cloud/exception/handler/dto/ErrorDto.java:[47,9] cannot find symbol
[ERROR]   symbol:   method setMessage(java.lang.String)
[ERROR]   location: class io.x.cloud.exception.handler.dto.ErrorDto
[ERROR] /home/mate/work/x-cloud/x-error/src/main/java/io/x/cloud/exception/handler/dto/ErrorDto.java:[48,9] cannot find symbol
[ERROR]   symbol:   method setErrorCode(java.lang.String)
[ERROR]   location: class io.x.cloud.exception.handler.dto.ErrorDto
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

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,
Mate

@ipkpjersi

This comment has been minimized.

Copy link

@ipkpjersi ipkpjersi commented Nov 24, 2018

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.

@arana198 arana198 changed the title Lombok not working with JDK 10 modules Lombok not working with JDK 11 modules (Jigsaw) Dec 2, 2018
@arana198

This comment has been minimized.

Copy link
Author

@arana198 arana198 commented Dec 2, 2018

Has anybody got this to work any version of Java/Lombok that allows modules?

@megha0703

This comment has been minimized.

Copy link

@megha0703 megha0703 commented Dec 13, 2018

let me know sa well

@teppah

This comment has been minimized.

Copy link

@teppah teppah commented Dec 28, 2018

Does anybody have a solution to this yet?

@micheljung

This comment has been minimized.

Copy link

@micheljung micheljung commented Jan 19, 2019

Are there any plans to fix this?

@dandudzi

This comment has been minimized.

Copy link

@dandudzi dandudzi commented Jan 21, 2019

I changed to lombok version 1.18.2. see: #2028

@rspilker

This comment has been minimized.

Copy link
Collaborator

@rspilker rspilker commented Jan 28, 2019

We're working on this.

@rspilker

This comment has been minimized.

Copy link
Collaborator

@rspilker rspilker commented Jan 29, 2019

We just released an edge release. Can you give it a try and report back:

  • if it fixes the problem
  • if everything else still works as expected
@MCMicS

This comment has been minimized.

Copy link

@MCMicS MCMicS commented Jan 29, 2019

After a short test it seems to be fixed. Compiling with Maven works and Intellij also compile the source files correctly.

Tested with JJDK 11 and JDK 12

I'll will try a wider test later this day.
Thanks for fix so far.

-- Addional comment--
if you remove the annotation processor configuration from pom then the lombok module is not found.
Maybe it is another problem to solve. If you configure the annotation path then it will work with maven on terminal or in IDE.

                         <annotationProcessorPaths>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>${lombok.version}</version>
                            </path>
                        </annotationProcessorPaths>

Error:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project simple-lombok: Compilation failure
simple-lombok/src/main/java/module-info.java:[2,21] module not found: lombok

Sample without annotation configuration: https://github.com/MCMicS/simple-lombok/blob/edge-release/pom.xml

Sample with annotation configuration (works): https://github.com/MCMicS/simple-lombok/blob/java-11/pom.xml

@gvart

This comment has been minimized.

Copy link

@gvart gvart commented Jan 31, 2019

Java Version: 11
Maven Version: 3.6.0
Lombok Version: edge-SNAPSHOT
Maven Surefire Plugin: 3.0.0-M3

Upper solution works to build entire project except testing. maven-surefire-plugin fails with follow stacktrace:

Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'Error occurred during initialization of boot layer'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'Error occurred during initialization of boot layer'.
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
	at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)
	at java.base/java.lang.Thread.run(Thread.java:834)


# Created at 2019-01-31T17:37:05.235
Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi'.
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
	at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
	at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)
	at java.base/java.lang.Thread.run(Thread.java:834)

@m-radzikowski

This comment has been minimized.

Copy link

@m-radzikowski m-radzikowski commented Jan 31, 2019

Hey,
using edge release I get lombok to work with Java 10 and Jigsaw modules. When building project with mvn clean package and running it with java -jar ... it works great.

But on the other hand run from IntelliJ fails with error:

/usr/lib/jvm/java-11-openjdk-amd64/bin/java -javaagent:/home/radzik/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/183.5429.30/lib/idea_rt.jar=43289:/home/radzik/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/183.5429.30/bin -Dfile.encoding=UTF-8 -p /home/radzik/Documents/lomboktest/target/classes:/home/radzik/.m2/repository/org/projectlombok/lombok/edge-SNAPSHOT/lombok-edge-20190129.004558-1.jar -m lomboktest/com.example.App
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi

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

module lomboktest {
	requires static lombok;
}

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());
	}
}
@bruce-stewart

This comment has been minimized.

Copy link

@bruce-stewart bruce-stewart commented Feb 18, 2019

@gvart The surefire plugin works for me if I configure forkCount as zero instead of the default value of 1:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
        <!-- needed so that lombok does not throw errors during tests -->
        <forkCount>0</forkCount>
    </configuration>
</plugin>
@pavanjava

This comment has been minimized.

Copy link

@pavanjava pavanjava commented Feb 25, 2019

taking the lombok edge version i have resolved the issue. below is the config i have used

org.apache.maven.plugins
maven-compiler-plugin
3.8.0

10


org.projectlombok
lombok
${lombok.version}





org.ow2.asm
asm
6.2


@vrapalis

This comment has been minimized.

Copy link

@vrapalis vrapalis commented Mar 28, 2019

Hello all,

in my company we want migrate from java 8 to java 12.
Can i use at the moment lombok in gradle based project with java 12? Thanks a lot.

Best Regards.

@wolfbang

This comment has been minimized.

Copy link

@wolfbang wolfbang commented Apr 10, 2019

upgrade your Lombok version, try this:

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

v1.18.6 and above support JDK10/11

@ipkpjersi

This comment has been minimized.

Copy link

@ipkpjersi ipkpjersi commented Apr 10, 2019

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.

@imbananko

This comment has been minimized.

Copy link

@imbananko imbananko commented Apr 11, 2019

Testing edge-snapshot and still facing an issue with private final fields
variable field not initialized in the default constructor

Class annotated with:

@Getter @Builder @JsonDeserialize(builder = Entity.EntityBuilder.class)

java 10.0.2 2018-07-17
gradle-5.1-all.zip

@wolfbang

This comment has been minimized.

Copy link

@wolfbang wolfbang commented Apr 11, 2019

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.

yes,i change the version.it is ok when i upgrade to v1.18.6

@rzwitserloot

This comment has been minimized.

Copy link
Owner

@rzwitserloot rzwitserloot commented Apr 30, 2019

sounds like this is fixed.

@GedMarc

This comment has been minimized.

Copy link

@GedMarc GedMarc commented Jun 18, 2019

@rzwitserloot What fixed it? Still happening???!?
I've had to delombok every single one of my projects cause of this - is there any eye to fix the processing in maven?

@christian-schlichtherle

This comment has been minimized.

Copy link

@christian-schlichtherle christian-schlichtherle commented Oct 23, 2019

I'm facing the same issue, so it's definitely not fixed:

OpenJDK 11.0.2
Lombok 1.18.10

I'm going to delombok my project.

@noguespi

This comment has been minimized.

Copy link

@noguespi noguespi commented Nov 14, 2019

Got the same issue usings jdeps (but I'm not going to delombok my project :D ).

Error: Module lombok does not read a module that exports org.mapstruct.ap.spi
jdeps failed

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.

@GedMarc

This comment has been minimized.

Copy link

@GedMarc GedMarc commented Nov 14, 2019

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

   <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.version}</version>
                    <configuration>
                        <source>${jdk.release}</source>
                        <target>${jdk.release}</target>
                        <release>${jdk.release}</release>
                        <annotationProcessorPaths>
                            <annotationProcessorPath>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>1.18.8</version>
                            </annotationProcessorPath>
                            <path>
                                <groupId>org.mapstruct</groupId>
                                <artifactId>mapstruct-processor</artifactId>
                                <version>1.3.0.Final</version>
                            </path>
                        </annotationProcessorPaths>
                        <compilerArguments>
                            <AaddGeneratedAnnotation>false</AaddGeneratedAnnotation>
                            <Adebug>true</Adebug>
                        </compilerArguments>
                        <failOnError>true</failOnError>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.ow2.asm</groupId>
                            <artifactId>asm</artifactId>
                            <version>${maven.asm.version}</version>
                            <type>jar</type>
                        </dependency>
                    </dependencies>
                </plugin>

Then in your module-info file,

requires static lombok;

To build full JLink Images though it goes a bit further,
Rather use the maven JLink module, and reference your project as a depedency,

<profile>
            <id>jlink</id>
            <modules>
                <module>JLink</module>
            </modules>
            <build>
                <plugins>
                    <!-- JLINK -->
                    <plugin>
                        <artifactId>maven-jlink-plugin</artifactId>
                        <version>3.0.0-alpha-2-SNAPSHOT</version>
                        <extensions>true</extensions>
                        <configuration>
                            <noHeaderFiles>true</noHeaderFiles>
                            <noManPages>true</noManPages>
                            <stripDebug>true</stripDebug>
                            <verbose>true</verbose>
                            <compress>2</compress>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.ow2.asm</groupId>
                                <artifactId>asm</artifactId>
                                <version>${maven.asm.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jmod-plugin</artifactId>
                        <version>3.0.0-alpha-1</version>
                        <extensions>true</extensions>
                        <dependencies>
                            <dependency>
                                <groupId>org.ow2.asm</groupId>
                                <artifactId>asm</artifactId>
                                <version>${maven.asm.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>

                    <!-- Config your tool chain appropriately !!! -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-toolchains-plugin</artifactId>
                        <version>1.1</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>toolchain</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <toolchains>
                                <jdk>
                                    <version>1.12</version>
                                    <vendor>oracle</vendor>
                                </jdk>
                            </toolchains>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.