String className = theClass.getName(); int index = className.lastIndexOf("."); URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class"); URI uri = URI.createURI(classURL.toString()); // Trim off the segments corresponding to the package nesting. // int count = 1; for (int i = 0; (i = className.indexOf('.', i)) != -1; ++i) { ++count; } uri = uri.trimSegments(count);
String className = theClass.getName(); int index = className.lastIndexOf("."); URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class"); URI uri = URI.createURI(classURL.toString()); // Trim off the segments corresponding to the package nesting. // int count = 1; for (int i = 0; (i = className.indexOf('.', i)) != -1; ++i) { ++count; } uri = uri.trimSegments(count);
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/common/EMFPlugin.java File path: /emf-2.4.1/src/org/eclipse/emf/common/util/DelegatingResourceLocator.java
Method name: void main(String[]) Method name: URL getBaseURL()
Number of AST nodes: 8 Number of AST nodes: 8
1
String className = theClass.getName();
1
String className = theClass.getName();
2
      int index = className.lastIndexOf(".");
2
            int index = className.lastIndexOf(".");
3
      URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class");
3
            URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class");
4
      URI uri = URI.createURI(classURL.toString());
4
            URI uri = URI.createURI(classURL.toString());
5
      // Trim off the segments corresponding to the package nesting.
5
            // Trim off the segments corresponding to the package nesting.
6
      //
6
      
7
      //
7
      int count = 1;
8
            int count = 1;
8
      for (int i = 0; (i = className.indexOf('.', i)) != -1; ++i)
9
            for (int i = 0; (i = className.indexOf('.', i)) != -1; ++i)
9
      {
10
      
11
      {
10
        ++count;
12
              ++count;
11
      }
13
          
14
  }
12
      uri = uri.trimSegments(count);
15
            uri = uri.trimSegments(count);
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 having the same super class
Number of node comparisons41
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    String className = theClass.getName();
    4
    String className = theClass.getName();
    7
    String className = theClass.getName();
    Differences
    Expression1Expression2Difference
    java.lang.Class<>java.lang.Class<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Class<> of variable theClass does not match with type java.lang.Class<> of variable theClass
    • Make classes java.lang.Class<> and java.lang.Class<> extend a common superclass
    7
    String className = theClass.getName();
    5
    int index = className.lastIndexOf(".");
    8
    int index = className.lastIndexOf(".");
    6
    URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class");
    6
    URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class");
    9
    URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class");
    Differences
    Expression1Expression2Difference
    java.lang.Class<>java.lang.Class<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Class<> of variable theClass does not match with type java.lang.Class<> of variable theClass
    • Make classes java.lang.Class<> and java.lang.Class<> extend a common superclass
    9
    URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class");
    7
    URI uri = URI.createURI(classURL.toString());
    10
    URI uri = URI.createURI(classURL.toString());
    8
    int count = 1;
    11
    int count = 1;
    9
    for (int i = 0; (i = className.indexOf('.', i)) != -1; ++i)
    12
    for (int i = 0; (i = className.indexOf('.', i)) != -1; ++i)
    10
    ++count;
    13
    ++count;
    11
    uri = uri.trimSegments(count);
    14
    uri = uri.trimSegments(count);
    Precondition Violations (3)
    Row Violation
    1Type java.lang.Class<> of variable theClass does not match with type java.lang.Class<> of variable theClass
    2Type java.lang.Class<> of variable theClass does not match with type java.lang.Class<> of variable theClass
    3Clone fragment #1 returns variables uri , while Clone fragment #2 returns variables uri, className, index