try { as.set(p, element, value); } catch (IllegalAccessException ie) { // impossible as getMethods should only return public methods throw new BuildException(ie); } catch (InvocationTargetException ite) { Throwable t = ite.getTargetException(); if (t instanceof BuildException) { throw (BuildException) t; } throw new BuildException(t); }
try { addText.invoke(element, new Object[] {text}); } catch (IllegalAccessException ie) { // impossible as getMethods should only return public methods throw new BuildException(ie); } catch (InvocationTargetException ite) { Throwable t = ite.getTargetException(); if (t instanceof BuildException) { throw (BuildException) t; } throw new BuildException(t); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/IntrospectionHelper.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/IntrospectionHelper.java
Method name: void setAttribute(Project, Object, String, String) Method name: void addText(Project, Object, String)
Number of AST nodes: 2 Number of AST nodes: 2
1
try {
1
try {
2
            as.set(p, element, value);
2
            addText.invoke(element, new Object[] {text});
3
        } catch (IllegalAccessException ie) {
3
        } catch (IllegalAccessException ie) {
4
            // impossible as getMethods should only return public methods
4
            // impossible as getMethods should only return public methods
5
            throw new BuildException(ie);
5
            throw new BuildException(ie);
6
        } catch (InvocationTargetException ite) {
6
        } catch (InvocationTargetException ite) {
7
            Throwable t = ite.getTargetException();
7
            Throwable t = ite.getTargetException();
8
            if (t instanceof BuildException) {
8
            if (t instanceof BuildException) {
9
                throw (BuildException) t;
9
                throw (BuildException) t;
10
            }
10
            }
11
            throw new BuildException(t);
11
            throw new BuildException(t);
12
        }
12
        }
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.3
Clones locationClones are declared in the same class
Number of node comparisons4
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    19
    try
    7
    try
                                                                                                
    8
    addText.invoke(element, new Object[] {text});
    Preondition Violations
    Unmatched statement addText.invoke(element,new Object[]{text}); 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
    8
    addText.invoke(element, new Object[] {text});
    20
    as.set(p, element, value);
    20
    as.set(p, element, value);
    Preondition Violations
    Unmatched statement as.set(p,element,value); 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
                                                            
    Precondition Violations (2)
    Row Violation
    1Unmatched statement addText.invoke(element,new Object[]{text}); 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
    2Unmatched statement as.set(p,element,value); 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