PlumNeedle n1 = new PlumNeedle(); PlumNeedle n2 = null; try { n2 = (PlumNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2));
WindNeedle n1 = new WindNeedle(); WindNeedle n2 = null; try { n2 = (WindNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2));
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/needle/junit/PlumNeedleTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/needle/junit/WindNeedleTests.java
Method name: void testCloning() Method name: void testCloning()
Number of AST nodes: 7 Number of AST nodes: 7
1
PlumNeedle n1 = new PlumNeedle();
1
WindNeedle n1 = new WindNeedle();
2
        PlumNeedle n2 = null;
2
        WindNeedle n2 = null;
3
        try {
3
        try {
4
            n2 = (PlumNeedle) n1.clone();
4
            n2 = (WindNeedle) n1.clone();
5
        }
5
        }
6
        catch (CloneNotSupportedException e) {
6
        catch (CloneNotSupportedException e) {
7
            e.printStackTrace();
7
            e.printStackTrace();
8
            System.err.println("Failed to clone.");
8
            System.err.println("Failed to clone.");
9
        }
9
        }
10
        assertTrue(n1 != n2);
10
        assertTrue(n1 != n2);
11
        assertTrue(n1.getClass() == n2.getClass());
11
        assertTrue(n1.getClass() == n2.getClass());
12
        assertTrue(n1.equals(n2));
12
        assertTrue(n1.equals(n2));
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 in different classes having the same super class
Number of node comparisons21
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)16.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    PlumNeedle n1 = new PlumNeedle();
    1
    PlumNeedle n1 = new PlumNeedle();
    1
    WindNeedle n1 = new WindNeedle();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    1
    WindNeedle n1 = new WindNeedle();
    2
    PlumNeedle n2 = null;
    2
    PlumNeedle n2 = null;
    2
    WindNeedle n2 = null;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    2
    WindNeedle n2 = null;
    3
    try
    3
    try
    4
    n2 = (PlumNeedle)n1.clone();
    4
    n2 = (PlumNeedle)n1.clone();
    4
    n2 = (WindNeedle)n1.clone();
    Differences
    Expression1Expression2Difference
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (PlumNeedle)n1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (WindNeedle)n1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    n2 = (WindNeedle)n1.clone();
    5
    assertTrue(n1 != n2);
    5
    assertTrue(n1 != n2);
    5
    assertTrue(n1 != n2);
    Differences
    Expression1Expression2Difference
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    5
    assertTrue(n1 != n2);
    6
    assertTrue(n1.getClass() == n2.getClass());
    6
    assertTrue(n1.getClass() == n2.getClass());
    6
    assertTrue(n1.getClass() == n2.getClass());
    Differences
    Expression1Expression2Difference
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    6
    assertTrue(n1.getClass() == n2.getClass());
    7
    assertTrue(n1.equals(n2));
    7
    assertTrue(n1.equals(n2));
    7
    assertTrue(n1.equals(n2));
    Differences
    Expression1Expression2Difference
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.needle.PlumNeedleorg.jfree.chart.needle.WindNeedleSUBCLASS_TYPE_MISMATCH
    7
    assertTrue(n1.equals(n2));
    Precondition Violations (2)
    Row Violation
    1Expression (PlumNeedle)n1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression (WindNeedle)n1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted