StoneDetector: Conventional and versatile code clone detection for Java
Thomas S. Heinze, André Schäfer, Wolfram Amme
TL;DR
StoneDetector addresses code clone detection in Java by encoding control-flow information through dominator-tree paths and performing approximate textual matching on encoded path descriptions. The approach maintains a conventional, language-agnostic clone-detection core that supports Java source and Bytecode, with configurable string metrics and hashing to balance recall, precision, and scalability. Thorough evaluations against BigCloneBench and additional benchmarks show competitive performance for exact and near-miss clones, and notable strength in harder-to-detect Type 3/4 clones, including large-scale codebases. The tool is publicly available and designed for extensibility, enabling experiments with alternative representations, metrics, and Bytecode-based analysis, with promising directions for integrating Deep Learning and multi-language support in future work.
Abstract
Copy & paste is a widespread practice when developing software and, thus, duplicated and subsequently modified code occurs frequently in software projects. Since such code clones, i.e., identical or similar fragments of code, can bloat software projects and cause issues like bug or vulnerability propagation, their identification is of importance. In this paper, we present StoneDetector and its underlying method for finding code clones in Java source and Bytecode. StoneDetector implements a conventional clone detection approach based upon the textual comparison of paths derived from the code's representation by dominator trees. In this way, the tool does not only find exact and syntactically similar near-miss code clones, but also code clones that are harder to detect due to their larger variety in the syntax. We demonstrate StoneDetector's versatility as a conventional clone detection tool and analyze its various available configuration parameters, including the usage of different string metrics, hashing algorithms, etc. In our exhaustive evaluation with other conventional clone detectors on several state-of-the-art benchmarks, we can show StoneDetector's performance and scalability in finding code clones in both, Java source and Bytecode.
