/** * Add all system properties which aren't already defined as * user properties to the project properties. */ public void setSystemProperties() { Properties systemP = System.getProperties(); Enumeration e = systemP.propertyNames(); while (e.hasMoreElements()) { String propertyName = (String) e.nextElement(); String value = systemP.getProperty(propertyName); this.setPropertyInternal(propertyName, value); } }
/** * Cache the system properties and set the system properties to the * new values. * @throws BuildException if Security prevented this operation. */ public void setSystem() throws BuildException { try { sys = System.getProperties(); Properties p = new Properties(); for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); p.put(name, sys.getProperty(name)); } p.putAll(mergePropertySets()); for (Enumeration e = variables.elements(); e.hasMoreElements();) { Environment.Variable v = (Environment.Variable) e.nextElement(); v.validate(); p.put(v.getKey(), v.getValue()); } System.setProperties(p); } catch (SecurityException e) { throw new BuildException("Cannot modify system properties", e); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/Project.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/CommandlineJava.java
Method name: void setSystemProperties() Method name: void setSystem()
Number of AST nodes: 4 Number of AST nodes: 3
1
/**
1
/**
2
     * Add all system properties which aren't already defined as
2
         * Cache the system properties and set the system properties to the
3
     * user properties to the project properties.
3
         * new values.
4
     */
4
         * @throws BuildException if Security prevented this operation.
5
    public void setSystemProperties() {
5
         */
6
        Properties systemP = System.getProperties();
6
        public void setSystem() throws BuildException {
7
        Enumeration e = systemP.propertyNames();
7
            try {
8
        while (e.hasMoreElements()) {
8
                sys = System.getProperties();
9
            String propertyName = (String) e.nextElement();
9
                Properties p = new Properties();
10
            String value = systemP.getProperty(propertyName);
10
                for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) {
11
            this.setPropertyInternal(propertyName, value);
11
                    String name = (String) e.nextElement();
12
        }
12
                    p.put(name, sys.getProperty(name));
13
    }
13
                }
14
                p.putAll(mergePropertySets());
15
                for (Enumeration e = variables.elements(); e.hasMoreElements();) {
16
                    Environment.Variable v = (Environment.Variable) e.nextElement();
17
                    v.validate();
18
                    p.put(v.getKey(), v.getValue());
19
                }
20
                System.setProperties(p);
21
            } catch (SecurityException e) {
22
                throw new BuildException("Cannot modify system properties", e);
23
            }
24
        }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.600
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    while (e.hasMoreElements())
    3
    while (e.hasMoreElements())
    4
    for (Enumeration e = sys.propertyNames(); e.hasMoreElements(); )
    Differences
    Expression1Expression2Difference
    systemPsysVARIABLE_NAME_MISMATCH
    systemPsysVARIABLE_NAME_MISMATCH
    systemPsysVARIABLE_NAME_MISMATCH
    4
    for (Enumeration e = sys.propertyNames(); e.hasMoreElements(); )
    4
    String propertyName = (String)e.nextElement();
    4
    String propertyName = (String)e.nextElement();
    5
    String name = (String)e.nextElement();
    Differences
    Expression1Expression2Difference
    propertyNamenameVARIABLE_NAME_MISMATCH
    5
    String name = (String)e.nextElement();
    5
    String value = systemP.getProperty(propertyName);
    5
    String value = systemP.getProperty(propertyName);
    Preondition Violations
    Unmatched statement String value=systemP.getProperty(propertyName); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                        
                                                                              
    6
    p.put(name, sys.getProperty(name));
    Preondition Violations
    Unmatched statement p.put(name,sys.getProperty(name)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    p.put(name, sys.getProperty(name));
    6
    this.setPropertyInternal(propertyName, value);
    6
    this.setPropertyInternal(propertyName, value);
    Preondition Violations
    Unmatched statement this.setPropertyInternal(propertyName,value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                    
    Precondition Violations (3)
    Row Violation
    1Unmatched statement String value=systemP.getProperty(propertyName); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement p.put(name,sys.getProperty(name)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement this.setPropertyInternal(propertyName,value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted