Project Lombok 是否支持 Java 9?

Does Project Lombok support Java 9?

我在项目中使用了Lombok,但是我的同事不同意使用,他的理由是(来自controversy of lombok documents

Both of these pieces of Project Lombok make use of non-public APIs to accomplish their sorcery. This means that there is a risk that Project Lombok will be broken with subsequent IDE or JDK releases.

不过是2010年写的很老的文档了,现在可能已经解决了,所以我想知道Lombok会不会支持Java9,是否还在使用非public API:s?

Lombok项目有an issue tracking Java 9 support. As of January 9th 2018 and version 1.16.20, Lombok officially supports Java 9. From the changelog:

  • PLATFORM: Better support for jdk9 in the new IntelliJ, Netbeans and for Gradle.
  • BREAKING CHANGE: lombok config key lombok.addJavaxGeneratedAnnotation now defaults to false instead of true. Oracle broke this annotation with the release of JDK9, necessitating this breaking change.
  • BREAKING CHANGE: lombok config key lombok.anyConstructor.suppressConstructorProperties is now deprecated and defaults to true, that is, by default lombok no longer automatically generates @ConstructorProperties annotations. New config key lombok.anyConstructor.addConstructorProperties now exists; set it to true if you want the old behavior. Oracle more or less broke this annotation with the release of JDK9, necessitating this breaking change.
  • DEVELOPMENT: Compiling lombok on JDK1.9 is now possible.

(目前,它不是模块,因此您需要将它放在 class 路径上。感谢 ,它首先提到了这一点。)

Java 9 的 lombok 当前状态在此处跟踪:https://github.com/rzwitserloot/lombok/issues/985

截至目前,此错误仍未解决并且(显然)正在积极处理中。有一个 edge release 可以解决大部分问题,所以在这一点上你需要做的就是等待..

此问题自 2018 年 1 月 9 日起似乎已得到解决:https://github.com/rzwitserloot/lombok/issues/985#issuecomment-356135454

根据 Lombok 版本 1.16.20 Java 9 受支持。

因为 Java 9 的 lombok 状态被跟踪 here

有关此问题原因的提示,请参阅 this 博客 post,其中解释了一些 "tricks"/"hacks"