Object[] listeners = _listeners.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event. SQLPanelEvent evt = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ISQLPanelListener.class) { // Lazily create the event: if (evt == null) { evt = new SQLPanelEvent(_session, this); } ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt); } }
Object[] listeners = _listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event. ObjectCacheChangeEvent evt = null; for (int i = listeners.length - 2; i >= 0; i-=2 ) { if (listeners[i] == IObjectCacheChangeListener.class) { // Lazily create the event: if (evt == null) { evt = new ObjectCacheChangeEvent(ObjectCache.this, obj); } ((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt); } }
Clone fragments detected by clone detection tool
File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLPanel.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/util/ObjectCache.java
Method name: void fireSQLEntryAreaClosed() Method name: void fireObjectRemoved(IHasIdentifier)
Number of AST nodes: 7 Number of AST nodes: 7
1
Object[] listeners = _listeners.getListenerList();
1
Object[] listeners = _listenerList.getListenerList();
2
      // Process the listeners last to first, notifying
2
			// Process the listeners last to first, notifying
3
      // those that are interested in this event.
3
			// those that are interested in this event.
4
      SQLPanelEvent evt = null;
4
			ObjectCacheChangeEvent evt = null;
5
      for (int i = listeners.length - 2; i >= 0; i -= 2)
5
			for (int i = listeners.length - 2; i >= 0; i-=
6
      {
7
         
6
2 )
7
			{
8
if (listeners[i] == ISQLPanelListener.class)
8
				if (listeners[i] == I
9
         {
10
            
9
ObjectCacheChangeListener.class)
10
				{
11
// Lazily create the event:
11
					// Lazily create the event:
12
            if (evt == null)
12
					if (evt == null)
13
            {
14
               evt = new SQLPanelEvent(_session, this);
15
            }
16
            ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt);
17
         }
18
      
13
					{
14
						evt = new ObjectCacheChangeEvent(ObjectCache.this, obj);
15
					}
16
					((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt);
17
				}
19
}
18
			}
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.5
Clones locationClones are in different classes
Number of node comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)3.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Object[] listeners = _listeners.getListenerList();
    1
    Object[] listeners = _listeners.getListenerList();
    1
    Object[] listeners = _listenerList.getListenerList();
    Differences
    Expression1Expression2Difference
    _listeners_listenerListVARIABLE_NAME_MISMATCH
    1
    Object[] listeners = _listenerList.getListenerList();
    2
    SQLPanelEvent evt = null;
    2
    SQLPanelEvent evt = null;
    2
    ObjectCacheChangeEvent evt = null;
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.client.session.event.SQLPanelEventnet.sourceforge.squirrel_sql.fw.util.ObjectCacheChangeEventSUBCLASS_TYPE_MISMATCH
    net.sourceforge.squirrel_sql.client.session.event.SQLPanelEventnet.sourceforge.squirrel_sql.fw.util.ObjectCacheChangeEventSUBCLASS_TYPE_MISMATCH
    2
    ObjectCacheChangeEvent evt = null;
    3
    for (int i = listeners.length - 2; i >= 0; i -= 2)
    3
    for (int i = listeners.length - 2; i >= 0; i -= 2)
    4
    if (listeners[i] == ISQLPanelListener.class)
    4
    if (listeners[i] == ISQLPanelListener.class)
    4
    if (listeners[i] == IObjectCacheChangeListener.class)
    Differences
    Expression1Expression2Difference
    ISQLPanelListener.classIObjectCacheChangeListener.classLITERAL_VALUE_MISMATCH
    4
    if (listeners[i] == IObjectCacheChangeListener.class)
    5
    if (evt == null)
    5
    if (evt == null)
    5
    if (evt == null)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.client.session.event.SQLPanelEventnet.sourceforge.squirrel_sql.fw.util.ObjectCacheChangeEventSUBCLASS_TYPE_MISMATCH
    5
    if (evt == null)
                                                                                                                    
    6
    evt = new ObjectCacheChangeEvent(ObjectCache.this, obj);
    Preondition Violations
    Unmatched statement evt=new ObjectCacheChangeEvent(ObjectCache.this,obj); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    evt = new ObjectCacheChangeEvent(ObjectCache.this, obj);
    6
    evt = new SQLPanelEvent(_session, this);
    6
    evt = new SQLPanelEvent(_session, this);
    Preondition Violations
    Unmatched statement evt=new SQLPanelEvent(_session,this); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement evt=new SQLPanelEvent(_session,this); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                    
    7
    ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt);
    7
    ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt);
    7
    ((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt);
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.client.session.event.SQLPanelEventnet.sourceforge.squirrel_sql.fw.util.ObjectCacheChangeEventSUBCLASS_TYPE_MISMATCH
    sqlEntryAreaClosedobjectRemovedMETHOD_INVOCATION_NAME_MISMATCH
    net.sourceforge.squirrel_sql.client.session.event.ISQLPanelListenernet.sourceforge.squirrel_sql.fw.util.IObjectCacheChangeListenerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt) is a void method call, and thus it cannot be parameterized
    Expression ((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt) is a void method call, and thus it cannot be parameterized
    Expression (ISQLPanelListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (IObjectCacheChangeListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type net.sourceforge.squirrel_sql.client.session.event.ISQLPanelListener does not match with type net.sourceforge.squirrel_sql.fw.util.IObjectCacheChangeListener
    • Make classes net.sourceforge.squirrel_sql.client.session.event.ISQLPanelListener and net.sourceforge.squirrel_sql.fw.util.IObjectCacheChangeListener extend a common superclass
    7
    ((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt);
    Precondition Violations (11)
    Row Violation
    1Unmatched statement evt=new ObjectCacheChangeEvent(ObjectCache.this,obj); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement evt=new SQLPanelEvent(_session,this); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement evt=new SQLPanelEvent(_session,this); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4Expression ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression ((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression ((ISQLPanelListener)listeners[i + 1]).sqlEntryAreaClosed(evt) is a void method call, and thus it cannot be parameterized
    7Expression ((IObjectCacheChangeListener)listeners[i + 1]).objectRemoved(evt) is a void method call, and thus it cannot be parameterized
    8Expression (ISQLPanelListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression (IObjectCacheChangeListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Type net.sourceforge.squirrel_sql.client.session.event.ISQLPanelListener does not match with type net.sourceforge.squirrel_sql.fw.util.IObjectCacheChangeListener
    11Clone fragment #1 returns variable evt with type net.sourceforge.squirrel_sql.client.session.event.SQLPanelEvent , while Clone fragment #2 returns variable evt with type net.sourceforge.squirrel_sql.fw.util.ObjectCacheChangeEvent