Table of Contents
Fetching ...

Depends-Kotlin: A Cross-Language Kotlin Dependency Extractor

Qiong Feng, Xiaotian Ma, Huan Ji, Wei Song, Peng Liang

TL;DR

The paper addresses the gap in Kotlin-aware dependency analysis, especially for cross-language Kotlin–Java code. It introduces Depends-Kotlin, a cross-language dependency extractor built on an extended Depends framework with a plug-in architecture (Depends-Core and Depends-Lang), a SPI-based Language Register, and an Antlr-based Kotlin Processor to extract entities and dependency relations. The approach supports Kotlin-Kotlin and Kotlin-Java dependencies, including cross-language interactions, and demonstrates high precision (up to ~99%) and solid recall (~85%) across three real-world projects. This work enables architecture analysis, code migration, and cross-language code-smell detection in Android ecosystems that mix Kotlin and Java.

Abstract

Since Google introduced Kotlin as an official programming language for developing Android apps in 2017, Kotlin has gained widespread adoption in Android development. However, compared to Java, there is limited support for Kotlin code dependency analysis, which is the foundation to software analysis. To bridge this gap, we develop Depends-Kotlin to extract entities and their dependencies in Kotlin source code. Not only does Depends-Kotlin support extracting entities' dependencies in Kotlin code, but it can also extract dependency relations between Kotlin and Java. Using three open-source Kotlin-Java mixing projects as our subjects, Depends-Kotlin demonstrates high accuracy and performance in resolving Kotlin-Kotlin and Kotlin-Java dependencies relations. The source code of Depends-Kotlin and the dataset used have been made available at https: //github.com/XYZboom/depends-kotlin. We also provide a screen-cast presenting Depends-Kotlin at https://youtu.be/ZPq8SRhgXzM.

Depends-Kotlin: A Cross-Language Kotlin Dependency Extractor

TL;DR

The paper addresses the gap in Kotlin-aware dependency analysis, especially for cross-language Kotlin–Java code. It introduces Depends-Kotlin, a cross-language dependency extractor built on an extended Depends framework with a plug-in architecture (Depends-Core and Depends-Lang), a SPI-based Language Register, and an Antlr-based Kotlin Processor to extract entities and dependency relations. The approach supports Kotlin-Kotlin and Kotlin-Java dependencies, including cross-language interactions, and demonstrates high precision (up to ~99%) and solid recall (~85%) across three real-world projects. This work enables architecture analysis, code migration, and cross-language code-smell detection in Android ecosystems that mix Kotlin and Java.

Abstract

Since Google introduced Kotlin as an official programming language for developing Android apps in 2017, Kotlin has gained widespread adoption in Android development. However, compared to Java, there is limited support for Kotlin code dependency analysis, which is the foundation to software analysis. To bridge this gap, we develop Depends-Kotlin to extract entities and their dependencies in Kotlin source code. Not only does Depends-Kotlin support extracting entities' dependencies in Kotlin code, but it can also extract dependency relations between Kotlin and Java. Using three open-source Kotlin-Java mixing projects as our subjects, Depends-Kotlin demonstrates high accuracy and performance in resolving Kotlin-Kotlin and Kotlin-Java dependencies relations. The source code of Depends-Kotlin and the dataset used have been made available at https: //github.com/XYZboom/depends-kotlin. We also provide a screen-cast presenting Depends-Kotlin at https://youtu.be/ZPq8SRhgXzM.
Paper Structure (8 sections, 2 figures, 4 tables)

This paper contains 8 sections, 2 figures, 4 tables.

Figures (2)

  • Figure 1: Plug-in architecture of Depends-Kotlin
  • Figure 2: J-K/K-J Dependency visualization(orange denotes K depends on J; green denotes J depends on K)