alexey.tsvetkov
02/01/2017, 6:06 PMerror/NonExistentClass
. If some Kotlin function signature, containing reference to generated code (as a parameter type or a return type), is processed by an annotation processor, the processor may generate reference to a NonExistentClass
in generated java code. This will cause Java compilation error ('unresolved reference') which is quite hard to diagnose, because javac does not report any additional information about errors in generated Java code.
Kapt2 was an attempt to overcome that limitation. Kapt2 implements JSR 269 by wrapping Intellij platform AST. However it became apparent that Intellij platform was not optimized for such use-case, so annotation processing could be very slow in some cases.
Kapt3 is a replacement of Kapt2 implementation. Kapt3 generates javac's Java AST from Kotlin code and reuses javac's AP directly.
All in all:
* There are two kapts from a user POV: one that can generate stubs is stable, the other is next-gen, experimental and WIP.
* Kapt2 and Kapt3 are different implementations of JSR 269.
* All the differences between Kapt2 and Kapt3 are implementation details, which are not usually documented (at least not in a user documentation).