IContextEvent e = new ContextEvent(this, value); // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == IContextListener.class) { ((IContextListener) listeners[i + 1]).contextChanged(e); } }
MailCheckingEvent e = new MailCheckingEvent(this, ref); // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == IMailCheckingListener.class) { ((IMailCheckingListener) listeners[i + 1]).newMessageArrived(e); } }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/core/src/main/java/org/columba/core/context/semantic/SemanticContext.java File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/mailchecking/MailCheckingManager.java
Method name: void fireContextChangedEvent(IStructureValue) Method name: void fireNewMessageArrived(IMailFolderCommandReference)
Number of AST nodes: 5 Number of AST nodes: 5
1
IContextEvent e = new ContextEvent(this, value);
1
MailCheckingEvent e = new MailCheckingEvent(this, ref);
2
		// Guaranteed to return a non-null array
2
		// Guaranteed to return a non-null array
3
		Object[] listeners = listenerList.getListenerList();
3
		Object[] listeners = listenerList.getListenerList();
4
		// Process the listeners last to first, notifying
4
		// Process the listeners last to first, notifying
5
		// those that are interested in this event
5
		// those that are interested in this event
6
		for (int i = listeners.length - 2; i >= 0; i -= 2) {
6
		for (int i = listeners.length - 2; i >= 0; i -= 2) {
7
			if (listeners[i] == IContextListener.class) {
7
			if (listeners[i] == IMailCheckingListener.class) {
8
				((IContextListener) listeners[i + 1]).contextChanged(e);
8
				((IMailCheckingListener) listeners[i + 1]).newMessageArrived(e);
9
			}
9
			}
10
		}
10
		}
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 comparisons9
  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.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                  
    1
    MailCheckingEvent e = new MailCheckingEvent(this, ref);
    Preondition Violations
    Unmatched statement MailCheckingEvent e=new MailCheckingEvent(this,ref); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    MailCheckingEvent e = new MailCheckingEvent(this, ref);
    1
    IContextEvent e = new ContextEvent(this, value);
    1
    IContextEvent e = new ContextEvent(this, value);
    Preondition Violations
    Unmatched statement IContextEvent e=new ContextEvent(this,value); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                    
    2
    Object[] listeners = listenerList.getListenerList();
    2
    Object[] listeners = listenerList.getListenerList();
    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] == IContextListener.class)
    4
    if (listeners[i] == IContextListener.class)
    4
    if (listeners[i] == IMailCheckingListener.class)
    Differences
    Expression1Expression2Difference
    IContextListener.classIMailCheckingListener.classLITERAL_VALUE_MISMATCH
    4
    if (listeners[i] == IMailCheckingListener.class)
    5
    ((IContextListener)listeners[i + 1]).contextChanged(e);
    5
    ((IContextListener)listeners[i + 1]).contextChanged(e);
    5
    ((IMailCheckingListener)listeners[i + 1]).newMessageArrived(e);
    Differences
    Expression1Expression2Difference
    org.columba.core.context.semantic.api.IContextEventorg.columba.mail.mailchecking.MailCheckingEventVARIABLE_TYPE_MISMATCH
    contextChangednewMessageArrivedMETHOD_INVOCATION_NAME_MISMATCH
    org.columba.core.context.semantic.api.IContextListenerorg.columba.mail.mailchecking.IMailCheckingListenerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.columba.core.context.semantic.api.IContextEvent of variable e does not match with type org.columba.mail.mailchecking.MailCheckingEvent of variable e
    • Make classes org.columba.core.context.semantic.api.IContextEvent and org.columba.mail.mailchecking.MailCheckingEvent extend a common superclass
    Expression ((IContextListener)listeners[i + 1]).contextChanged(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((IMailCheckingListener)listeners[i + 1]).newMessageArrived(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((IContextListener)listeners[i + 1]).contextChanged(e) is a void method call, and thus it cannot be parameterized
    Expression ((IMailCheckingListener)listeners[i + 1]).newMessageArrived(e) is a void method call, and thus it cannot be parameterized
    Expression (IContextListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (IMailCheckingListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.columba.core.context.semantic.api.IContextListener does not match with type org.columba.mail.mailchecking.IMailCheckingListener
    • Make classes org.columba.core.context.semantic.api.IContextListener and org.columba.mail.mailchecking.IMailCheckingListener extend a common superclass
    5
    ((IMailCheckingListener)listeners[i + 1]).newMessageArrived(e);
    Precondition Violations (11)
    Row Violation
    1Unmatched statement MailCheckingEvent e=new MailCheckingEvent(this,ref); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement IContextEvent e=new ContextEvent(this,value); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Type org.columba.core.context.semantic.api.IContextEvent of variable e does not match with type org.columba.mail.mailchecking.MailCheckingEvent of variable e
    4Expression ((IContextListener)listeners[i + 1]).contextChanged(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression ((IMailCheckingListener)listeners[i + 1]).newMessageArrived(e) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression ((IContextListener)listeners[i + 1]).contextChanged(e) is a void method call, and thus it cannot be parameterized
    7Expression ((IMailCheckingListener)listeners[i + 1]).newMessageArrived(e) is a void method call, and thus it cannot be parameterized
    8Expression (IContextListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression (IMailCheckingListener)listeners[i + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Type org.columba.core.context.semantic.api.IContextListener does not match with type org.columba.mail.mailchecking.IMailCheckingListener
    11The refactoring of the clones is infeasible, because classes org.columba.core.context.semantic.SemanticContext and org.columba.mail.mailchecking.MailCheckingManager do not have a common superclass