if (className == null) throw new IllegalArgumentException("className == null"); IExtensionInterface plugin = null; Class actClass; actClass = loader.loadClass(className); // // we can't just load the first constructor // -> go find the correct constructor based // -> based on the arguments // if ((arguments == null) || (arguments.length == 0)) { plugin = (IExtensionInterface) actClass.newInstance(); } else { Constructor constructor; constructor = ClassLoaderHelper .findConstructor(arguments, actClass); // couldn't find correct constructor if (constructor == null) { LOG.severe("Couldn't find constructor for " + className + " with matching argument-list: "); for (int i = 0; i < arguments.length; i++) { LOG.severe("argument[" + i + "]=" + arguments[i]); } return null; } else { plugin = (IExtensionInterface) constructor .newInstance(arguments); } } return plugin;
if (className == null) throw new IllegalArgumentException("className == null"); IExtensionInterface plugin = null; // use our global class loader ClassLoader loader = Main.mainClassLoader; Class actClass; actClass = loader.loadClass(className); // // we can't just load the first constructor // -> go find the correct constructor based // -> based on the arguments // if ((arguments == null) || (arguments.length == 0)) { plugin = (IExtensionInterface) actClass.newInstance(); } else { Constructor constructor; constructor = ClassLoaderHelper .findConstructor(arguments, actClass); // couldn't find correct constructor if (constructor == null) { LOG.severe("Couldn't find constructor for " + className + " with matching argument-list: "); for (int i = 0; i < arguments.length; i++) { LOG.severe("argument[" + i + "]=" + arguments[i]); } return null; } else { plugin = (IExtensionInterface) constructor .newInstance(arguments); } } return plugin;
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/core/src/main/java/org/columba/core/plugin/DefaultPluginLoader.java File path: /columba-1.4-src/core/src/main/java/org/columba/core/plugin/Extension.java
Method name: IExtensionInterface loadPlugin(String, String, Object[]) Method name: IExtensionInterface instanciateJavaClass(String, Object[])
Number of AST nodes: 16 Number of AST nodes: 17
1
if (className == null)
1
if (className == null)
2
			throw new IllegalArgumentException("className == null");
2
			throw new IllegalArgumentException("className == null");
3
		IExtensionInterface plugin = null;
3
		IExtensionInterface plugin = null;
4
		// use our global class loader
5
		ClassLoader loader = Main.mainClassLoader;
6
		
4
		Class actClass;
7
		Class actClass;
5
		actClass = loader.loadClass(className);
8
		actClass = loader.loadClass(className);
6
		//
9
		//
7
		// we can't just load the first constructor
10
		// we can't just load the first constructor
8
		// -> go find the correct constructor based
11
		// -> go find the correct constructor based
9
		// -> based on the arguments
12
		// -> based on the arguments
10
		//
13
		//
11
		if ((arguments == null) || (arguments.length == 0)) {
14
		if ((arguments == null) || (arguments.length == 0)) {
12
			plugin = (IExtensionInterface) actClass.newInstance();
15
			plugin = (IExtensionInterface) actClass.newInstance();
13
		} else {
16
		} else {
14
			Constructor constructor;
17
			Constructor constructor;
15
			constructor = ClassLoaderHelper
18
			constructor = ClassLoaderHelper
16
					.findConstructor(arguments, actClass);
19
					.findConstructor(arguments, actClass);
17
			// couldn't find correct constructor
20
			// couldn't find correct constructor
18
			if (constructor == null) {
21
			if (constructor == null) {
19
				LOG.severe("Couldn't find constructor for " + className
22
				LOG.severe("Couldn't find constructor for " + className
20
						+ " with matching argument-list: ");
23
						+ " with matching argument-list: ");
21
				for (int i = 0; i < arguments.length; i++) {
24
				for (int i = 0; i < arguments.length; i++) {
22
					LOG.severe("argument[" + i + "]=" + arguments[i]);
25
					LOG.severe("argument[" + i + "]=" + arguments[i]);
23
				}
26
				}
24
				return null;
27
				return null;
25
			} else {
28
			} else {
26
				plugin = (IExtensionInterface) constructor
29
				plugin = (IExtensionInterface) constructor
27
						.newInstance(arguments);
30
						.newInstance(arguments);
28
			}
31
			}
29
		}
32
		}
30
		return plugin;
33
		return plugin;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)1.0
Clones locationClones are in different classes
Number of node comparisons61
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)9.6
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (className == null)
    1
    if (className == null)
    2
    throw new IllegalArgumentException("className == null");
    2
    throw new IllegalArgumentException("className == null");
    3
    IExtensionInterface plugin = null;
    3
    IExtensionInterface plugin = null;
                                                                                          
    4
    ClassLoader loader = Main.mainClassLoader;
    4
    Class actClass;
    5
    Class actClass;
    5
    actClass = loader.loadClass(className);
    6
    actClass = loader.loadClass(className);
    6
    if ((arguments == null) || (arguments.length == 0))
    7
    if ((arguments == null) || (arguments.length == 0))
    7
    plugin = (IExtensionInterface)actClass.newInstance();
    8
    plugin = (IExtensionInterface)actClass.newInstance();
    else
    else
    8
    Constructor constructor;
    9
    Constructor constructor;
    9
    constructor = ClassLoaderHelper.findConstructor(arguments, actClass);
    10
    constructor = ClassLoaderHelper.findConstructor(arguments, actClass);
    10
    if (constructor == null)
    11
    if (constructor == null)
    11
    LOG.severe("Couldn't find constructor for " + className + " with matching argument-list: ");
    12
    LOG.severe("Couldn't find constructor for " + className + " with matching argument-list: ");
    12
    for (int i = 0; i < arguments.length; i++)
    13
    for (int i = 0; i < arguments.length; i++)
    13
    LOG.severe("argument[" + i + "]=" + arguments[i]);
    14
    LOG.severe("argument[" + i + "]=" + arguments[i]);
    14
    return null;
    15
    return null;
    else
    else
    15
    plugin = (IExtensionInterface)constructor.newInstance(arguments);
    16
    plugin = (IExtensionInterface)constructor.newInstance(arguments);
    16
    return plugin;
    17
    return plugin;
    Precondition Violations (0)
    Row Violation