paperbot · PL 论文追踪

全部论文 待读 收藏

P2 API-misuse detection driven by fine-grained API-constraint knowledge graph

细粒度 API 约束知识图谱驱动的 API 误用检测
ASE Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering2020匹配度 3/10 · 该论文属于程序分析与API误用检测,与静态分析有交集,但未涉及机器学习系统、Agentic程序、LLM辅助分析、浮点程序分析或贝叶斯程序分析,与用户的核心研究方向不匹配。引用 64 inbox
Xiaoxue Ren, Xinyuan Ye, Zhenchang Xing, Xin Xia, Xiwei Xu, Liming Zhu, Jianling Sun
crossref: 2026-09-12

AI 速览

一句话:从 API 参考文档抽取细粒度 API 约束知识图谱,据此直接检测缺失调用、缺失条件检查与缺失异常处理三类 API 误用。

现有 API 误用检测方法大多以从代码库中挖掘的高频 API 用法模式为基准,隐含假设“偏离最常见用法即为误用”,但用法模式在完整性、可解释性和最佳实践上与 API 使用注意事项存在明显知识鸿沟。本文提出直接面向 API 注意事项知识进行误用检测的新思路:采用开放信息抽取方法,从 API 参考文档中构建 API 约束知识图谱,显式建模调用顺序与条件检查两类 API 约束关系,并为返回与抛出关系补充返回条件和异常触发条件。该知识图谱支持检测三类常见 API 误用——缺失调用、缺失条件检查和缺失异常处理,而现有检测器大多只关注缺失调用。作者在 Java SDK API 规范上开展概念验证,评估显示抽取的 API 约束关系准确率较高;在 MuBench 基准上,知识驱动的检测器达到 0.60(68/113)精确率与 0.28(68/239)召回率,显著优于基于模式的检测器;12 名开发者参与的初步用户研究也表明该方法在帮助开发者避免 API 误用、调试相关缺陷方面具有前景。

问题
基于高频 API 用法模式的误用检测把“偏离最常见用法”等同于误用,与 API 文档中真正的使用注意事项在完整性、可解释性与最佳实践上存在知识鸿沟,且多数检测器仅能发现缺失调用一类问题。
方法
使用开放信息抽取从 API 参考文档构建 API 约束知识图谱,显式建模调用顺序与条件检查两类约束关系,并丰富返回/抛出关系及其条件,进而以该知识图谱为依据检测缺失调用、缺失条件检查和缺失异常处理。
评估
在 Java SDK API 规范上验证抽取的 API 约束关系准确率,并在 API 误用基准 MuBench 上测量检测精确率与召回率,与现有基于模式的检测器对比,同时开展 12 名开发者参与的用户研究。
原文摘要(Abstract)

API misuses cause significant problem in software development. Existing methods detect API misuses against frequent API usage patterns mined from codebase. They make a naive assumption that API usage that deviates from the most-frequent API usage is a misuse. However, there is a big knowledge gap between API usage patterns and API usage caveats in terms of comprehensiveness, explainability and best practices. In this work, we propose a novel approach that detects API misuses directly against the API caveat knowledge, rather than API usage patterns. We develop open information extraction methods to construct a novel API-constraint knowledge graph from API reference documentation. This knowledge graph explicitly models two types of API-constraint relations (call-order and condition-checking) and enriches return and throw relations with return conditions and exception triggers. It empowers the detection of three types of frequent API misuses - missing calls, missing condition checking and missing exception handling, while existing detectors mostly focus on only missing calls. As a proof-of-concept, we apply our approach to Java SDK API Specification. Our evaluation confirms the high accuracy of the extracted API-constraint relations. Our knowledge-driven API misuse detector achieves 0.60 (68/113) precision and 0.28 (68/239) recall for detecting Java API misuses in the API misuse benchmark MuBench. This performance is significantly higher than that of existing pattern-based API misused detectors. A pilot user study with 12 developers shows that our knowledge-driven API misuse detection is very promising in helping developers avoid API misuses and debug the bugs caused by API misuses.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot6005,
  title = {API-misuse detection driven by fine-grained API-constraint knowledge graph},
  author = {Xiaoxue Ren and Xinyuan Ye and Zhenchang Xing and Xin Xia and Xiwei Xu and Liming Zhu and Jianling Sun},
  booktitle = {ASE},
  year = {2020},
  doi = {10.1145/3324884.3416551}
}