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);
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);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/MapperTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/PathTest.java
Method name: void testCircularReferenceCheck() Method name: void testCircularReferenceCheck()
Number of AST nodes: 7 Number of AST nodes: 7
1
project.addReference("dummy3", m3);
1
project.addReference("dummy3", p3);
2
        m3.setRefid(new Reference("dummy1"));
2
        p3.setRefid(new Reference("dummy1"));
3
        try {
3
        try {
4
            m1.getImplementation();
4
            p1.list();
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
10
        // dummy1 --> dummy2 --> dummy3
11
        // (which holds a glob mapper from "*.java" to "*.class"
11
 (with Path "/a")
12
        m1 = new Mapper(project);
12
        p1 = new Path(project);
13
        project.addReference("dummy1", m1);
13
        project.addReference("dummy1", p1);
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)11.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    14
    project.addReference("dummy3", m3);
    14
    project.addReference("dummy3", m3);
    12
    project.addReference("dummy3", p3);
    Differences
    Expression1Expression2Difference
    m3p3VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Mapperorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    12
    project.addReference("dummy3", p3);
    15
    m3.setRefid(new Reference("dummy1"));
    15
    m3.setRefid(new Reference("dummy1"));
    13
    p3.setRefid(new Reference("dummy1"));
    Differences
    Expression1Expression2Difference
    m3p3VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Mapperorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    13
    p3.setRefid(new Reference("dummy1"));
    16
    try
    14
    try
                                
    15
    p1.list();
    17
    m1.getImplementation();
    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
                                                          
    18
    fail("Can make circular reference.");
    16
    fail("Can make circular reference.");
    19
    m1 = new Mapper(project);
    19
    m1 = new Mapper(project);
    17
    p1 = new Path(project);
    Differences
    Expression1Expression2Difference
    m1p1VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Mapperorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.Mapperorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    17
    p1 = new Path(project);
    20
    project.addReference("dummy1", m1);
    20
    project.addReference("dummy1", m1);
    18
    project.addReference("dummy1", p1);
    Differences
    Expression1Expression2Difference
    m1p1VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Mapperorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    18
    project.addReference("dummy1", p1);
    Precondition Violations (2)
    Row Violation
    1Unmatched 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
    2Clone fragment #1 returns variable m1 with type org.apache.tools.ant.types.Mapper , while Clone fragment #2 returns variable p1 with type org.apache.tools.ant.types.Path