arrow
Return

iJTyper: An effective type inference framework for incomplete java codes by integrating constraint- and statistics-based methods

delete2025-10-09
delete0
PRE
AI
Z
Zhixiang Chen
A
Anji Li
张能 cover
张能 (Neng Zhang)
陈建国 cover
陈建国 (Chen, Jianguo)
黄袁 cover
黄袁 (Yuan Huang)
Z
Zibin Zheng
DOI:10.1016/j.eswa.2025.129972delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Inferring the types of APIs used in incomplete codes (also referred to as code snippets), e.g., those on Q&A forums, is a prerequisite step required to work with the codes. Existing type inference methods proposed for incomplete Java codes can be primarily categorized as constraint-based or statistics-based. The former relies on a pre-built API knowledge base (KB) and the type constraints in code snippets, which imposes higher requirements on code syntax and thus suffers from low recall due to the syntactic limitation. The latter overcomes the syntactic limitation by learning statistical regularities from a code corpus, however it rarely employs the type constraints in code snippets, which may lead to low precision. In this paper, we propose an effective type inference framework, called iJTyper, for incomplete Java codes by integrating the complementary advantages of constraint- and statistics-based methods. For a code snippet, iJTyper first applies a constraint-based method and augments the code context with the inferred API types. Then, it applies a statistics-based method to the augmented code snippet. The types predicted for APIs are further used to improve the constraint-based method by reducing its pre-built KB. iJTyper iteratively executes both methods and performs the code context augmentation and KB reduction mechanisms until a termination condition is satisfied. The final inference results are produced by combining the results of both methods. We implemented a version of iJTyper by integrating two state-of-the-art methods, SnR and MLMTyper, and evaluated iJTyper on two open-source datasets. Results show that 1) iJTyper achieves the highest average precision/recall1 of 97.3 % and 92.5 % on both datasets; 2) iJTyper improves the average recall of SnR and MLMTyper by at least 7.3 % and 27.4 %, respectively; and 3) iJTyper improves the average precision/recall of the recently popular language model, ChatGPT, by 3.2 % and 0.5 % on both datasets.

Journal

Expert Systems with Applications cover
Expert Systems with Applications
IF:
7.5
Papers:
3.0W
Citations:
10.2W

Organization

S
sun yat-sen university
Scholars:
1.9W
Papers: 6.4K
Citations: 14
C
Central China Normal University
Scholars:
1.1W
Papers: 8.1K
Citations: 1.1W
Cited Papers

Cited Papers

Concrete Type Inference for Code Optimization using Machine Learning with SMT Solving
err
IF0
err2023-10-16
err0
PREAI
errFangke Ye; Jisheng Zhao; Jun Shirako; Vivek Sarkar
errShare
errSave
On the Naturalness of Software
err2016-04-26
err164
PREAI
errHindle, Abram; Barr, Earl T.; Gabel, Mark; Su, Zhendong; Devanbu, Premkumar
errShare
errSave
A text classification approach to API type resolution for incomplete code snippets
err2023-04-01
err0
errOAAI
errCamilo Velázquez-Rodríguez; Dario Di Nucci; Coen De Roover
errShare
errSave
ZS4C: Zero-Shot Synthesis of Compilable Code for Incomplete Code Snippets using LLMs
err2024-11-05
err0
errOAAI
errAzmain Kabir; Shaowei Wang; Yuan Tian; Tse-Hsun (Peter) Chen; Muhammad Asaduzzaman; Wenbin Zhang
errShare
errSave
errShare
errSave
Mining API usage scenarios from stack overflow
err2020-06-01
err26
errOAAI
errUddin, Gias; Khomh, Foutse; Roy, Chanchal K.
errShare
errSave
err
IF0
err
err0
PREAI
err
errShare
errSave
Survey of Hallucination in Natural Language Generation
err2023-03-03
err707
errOAAI
errJi, Ziwei; Lee, Nayeon; Frieske, Rita; Yu, Tiezheng; Su, Dan; Xu, Yan; Ishii, Etsuko; Bang, Ye Jin; Madotto, Andrea; Fung, Pascale
errShare
errSave
no more