Kotlin doesn't see Java Lombok accessors?

前端 未结 4 1690
野性不改
野性不改 2020-12-02 21:48

Using Kotlin 1.0.0 release (compiling in IntelliJ 15).

println(myPojoInstance.foo)

When it tries to compile code (in IntelliJ or Gradle) th

4条回答
  •  北海茫月
    2020-12-02 22:47

    Generally, no, it doesn't. The reason of that behavior is that Lombok is an annotation processor for javac but when the kotlin compiler runs it uses javac as well but with no annotation processing so this is why kotlin don't see declarations that wasn't yet generated.

    The only workaround for now is to define strict compilation order: Java first and after that kotlin. Unfortunately this approach has great disadvantage: you can't use Kotlin code from Java in this case. To workaround it you may need multimodule project that may cause a lot of pain

提交回复
热议问题