I want to do this for Java or Kotlin: given the code below
try { ...
} catch (@AutoLog e: Exception) { //position1
}
add a logging statement at position1 automatically during build time. I can add code with AspectJ for catch block(for both Java and Kotlin), but it's for all catch blocks, I can't check whether @AutoLog annotation is present and add code only when it is. So I think I have to turn to APT(Annotation processing tool) for Java (or KAPT for Kotlin)?
Btw, I found a KAPT code generation example here: https://github.com/JetBrains/kotlin-examples/tree/master/gradle/kotlin-code-generation , but it generates code to separate file, while what I want to do is modify the original file/class and add a statement in catch block.