Lombok: Add jdk9 compiler support

Created on 6 Dec 2015  路  98Comments  路  Source: projectlombok/lombok

Status (Updated 2018-01-09)

  • Given the right amount of --add-opens parameters, we can compile code that contains lombok annotations on build 9.0.1+11
  • 1.16.20 supports jdk9, gradle 4.2.1, maven 3.5.0 (example pom)
  • module-info.java is not present for lombok, so far lombok can only be used on the classpath, It's uncertain if you can compile modules.
  • @javax.annotation.Generated will no longer be generated by default, see below
  • We didn't even look at ecj/Eclipse support. It might just work, it might not
  • We will probably run into problems with classes compiled with jdk9 that have new contant pool entries. We will need to fix ClassFileMetaData

Most recent information (Based on build 9.0.1+11)

module jdk.compiler does not "opens com.sun.tools.javac.processing" to unnamed module @6b927fb

Lombok uses non-exposed APIs. We need to instruct the jvm that that's okay.

javac \
-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
-cp lombok.jar \
Test.java

According to this mail by Mark Reinhold we can replace all the --add-opens clauses by --permit-illegal-access in a future version of jdk9. However, that will generate warnings on the stderr. Using --add-opens does not.

package javax.annotation is not visible

Since 1.16.20, this message will only occur if your explicitly turned it on in lombok.config using lombok.addJavaxGeneratedAnnotation = true.

If specified, lombok adds @javax.annotation.Generated("lombok") to all generated methods.

Since the new module system, this annotation is no longer standard available.

There are two ways to fix this:

  1. Remove the following line from your project lombok.config file:

    lombok.addJavaxGeneratedAnnotation = true
    
  2. Add --add-modules=java.xml.ws.annotation to your javac command line parameters.

_This description will be updated if more information is available._

Most helpful comment

1.16.20 has just been uploaded to our website and should be available on maven central soon.

All 98 comments

I've just created an edge release. This takes care of the pid problem.

I only tested @Data, and expect that features that depend on resolution, like val, @Delegate and @ExtensionMethod will result in some more problems.

Building with Bazel works now. Thanks!

can we get this released ?

Cheers

Any chance that this will be released to maven soon?
I'm having the error prone issue.

The fixes are part of version 1.16.8, that has been released 2016-03-07. Are you already using that version?

Let me give it a shot again.

It seems like it works!
Thanks!

Hey,

since JDK 9 is coming closer - are there any updates regarding this issue?

Cheers,
Christoph

There's still too much motion on the module specification to have any meaningful estimation.

I'm convinced it will work in the end. I do fear that there need to be compiler flags to open up to lombok. How bad it will be, we don't know yet.

I tried to switch my project to jdk9 in heroku and got the same error.

JDK 9 rampdown has begun, so I think it's safe to start working on this.
http://openjdk.java.net/projects/jdk9/

@javadev What do you mean by "the same error"?

It's a little hard to tell what is already fixed, and what isn't.

I'm specifically concerned about module jdk.compiler does not "opens com.sun.tools.javac.processing" to unnamed module @6b927fb. I'm seeing this in a build using 1.16.16. So I assume it isn't fixed yet? Is there a snapshot I can use for now?

Sorry, misunderstood ... those --add-opens are needed for the javac invocation for compiling code that uses lombok.

The new JDK9 flag --permit-illegal-access, introduced just a few weeks ago, is a lot easier to use than the litany of --add-opens flags you need otherwise. It's mentioned in the issue update.

with lombok 1.16.16 and errorprone 2.0.19 (plexus-compiler-javac-errorprone 2.8.1), everything appears to work but outputs this troubling looking stack trace during compilation:

java.lang.NullPointerException
    at lombok.javac.apt.LombokFileObjects.createEmpty(LombokFileObjects.java:123)
    at lombok.javac.apt.InterceptingJavaFileManager.getJavaFileForOutput(InterceptingJavaFileManager.java:47)
    at com.sun.tools.javac.processing.JavacFiler.createSourceOrClassFile(JavacFiler.java:414)
    at com.sun.tools.javac.processing.JavacFiler.createSourceFile(JavacFiler.java:388)
    at lombok.javac.apt.LombokProcessor.forceNewRound(LombokProcessor.java:333)
    at lombok.javac.apt.LombokProcessor.process(LombokProcessor.java:322)
    at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:114)
    at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:164)
    at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(AnnotationProcessor.java:74)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:826)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:742)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:100)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1046)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1153)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1120)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:814)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:97)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
    at com.google.errorprone.BaseErrorProneJavaCompiler$1.call(BaseErrorProneJavaCompiler.java:99)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
    at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:119)
    at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:66)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:886)
    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:153)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
