synchronized (runtime.getHierarchyLock()) { Set<RubyClass> oldSubclasses = subclasses; if (oldSubclasses == null) subclasses = oldSubclasses = new WeakHashSet<RubyClass>(4); oldSubclasses.add(subclass); }
synchronized (getRuntime().getHierarchyLock()) { Set<RubyClass> oldIncludingHierarchies = includingHierarchies; if (oldIncludingHierarchies == null) includingHierarchies = oldIncludingHierarchies = new WeakHashSet(4); oldIncludingHierarchies.add(hierarchy); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyClass.java File path: /jruby-1.4.0/src/org/jruby/RubyModule.java
Method name: void addSubclass(RubyClass) Method name: void addIncludingHierarchy(IncludedModuleWrapper)
Number of AST nodes: 5 Number of AST nodes: 5
1
synchronized (runtime.getHierarchyLock()) {
1
synchronized (getRuntime().getHierarchyLock()) {
2
            Set<RubyClass> oldSubclasses = subclasses;
2
            Set<RubyClass> oldIncludingHierarchies = includingHierarchies;
3
            if (oldSubclasses == null) subclasses = oldSubclasses = new WeakHashSet<RubyClass>(4);
3
            if (oldIncludingHierarchies == null) includingHierarchies = oldIncludingHierarchies = new WeakHashSet(4);
4
            oldSubclasses.add(subclass);
4
            oldIncludingHierarchies.add(hierarchy);
5
        }
5
        }
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.6
Clones locationClones are in different classes having the same super class
Number of node comparisons13
  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)1.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    synchronized (runtime.getHierarchyLock())
    1
    synchronized (runtime.getHierarchyLock())
    1
    synchronized (getRuntime().getHierarchyLock())
    Differences
    Expression1Expression2Difference
    runtimegetRuntime()TYPE_COMPATIBLE_REPLACEMENT
    1
    synchronized (getRuntime().getHierarchyLock())
    2
    Set<RubyClass> oldSubclasses = subclasses;
    2
    Set<RubyClass> oldSubclasses = subclasses;
    2
    Set<RubyClass> oldIncludingHierarchies = includingHierarchies;
    Differences
    Expression1Expression2Difference
    oldSubclassesoldIncludingHierarchiesVARIABLE_NAME_MISMATCH
    subclassesincludingHierarchiesVARIABLE_NAME_MISMATCH
    2
    Set<RubyClass> oldIncludingHierarchies = includingHierarchies;
    3
    if (oldSubclasses == null)
    3
    if (oldSubclasses == null)
    3
    if (oldIncludingHierarchies == null)
    Differences
    Expression1Expression2Difference
    oldSubclassesoldIncludingHierarchiesVARIABLE_NAME_MISMATCH
    3
    if (oldIncludingHierarchies == null)
                                                                                                                                          
    4
    includingHierarchies = oldIncludingHierarchies = new WeakHashSet(4);
    Preondition Violations
    Unmatched statement includingHierarchies=oldIncludingHierarchies=new WeakHashSet(4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    includingHierarchies = oldIncludingHierarchies = new WeakHashSet(4);
    4
    subclasses = oldSubclasses = new WeakHashSet<RubyClass>(4);
    4
    subclasses = oldSubclasses = new WeakHashSet<RubyClass>(4);
    Preondition Violations
    Unmatched statement subclasses=oldSubclasses=new WeakHashSet<RubyClass>(4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                        
    5
    oldSubclasses.add(subclass);
    5
    oldSubclasses.add(subclass);
    5
    oldIncludingHierarchies.add(hierarchy);
    Differences
    Expression1Expression2Difference
    subclasshierarchyVARIABLE_NAME_MISMATCH
    org.jruby.RubyClassorg.jruby.IncludedModuleWrapperSUBCLASS_TYPE_MISMATCH
    oldSubclassesoldIncludingHierarchiesVARIABLE_NAME_MISMATCH
    5
    oldIncludingHierarchies.add(hierarchy);
    Precondition Violations (2)
    Row Violation
    1Unmatched statement includingHierarchies=oldIncludingHierarchies=new WeakHashSet(4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement subclasses=oldSubclasses=new WeakHashSet<RubyClass>(4); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted