Software developers must often replace existing components in their systems to adapt to evolving environments or tooling. While traditional code search systems are effective at retrieving components with related functionality, it is much more challenging to retrieve components that can be used to directly replace existing functionality, as replacements must account for more fundamental program properties such as type compatibility. To address this problem, we introduce ClassFinder, a system which given a query class Q, and a search corpus S, returns a ranked subset of classes that can replace Q and its functionality. ClassFinder produces afield and method mapping between the classes that can provide useful hints to a developer and can be used to effectively refine the ranking of candidate replacement classes. Our technique leverages the complementary strengths of a distributed embeddings-based search and type-based analysis, using the former to prune down candidates for an optimization-based approach based on the latter. ClassFinder retrieves replacement classes, along with a type-aware field/method mapping between classes. We evaluate ClassFinder on a search space of ~600thousand open sourceJava classes. Querying ClassFinder with 24 known Java classes provided meaningful replacement classes and mappings, in many cases producing complete mappings with functionally identical replacement classes.
翻译:软件开发者通常必须更换其系统中的现有组件,以适应不断变化的环境或工具。传统代码搜索系统在检索相关功能的组件时有效,但检索能够直接替换现有功能的组件则更具挑战性,因为替换必须说明更基本的程序属性,例如类型兼容性。为了解决这个问题,我们引入了分类Finder,一个给一个查询类Q的系统,和一个搜索系统S,返回了能够取代Q及其功能的等级分级组。类Finder在为开发者提供有用提示的类别之间制作了场和方法映射,并可用于有效改进候选替换类的排名。我们的技术利用分布式嵌入式搜索和类型分析的互补优势,利用前者为候选人提供基于后者的优化方法。级Finder检索了替换等级,同时在类别之间绘制了一种类型认知的字段/方法图。我们评估了能够向开发者提供有用提示的分类和方法映射,并可用于有效改进候选替换类的排序。Queringing AliFindersal 和在已知的24个类中完成功能性替换。