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.
翻译:背景:自 2017 年 Google 将 Kotlin 作为 Android 应用开发的官方编程语言推出以来,Kotlin 在 Android 开发中得到了广泛采用。Java 与 Kotlin 的设计本质具有互操作性,使得它们能够在项目中平滑共存并相互交互。目的:然而,关于 Java 与 Kotlin 在真实项目中如何相互交互以及这些交互过程中面临哪些挑战的研究仍然有限。这些问题的答案对于理解此类跨语言软件系统至关重要。方法:本文实现了一个名为 DependEx-tractor 的工具,该工具能够提取 11 种 Kotlin-Java 依赖关系,并对包含 3,227 个 Java 和 8,630 个 Kotlin 源文件的 23 个 Kotlin-Java 真实项目进行了实证研究。结果:我们的研究发现,在这些跨语言项目中,Java 与 Kotlin 频繁交互,其中访问和调用依赖类型最为主要。与仅与同语言文件交互的文件相比,参与跨语言交互的 Java/Kotlin 源文件经历了更多的提交。此外,在所有 Kotlin-Java 有问题的交互中,我们识别出七种常见错误及其修复策略。结论:本研究的结果有助于开发者理解和应对 Kotlin-Java 项目中的挑战。