Cross-Language Dependencies: An Empirical Study of Kotlin-Java
Qiong Feng, Huan Ji, Xiaotian Ma, Peng Liang
TL;DR
This work investigates cross-language dependencies between Kotlin and Java in 23 real-world projects, addressing the gap in understanding Kotlin-Java interoperability. It introduces DependExtractor, a Kotlin-based static analysis tool that exhaustively extracts 11 Kotlin-Java dependencies and outputs a file-level dependency graph, complemented by a manual process to identify seven categories of problematic Kotlin-Java interactions. The study finds that Kotlin-Java dependencies are widespread and that interface files incur more commits, with a notable concentration of null-safety related issues (NPEs), informing both practitioners and researchers about maintenance challenges and opportunities for automated detection and repair. Overall, the paper provides actionable taxonomy and empirical evidence to improve Kotlin-Java interoperability in real-world systems.
Abstract
Background: Since Google introduced Kotlin as an official programming language for developing Android apps in 2017, Kotlin has gained widespread adoption in Android development. The inter-operability of Java and Kotlin's design nature allows them to coexist and interact with each other smoothly within a project. Aims: However, there is limited research on how Java and Kotlin interact with each other in real-world projects and what challenges are faced during these interactions. The answers to these questions are key to understanding these kinds of cross-language software systems. Methods: In this paper, we implemented a tool named DependEx-tractor, which can extract 11 kinds of Kotlin-Java dependencies, and conducted an empirical study of 23 Kotlin-Java real-world projects with 3,227 Java and 8,630 Kotlin source files. Results: Our findings revealed that Java and Kotlin frequently interact with each other in these cross-language projects, with access and call dependency types being the most dominant. Compared to files interacting with other files in the same language, Java/Kotlin source files, which participate in the cross-language interactions, undergo more commits. Additionally, among all Kotlin-Java problematic interactions, we identified seven common mistakes, along with their fixing strategies. Conclusions: The findings of this study can help developers understand and address the challenges in Kotlin-Java projects.
