Demystify official API usage directives with crowdsourced API misuse scenarios, erroneous code examples and patches
Xiaoxue Ren, Jiamou Sun, Zhenchang Xing, Xin Xia, Jianling Sun
Abstract
API usage directives in official API documentation describe the contracts, constraints and guidelines for using APIs in natural language. Through the investigation of API misuse scenarios on Stack Overflow, we identify three barriers that hinder the understanding of the API usage directives, i.e., lack of specific usage context, indirect relationships to cooperative APIs, and confusing APIs with subtle differences. To overcome these barriers, we develop a text mining approach to discover the crowdsourced API misuse scenarios on Stack Overflow and extract from these scenarios erroneous code examples and patches, as well as related API and confusing APIs to construct demystification reports to help developers understand the official API usage directives described in natural language. We apply our approach to API usage directives in official Android API documentation and android-tagged discussion threads on Stack Overflow. We extract 159,116 API misuse scenarios for 23,969 API usage directives of 3138 classes and 7471 methods, from which we generate the demystification reports. Our manual examination confirms that the extracted information in the generated demystification reports are of high accuracy. By a user study of 14 developers on 8 API-misuse related error scenarios, we show that our demystification reports help developer understand and debug API-misuse related program errors faster and more accurately, compared with reading only plain API usage-directive sentences.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext ae7eb152-5e89-4284-a34e-6617f4180c78Cited by top-tier papers9
- API-Misuse Detection Driven by Fine-Grained API-Constraint Knowledge GraphXiaoxue Ren, Xinyuan Ye, Zhenchang Xing, Xin Xia et al.ASE 2020 · 62 citations
- PyART: Python API Recommendation in Real-TimeXincheng He, Lei Xu, Xiangyu Zhang, Rui Hao et al.ICSE 2021 · 29 citations
- From Misuse to Mastery: Enhancing Code Generation with Knowledge-Driven AI ChainingXiaoxue Ren, Xinyuan Ye, Dehai Zhao, Zhenchang Xing et al.ASE 2023 · 28 citations
- ARCLIN: Automated API Mention Resolution for Unformatted TextsYintong Huo, Yuxin Su, Hongming Zhang, Michael R. LyuICSE 2022 · 6 citations
- Improving API Knowledge Discovery with ML: A Case Study of Comparable API MethodsDaye Nam, Brad A. Myers, Bogdan Vasilescu, Vincent J. HellendoornICSE 2023 · 6 citations
Related papers
- When APIs are intentionally bypassed: an exploratory study of API workaroundsMaxime Lamothe, Weiyi ShangICSE 2020 · 14 citations
- You Get Where You're Looking for: The Impact of Information Sources on Code SecurityYasemin Acar, Michael Backes, Sascha Fahl, Doowon Kim et al.S&P 2016 · 325 citations
- APICAD: Augmenting API Misuse Detection through Specifications from Code and DocumentsXiaoke Wang, Lei ZhaoICSE 2023 · 7 citations
- SFA-Miner: Mining Path-Sensitive API Usage Patterns Via Symbolic Finite AutomataJiasheng Jiang, Mingwei Zheng, Qingkai Shi, Xiangyu ZhangS&P 2026 · 1 citation
- ARBITRAR: User-Guided API Misuse DetectionZiyang Li, Aravind Machiry, Binghong Chen, Mayur Naik et al.S&P 2021 · 30 citations
