try { p.getIncludePatterns(project); fail("Can make PatternSet a Reference to itself."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } try { p.getExcludePatterns(project); fail("Can make PatternSet a Reference to itself."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); }
try { f.getDir(project); fail("Can make FileList a Reference to itself."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } try { f.getFiles(project); fail("Can make FileList a Reference to itself."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/PatternSetTest.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: 6 Number of AST nodes: 6
1
try {
1
try {
2
            p.getIncludePatterns(project);
2
            f.getDir(project);
3
            fail("Can make PatternSet a Reference to itself.");
3
            fail("Can make FileList a Reference to itself.");
4
        } catch (BuildException be) {
4
        } catch (BuildException be) {
5
            assertEquals("This data type contains a circular reference.",
5
            assertEquals("This data type contains a circular reference.",
6
                         be.getMessage());
6
                         be.getMessage());
7
        }
7
        }
8
        try {
8
        try {
9
            p.getExcludePatterns(project);
9
            f.getFiles(project);
10
            fail("Can make PatternSet a Reference to itself.");
10
            fail("Can make FileList a Reference to itself.");
11
        } catch (BuildException be) {
11
        } catch (BuildException be) {
12
            assertEquals("This data type contains a circular reference.",
12
            assertEquals("This data type contains a circular reference.",
13
                         be.getMessage());
13
                         be.getMessage());
14
        }
14
        }
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.5
Clones locationClones are in different classes having the same super class
Number of node comparisons28
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)30.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    try
    7
    try
    5
    p.getIncludePatterns(project);
    5
    p.getIncludePatterns(project);
    8
    f.getFiles(project);
    Differences
    Expression1Expression2Difference
    getIncludePatternsgetFilesMETHOD_INVOCATION_NAME_MISMATCH
    pfVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.PatternSetorg.apache.tools.ant.types.FileListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression p.getIncludePatterns(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f.getFiles(project) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression p.getIncludePatterns(project) is a void method call, and thus it cannot be parameterized
    Expression f.getFiles(project) is a void method call, and thus it cannot be parameterized
    Expression p cannot be unified with expression f , because common superclass org.apache.tools.ant.types.DataType does not declare member(s) public java.lang.String[] getIncludePatterns(org.apache.tools.ant.Project) , public java.lang.String[] getFiles(org.apache.tools.ant.Project)
    8
    f.getFiles(project);
    6
    fail("Can make PatternSet a Reference to itself.");
    6
    fail("Can make PatternSet a Reference to itself.");
    9
    fail("Can make FileList a Reference to itself.");
    Differences
    Expression1Expression2Difference
    "Can make PatternSet a Reference to itself.""Can make FileList a Reference to itself."LITERAL_VALUE_MISMATCH
    9
    fail("Can make FileList a Reference to itself.");
    7
    try
    4
    try
                                              
    5
    f.getDir(project);
    Preondition Violations
    Unmatched statement f.getDir(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
    5
    f.getDir(project);
    8
    p.getExcludePatterns(project);
    8
    p.getExcludePatterns(project);
    Preondition Violations
    Unmatched statement p.getExcludePatterns(project); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement p.getExcludePatterns(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
                                                                      
    9
    fail("Can make PatternSet a Reference to itself.");
    9
    fail("Can make PatternSet a Reference to itself.");
    6
    fail("Can make FileList a Reference to itself.");
    Differences
    Expression1Expression2Difference
    "Can make PatternSet a Reference to itself.""Can make FileList a Reference to itself."LITERAL_VALUE_MISMATCH
    6
    fail("Can make FileList a Reference to itself.");
    Precondition Violations (9)
    Row Violation
    1Expression p.getIncludePatterns(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression f.getFiles(project) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    3Expression p.getIncludePatterns(project) is a void method call, and thus it cannot be parameterized
    4Expression f.getFiles(project) is a void method call, and thus it cannot be parameterized
    5Expression p cannot be unified with expression f , because common superclass org.apache.tools.ant.types.DataType does not declare member(s) public java.lang.String[] getIncludePatterns(org.apache.tools.ant.Project) , public java.lang.String[] getFiles(org.apache.tools.ant.Project)
    6Unmatched statement f.getDir(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
    7Unmatched statement p.getExcludePatterns(project); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement p.getExcludePatterns(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
    9The refactoring of the clones is infeasible, because classes org.apache.tools.ant.types.PatternSetTest and org.apache.tools.ant.types.FileListTest do not have a common superclass