Daniel Pfeffer, Markus Weninger,
"On the Applicability of Annotation-Based Source Code Modification in Kotlin"
: MPLR 2023: Proceedings of the 20th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes, ACM Digital Library, 10-2023
Original Titel:
On the Applicability of Annotation-Based Source Code Modification in Kotlin
Sprache des Titels:
Englisch
Original Buchtitel:
MPLR 2023: Proceedings of the 20th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes
Original Kurzfassung:
Annotations add metadata to source code entities such as classes or functions, which later can be processed by so-called annotation processors to, for example, modify the annotated program?s source code. While annotation processing has been well-explored in Java, the Kotlin community still lacks a comprehensive summary. Thus, in this paper, we summarize the main approaches available in Kotlin: (1)??Compile-time annotation processing using (a)??Kotlin Annotation Processing Tool (KAPT), (b)??Kotlin Symbolic Processing (KSP), or (c)??writing a custom Kotlin Compiler plugin; as well as (2)??load-time code modification using an agent or a custom class loader. We provide proof-of-concept implementations, discuss advantages and disadvantages, and specifically focus on how well each approach supports modifying the annotated source code. This should help developers and researchers to better decide when to use which approach.