一句话:结合自动定位与人工检查,对 9 个库中 API 参数规则的类型与分布开展大规模实证研究。
当开发者不适当地设置软件库 API 参数时,程序可能表现出意外的运行时行为;已有研究构建工具挖掘 API 参数规则,但人们尚不清楚参数规则有哪些类型,以及它们如何在文档与源码中分布。为回答这些问题,本文采用自动定位与人工检查相结合的混合方法:自动工具 PaRu 定位受约束的参数,这些约束或记录于 Javadoc(文档规则),或隐含于源代码(代码规则);随后人工识别并归类这些参数的规则,并建立文档规则与代码规则之间的映射。作者将 PaRu 应用于 9 个广泛使用的库,共定位到 5334 个具有文档或代码规则的参数,其中仅 187 个参数同时具有两类规则,且这 187 个参数中有 79 对规则不匹配;PaRu 还从 Javadoc 与代码中抽取了 1688 条规则语句,人工将其划分为六类,其中两类被以往方法忽视。统计显示,86.2% 的参数只有代码规则,10.3% 只有文档规则,仅 3.5% 同时具有两类规则。研究揭示了参数规则自动抽取所面临的挑战,并基于发现讨论了既有方法的潜力与未来工具设计的启示。
Developers build programs based on software libraries to reduce coding effort. If a program inappropriately sets an API parameter, the program may exhibit unexpected runtime behaviors. To help developers correctly use library APIs, researchers built tools to mine API parameter rules. However, it is still unknown (1) what types of parameter rules there are, and (2) how these rules distribute inside documents and source files. In this paper, we conducted an empirical study to investigate the above-mentioned questions. To analyze as many parameter rules as possible, we took a hybrid approach that combines automatic localization of constrained parameters with manual inspection. Our automatic approach---PaRu---locates parameters that have constraints either documented in Javadoc (i.e., document rules) or implied by source code (i.e., code rules). Our manual inspection (1) identifies and categorizes rules for the located parameters, and (2) establishes mapping between document and code rules. By applying PaRu to 9 widely used libraries, we located 5,334 parameters with either document or code rules. Interestingly, there are only 187 parameters that have both types of rules, and 79 pairs of these parameter rules are unmatched. Additionally, PaRu extracted 1,688 rule sentences from Javadoc and code. We manually classified these sentences into six categories, two of which are overlooked by prior approaches. We found that 86.2% of parameters have only code rules; 10.3% of parameters have only document rules; and only 3.5% of parameters have both document and code rules. Our research reveals the challenges for automating parameter rule extraction. Based on our findings, we discuss the potentials of prior approaches and present our insights for future tool design.
DOI 原文 ·
@inproceedings{paperbot5615,
title = {An empirical study on API parameter rules},
author = {Hao Zhong and Na Meng and Zexuan Li and Li Jia},
booktitle = {ICSE},
year = {2020},
doi = {10.1145/3377811.3380922}
}