try { String result = EcoreUtil.convertToString(memberType, objectValue); if (result != null) { return result; } } catch (Exception e) { // Keep trying until all else false. }
try { Object result = EcoreUtil.createFromString(memberType, stringValue); if (result != null) { return result; } } catch (RuntimeException exception) { // Keep trying until all else has failed. }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/impl/EFactoryImpl.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/impl/EFactoryImpl.java
Method name: String convertToString(EDataType, Object) Method name: Object createFromString(EDataType, String)
Number of AST nodes: 4 Number of AST nodes: 4
1
try
1
try
2
          {
2
        {
3
            String result = EcoreUtil.convertToString(memberType, objectValue);
3
          Object result = EcoreUtil.createFromString(memberType, stringValue);
4
            if (result != null)
4
          if (result != null)
5
            {
5
          {
6
              return result;
6
            return result;
7
            }
7
          }
8
          }
8
        
9
  
9
}
10
        catch (Exception e)
10
        catch (RuntimeException exception)
11
          {
11
        
12
  
12
{
13
          // Keep trying until all else false.
13
          // Keep trying until all else 
14
  
14
has failed.
15
        }
15
        }
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.1
Clones locationClones are declared in the same class
Number of node comparisons9
  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.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    22
    try
    22
    try
    30
    try
    Differences
    Expression1Expression2Difference
    java.lang.Exceptionjava.lang.RuntimeExceptionSUBCLASS_TYPE_MISMATCH
    eexceptionVARIABLE_NAME_MISMATCH
    java.lang.Exceptionjava.lang.RuntimeExceptionSUBCLASS_TYPE_MISMATCH
    30
    try
    23
    String result = EcoreUtil.convertToString(memberType, objectValue);
    23
    String result = EcoreUtil.convertToString(memberType, objectValue);
    Preondition Violations
    Unmatched statement String result=EcoreUtil.convertToString(memberType,objectValue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                            
                                                                                                                                              
    31
    Object result = EcoreUtil.createFromString(memberType, stringValue);
    Preondition Violations
    Unmatched statement Object result=EcoreUtil.createFromString(memberType,stringValue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    31
    Object result = EcoreUtil.createFromString(memberType, stringValue);
    24
    if (result != null)
    24
    if (result != null)
    32
    if (result != null)
    Differences
    Expression1Expression2Difference
    java.lang.Stringjava.lang.ObjectVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable result does not match with type java.lang.Object of variable result
    • Make classes java.lang.String and java.lang.Object extend a common superclass
    32
    if (result != null)
    25
    return result;
    25
    return result;
    Preondition Violations
    Unmatched return result;
                                        
                                        
    33
    return result;
    Preondition Violations
    Unmatched return result;
    33
    return result;
    Precondition Violations (5)
    Row Violation
    1Unmatched statement String result=EcoreUtil.convertToString(memberType,objectValue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Object result=EcoreUtil.createFromString(memberType,stringValue); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type java.lang.String of variable result does not match with type java.lang.Object of variable result
    4Unmatched return result;
    5Unmatched return result;