for (int i = 0; i < values.length - 1; i++) { sum += Integer.parseInt(((CompoundVariable) values[i]).execute()); } try { sum += Integer.parseInt(varName); varName = null; // there is no variable name } catch (NumberFormatException ignored) { } String totalString = Integer.toString(sum);
for (int i = 0; i < values.length - 1; i++) { sum += Long.parseLong(((CompoundVariable) values[i]).execute()); } try { sum += Long.parseLong(varName); varName = null; // there is no variable name } catch (NumberFormatException ignored) { } String totalString = Long.toString(sum);
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/functions/IntSum.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/functions/LongSum.java
Method name: String execute(SampleResult, Sampler) Method name: String execute(SampleResult, Sampler)
Number of AST nodes: 6 Number of AST nodes: 6
1
for (int i = 0; i < values.length - 1; i++) {
1
for (int i = 0; i < values.length - 1; i++) {
2
			sum += Integer.parseInt(((CompoundVariable) values[i]).execute());
2
			sum += Long.parseLong(((CompoundVariable) values[i]).execute());
3
		}
3
		}
4
        try {
4
        try {
5
            sum += Integer.parseInt(varName);
5
            sum += Long.parseLong(varName);
6
            varName = null; // there is no variable name
6
            varName = null; // there is no variable name
7
        } catch (NumberFormatException ignored) {
7
        } catch (NumberFormatException ignored) {
8
        }
8
        }
9
        
9
        
10
String totalString = Integer.toString(sum);
10
		String totalString = Long.toString(sum);
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 comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)2.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    for (int i = 0; i < values.length - 1; i++)
    4
    for (int i = 0; i < values.length - 1; i++)
                                                                                                                                    
    5
    sum += Long.parseLong(((CompoundVariable)values[i]).execute());
    Preondition Violations
    Unmatched statement sum+=Long.parseLong(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement sum+=Long.parseLong(((CompoundVariable)values[i]).execute()); 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
    sum += Long.parseLong(((CompoundVariable)values[i]).execute());
    5
    sum += Integer.parseInt(((CompoundVariable)values[i]).execute());
    5
    sum += Integer.parseInt(((CompoundVariable)values[i]).execute());
    Preondition Violations
    Unmatched statement sum+=Integer.parseInt(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement sum+=Integer.parseInt(((CompoundVariable)values[i]).execute()); 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
                                                                                                                                        
    6
    try
    6
    try
                                                                    
    7
    sum += Long.parseLong(varName);
    Preondition Violations
    Unmatched statement sum+=Long.parseLong(varName); 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
    7
    sum += Long.parseLong(varName);
    7
    sum += Integer.parseInt(varName);
    7
    sum += Integer.parseInt(varName);
    Preondition Violations
    Unmatched statement sum+=Integer.parseInt(varName); 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
    varName = null;
    8
    varName = null;
    9
    String totalString = Integer.toString(sum);
    9
    String totalString = Integer.toString(sum);
    9
    String totalString = Long.toString(sum);
    Differences
    Expression1Expression2Difference
    intlongVARIABLE_TYPE_MISMATCH
    java.lang.Integerjava.lang.LongSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Type int of variable sum does not match with type long of variable sum
    Expression Integer cannot be unified with expression Long , because common superclass java.lang.Number does not declare member(s) public static java.lang.String toString(int) , public static java.lang.String toString(long)
    9
    String totalString = Long.toString(sum);
    Precondition Violations (9)
    Row Violation
    1Unmatched statement sum+=Long.parseLong(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement sum+=Long.parseLong(((CompoundVariable)values[i]).execute()); 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
    3Unmatched statement sum+=Integer.parseInt(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement sum+=Integer.parseInt(((CompoundVariable)values[i]).execute()); 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
    5Unmatched statement sum+=Long.parseLong(varName); 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
    6Unmatched statement sum+=Integer.parseInt(varName); 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
    7Type int of variable sum does not match with type long of variable sum
    8Expression Integer cannot be unified with expression Long , because common superclass java.lang.Number does not declare member(s) public static java.lang.String toString(int) , public static java.lang.String toString(long)
    9Clone fragment #1 returns variables i, varName, totalString , while Clone fragment #2 returns variables i, varName, totalString