int result = intUnaryOperation((Integer)operand, kind); // ++ and -- must be cast back the original type if(kind == INCR || kind == DECR) { if(operandType == Byte.TYPE) return new Primitive((byte)result); if(operandType == Short.TYPE) return new Primitive((short)result); if(operandType == Character.TYPE) return new Primitive((char)result); } return new Primitive(result);
int result = Primitive.intUnaryOperation((Integer)operand, kind); // ++ and -- must be cast back the original type if(kind == INCR || kind == DECR) { if(operandType == Byte.TYPE) return new Byte((byte)result); if(operandType == Short.TYPE) return new Short((short)result); if(operandType == Character.TYPE) return new Character((char)result); } return new Integer(result);
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/Primitive.java File path: /jEdit-4.2/src/bsh/BSHUnaryExpression.java
Method name: Primitive unaryOperation(Primitive, int) Method name: Object primitiveWrapperUnaryOperation(Object, int)
Number of AST nodes: 9 Number of AST nodes: 9
1
int result = intUnaryOperation((Integer)operand, kind);
1
int result = Primitive.intUnaryOperation((Integer)operand, kind);
2
            // ++ and -- must be cast back the original type
2
            // ++ and -- must be cast back the original type
3
            if(kind == INCR || kind == DECR)
3
            if(kind == INCR || kind == DECR)
4
            {
4
            {
5
                if(operandType == Byte.TYPE)
5
                if(operandType == Byte.TYPE)
6
                    return new Primitive((byte)result);
6
                    return new Byte((byte)result);
7
                if(operandType == Short.TYPE)
7
                if(operandType == Short.TYPE)
8
                    return new Primitive((short)result);
8
                    return new Short((short)result);
9
                if(operandType == Character.TYPE)
9
                if(operandType == Character.TYPE)
10
                    return new Primitive((char)result);
10
                    return new Character((char)result);
11
            }
11
            }
12
            return new Primitive(result);
12
            return new Integer(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)1.6
Clones locationClones are in different classes
Number of node comparisons33
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)3.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    10
    int result = intUnaryOperation((Integer)operand, kind);
    10
    int result = intUnaryOperation((Integer)operand, kind);
    6
    int result = Primitive.intUnaryOperation((Integer)operand, kind);
    Differences
    Expression1Expression2Difference
    PrimitiveMISSING_METHOD_INVOCATION_EXPRESSION
    6
    int result = Primitive.intUnaryOperation((Integer)operand, kind);
    11
    if (kind == INCR || kind == DECR)
    7
    if (kind == INCR || kind == DECR)
    12
    if (operandType == Byte.TYPE)
    12
    if (operandType == Byte.TYPE)
    12
    if (operandType == Character.TYPE)
    Differences
    Expression1Expression2Difference
    java.lang.Bytejava.lang.CharacterVARIABLE_TYPE_MISMATCH
    java.lang.Classjava.lang.ClassVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Byte of variable Byte does not match with type java.lang.Character of variable Character
    • Make classes java.lang.Byte and java.lang.Character extend a common superclass
    Type java.lang.Class<java.lang.Byte> of variable Byte.TYPE does not match with type java.lang.Class<java.lang.Character> of variable Character.TYPE
    • Make classes java.lang.Class and java.lang.Class extend a common superclass
    12
    if (operandType == Character.TYPE)
                                                                                  
    13
    return new Character((char)result);
    13
    return new Primitive((byte)result);
                                                                                  
    14
    if (operandType == Short.TYPE)
    10
    if (operandType == Short.TYPE)
                                                                            
    11
    return new Short((short)result);
    15
    return new Primitive((short)result);
                                                                                    
    16
    if (operandType == Character.TYPE)
    16
    if (operandType == Character.TYPE)
    8
    if (operandType == Byte.TYPE)
    Differences
    Expression1Expression2Difference
    java.lang.Characterjava.lang.ByteVARIABLE_TYPE_MISMATCH
    java.lang.Classjava.lang.ClassVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Character of variable Character does not match with type java.lang.Byte of variable Byte
    • Make classes java.lang.Character and java.lang.Byte extend a common superclass
    Type java.lang.Class<java.lang.Character> of variable Character.TYPE does not match with type java.lang.Class<java.lang.Byte> of variable Byte.TYPE
    • Make classes java.lang.Class and java.lang.Class extend a common superclass
    8
    if (operandType == Byte.TYPE)
                                                                      
    9
    return new Byte((byte)result);
    17
    return new Primitive((char)result);
                                                                                  
                                                                  
    14
    return new Integer(result);
    18
    return new Primitive(result);
                                                                      
    Precondition Violations (4)
    Row Violation
    1Type java.lang.Byte of variable Byte does not match with type java.lang.Character of variable Character
    2Type java.lang.Class<java.lang.Byte> of variable Byte.TYPE does not match with type java.lang.Class<java.lang.Character> of variable Character.TYPE
    3Type java.lang.Character of variable Character does not match with type java.lang.Byte of variable Byte
    4Type java.lang.Class<java.lang.Character> of variable Character.TYPE does not match with type java.lang.Class<java.lang.Byte> of variable Byte.TYPE