ZipLong zl = new ZipLong(0x12345678); byte[] result = zl.getBytes(); assertEquals("length getBytes", 4, result.length); assertEquals("first byte getBytes", 0x78, result[0]); assertEquals("second byte getBytes", 0x56, result[1]);
ZipShort zs = new ZipShort(0x1234); byte[] result = zs.getBytes(); assertEquals("length getBytes", 2, result.length); assertEquals("first byte getBytes", 0x34, result[0]); assertEquals("second byte getBytes", 0x12, result[1]);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/zip/ZipLongTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/zip/ZipShortTest.java
Method name: void testToBytes() Method name: void testToBytes()
Number of AST nodes: 5 Number of AST nodes: 5
1
ZipLong zl = new ZipLong(0x12345678);
1
ZipShort zs = new ZipShort(0x1234);
2
        byte[] result = zl.getBytes();
2
        byte[] result = zs.getBytes();
3
        assertEquals("length getBytes", 4, result.length);
3
        assertEquals("length getBytes", 2, result.length);
4
        assertEquals("first byte getBytes", 0x78, result[0]);
4
        assertEquals("first byte getBytes", 0x34, result[0]);
5
        assertEquals("second byte getBytes", 0x56, result[1]);
5
        assertEquals("second byte getBytes", 0x12, result[1]);
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.0
Clones locationClones are in different classes having the same super class
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    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.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                            
    1
    ZipShort zs = new ZipShort(0x1234);
    Preondition Violations
    Unmatched statement ZipShort zs=new ZipShort(0x1234); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    ZipShort zs = new ZipShort(0x1234);
    1
    ZipLong zl = new ZipLong(0x12345678);
    1
    ZipLong zl = new ZipLong(0x12345678);
    Preondition Violations
    Unmatched statement ZipLong zl=new ZipLong(0x12345678); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                
    2
    byte[] result = zl.getBytes();
    2
    byte[] result = zl.getBytes();
    2
    byte[] result = zs.getBytes();
    Differences
    Expression1Expression2Difference
    zlzsVARIABLE_NAME_MISMATCH
    org.apache.tools.zip.ZipLongorg.apache.tools.zip.ZipShortVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.zip.ZipLong of variable zl does not match with type org.apache.tools.zip.ZipShort of variable zs
    • Make classes org.apache.tools.zip.ZipLong and org.apache.tools.zip.ZipShort extend a common superclass
    2
    byte[] result = zs.getBytes();
    3
    assertEquals("length getBytes", 4, result.length);
    3
    assertEquals("length getBytes", 4, result.length);
    3
    assertEquals("length getBytes", 2, result.length);
    Differences
    Expression1Expression2Difference
    42LITERAL_VALUE_MISMATCH
    3
    assertEquals("length getBytes", 2, result.length);
    4
    assertEquals("first byte getBytes", 0x78, result[0]);
    4
    assertEquals("first byte getBytes", 0x78, result[0]);
    4
    assertEquals("first byte getBytes", 0x34, result[0]);
    Differences
    Expression1Expression2Difference
    0x780x34LITERAL_VALUE_MISMATCH
    4
    assertEquals("first byte getBytes", 0x34, result[0]);
    5
    assertEquals("second byte getBytes", 0x56, result[1]);
    5
    assertEquals("second byte getBytes", 0x56, result[1]);
    5
    assertEquals("second byte getBytes", 0x12, result[1]);
    Differences
    Expression1Expression2Difference
    0x560x12LITERAL_VALUE_MISMATCH
    5
    assertEquals("second byte getBytes", 0x12, result[1]);
    Precondition Violations (4)
    Row Violation
    1Unmatched statement ZipShort zs=new ZipShort(0x1234); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement ZipLong zl=new ZipLong(0x12345678); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Type org.apache.tools.zip.ZipLong of variable zl does not match with type org.apache.tools.zip.ZipShort of variable zs
    4Clone fragment #1 returns variables result , while Clone fragment #2 returns variables