for (int i = 0; i <= cnt; i++) { String match = matcher.group(i); // treat non-matching groups as empty matches if (match == null) { match = ""; } v.addElement(match); }
for (int i = 0; i < cnt; i++) { String match = mr.group(i); // treat non-matching groups as empty matches if (match == null) { match = ""; } v.addElement(match); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
Method name: Vector getGroups(String, int) Method name: Vector getGroups(String, int)
Number of AST nodes: 5 Number of AST nodes: 5
1
for (int i = 0; i <= cnt; i++) {
1
for (int i = 0; i < cnt; i++) {
2
            String match = matcher.group(i);
2
            String match = mr.group(i);
3
            // treat non-matching groups as empty matches
3
            // treat non-matching groups as empty matches
4
            if (match == null) {
4
            if (match == null) {
5
                match = "";
5
                match = "";
6
            }
6
            }
7
            v.addElement(match);
7
            v.addElement(match);
8
        }
8
        }
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 comparisons6
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    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.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    8
    String match = matcher.group(i);
    8
    String match = matcher.group(i);
    7
    String match = mr.group(i);
    Differences
    Expression1Expression2Difference
    matchermrVARIABLE_NAME_MISMATCH
    java.util.regex.Matcherorg.apache.oro.text.regex.MatchResultVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.regex.Matcher of variable matcher does not match with type org.apache.oro.text.regex.MatchResult of variable mr
    • Make classes java.util.regex.Matcher and org.apache.oro.text.regex.MatchResult extend a common superclass
    7
    String match = mr.group(i);
    9
    if (match == null)
    8
    if (match == null)
    10
    match = "";
    9
    match = "";
    Precondition Violations (1)
    Row Violation
    1Type java.util.regex.Matcher of variable matcher does not match with type org.apache.oro.text.regex.MatchResult of variable mr