warning: Can't force a new processing round. Lombok won't work.

Is that a known/expected/safe error?

No. I've just pushed 539b2a767f604dd561a7da09ae26114e8cfc065a to add some additional debug information. Can you please download the edge release and compile with that? You will probably need to do some maven magic to use this jar, like put it in your cache under the wrong name.

It will not fix your problem, but will help us fix it, so please tell us if you now get an IllegalArgumentException, and what the message is,

 warning: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.google.errorprone.MaskedClassLoader$MaskedFileManager extends com.sun.tools.javac.file.JavacFileManager
    at lombok.javac.apt.LombokFileObjects.getCompiler(LombokFileObjects.java:127)
    at lombok.javac.apt.InterceptingJavaFileManager.<init>(InterceptingJavaFileManager.java:40)
    at lombok.javac.apt.LombokProcessor.placePostCompileAndDontMakeForceRoundDummiesHook(LombokProcessor.java:164)
    at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:85)
    at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
    at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:140)
    at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:69)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:539)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:636)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:727)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:100)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1046)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1153)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1120)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:814)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:97)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
    at com.google.errorprone.BaseErrorProneJavaCompiler$1.call(BaseErrorProneJavaCompiler.java:99)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
    at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:119)
    at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:66)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:886)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Thanks. We've just created a new edge release, that just might fix your problem. Can you please try it again?

Getting a different exception with the latest edge release:

java.lang.IllegalArgumentException: URI has an authority component
    at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
    at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
    at java.nio.file.Paths.get(Paths.java:138)
    at lombok.javac.apt.LombokFileObjects$Java9Compiler.wrap(LombokFileObjects.java:151)
    at lombok.javac.apt.LombokFileObjects.createEmpty(LombokFileObjects.java:132)
    at lombok.javac.apt.InterceptingJavaFileManager.getJavaFileForOutput(InterceptingJavaFileManager.java:47)
    at com.sun.tools.javac.processing.JavacFiler.createSourceOrClassFile(JavacFiler.java:414)
    at com.sun.tools.javac.processing.JavacFiler.createSourceFile(JavacFiler.java:388)
    at lombok.javac.apt.LombokProcessor.forceNewRound(LombokProcessor.java:333)
    at lombok.javac.apt.LombokProcessor.process(LombokProcessor.java:322)
    at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:114)
    at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:164)
    at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(AnnotationProcessor.java:74)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:826)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:742)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:100)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1046)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1153)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1120)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:814)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:97)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
    at com.google.errorprone.BaseErrorProneJavaCompiler$1.call(BaseErrorProneJavaCompiler.java:99)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
    at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:119)
    at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:66)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:886)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
warning: Can't force a new processing round. Lombok won't work.

I encountered the same issue with @jbarnettwomply. Looking forward for your solution, thx! :)

@rspilker Bazel test is failing although Baazel build is perfect working.

This issue is a blocker for me. Netbeans uses JDK9 internally, making lombok completely unusable under this IDE. There is no workaround.

With the JDK9 release around the corner, expect more IDEs to get impacted as they begin adding their own support.

Please make this issue a top priority.

@cowwoc I'm pretty sure this has been where most of the maintainers' time was put into for more than half a year. It is definitely the most top priority issue already.

Regarding the java.lang.IllegalArgumentException: URI has an authority component

I've tried to reproduce it om my machine (Windows) using errorprone (com.google.errorprone:error_prone_core:2.0.19) and maven (org.codehaus.plexus:plexus-compiler-javac-errorprone:2.8) and couldn't, but possibly I misconfigured it. So I've added new debugging information to the source. It should not fix the problem though.

We've just created a new edge release. @jbarnettwomply or @CiaoWood, can you please try it again and report the error message?

You will probably need to do some maven magic to use this jar, like put it in your cache under the wrong name.

