try { Hashtable hash = new Hashtable(); hash.put("VERSION", "1.0.3"); hash.put("b", "ffff"); System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $", hash)); } catch (Exception e) { e.printStackTrace(); }
try { Mapper.MapperType mt = new Mapper.MapperType(); mt.setValue("glob"); m.setType(mt); fail("Can set type in Mapper that is a reference."); } catch (BuildException be) { assertEquals("You must not specify more than one attribute when using refid", be.getMessage()); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/KeySubst.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/MapperTest.java
Method name: void main(String[]) Method name: void testEmptyElementIfIsReference()
Number of AST nodes: 5 Number of AST nodes: 5
1
try {
1
try {
2
            Hashtable hash = new Hashtable();
2
            
3
            hash.put("VERSION", "1.0.3");
4
            hash.put("b", "ffff");
5
            System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",
6
                                                hash));
7
        } catch (Exception e) {
8
            e.printStackTrac
3
Mapper.MapperType mt = new Mapper.MapperType();
4
            mt.setValue("glob");
5
            m.setType(mt);
6
            fail("Can set type in Mapper that is a reference.");
7
        } catch (BuildException be) {
8
            assertEquals("You must not specify more than one attribute when using refid",
9
e();
9
                         be.getMessage());
10
        }
10
        }
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
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)9.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    try
    1
    try
    16
    try
    Differences
    Expression1Expression2Difference
    java.lang.Exceptionorg.apache.tools.ant.BuildExceptionSUBCLASS_TYPE_MISMATCH
    ebeVARIABLE_NAME_MISMATCH
    java.lang.Exceptionorg.apache.tools.ant.BuildExceptionSUBCLASS_TYPE_MISMATCH
    printStackTraceassertEqualsMETHOD_INVOCATION_NAME_MISMATCH
    e.printStackTrace()assertEquals("You must not specify more than one attribute when using refid",be.getMessage())ARGUMENT_NUMBER_MISMATCH
    eMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression assertEquals("You must not specify more than one attribute when using refid",be.getMessage()) is a void method call, and thus it cannot be parameterized
    Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    Expression assertEquals("You must not specify more than one attribute when using refid",be.getMessage()) is a void method call, and thus it cannot be parameterized
    16
    try
    2
    Hashtable hash = new Hashtable();
                                                                        
    3
    hash.put("VERSION", "1.0.3");
                                                                  
    4
    hash.put("b", "ffff");
                                                    
                                                                                                      
    17
    Mapper.MapperType mt = new Mapper.MapperType();
                                                    
    18
    mt.setValue("glob");
    Preondition Violations
    Unmatched statement mt.setValue("glob"); 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
    mt.setValue("glob");
                                        
    19
    m.setType(mt);
    5
    System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $", hash));
    5
    System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $", hash));
    20
    fail("Can set type in Mapper that is a reference.");
    Differences
    Expression1Expression2Difference
    printlnfailMETHOD_INVOCATION_NAME_MISMATCH
    KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)"Can set type in Mapper that is a reference."TYPE_COMPATIBLE_REPLACEMENT
    System.outMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a void method call, and thus it cannot be parameterized
    Expression fail("Can set type in Mapper that is a reference.") is a void method call, and thus it cannot be parameterized
    Expression KeySubst.replace("$f ${VERSION} f ${b} jj $",hash) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a void method call, and thus it cannot be parameterized
    Expression fail("Can set type in Mapper that is a reference.") is a void method call, and thus it cannot be parameterized
    20
    fail("Can set type in Mapper that is a reference.");
    Precondition Violations (12)
    Row Violation
    1Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    2Expression assertEquals("You must not specify more than one attribute when using refid",be.getMessage()) is a void method call, and thus it cannot be parameterized
    3Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    4Expression assertEquals("You must not specify more than one attribute when using refid",be.getMessage()) is a void method call, and thus it cannot be parameterized
    5Unmatched statement mt.setValue("glob"); 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
    6Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    7Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a void method call, and thus it cannot be parameterized
    8Expression fail("Can set type in Mapper that is a reference.") is a void method call, and thus it cannot be parameterized
    9Expression KeySubst.replace("$f ${VERSION} f ${b} jj $",hash) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    10Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    11Expression System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $",hash)) is a void method call, and thus it cannot be parameterized
    12Expression fail("Can set type in Mapper that is a reference.") is a void method call, and thus it cannot be parameterized