Cross-language code search using static and dynamic analyses

Cross-language code search using static and dynamic analyses
复制标题

DOI:
10.1145/3468264.3468538
复制
发表时间:
2021-06
期刊:
Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering
影响因子:
--
通讯作者:
George Mathew;Kathryn T. Stolee
George Mathew;Kathryn T. Stolee
中科院分区:
其他
文献类型:
--
作者:
George Mathew;Kathryn T. Stolee

文献摘要

相似文献

随着代码搜索渗透到软件开发中的大多数活动时,代码对代码搜索已出现以支持使用代码作为查询并在搜索结果中检索类似代码。应用程序包括用于重构的重复代码检测,用于修复程序修复的补丁标识和语言翻译。现有的代码对代码搜索工具依赖于静态相似性方法,例如令牌和抽象语法树(AST)的比较到近似动态行为,从而导致精确度较低。大多数工具不支持跨语言代码搜索,而那些搜索的工具则依赖于需要标记培训数据的机器学习模型。我们跨语言(COSAL)介绍了代码对代码搜索,这是一种跨语言技术,它使用静态和动态分析来识别相似的代码,并且不需要机器学习模型。代码段是根据代码令牌相似性,结构相似性和行为相似性的非主导分类对代码段进行的。我们在43,146java和Python文件以及55,499个Java文件的两个数据集上进行了经验评估COSAL,并发现基于静态和动态相似性度量的非主导排名的代码搜索比单一或加权度量相比更有效; 2)与最新的语言和跨语言代码搜索工具相比,COSAL具有更好的精度和回忆。我们探索在大型开源存储库上使用COSAL的潜力,并讨论对更多语言和相似性指标的可扩展性,从而为实用的多语言代码搜索提供了网关。
As code search permeates most activities in software development,code-to-code search has emerged to support using code as a query and retrieving similar code in the search results. Applications include duplicate code detection for refactoring, patch identification for program repair, and language translation. Existing code-to-code search tools rely on static similarity approaches such as the comparison of tokens and abstract syntax trees (AST) to approximate dynamic behavior, leading to low precision. Most tools do not support cross-language code-to-code search, and those that do, rely on machine learning models that require labeled training data. We present Code-to-Code Search Across Languages (COSAL), a cross-language technique that uses both static and dynamic analyses to identify similar code and does not require a machine learning model. Code snippets are ranked using non-dominated sorting based on code token similarity, structural similarity, and behavioral similarity. We empirically evaluate COSAL on two datasets of 43,146Java and Python files and 55,499 Java files and find that 1) code search based on non-dominated ranking of static and dynamic similarity measures is more effective compared to single or weighted measures; and 2) COSAL has better precision and recall compared to state-of-the-art within-language and cross-language code-to-code search tools. We explore the potential for using COSAL on large open-source repositories and discuss scalability to more languages and similarity metrics, providing a gateway for practical,multi-language code-to-code search.