Object[] listeners = listenerList.getListenerList(); SessionEvent evt = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ISessionListener.class) { // Lazily create the event: if (evt == null) { evt = new SessionEvent(session); } ((ISessionListener)listeners[i + 1]).sessionClosing(evt); } }
Object[] listeners = _listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event. HtmlViewerPanelListenerEvent evt = null; for (int i = listeners.length - 2; i >= 0; i-=2 ) { if (listeners[i] == IHtmlViewerPanelListener.class) { // Lazily create the event. if (evt == null) { evt = new HtmlViewerPanelListenerEvent(this); } ((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(evt); } }
Clone fragments detected by clone detection tool
File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/session/SessionManager.java File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/gui/HtmlViewerPanel.java
Method name: void fireSessionClosing(ISession) Method name: void fireURLChanged()
Number of AST nodes: 7 Number of AST nodes: 7
1
Object[] listeners = listenerList.getListenerList();
1
Object[] listeners = _listenerList.getListenerList();
2
      Session
2
		// Process the listeners last to first, notifying
3
		// those that are interested in this event.
3
Event evt = null;
4
		HtmlViewerPanelListenerEvent evt = null;
4
      for (int i = listeners.length - 2; i >= 0; i -= 2)
5
		for (int i = listeners.length - 2; i >= 0; i-=
5
      {
6
         
6
2 )
7
		{
7
if (listeners[i] == ISessionListener.class)
8
			if (listeners[i] == IHtmlViewerPanelListener.class)
8
         {
9
            
9
			{
10
// Lazily create the event:
10
				// Lazily create the event
11
            
11
.
12
if (evt == null)
12
				if (evt == null)
13
            {
14
               evt = new SessionEvent(session);
15
            }
16
            ((ISessionListener)listeners[i + 1]).sessionClosing(evt);
17
         }
18
      
13
				{
14
					evt = new HtmlViewerPanelListenerEvent(this);
15
				}
16
				((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(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.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Object[] listeners = listenerList.getListenerList();
    1
    Object[] listeners = listenerList.getListenerList();
    1
    Object[] listeners = _listenerList.getListenerList();
    Differences
    Expression1Expression2Difference
    listenerList_listenerListVARIABLE_NAME_MISMATCH
    1
    Object[] listeners = _listenerList.getListenerList();
    2
    SessionEvent evt = null;
    2
    SessionEvent evt = null;
    2
    HtmlViewerPanelListenerEvent evt = null;
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.client.session.event.SessionEventnet.sourceforge.squirrel_sql.client.gui.HtmlViewerPanelListenerEventSUBCLASS_TYPE_MISMATCH
    net.sourceforge.squirrel_sql.client.session.event.SessionEventnet.sourceforge.squirrel_sql.client.gui.HtmlViewerPanelListenerEventSUBCLASS_TYPE_MISMATCH
    2
    HtmlViewerPanelListenerEvent 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] == ISessionListener.class)
    4
    if (listeners[i] == ISessionListener.class)
    4
    if (listeners[i] == IHtmlViewerPanelListener.class)
    Differences
    Expression1Expression2Difference
    ISessionListener.classIHtmlViewerPanelListener.classLITERAL_VALUE_MISMATCH
    4
    if (listeners[i] == IHtmlViewerPanelListener.class)
    5
    if (evt == null)
    5
    if (evt == null)
    5
    if (evt == null)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.client.session.event.SessionEventnet.sourceforge.squirrel_sql.client.gui.HtmlViewerPanelListenerEventSUBCLASS_TYPE_MISMATCH
    5
    if (evt == null)
                                                                                                
    6
    evt = new HtmlViewerPanelListenerEvent(this);
    Preondition Violations
    Unmatched statement evt=new HtmlViewerPanelListenerEvent(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 HtmlViewerPanelListenerEvent(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
    6
    evt = new HtmlViewerPanelListenerEvent(this);
    6
    evt = new SessionEvent(session);
    6
    evt = new SessionEvent(session);
    Preondition Violations
    Unmatched statement evt=new SessionEvent(session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement evt=new SessionEvent(session); 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
    ((ISessionListener)listeners[i + 1]).sessionClosing(evt);
    7
    ((ISessionListener)listeners[i + 1]).sessionClosing(evt);
    7
    ((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(evt);
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.client.session.event.SessionEventnet.sourceforge.squirrel_sql.client.gui.HtmlViewerPanelListenerEventSUBCLASS_TYPE_MISMATCH
    sessionClosingcurrentURLHasChangedMETHOD_INVOCATION_NAME_MISMATCH
    net.sourceforge.squirrel_sql.client.session.event.ISessionListenernet.sourceforge.squirrel_sql.client.gui.IHtmlViewerPanelListenerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression ((ISessionListener)listeners[i + 1]).sessionClosing(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((ISessionListener)listeners[i + 1]).sessionClosing(evt) is a void method call, and thus it cannot be parameterized
    Expression ((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(evt) is a void method call, and thus it cannot be parameterized
    Expression (ISessionListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (IHtmlViewerPanelListener)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.ISessionListener does not match with type net.sourceforge.squirrel_sql.client.gui.IHtmlViewerPanelListener
    • Make classes net.sourceforge.squirrel_sql.client.session.event.ISessionListener and net.sourceforge.squirrel_sql.client.gui.IHtmlViewerPanelListener extend a common superclass
    7
    ((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(evt);
    Precondition Violations (12)
    Row Violation
    1Unmatched statement evt=new HtmlViewerPanelListenerEvent(this); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement evt=new HtmlViewerPanelListenerEvent(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
    3Unmatched statement evt=new SessionEvent(session); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement evt=new SessionEvent(session); 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
    5Expression ((ISessionListener)listeners[i + 1]).sessionClosing(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression ((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(evt) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression ((ISessionListener)listeners[i + 1]).sessionClosing(evt) is a void method call, and thus it cannot be parameterized
    8Expression ((IHtmlViewerPanelListener)listeners[i + 1]).currentURLHasChanged(evt) is a void method call, and thus it cannot be parameterized
    9Expression (ISessionListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression (IHtmlViewerPanelListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Type net.sourceforge.squirrel_sql.client.session.event.ISessionListener does not match with type net.sourceforge.squirrel_sql.client.gui.IHtmlViewerPanelListener
    12Clone fragment #1 returns variable evt with type net.sourceforge.squirrel_sql.client.session.event.SessionEvent , while Clone fragment #2 returns variable evt with type net.sourceforge.squirrel_sql.client.gui.HtmlViewerPanelListenerEvent