if (chars == null) return null; Character[] characters = new Character[chars.length]; for (int i = 0 ; i < chars.length ; i++) { characters[i] = new Character( chars[i] ); } return characters;
if (bytes == null) return null; int length = bytes.length; Byte[] result = new Byte[length]; for ( int index = 0; index < length ; index++ ) { result[index] = new Byte( bytes[index] ); } return result;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/CharacterArrayType.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/WrapperBinaryType.java
Method name: Object toExternalFormat(char[]) Method name: Object toExternalFormat(byte[])
Number of AST nodes: 6 Number of AST nodes: 7
1
if (chars == null) return null;
1
if (bytes == null) return null;
2
		Character[] characters
2
		int length = bytes.length;
3
 = new Character[chars.length];
3
		Byte[] result = new Byte[length];
4
		for (int i = 0 ; i < chars.length ; i++) {
4
		for ( int index = 0; index < length ; index++ ) {
5
			characters[i] = new Character( chars[i] );
5
			result[index] = new Byte( bytes[index] );
6
		}
6
		}
7
		return characters;
7
		return result;
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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)1.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (chars == null)
    1
    if (chars == null)
    1
    if (bytes == null)
    Differences
    Expression1Expression2Difference
    charsbytesVARIABLE_NAME_MISMATCH
    char[]byte[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type char[] of variable chars does not match with type byte[] of variable bytes
    • Make classes char[] and byte[] extend a common superclass
    1
    if (bytes == null)
    2
    return null;
    2
    return null;
                                                          
    3
    int length = bytes.length;
    3
    Character[] characters = new Character[chars.length];
                                                                                                                
                                                                        
    4
    Byte[] result = new Byte[length];
    4
    for (int i = 0; i < chars.length; i++)
    4
    for (int i = 0; i < chars.length; i++)
    5
    for (int index = 0; index < length; index++)
    Differences
    Expression1Expression2Difference
    iindexVARIABLE_NAME_MISMATCH
    iindexVARIABLE_NAME_MISMATCH
    chars.lengthlengthTYPE_COMPATIBLE_REPLACEMENT
    iindexVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    for (int index = 0; index < length; index++)
    5
    characters[i] = new Character(chars[i]);
    5
    characters[i] = new Character(chars[i]);
    Preondition Violations
    Unmatched statement characters[i]=new Character(chars[i]); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
                                                                                    
    6
    result[index] = new Byte(bytes[index]);
    Preondition Violations
    Unmatched statement result[index]=new Byte(bytes[index]); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    result[index] = new Byte(bytes[index]);
    6
    return characters;
    6
    return characters;
    Preondition Violations
    Unmatched return characters;
                                              
                                      
    7
    return result;
    Preondition Violations
    Unmatched return result;
    7
    return result;
    Precondition Violations (7)
    Row Violation
    1Type char[] of variable chars does not match with type byte[] of variable bytes
    2Expression length cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement characters[i]=new Character(chars[i]); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement result[index]=new Byte(bytes[index]); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched return characters;
    6Unmatched return result;
    7Not all possible execution flows end in a return statement