java.lang.IllegalArgumentException: Problems in URI 'file://lombok/dummy/ForceNewRound0.java' (lombok/dummy/ForceNewRound0.java)
    at lombok.javac.apt.LombokFileObjects$Java9Compiler.wrap(LombokFileObjects.java:156)
    at lombok.javac.apt.LombokFileObjects.createEmpty(LombokFileObjects.java:133)
    at lombok.javac.apt.InterceptingJavaFileManager.getJavaFileForOutput(InterceptingJavaFileManager.java:47)
    at com.sun.tools.javac.processing.JavacFiler.createSourceOrClassFile(JavacFiler.java:414)
    at com.sun.tools.javac.processing.JavacFiler.createSourceFile(JavacFiler.java:388)
    at lombok.javac.apt.LombokProcessor.forceNewRound(LombokProcessor.java:333)
    at lombok.javac.apt.LombokProcessor.process(LombokProcessor.java:322)
    at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:114)
    at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:164)
    at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(AnnotationProcessor.java:74)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:826)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:742)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2000(JavacProcessingEnvironment.java:100)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1046)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1153)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1120)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:814)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:97)
    at com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:128)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
    at com.google.errorprone.BaseErrorProneJavaCompiler$1.call(BaseErrorProneJavaCompiler.java:99)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
    at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:119)
    at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:66)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:886)
    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:153)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.IllegalArgumentException: URI has an authority component
    at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
    at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
    at java.nio.file.Paths.get(Paths.java:138)
    at lombok.javac.apt.LombokFileObjects$Java9Compiler.wrap(LombokFileObjects.java:154)
    ... 56 more
warning: Can't force a new processing round. Lombok won't work.

Based on the error message I think we've located the problem.

A new edge release might contain the fix. Feedback is welcome.

Not seeing any error messages with the latest edge release. Thanks!

@rspilker I'm still getting the error message when using the latest edge release

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project <...>: Fatal error compiling: java.lang.ExceptionInInitializerError: Unable to make field private com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs accessible: module jdk.compiler does not "opens com.sun.tools.javac.processing" to unnamed module @5bdda90b -> [Help 1]

I installed it using the following command:

mvn install:install-file -Dfile=lombok-edge.jar -DgroupId=org.lombokproject -DartifactId=lombok -Dversion=1.16.17 -Dpackaging=jar

My current jdk version is jdk-9+173 and my maven info is

Apache Maven 3.5.0 (NON-CANONICAL_2017-04-10T13:56:20+03:00_root; 2017-04-10T10:56:20Z)
Maven home: /opt/maven
Java version: 9-ea, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-9-jdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.11.3-1-arch", arch: "amd64", family: "unix"

I can confirm what @jamiemagee is saying, jdk-9+174 w/ edge just downloaded + Maven 3.3.9

@JamieMagee, @md-5 did you add all the --add-opens parameters as stated in the description?

Apologies, -J--permit-illegal-access is sufficient for me to compile. Thought they may not be required.

@rspilker Thanks for the comment. Adding the following to my pom.xml seems to have fixed the issue. I'm getting different failures now, but they seem to be unrelated to lombok.

<fork>true</fork>
<compilerArgs>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
</compilerArgs>

What is the longer term plan for Lombok given that you won't be able to add opens in the future?

I ask because I don't think we have the ability to set the above switches for the Netbeans built-in compiler without changing the IDE source-code and I suspect I'll run into resistance if I ask for them to get added.

I don't know anything about the Lombok implementation but just to point out some details in the stack trace above:

java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)

This is Unix-only exception. Is there any chance that a URI to a file on Windows has found its way into being used on a Linux or OS X machine?

Also on the @Generated annotation then look at javax.annotation.processing.Generated. It's probably what you want to use going forward as the java.xml.ws module is deprecated-for-removal.

@cowwoc [Re: Longer term plans in the face of future restrictions on what you can access with reflection]:

In order:

  1. Work with the relevant tool(s) to fix it, for example by telling them which open switches to add to make this work.
  2. Failing that, we have some more fancy hacks in our toolbox we can apply here.
  3. Failing that, we can agent our way in and arrange things to work out. We already do this for eclipse. It'd be a minor inconvenience.
  4. Failing that, ship a tool to 'fix' your JDK which is pretty drastic and not something we'd be likely to shoot for. But we're pretty far into the deep end if we're down to option #4.

Of course, if the compiler adds the stuff we need we can eliminate the reflection entirely.

java.lang.IllegalArgumentException: URI has an authority component has been solved in 1.16.18.

