SnR: Constraint-Based Type Inference for Incomplete Java Code Snippets
Thu 12 May 2022 22:15 - 22:20 at ICSE room 3-even hours - Reuse and Economics Chair(s): Rick Kazman
Code snippets are prevalent on websites such as Stack Overflow and are effective in demonstrating API usages concisely. However they are usually difficult to be used directly because most code snippets not only are syntactically incomplete but also lack dependency information, and thus do not compile. For example, Java snippets usually do not have import statements or required library names; only 6.88% of Java snippets on Stack Overflow include import statements necessary for compilation.
This paper proposes SnR, a precise, efficient, constraint-based technique to automatically infer the exact types used in code snippets and the libraries containing the inferred types, to compile and therefore reuse the code snippets. Initially, SnR builds a knowledge base of APIs, i.e., various facts about the available APIs, from a corpus of Java libraries. Given a code snippet with missing import statements, SnR automatically extracts typing constraints from the snippet, solves the constraints against the knowledge base, and returns a set of APIs that satisfies the constraints to be imported into the snippet.
We have evaluated SnR on a benchmark of 267 code snippets from Stack Overflow. SnR significantly outperforms the state-of-the-art tool Coster. SnR correctly infers 91% of the import statements, which makes 73.8% of the snippets compile, compared to 36.0% of the import statements and 9.0% of the snippets by Coster.
Wed 11 MayDisplayed time zone: Eastern Time (US & Canada) change
13:00 - 14:00 | Requirements and ReuseTechnical Track / Journal-First Papers at ICSE room 2-odd hours Chair(s): Andrea Zisman The Open University | ||
13:00 5mTalk | On Systematically Building a CNL for Functional Requirements Journal-First Papers Alvaro Veizaga Interdisciplinary Centre for Security, Reliability and Trust (SnT), University of Luxembourg, Luxembourg, Mauricio Alferez Interdisciplinary Centre for Security, Reliability and Trust (SnT), University of Luxembourg, Damiano Torre University of Luxembourg, Mehrdad Sabetzadeh University of Ottawa, Lionel Briand University of Luxembourg; University of Ottawa Link to publication DOI Pre-print Media Attached | ||
13:05 5mTalk | Präzi: From Package-based to Call-based Dependency Networks Journal-First Papers Joseph Hejderup Endor Labs & Delft University of Technology, Moritz Beller Facebook, USA, Konstantinos Triantafyllou University of Athens, Georgios Gousios Endor Labs & Delft University of Technology DOI Pre-print Media Attached | ||
13:10 5mTalk | Automated Handling of Anaphoric Ambiguity in Requirements: A Multi-solution Study Technical Track Saad Ezzini University of Luxembourg, Sallam Abualhaija University of Luxembourg, Chetan Arora Deakin University, Mehrdad Sabetzadeh University of Ottawa Pre-print Media Attached | ||
13:15 5mTalk | DeepSTL - From English Requirements to Signal Temporal Logic Technical Track Jie He Technische Universität Wien, Ezio Bartocci , Dejan Nickovic Austrian Institute of Technology, Haris Isakovic Technische Universität Wien, Radu Grosu Vienna University of Technology DOI Pre-print Media Attached | ||
13:20 5mTalk | SnR: Constraint-Based Type Inference for Incomplete Java Code Snippets Technical Track Yiwen Dong University of Waterloo, Tianxiao Gu Tiktok Inc., Yongqiang Tian University of Waterloo, Chengnian Sun University of Waterloo Pre-print Media Attached |
Thu 12 MayDisplayed time zone: Eastern Time (US & Canada) change
22:00 - 23:00 | Reuse and EconomicsNIER - New Ideas and Emerging Results / SEIP - Software Engineering in Practice / Technical Track / Journal-First Papers at ICSE room 3-even hours Chair(s): Rick Kazman University of Hawai‘i at Mānoa | ||
22:00 5mTalk | CodeMatcher: Searching Code Based on Sequential Semantics of Important Query Words Journal-First Papers Chao Liu Chongqing University, Xin Xia Huawei Software Engineering Application Technology Lab, David Lo Singapore Management University, Zhiwei Liu Baidu Inc., Ahmed E. Hassan Queen's University, Shanping Li Zhejiang University Link to publication DOI Pre-print Media Attached | ||
22:05 5mTalk | The best defense is a good defense: adapting negotiation methods for tackling pressure over software project estimates NIER - New Ideas and Emerging Results Patricia Matsubara UFAM & UFMS, Igor Steinmacher Northern Arizona University, Bruno Gadelha UFAM, Tayana Conte Universidade Federal do Amazonas Pre-print Media Attached | ||
22:10 5mTalk | The Unexplored Terrain of Compiler Warnings SEIP - Software Engineering in Practice Gunnar Kudrjavets University of Groningen, Aditya Kumar Snap, Inc., Nachiappan Nagappan Microsoft Research, Ayushi Rastogi University of Groningen, The Netherlands DOI Pre-print Media Attached | ||
22:15 5mTalk | SnR: Constraint-Based Type Inference for Incomplete Java Code Snippets Technical Track Yiwen Dong University of Waterloo, Tianxiao Gu Tiktok Inc., Yongqiang Tian University of Waterloo, Chengnian Sun University of Waterloo Pre-print Media Attached | ||
22:20 5mTalk | Cross-Domain Deep Code Search with Few-Shot Learning Technical Track Yitian Chai School of Software, Shanghai Jiao Tong University, Hongyu Zhang University of Newcastle, Beijun Shen School of Electronic Information and Electrical Engineering, Shanghai Jiao Tong University, Xiaodong Gu Shanghai Jiao Tong University, China DOI Pre-print Media Attached File Attached | ||
22:25 5mTalk | GitHub Sponsors: Exploring a New Way to Contribute to Open Source Technical Track Naomichi Shimada Nara Institute of Science and Technology, Tao Xiao Nara Institute of Science and Technology, Hideaki Hata Shinshu University, Christoph Treude University of Melbourne, Kenichi Matsumoto Nara Institute of Science and Technology DOI Pre-print Media Attached |