Skip to main content
QUICK REVIEW

[Paper Review] Clone Removal in Java Programs as a Process of Stepwise Unification

Daniel Speicher, Andri Bremm|arXiv (Cornell University)|Jan 11, 2013
Software Engineering ResearchComputer Science5 references4 citations
TL;DR

This paper proposes a stepwise unification approach to automate clone removal in Java programs by modeling refactoring as a sequence of unification steps over Program Dependence Graphs (PDGs). By analyzing data and control dependencies, the method identifies unifiable statements, applies refactorings like extract method or lambda expressions, and uses backtracking to generate precise, behavior-preserving refactoring suggestions for clone elimination.

ABSTRACT

Cloned code is one of the most important obstacles against consistent software maintenance and evolution. Although today's clone detection tools find a variety of clones, they do not offer any advice how to remove such clones. We explain the problems involved in finding a sequence of changes for clone removal and suggest to view this problem as a process of stepwise unification of the clone instances. Consequently the problem can be solved by backtracking over the possible unification steps.

Motivation & Objective

  • To address the gap in existing clone detection tools, which identify clones but do not suggest how to remove them.
  • To provide a systematic, automated approach for generating precise refactoring sequences that eliminate code clones while preserving program behavior.
  • To model clone removal as a process of unifying statements and control flow through refactorings, guided by PDG analysis.
  • To support complex clone types—especially those with differing expressions or control structures—by leveraging refactorings like lambda extraction and method extraction.

Proposed method

  • Construct Program Dependence Graphs (PDGs) for each clone candidate, modeling control and data dependencies, including method invocations as read/write accesses.
  • Identify unifiable statements by comparing PDGs, considering refactorings such as rename, introduce parameter, and generalize types.
  • Apply backtracking over possible unification steps to explore valid sequences of refactorings that eliminate clones.
  • Use extract method and extract lambda expression refactorings to isolate non-unifiable statements, especially for differences in expressions or control flow.
  • Preserve data dependency order to ensure semantic correctness, including handling anti-dependencies to prevent unintended behavior changes.
  • Leverage existing tools like JTransformer to provide AST and binding information for accurate refactoring application.

Experimental results

Research questions

  • RQ1How can we systematically generate behavior-preserving refactoring sequences to remove code clones in Java programs?
  • RQ2What role do Program Dependence Graphs (PDGs) play in identifying unifiable statements and guiding refactoring decisions?
  • RQ3Which refactorings—such as extract method, lambda expression, or reorder parameters—are most effective for unifying non-identical clones?
  • RQ4How can control flow be safely restructured to separate non-unifiable statements while preserving program semantics?
  • RQ5In what scenarios is the use of lambda expressions more appropriate than design patterns like template method for clone removal?

Key findings

  • The approach successfully transforms non-identical clones into unified code by applying a sequence of refactorings derived from PDG analysis.
  • Lambda expressions enable effective extraction of differing expressions, such as method calls with different parameters, without requiring complex design patterns.
  • Extract method refactoring is effective for isolating non-unifiable statements when they form a contiguous block with limited data dependencies.
  • Backtracking over unification steps allows the tool to explore and suggest multiple valid refactoring sequences, increasing flexibility in clone removal.
  • The method reduces the cost of clone removal by focusing only on relevant method pairs identified by existing clone detection tools, avoiding full program comparison.
  • The use of PDGs with extended data dependency modeling—including method invocations and aliasing—improves accuracy in identifying safe refactoring points.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.