Another possible issue or annoyance, ConstructorProperties lives in the java.desktop module, which drags in a lot of cruft when trying to build a minimal runtime for containers.

java.management.ConstructorProperties is an alternative to java.beans.ConstructorProperties supported by JMX.

@rspilker

I added compilerArgs to maven-compiler-plugin, it does not work, it still report compilation error.

 <compilerArgs>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
                        <arg>-J--add-opens -Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
                    </compilerArgs>

Using maven, the solution to add some -J--add-opens arguments to the compiler won't help you for now because of a bug in the compiler-plugin. Please vote for issue MCOMPILER-291 to get this fixed.

One other thing, it did compile on my machine, but possibly I just didn't fail on warnings.

New instructions for maven. I got it running warning free.

1) Have a lombok.config containing lombok.addJavaxGeneratedAnnotation = false
2) Configure the compiler plugin to fork and provide a bunch of compiler arguments:

<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-jdk9</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.9</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <fork>true</fork>
                    <compilerargs>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
                <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
                    </compilerargs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.18</version>
            <scope>provided</scope>
        </dependency>   
    </dependencies>

</project>

I had to add dependency on

<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>jsr250-api</artifactId>
    <version>1.0</version>
</dependency>

as well to make previous comment works for me

That, or modify lombok.config to no longer generate ConstructorProperties

@rspilker I still get warnings with the solution form your comment:

