project.addReference("dummy3", p3); p3.setRefid(new Reference("dummy1")); try { p1.list(); fail("Can make circular reference."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } // dummy1 --> dummy2 --> dummy3 (with Path "/a") p1 = new Path(project); project.addReference("dummy1", p1);
project.addReference("dummy3", m3); m3.setRefid(new Reference("dummy1")); try { m1.getImplementation(); fail("Can make circular reference."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } // dummy1 --> dummy2 --> dummy3 // (which holds a glob mapper from "*.java" to "*.class" m1 = new Mapper(project); project.addReference("dummy1", m1);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/PathTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/MapperTest.java
Method name: void testCircularReferenceCheck() Method name: void testCircularReferenceCheck()
Number of AST nodes: 7 Number of AST nodes: 7
1
project.addReference("dummy3", p3);
1
project.addReference("dummy3", m3);
2
        p3.setRefid(new Reference("dummy1"));
2
        m3.setRefid(new Reference("dummy1"));
3
        try {
3
        try {
4
            p1.list();
4
            m1.getImplementation();
5
            fail("Can make circular reference.");
5
            fail("Can make circular reference.");
6
        } catch (BuildException be) {
6
        } catch (BuildException be) {
7
            assertEquals("This data type contains a circular reference.",
7
            assertEquals("This data type contains a circular reference.",
8
                         be.getMessage());
8
                         be.getMessage());
9
        }
9
        }
10
        // dummy1 --> dummy2 --> dummy3 (with Path "/a")
10
        // dummy1 --> dummy2 --> dummy3
11
        // (which holds a glob mapper from "*.java" to "*.class"
11
        p1 = new Path(project);
12
        m1 = new Mapper(project);
12
        project.addReference("dummy1", p1);
13
        project.addReference("dummy1", m1);
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 comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)34.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    12
    project.addReference("dummy3", p3);
    12
    project.addReference("dummy3", p3);
    14
    project.addReference("dummy3", m3);
    Differences
    Expression1Expression2Difference
    p3m3VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    14
    project.addReference("dummy3", m3);
    13
    p3.setRefid(new Reference("dummy1"));
    13
    p3.setRefid(new Reference("dummy1"));
    15
    m3.setRefid(new Reference("dummy1"));
    Differences
    Expression1Expression2Difference
    p3m3VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    15
    m3.setRefid(new Reference("dummy1"));
    14
    try
    16
    try
    15
    p1.list();
    15
    p1.list();
    Preondition Violations
    Unmatched statement p1.list(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                
                                                          
    17
    m1.getImplementation();
    Preondition Violations
    Unmatched statement m1.getImplementation(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    17
    m1.getImplementation();
    16
    fail("Can make circular reference.");
    18
    fail("Can make circular reference.");
    17
    p1 = new Path(project);
    17
    p1 = new Path(project);
    19
    m1 = new Mapper(project);
    Differences
    Expression1Expression2Difference
    p1m1VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Path(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Mapper(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19
    m1 = new Mapper(project);
    18
    project.addReference("dummy1", p1);
    18
    project.addReference("dummy1", p1);
    20
    project.addReference("dummy1", m1);
    Differences
    Expression1Expression2Difference
    p1m1VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    20
    project.addReference("dummy1", m1);
    Precondition Violations (5)
    Row Violation
    1Unmatched statement p1.list(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    2Unmatched statement m1.getImplementation(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    3Expression new Path(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression new Mapper(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variable p1 with type org.apache.tools.ant.types.Path , while Clone fragment #2 returns variable m1 with type org.apache.tools.ant.types.Mapper