f2.setRefid(new Reference("dummy3")); AbstractFileSet f3 = getInstance(); project.addReference("dummy3", f3); f3.setRefid(new Reference("dummy1")); try { f1.getDir(project); fail("Can make circular reference."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } try { f1.getDirectoryScanner(project); fail("Can make circular reference."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } // dummy1 --> dummy2 --> dummy3 // (which has the Project's basedir as root). f1 = getInstance();
f2.setRefid(new Reference("dummy3")); FileList f3 = new FileList(); project.addReference("dummy3", f3); f3.setRefid(new Reference("dummy1")); try { f1.getDir(project); fail("Can make circular reference."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } try { f1.getFiles(project); fail("Can make circular reference."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } // dummy1 --> dummy2 --> dummy3 // (which has the Project's basedir as root). f1 = new FileList();
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/AbstractFileSetTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/FileListTest.java
Method name: void testCircularReferenceCheck() Method name: void testCircularReferenceCheck()
Number of AST nodes: 11 Number of AST nodes: 11
1
f2.setRefid(new Reference("dummy3"));
1
f2.setRefid(new Reference("dummy3"));
2
        AbstractFileSet f3 = getInstance();
2
        FileList f3 = new FileList();
3
        project.addReference("dummy3", f3);
3
        project.addReference("dummy3", f3);
4
        f3.setRefid(new Reference("dummy1"));
4
        f3.setRefid(new Reference("dummy1"));
5
        try {
5
        try {
6
            f1.getDir(project);
6
            f1.getDir(project);
7
            fail("Can make circular reference.");
7
            fail("Can make circular reference.");
8
        } catch (BuildException be) {
8
        } catch (BuildException be) {
9
            assertEquals("This data type contains a circular reference.",
9
            assertEquals("This data type contains a circular reference.",
10
                         be.getMessage());
10
                         be.getMessage());
11
        }
11
        }
12
        try {
12
        try {
13
            f1.getDirectoryScanner(project);
13
            f1.getFiles(project);
14
            fail("Can make circular reference.");
14
            fail("Can make circular reference.");
15
        } catch (BuildException be) {
15
        } catch (BuildException be) {
16
            assertEquals("This data type contains a circular reference.",
16
            assertEquals("This data type contains a circular reference.",
17
                         be.getMessage());
17
                         be.getMessage());
18
        }
18
        }
19
        // dummy1 --> dummy2 --> dummy3
19
        // dummy1 --> dummy2 --> dummy3
20
        // (which has the Project's basedir as root).
20
        // (which has the Project's basedir as root).
21
        f1 = getInstance();
21
        f1 = new FileList();
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.6
Clones locationClones are in different classes having the same super class
Number of node comparisons41
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)46.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    15
    f2.setRefid(new Reference("dummy3"));
    15
    f2.setRefid(new Reference("dummy3"));
    15
    f2.setRefid(new Reference("dummy3"));
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    15
    f2.setRefid(new Reference("dummy3"));
    16
    AbstractFileSet f3 = getInstance();
    16
    AbstractFileSet f3 = getInstance();
    16
    FileList f3 = new FileList();
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    getInstance()new FileList()TYPE_COMPATIBLE_REPLACEMENT
    16
    FileList f3 = new FileList();
    17
    project.addReference("dummy3", f3);
    17
    project.addReference("dummy3", f3);
    17
    project.addReference("dummy3", f3);
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    17
    project.addReference("dummy3", f3);
    18
    f3.setRefid(new Reference("dummy1"));
    18
    f3.setRefid(new Reference("dummy1"));
    18
    f3.setRefid(new Reference("dummy1"));
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    18
    f3.setRefid(new Reference("dummy1"));
    19
    try
    19
    try
    20
    f1.getDir(project);
    20
    f1.getDir(project);
    20
    f1.getDir(project);
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression f1 cannot be unified with expression f1 , because common superclass org.apache.tools.ant.types.DataType does not declare member(s) public synchronized java.io.File getDir(org.apache.tools.ant.Project)
    20
    f1.getDir(project);
    21
    fail("Can make circular reference.");
    21
    fail("Can make circular reference.");
    22
    try
    22
    try
                                                      
    23
    f1.getFiles(project);
    Preondition Violations
    Unmatched statement f1.getFiles(project); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement f1.getFiles(project); 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
    23
    f1.getFiles(project);
    23
    f1.getDirectoryScanner(project);
    23
    f1.getDirectoryScanner(project);
    Preondition Violations
    Unmatched statement f1.getDirectoryScanner(project); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement f1.getDirectoryScanner(project); 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
                                                                            
    24
    fail("Can make circular reference.");
    24
    fail("Can make circular reference.");
    25
    f1 = getInstance();
    25
    f1 = getInstance();
    25
    f1 = new FileList();
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    getInstance()new FileList()TYPE_COMPATIBLE_REPLACEMENT
    25
    f1 = new FileList();
    Precondition Violations (7)
    Row Violation
    1Expression f1 cannot be unified with expression f1 , because common superclass org.apache.tools.ant.types.DataType does not declare member(s) public synchronized java.io.File getDir(org.apache.tools.ant.Project)
    2Unmatched statement f1.getFiles(project); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement f1.getFiles(project); 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
    4Unmatched statement f1.getDirectoryScanner(project); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement f1.getDirectoryScanner(project); 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
    6Clone fragment #1 returns variables f1, f3 , while Clone fragment #2 returns variables f1, f3
    7The refactoring of the clones is infeasible, because classes org.apache.tools.ant.types.AbstractFileSetTest and org.apache.tools.ant.types.FileListTest do not have a common superclass