[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ apikey-api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 207 source files to /home/test/target/classes
[WARNING] WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: Unknown module: -Jjdk.compiler specified to --add-opens
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by lombok.javac.apt.LombokProcessor to field com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs
WARNING: Please consider reporting this to the maintainers of lombok.javac.apt.LombokProcessor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

My compiler configuration:

            <plugin>                                                            
                <artifactId>maven-compiler-plugin</artifactId>                  
                <version>3.7.0</version>                                        
                <configuration>                                                 
                    <source>9</source>                                          
                    <target>9</target>                                          
                    <fork>true</fork>                                           
                    <compilerArgs>                                              
                        <arg>-Xlint:all,-processing,-cast,-serial,-try</arg>    
                        <!-- TODO: Enable when lombok fixes problem with Builder.Default -->
                        <!--                                                    
                        <arg>-Werror</arg>                                                                                                                                   
                        -->                                                     
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
                        <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
                    </compilerArgs>                                             
                    <showWarnings>true</showWarnings>                           
                    <showDeprecation>true</showDeprecation>                     
                </configuration>                                                
            </plugin>    

Removing Xlint doesn't change anything.

Has anyone found a workaround to make @Builder(toBuilder = true) work? I get this error on this instruction

incompatible types: bad type in conditional expression
java.util.List<java.lang.String> cannot be converted to boolean` error

(sample project hosted at https://github.com/jonathanlermitage/manon/tree/spring5, see last commit)

@krzyk I'm not a Maven user, but have you tried the following:

<arg>-J--add-opens</arg> <arg>-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
:
etc. for all 9 packages
:
<arg>-J--add-opens</arg> <arg>-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>

In my Gradle-based projects --add-opens and jdk.compiler/...=ALL-UNNAMED are two _separate_ arguments to javac, separated by space (not joined by = as you showed above). I think Gradle prepends the -J for me, but in Maven you probably need the -J on each individual <arg>.

Given newer java releases only warn on illegal access, those flags won鈥檛 make something work, just supress warnings on already working things.

More to the point, seeing how JDK10 is shipping in 6 months with these warnings turning into errors, you might want to take the time to fix the underlying problem instead of trying to mask it.

How to get rid of the warning: [options] --add-opens has no effect at compile time when using lombok on Java 9? Apparently, javac do not likes those --add-opens command-line parameters.

I tried the edge release which solved the problems I had for Java 9. When will this be release?

Not sure if related, but when trying this out with config:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.7.0</version>
    <configuration>
        <annotationProcessors>
            <annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor
            </annotationProcessor>
        </annotationProcessors>
        <fork>true</fork>
        <compilerArgs>
            <!-- see https://github.com/rzwitserloot/lombok/issues/985 -->
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
            <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
        </compilerArgs>
    </configuration>
</plugin>

The build fails on JavaDoc, not being able to cope with the @__

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.0-M1:jar (attach-javadocs) on project persistence: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - warning: unknown enum constant XmlAccessType.FIELD
[ERROR]   reason: class file for javax.xml.bind.annotation.XmlAccessType not found
[ERROR] /some/dir/JooqModule.java:44: error: cannot find symbol
[ERROR]     @RequiredArgsConstructor(onConstructor = @__(@Inject))
[ERROR]                                               ^
[ERROR]   symbol:   class __
[ERROR]   location: class JooqModule
[ERROR]
[ERROR] Command line was: /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/javadoc @options @packages

Has anyone tackled that already? We can't wait to get Java 9 working here :D

1.16.18 fails with Java 9.0.1+11:

> Task :compileJava 
warning: [options] --add-opens has no effect at compile time
... warning: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.sun.tools.javac.api.ClientCodeWrapper$WrappedStandardJavaFileManager extends com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager implements javax.tools.StandardJavaFileManager
public class MentionHelper {
       ^
        at lombok.javac.apt.LombokFileObjects.getCompiler(LombokFileObjects.java:130)
        at lombok.javac.apt.InterceptingJavaFileManager.<init>(InterceptingJavaFileManager.java:40)
        at lombok.javac.apt.LombokProcessor.placePostCompileAndDontMakeForceRoundDummiesHook(LombokProcessor.java:164)
        at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:85)
        at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
        at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:140)
        at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:69)

UPDATE
Tried edge build and it started to work, even without --add-opens.

Under macOS 10.13.2 with Java 9.0.1+11 I get this:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by lombok.installer.AppleNativeLook to method com.apple.eawt.Application.getApplication()
WARNING: Please consider reporting this to the maintainers of lombok.installer.AppleNativeLook
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
objc[23121]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fff95a0db68) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x16f553cd8). One of the two will be used. Which one is undefined.

1.16.18 fails with Java 9.0.1:

/home/fedorchuck/Documents/projects/developers-notification/src/main/java/com/github/fedorchuck/developers_notification/antispam/MessageTypes.java:27: 
warning: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this 
compilation: java.lang.IllegalArgumentException: 
com.sun.tools.javac.api.ClientCodeWrapper$WrappedStandardJavaFileManager extends 
com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager implements 
javax.tools.StandardJavaFileManager

public enum MessageTypes {
       ^
    at lombok.javac.apt.LombokFileObjects.getCompiler(LombokFileObjects.java:130)
    at lombok.javac.apt.InterceptingJavaFileManager.<init>(InterceptingJavaFileManager.java:40)
    at lombok.javac.apt.LombokProcessor.placePostCompileAndDontMakeForceRoundDummiesHook(LombokProcessor.java:164)
    at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:85)
    at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
    at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:140)
    at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:69)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:675)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:774)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:869)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2200(JavacProcessingEnvironment.java:108)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1206)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1315)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1246)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:922)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:48)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:35)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:98)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:51)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:37)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
    at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:207)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:192)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:124)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.base/java.lang.Thread.run(Thread.java:844)

Can you please test using the edge release? We did try to fix it in that version.

I can confirm that we have been able to build all our projects in Java 9 using lombok-edge.jar (1.16.19) as a dependency and including it in the repository. Looking forward until this build hits release. :+1:

Helpful side-note: Make sure you run the latest Java 9 if you run OpenJDK (Java 9.0.1, not in apt yet but deb files are available to download) and maven (3.3.0+ or 3.5.0+). We had a lot of mysterious CompilationError on lower versions. I wouldn't assume this is a requirement for it to work but it certainly helped us.

@Foorack Does it include Delombok update?

@rafalwrzeszcz I have not gotten delombok to work, however, I don't know if that is because lombok or the maven plugin (which does not use edge).

The edge release fixes most problems for me, but I still get the following warning from Maven:

--- maven-compiler-plugin:3.1:compile (default-compile) @ DeepLearning ---
Changes detected - recompiling the module!
Compiling 1 source file to C:\Users\Gili\Documents\NetBeansProjects\DeepLearning\target\classes
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by lombok.javac.apt.LombokProcessor to field com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs
WARNING: Please consider reporting this to the maintainers of lombok.javac.apt.LombokProcessor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

As far as I can tell, the compiler is using the edge version.

Hello @rspilker, with the edge release is there any maven repository for me configure at pom.xml?

@renatojava AFAIK no, I had to include the lombok-edge.jar as a local file jar dependency.

@renatojava @Foorack Maven issue #1519 about Maven repository

maybe lombok-edge better commit to maven repository? Like BETA1 version? For easiest testing in gradle and etc...

1.16.20 has just been uploaded to our website and should be available on maven central soon.

I take it this means 1.16.20 adds JDK 9 support?
Nice work!

Does lombok on java 9 still need special compiler flags / maven configuration to make it work? If so, it would be nice if this was documented on the main lombok site so people don't need to search for this ticket to find out ;-)

Runs without config / flags for me.

@rspilker Just a note that in your https://github.com/rzwitserloot/lombok/issues/985#issuecomment-337741287 there is a bug in the options, you should not add another -J in the command line there.

Generally you shown options like this:

 <arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>

But it should be:

<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>

(Notice the lack of -J after --add-opens=).

I also had to add <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg> (used by lombok).

So the full working (warning free) config looks like this:

<plugin>
   <artifactId>maven-compiler-plugin</artifactId>                                        
    <version>3.7.0</version>
    <configuration>
        <source>9</source>
        <target>9</target>
        <fork>true</fork>
        <compilerArgs>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
            <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
        </compilerArgs>
     <showWarnings>true</showWarnings>                   
    </configuration>                                                
</plugin>                                                           

(BTW. for spring users you might need also:

<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>

)

Did anybody manage to compile with Lombok on the module path?

I'm constantly getting the following error:

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by lombok.javac.apt.LombokProcessor to field com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs WARNING: Please consider reporting this to the maintainers of lombok.javac.apt.LombokProcessor WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release lombok/dummy/ForceNewRound0.java:1: error: file should be on source path, or on patch path for module 1 error

@krzyk If you update lombok to versino 1.16.20 and then it should work without the need of extra java parameters.

@iherasymenko Please put lombok on the classpath rather than the module path. While working with Java 9, lombok is not a module yet AFAIK.

@Foorack could you please provide an example of how it can be achieved? I want to have the module-info.java inside my module. How should I refer to lombok in it?

I have the same problem as @iherasymenko.
I tried to compile a Java 9 module that uses lombok annotations.
Maven 3.3.9, Lombok 1.16.20 (Maven 3.5 tested, but makes no difference).
Lombok is on the classpath (according to maven debug log) as @Foorack suggested.

Compilation errors:
[ERROR] lombok/dummy/ForceNewRound0.java:[1,1] file should be on source path, or on patch path for module [ERROR] /xxxxxxx/java9test/src/main/java/java9test/model/Group.java:[4,8] package lombok is not visible (package lombok is declared in the unnamed module, but module lombok does not read it)

According to the compilation errors I assume that lombok is generating 'ForceNewRound0.java'.
But somehow javac thinks, that the generated class (raher the package of the class) is not part of this module and assumes that it must be part of another (unnamed) module.

I tried to edit the module-info.java of my module:
requires lombok --> compiler complains that there is no module lombok (yes, that's true as it's not on the module path)

Maybe it's somehow because linked modules must not contain similar packages.
I'll try to compile without maven but with the mentioned compiler args.
Even though, I think it's a different problem.

Update:
Using lombok annotations within a module and the lombok.jar on the classpath won't work because the classpath ('unnamed module') is not visible to modules in java9.

Is there a solution to make it work with module-info? When I don't use a module-info.java everything works fine. But as soon as I add it, it seems like lombok doesn't run anymore. In IntelliJ the annotations are recognized, and it gives no errors, until you actually try to run it. Then it doesn't seem to have the generated code by Lombok.

Besides that, great work getting this to work in Java 9!! 鉂わ笍

I'm almost there. Tomorrow evening there will be an edge release with preliminary support.

Okay all, give this a shot:

https://projectlombok.org/setup/javac

fixed via a bunch of commits:

fee0ad33abceb0219076dde05c9d5d9ba950000f through bb95ad218d29a9f5b1011b7c7b919ed41337a00b

In my case, I constantly get the following exception while compiling my project with the edge release:

javax.annotation.processing.FilerException: Module: myModule does not exist.
    at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.checkOrInferModule(JavacFiler.java:466)
    at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.createSourceFile(JavacFiler.java:424)
    at lombok.javac.apt.LombokProcessor.forceNewRound(LombokProcessor.java:365)
    at lombok.javac.apt.LombokProcessor.process(LombokProcessor.java:352)
    at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:115)
    at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:165)
    at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(AnnotationProcessor.java:99)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:968)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:884)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2200(JavacProcessingEnvironment.java:108)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1206)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1315)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1246)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:922)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1075)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:168)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

Is it possible to publish the snapshot release of Lombok to a publicly available Maven repository, so that everyone could test the latest build more easily?

UPD.

It seems to me that something went wrong in the method which extracts the module name. If my Java 9 module has the following name test.myModule then I get the exception I mentioned earlier. But if I change it to, let's say, myModule then I get the following error:

lombok/dummy/ForceNewRound0.java:[1,1] file should be on source path, or on patch path for module

@rspilker (pid)
Compile still fails with the edge version. I think Lombok should officially retire Java9 compatibility.
Many criteria should be reworked on (@Log4j2 etc... )

In my opinion, Lombok's biggest mistake is using bytecode generation. You could achieve the same thing using compile-time code generation and you would have zero compatibility problems with JDKs, IDEs. The resulting code would be easier to debug as well once the "magic" is out of the way. Please consider killing bytecode generation.

@Slf4j doesn't work in java 9 , and module-info.java add 'require static lomlok',cannot found symbol: variable log while compiling in intellij 2018 EAP idea, and install lombok plugin,use lomlok.jar with latest version(1.16.20).

@godpit do you have an example project (basically a Minimal, Complete, and Verifiable example)?
Does it work in IDEA 2017?

In my project @SLF4j works in IntlelliJ 2017.5 using java 9 compiler. I think lombok plugin is not compatible with latest 2018 EAP.

+1, Lombok plugin is not compatible with IntelliJ 2018 EAP yet.
Try to compile your project with command line. If it fails too, don't use module-info at all.

@krzyk I try to use intellij 2017.3.4,but it also doesn't work, however i try to use java 8, it work well.

Lombok in Eclipse fails the build with the following error when adding a module-info.java to the project:

Errors occurred during the build.
Errors running builder 'Java Builder' on project 'entities'.
Unknown constant pool type 19

I tested a minimal project setup with edge release. As soon as I add module-info.java with single line requires static lombok code generation stops working: no getters are generated.
If I remove module-info it works again. I used this project as a baseline for my experiment:
https://github.com/krzyk/lombok-jdk10-example

1.18.0 is still not working with module-info.java (IntelliJ IDEA 2018.1.3), although release 1.16.22 has this note:

PLATFORM: Fix for using lombok together with JDK9+'s new module-info.java feature. Issue #985

After moving lombok to class path, compilation succeeded, but when I run application I get this error:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi

I get the same error.
In my Java 11 Module project I have added the Maven dependency:

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.2</version>
    <scope>provided</scope>
</dependency>

In my module-info I added

requires static lombok

but when I run my application in Eclipse Photon I get the error:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi

Error: java.lang.module.ResolutionException: Module lombok does not read a module that exports org.mapstruct.ap.spi

Issue #1806 - the above problem has been rosolved in the edge version.

What edge version? I am using the latest one (119-769185e1 - from here) and it is still present.

To clarify I mean the mapstruct error is still present - the names containing a dot issue has indeed been resolved :)

@hughjdavey the 'edge' version can be downloaded from here https://projectlombok.org/download-edge

@hughjdavey yes the mapstruct error still exists,

@hughjdavey Did you also add the mapstruct-processor-1.3.0.Beta1.jar to your module path? When I did that the error disappeared.

Sorry I could have mentioned about the mapstruct-processor.
For me it works as well with current final version 1.2.0.Final pom.xml.

@tzieleniewski so no need to do --add-modules I can just add it as a dependency in build.gradle (as you have done in your maven file)?

@arrowman53 how do I do that? Is it one of those --add-modules or --add-reads flags?

@hughjdavey Yes, its the --add-modules you need to add it to.

@hughjdavey I am not familiar with Gradle but my investigation with Maven showed that Maven during compilation adds to the module path those dependencies which are modular JARs, other dependencies are added to classpath (unnamed module).

So in my case it was not the --add-modules missing. I needed to extend the list of observable modules. For that purpose I used the --upgrade-module-path parameter. Otherwise org.mapstruct.ap.spi, as a not modular JAR, would not be resolable.

At this point, lombok works fine in jdk9. I see lots of comments, many referencing gradle and such. That's a different issue (and various gradle issues have already been filed).

Was this page helpful?
0 / 5 - 0 ratings