Class c = Class.forName(RMIC_CLASSNAME); Constructor cons = c.getConstructor(new Class[] {OutputStream.class, String.class}); Object rmic = cons.newInstance(new Object[] {logstr, "rmic"}); Method doRmic = c.getMethod("compile", new Class [] {String[].class});
Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME); Constructor cons = c.getConstructor(new Class[] {OutputStream.class, String.class}); Object compiler = cons.newInstance(new Object[] {logstr, "javac"}); // Call the compile() method Method compile = c.getMethod("compile", new Class [] {String[].class});
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/rmic/SunRmic.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/compilers/Javac12.java
Method name: boolean execute() Method name: boolean execute()
Number of AST nodes: 4 Number of AST nodes: 4
1
Class c = Class.forName(RMIC_CLASSNAME);
1
Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME);
2
            Constructor cons
2
            Constructor cons =
3
                = c.getConstructor(new Class[]  {OutputStream.class,
3
                c.getConstructor(new Class[] {OutputStream.class,
4
 String.class});
4
                                              String.class});
5
            Object rmic
5
            Object compiler
6
 = cons.newInstance(new Object[] {logstr, "rmic"});
6
                = cons.newInstance(new Object[] {logstr, "javac"});
7
            Method doRmic
7
            // Call the compile() method
8
 = c.getMethod("compile",
8
            Method compile = c.getMethod("compile",
9
                                        new Class [] {String[].class});
9
                                         new Class [] {String[].class});
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.0
Clones locationClones are in different classes
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    Class c = Class.forName(RMIC_CLASSNAME);
    5
    Class c = Class.forName(RMIC_CLASSNAME);
    5
    Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME);
    Differences
    Expression1Expression2Difference
    RMIC_CLASSNAMECLASSIC_COMPILER_CLASSNAMEVARIABLE_NAME_MISMATCH
    5
    Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME);
    6
    Constructor cons = c.getConstructor(new Class[] {OutputStream.class, String.class});
    6
    Constructor cons = c.getConstructor(new Class[] {OutputStream.class, String.class});
    7
    Object rmic = cons.newInstance(new Object[] {logstr, "rmic"});
    7
    Object rmic = cons.newInstance(new Object[] {logstr, "rmic"});
    7
    Object compiler = cons.newInstance(new Object[] {logstr, "javac"});
    Differences
    Expression1Expression2Difference
    rmiccompilerVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.taskdefs.LogOutputStreamjava.io.OutputStreamSUBCLASS_TYPE_MISMATCH
    "rmic""javac"LITERAL_VALUE_MISMATCH
    7
    Object compiler = cons.newInstance(new Object[] {logstr, "javac"});
    8
    Method doRmic = c.getMethod("compile", new Class[] {String[].class});
    8
    Method doRmic = c.getMethod("compile", new Class[] {String[].class});
    8
    Method compile = c.getMethod("compile", new Class[] {String[].class});
    Differences
    Expression1Expression2Difference
    doRmiccompileVARIABLE_NAME_MISMATCH
    8
    Method compile = c.getMethod("compile", new Class[] {String[].class});
    Precondition Violations (2)
    Row Violation
    1Clone fragment #1 returns variables rmic, doRmic , while Clone fragment #2 returns variables compiler, compile
    2The refactoring of the clones is infeasible, because classes org.apache.tools.ant.taskdefs.rmic.SunRmic and org.apache.tools.ant.taskdefs.compilers.Javac12 do not have a common superclass