Where are kotlin stdlib's annotation processors de...
# kapt
s
Where are kotlin stdlib's annotation processors defined?
g
There are no APs in stdlib, what do you exactly mean?
s
@gildor I meant, some of the annotations that comes with stdlib like JvmStatic
How are those applied?
m
s
@Marc Knaup Yes, but i'm looking for the processor implementation for JvmStatic
m
I guess it's part of the Kotlin compiler and doesn't need a separate annotation processor.
s
Okay, is that source available somewhere? The closest i came to is plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/annotationProcessing.kt which has this single entry point (doAnnotationProcessing) to work with all loaded processors
g
@Sam As Marc said, there is no annotation processing involved, this is part of compiler and compiler uses those annotations and generate bytecode directly, this is pretty different from annotation processing which is Java API to generate source code File that you mention above is part of kapt, tool to support annotation processing for Kotlin code, but this is not used by kotlin itself, only to support third party APs
s
@gildor Gotcha, thanks. Let me see if i can find corresponding code in compiler project.
g
What exactly are you looking for?
s
an existing implementation for best practice and now i'm curious how different would it be from a third party APs
g
Beat practices of what?
s
of the actual processing
g
This is completely different from annotation processor, because it doesn't work with source, but with own AST and generates bytecode, not code
s
Oh wov, interesting
g
Also, it's not something isolated like annotation processor for a single annotation, this is part of compilation process which has a lot of different parts I just don't think that you can find any best practices or useful code there if you don't plan to contribute to Kotlin Compiler
s
Makes sense, thanks
g
It's possible to implement something similar using compiler plugin, but there is no API and for now it highly coupled with the compiler
s
Yeah, looking forward to the compiler plugin feature
g
It’s not something that will be available soon
s
Yeah, fingers crossed
@gildor FWIW, i found Transform API from AGP which can be used for byte code transformations for Android (before Dex/D8). It gets class files post javac/kotlinc compilation. http://tools.android.com/tech-docs/new-build-system/transform-api
g
Yes, it one of possible ways, some libraries use it, for example Smuggler https://github.com/joomcode/smuggler