synchronized (pw) { super.printStackTrace(pw); if (cause != null) { pw.println("--- Nested Exception ---"); cause.printStackTrace(pw); } }
synchronized (ps) { super.printStackTrace(ps); if (cause != null) { ps.println("--- Nested Exception ---"); cause.printStackTrace(ps); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/BuildException.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/BuildException.java
Method name: void printStackTrace(PrintWriter) Method name: void printStackTrace(PrintStream)
Number of AST nodes: 5 Number of AST nodes: 5
1
synchronized (pw) {
1
synchronized (ps) {
2
            super.printStackTrace(pw);
2
            super.printStackTrace(ps);
3
            if (cause != null) {
3
            if (cause != null) {
4
                pw.println("--- Nested Exception ---");
4
                ps.println("--- Nested Exception ---");
5
                cause.printStackTrace(pw);
5
                cause.printStackTrace(ps);
6
            }
6
            }
7
        }
7
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    super.printStackTrace(pw);
    2
    super.printStackTrace(pw);
    2
    super.printStackTrace(ps);
    Differences
    Expression1Expression2Difference
    pwpsVARIABLE_NAME_MISMATCH
    java.io.PrintWriterjava.io.PrintStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.PrintWriter of variable pw does not match with type java.io.PrintStream of variable ps
    • Make classes java.io.PrintWriter and java.io.PrintStream extend a common superclass
    2
    super.printStackTrace(ps);
    3
    if (cause != null)
    3
    if (cause != null)
    4
    pw.println("--- Nested Exception ---");
    4
    pw.println("--- Nested Exception ---");
    4
    ps.println("--- Nested Exception ---");
    Differences
    Expression1Expression2Difference
    pwpsVARIABLE_NAME_MISMATCH
    java.io.PrintWriterjava.io.PrintStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.PrintWriter of variable pw does not match with type java.io.PrintStream of variable ps
    • Make classes java.io.PrintWriter and java.io.PrintStream extend a common superclass
    4
    ps.println("--- Nested Exception ---");
    5
    cause.printStackTrace(pw);
    5
    cause.printStackTrace(pw);
    5
    cause.printStackTrace(ps);
    Differences
    Expression1Expression2Difference
    pwpsVARIABLE_NAME_MISMATCH
    java.io.PrintWriterjava.io.PrintStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.PrintWriter of variable pw does not match with type java.io.PrintStream of variable ps
    • Make classes java.io.PrintWriter and java.io.PrintStream extend a common superclass
    5
    cause.printStackTrace(ps);
    Precondition Violations (3)
    Row Violation
    1Type java.io.PrintWriter of variable pw does not match with type java.io.PrintStream of variable ps
    2Type java.io.PrintWriter of variable pw does not match with type java.io.PrintStream of variable ps
    3Type java.io.PrintWriter of variable pw does not match with type java.io.PrintStream of variable ps