if (encoding == null) { return name.getBytes(); } else { try { return name.getBytes(encoding); } catch (UnsupportedEncodingException uee) { throw new ZipException(uee.getMessage()); } }
if (encoding == null) { return new String(bytes); } else { try { return new String(bytes, encoding); } catch (UnsupportedEncodingException uee) { throw new ZipException(uee.getMessage()); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/zip/ZipOutputStream.java File path: /apache-ant-1.7.0/src/org/apache/tools/zip/ZipFile.java
Method name: byte[] getBytes(String) Method name: String getString(byte[])
Number of AST nodes: 4 Number of AST nodes: 4
1
if (encoding == null) {
1
if (encoding == null) {
2
            return name.getBytes();
2
            return new String(bytes);
3
        } else {
3
        } else {
4
            try {
4
            try {
5
                return name.getBytes(encoding);
5
                return new String(bytes, encoding);
6
            } catch (UnsupportedEncodingException uee) {
6
            } catch (UnsupportedEncodingException uee) {
7
                throw new ZipException(uee.getMessage());
7
                throw new ZipException(uee.getMessage());
8
            }
8
            }
9
        }
9
        }
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 in different classes
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (encoding == null)
    1
    if (encoding == null)
                                                            
    2
    return new String(bytes);
    Preondition Violations
    Unmatched return new String(bytes);
    2
    return new String(bytes);
    2
    return name.getBytes();
    2
    return name.getBytes();
    Preondition Violations
    Unmatched return name.getBytes();
                                                        
    else
    else
    3
    try
    3
    try
                                                                              
    4
    return new String(bytes, encoding);
    Preondition Violations
    Unmatched statement return new String(bytes,encoding); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return new String(bytes,encoding);
    4
    return new String(bytes, encoding);
    4
    return name.getBytes(encoding);
    4
    return name.getBytes(encoding);
    Preondition Violations
    Unmatched statement return name.getBytes(encoding); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement return name.getBytes(encoding); 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
    Unmatched return name.getBytes(encoding);
                                                                        
    Precondition Violations (7)
    Row Violation
    1Unmatched return new String(bytes);
    2Unmatched return name.getBytes();
    3Unmatched statement return new String(bytes,encoding); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched return new String(bytes,encoding);
    5Unmatched statement return name.getBytes(encoding); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement return name.getBytes(encoding); 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
    7Unmatched return name.getBytes(encoding);