if ( importedObjects == null ) importedObjects = new Vector(); // If it exists, remove it and add it at the end (avoid memory leak) if ( importedObjects.contains( obj ) ) importedObjects.remove( obj ); importedObjects.addElement( obj ); nameSpaceChanged();
if(importedPackages == null) importedPackages = new Vector(); // If it exists, remove it and add it at the end (avoid memory leak) if ( importedPackages.contains( name ) ) importedPackages.remove( name ); importedPackages.addElement(name); nameSpaceChanged();
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/NameSpace.java File path: /jEdit-4.2/src/bsh/NameSpace.java
Method name: void importObject(Object) Method name: void importPackage(String)
Number of AST nodes: 6 Number of AST nodes: 6
1
if ( importedObjects == null )
1
if(importedPackages == null)
2
			importedObjects = new Vector();
2
			importedPackages = new Vector();
3
		// If it exists, remove it and add it at the end (avoid memory leak)
3
		// If it exists, remove it and add it at the end (avoid memory leak)
4
		if ( importedObjects.contains( obj ) )
4
		if ( importedPackages.contains( name ) )
5
			importedObjects.remove( obj );
5
			importedPackages.remove( name );
6
		importedObjects.addElement( obj );
6
		importedPackages.addElement(name);
7
		nameSpaceChanged();
7
		nameSpaceChanged();
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 declared in the same class
Number of node comparisons17
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    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.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (importedObjects == null)
    1
    if (importedObjects == null)
    1
    if (importedPackages == null)
    Differences
    Expression1Expression2Difference
    importedObjectsimportedPackagesVARIABLE_NAME_MISMATCH
    1
    if (importedPackages == null)
    2
    importedObjects = new Vector();
    2
    importedObjects = new Vector();
    2
    importedPackages = new Vector();
    Differences
    Expression1Expression2Difference
    importedObjectsimportedPackagesVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression importedObjects is a field being modified, and thus it cannot be parameterized
    Expression importedPackages is a field being modified, and thus it cannot be parameterized
    2
    importedPackages = new Vector();
    3
    if (importedObjects.contains(obj))
    3
    if (importedObjects.contains(obj))
    3
    if (importedPackages.contains(name))
    Differences
    Expression1Expression2Difference
    objnameVARIABLE_NAME_MISMATCH
    java.lang.Objectjava.lang.StringVARIABLE_TYPE_MISMATCH
    importedObjectsimportedPackagesVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable obj does not match with type java.lang.String of variable name
    • Make classes java.lang.Object and java.lang.String extend a common superclass
    Expression importedObjects cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    if (importedPackages.contains(name))
    4
    importedObjects.remove(obj);
    4
    importedObjects.remove(obj);
    4
    importedPackages.remove(name);
    Differences
    Expression1Expression2Difference
    objnameVARIABLE_NAME_MISMATCH
    java.lang.Objectjava.lang.StringVARIABLE_TYPE_MISMATCH
    importedObjectsimportedPackagesVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable obj does not match with type java.lang.String of variable name
    • Make classes java.lang.Object and java.lang.String extend a common superclass
    Expression importedObjects cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    importedPackages.remove(name);
    5
    importedObjects.addElement(obj);
    5
    importedObjects.addElement(obj);
    5
    importedPackages.addElement(name);
    Differences
    Expression1Expression2Difference
    objnameVARIABLE_NAME_MISMATCH
    java.lang.Objectjava.lang.StringVARIABLE_TYPE_MISMATCH
    importedObjectsimportedPackagesVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable obj does not match with type java.lang.String of variable name
    • Make classes java.lang.Object and java.lang.String extend a common superclass
    Expression importedObjects cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    importedPackages.addElement(name);
    6
    nameSpaceChanged();
    6
    nameSpaceChanged();
    Precondition Violations (11)
    Row Violation
    1Expression importedObjects is a field being modified, and thus it cannot be parameterized
    2Expression importedPackages is a field being modified, and thus it cannot be parameterized
    3Type java.lang.Object of variable obj does not match with type java.lang.String of variable name
    4Expression importedObjects cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Type java.lang.Object of variable obj does not match with type java.lang.String of variable name
    7Expression importedObjects cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Type java.lang.Object of variable obj does not match with type java.lang.String of variable name
    10Expression importedObjects cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted