Saved in:
Bibliographic Details
Main Authors: Chen, Zhixiang, Li, Anji, Zhang, Neng, Chen, Jianguo, Huang, Yuan, Zheng, Zibin
Format: Preprint
Published: 2024
Subjects:
Online Access:https://arxiv.org/abs/2402.09995
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866910332535963648
author Chen, Zhixiang
Li, Anji
Zhang, Neng
Chen, Jianguo
Huang, Yuan
Zheng, Zibin
author_facet Chen, Zhixiang
Li, Anji
Zhang, Neng
Chen, Jianguo
Huang, Yuan
Zheng, Zibin
contents Inferring the types of API elements in incomplete code snippets (e.g., those on Q&A forums) is a prepositive step required to work with the code snippets. Existing type inference methods can be mainly categorized as constraint-based or statistically-based. The former imposes higher requirements on code syntax and often suffers from low recall due to the syntactic limitation of code snippets. The latter relies on the statistical regularities learned from a training corpus and does not take full advantage of the type constraints in code snippets, which may lead to low precision. In this paper, we propose an iterative type inference framework for Java, called iJTyper, by integrating the strengths of both constraint- and statistically-based methods. For a code snippet, iJTyper first applies a constraint-based method and augments the code context with the inferred types of API elements. iJTyper then applies a statistically-based method to the augmented code snippet. The predicted candidate types of API elements are further used to improve the constraint-based method by reducing its pre-built knowledge base. iJTyper iteratively executes both methods and performs code context augmentation and knowledge base reduction until a termination condition is satisfied. Finally, the final inference results are obtained by combining the results of both methods. We evaluated iJTyper on two open-source datasets. Results show that 1) iJTyper achieves high average precision/recall of 97.31% and 92.52% on both datasets; 2) iJTyper significantly improves the recall of two state-of-the-art baselines, SnR and MLMTyper, by at least 7.31% and 27.44%, respectively; and 3) iJTyper improves the average precision/recall of the popular language model, ChatGPT, by 3.25% and 0.51% on both datasets.
format Preprint
id arxiv_https___arxiv_org_abs_2402_09995
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle iJTyper: An Iterative Type Inference Framework for Java by Integrating Constraint- and Statistically-based Methods
Chen, Zhixiang
Li, Anji
Zhang, Neng
Chen, Jianguo
Huang, Yuan
Zheng, Zibin
Software Engineering
Inferring the types of API elements in incomplete code snippets (e.g., those on Q&A forums) is a prepositive step required to work with the code snippets. Existing type inference methods can be mainly categorized as constraint-based or statistically-based. The former imposes higher requirements on code syntax and often suffers from low recall due to the syntactic limitation of code snippets. The latter relies on the statistical regularities learned from a training corpus and does not take full advantage of the type constraints in code snippets, which may lead to low precision. In this paper, we propose an iterative type inference framework for Java, called iJTyper, by integrating the strengths of both constraint- and statistically-based methods. For a code snippet, iJTyper first applies a constraint-based method and augments the code context with the inferred types of API elements. iJTyper then applies a statistically-based method to the augmented code snippet. The predicted candidate types of API elements are further used to improve the constraint-based method by reducing its pre-built knowledge base. iJTyper iteratively executes both methods and performs code context augmentation and knowledge base reduction until a termination condition is satisfied. Finally, the final inference results are obtained by combining the results of both methods. We evaluated iJTyper on two open-source datasets. Results show that 1) iJTyper achieves high average precision/recall of 97.31% and 92.52% on both datasets; 2) iJTyper significantly improves the recall of two state-of-the-art baselines, SnR and MLMTyper, by at least 7.31% and 27.44%, respectively; and 3) iJTyper improves the average precision/recall of the popular language model, ChatGPT, by 3.25% and 0.51% on both datasets.
title iJTyper: An Iterative Type Inference Framework for Java by Integrating Constraint- and Statistically-based Methods
topic Software Engineering
url https://arxiv.org/abs/2402.09995