On the Applicability of Annotation-Based Source Code Modification in Kotlin (Work in Progress)
Sprache des Vortragstitels:
Englisch
Original Tagungtitel:
Intl. Conf. on Managed Programming Languages & Runtimes (MPLR?23)
Sprache des Tagungstitel:
Englisch
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.