You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2018/05/26 15:46:15 UTC

[2/4] ant git commit: Use foreach loops (cherry-pick 1c80d50)

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 74ef819..b7235e1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -291,10 +291,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             Hashtable newroots = new Hashtable();
             // put in the newroots vector the include patterns without
             // wildcard tokens
-            for (int icounter = 0; icounter < includes.length; icounter++) {
+            for (String include : includes) {
                 String newpattern =
-                    SelectorUtils.rtrimWildcardTokens(includes[icounter]);
-                newroots.put(newpattern, includes[icounter]);
+                        SelectorUtils.rtrimWildcardTokens(include);
+                newroots.put(newpattern, include);
             }
             if (task.getRemotedir() == null) {
                 try {
@@ -412,11 +412,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     ftp.changeToParentDirectory();
                     return;
                 }
-                for (int i = 0; i < newfiles.length; i++) {
-                    FTPFile file = newfiles[i];
+                for (FTPFile file : newfiles) {
                     if (file != null
-                        && !file.getName().equals(".")
-                        && !file.getName().equals("..")) {
+                            && !".".equals(file.getName())
+                            && !"..".equals(file.getName())) {
                         String name = vpath + file.getName();
                         scannedDirs.put(name, new FTPFileProxy(file));
                         if (isFunctioningAsDirectory(ftp, dir, file)) {
@@ -426,7 +425,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                                 slowScanAllowed = false;
                             } else if (isIncluded(name)) {
                                 accountForIncludedDir(name,
-                                                      new AntFTPFile(ftp, file, completePath) , fast);
+                                        new AntFTPFile(ftp, file, completePath), fast);
                             } else {
                                 dirsNotIncluded.addElement(name);
                                 if (fast && couldHoldIncluded(name)) {
@@ -482,9 +481,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
          * @param fast boolean
          */
         private void accountForIncludedDir(String name, AntFTPFile file, boolean fast) {
-            if (!dirsIncluded.contains(name)
-                && !dirsExcluded.contains(name)) {
-
+            if (!dirsIncluded.contains(name) && !dirsExcluded.contains(name)) {
                 if (!isExcluded(name)) {
                     if (fast) {
                         if (file.isSymbolicLink()) {
@@ -658,14 +655,14 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             }
         }
         private String fiddleName(String origin) {
-            StringBuffer result = new StringBuffer();
-            for (int icounter = 0; icounter < origin.length(); icounter++) {
-                if (Character.isLowerCase(origin.charAt(icounter))) {
-                    result.append(Character.toUpperCase(origin.charAt(icounter)));
-                } else if (Character.isUpperCase(origin.charAt(icounter))) {
-                    result.append(Character.toLowerCase(origin.charAt(icounter)));
+            StringBuilder result = new StringBuilder();
+            for (char ch : origin.toCharArray()) {
+                if (Character.isLowerCase(ch)) {
+                    result.append(Character.toUpperCase(ch));
+                } else if (Character.isUpperCase(ch)) {
+                    result.append(Character.toLowerCase(ch));
                 } else {
-                    result.append(origin.charAt(icounter));
+                    result.append(ch);
                 }
             }
             return result.toString();
@@ -713,7 +710,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             public AntFTPFile(AntFTPFile parent, String path) {
                 this.parent = parent;
                 this.client = parent.client;
-                Vector pathElements = SelectorUtils.tokenizePath(path);
+                Vector<String> pathElements = SelectorUtils.tokenizePath(path);
                 try {
                     boolean result = this.client.changeWorkingDirectory(parent.getAbsolutePath());
                     //this should not happen, except if parent has been deleted by another process
@@ -722,18 +719,15 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     }
                     this.curpwd = parent.getAbsolutePath();
                 } catch (IOException ioe) {
-                    throw new BuildException("could not change working dir to "
-                                             + parent.curpwd);
+                    throw new BuildException("could not change working dir to " + parent.curpwd);
                 }
-                final int size = pathElements.size();
-                for (int fcount = 0; fcount < size - 1; fcount++) {
-                    String currentPathElement = (String) pathElements.elementAt(fcount);
+                for (String currentPathElement : pathElements) {
                     try {
                         boolean result = this.client.changeWorkingDirectory(currentPathElement);
                         if (!result && !isCaseSensitive()
                             && (remoteSystemCaseSensitive || !remoteSensitivityChecked)) {
                             currentPathElement = findPathElementCaseUnsensitive(this.curpwd,
-                                                                                currentPathElement);
+                                    currentPathElement);
                             if (currentPathElement == null) {
                                 return;
                             }
@@ -744,14 +738,12 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                             + currentPathElement;
                     } catch (IOException ioe) {
                         throw new BuildException("could not change working dir to "
-                                                 + (String) pathElements.elementAt(fcount)
-                                                 + " from " + this.curpwd);
+                                + currentPathElement + " from " + this.curpwd);
                     }
 
                 }
-                String lastpathelement = (String) pathElements.elementAt(size - 1);
-                FTPFile [] theFiles = listFiles(this.curpwd);
-                this.ftpFile = getFile(theFiles, lastpathelement);
+                String lastpathelement = pathElements.get(pathElements.size() - 1);
+                this.ftpFile = getFile(listFiles(this.curpwd), lastpathelement);
             }
             /**
              * find a file in a directory in case insensitive way
@@ -763,14 +755,13 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                                                           String soughtPathElement) {
                 // we are already in the right path, so the second parameter
                 // is false
-                FTPFile[] theFiles = listFiles(parentPath, false);
-                if (theFiles == null) {
+                FTPFile[] files = listFiles(parentPath, false);
+                if (files == null) {
                     return null;
                 }
-                for (int icounter = 0; icounter < theFiles.length; icounter++) {
-                    if (theFiles[icounter] != null
-                        && theFiles[icounter].getName().equalsIgnoreCase(soughtPathElement)) {
-                        return theFiles[icounter].getName();
+                for (FTPFile file : files) {
+                    if (file != null && file.getName().equalsIgnoreCase(soughtPathElement)) {
+                        return file.getName();
                     }
                 }
                 return null;
@@ -1174,8 +1165,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     task.setGranularityMillis(task.getTimestampGranularity()
                                               .getMilliseconds(task.getAction()));
                 }
-                for (int i = 0; i < dsfiles.length; i++) {
-                    final String dsfile = dsfiles[i];
+                for (final String dsfile : dsfiles) {
                     executeRetryable(h, new Retryable() {
                         public void execute() throws IOException {
                             switch (task.getAction()) {
@@ -1373,7 +1363,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
      *  find a suitable name for local and remote temporary file
      */
     private File findFileName(FTPClient ftp) {
-        FTPFile [] theFiles = null;
+        FTPFile[] files = null;
         final int maxIterations = 1000;
         for (int counter = 1; counter < maxIterations; counter++) {
             File localFile = FILE_UTILS.createTempFile(
@@ -1382,12 +1372,11 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
             String fileName = localFile.getName();
             boolean found = false;
             try {
-                if (theFiles == null) {
-                    theFiles = ftp.listFiles();
+                if (files == null) {
+                    files = ftp.listFiles();
                 }
-                for (int counter2 = 0; counter2 < theFiles.length; counter2++) {
-                    if (theFiles[counter2] != null
-                        && theFiles[counter2].getName().equals(fileName)) {
+                for (FTPFile file : files) {
+                    if (file != null && file.getName().equals(fileName)) {
                         found = true;
                         break;
                     }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java
index dfb6e69..48e36b0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java
@@ -147,10 +147,9 @@ public class SoundTask extends Task {
             if (source.exists()) {
                 if (source.isDirectory()) {
                     // get the list of files in the dir
-                    String[] entries = source.list();
-                    Vector files = new Vector();
-                    for (int i = 0; i < entries.length; i++) {
-                        File f = new File(source, entries[i]);
+                    Vector<File> files = new Vector<File>();
+                    for (String file : source.list()) {
+                        File f = new File(source, file);
                         if (f.isFile()) {
                             files.addElement(f);
                         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
index fb80c8c..bbc186a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
@@ -86,10 +86,9 @@ public class SSHSession extends SSHBase {
      * tunnel specifications
      */
     public void setLocaltunnels(final String tunnels) {
-        final String[] specs = tunnels.split(", ");
-        for (int i = 0; i < specs.length; i++) {
-            if (specs[i].length() > 0) {
-                final String[] spec = specs[i].split(":", 3);
+        for (String tunnelSpec : tunnels.split(", ")) {
+            if (tunnelSpec.length() > 0) {
+                final String[] spec = tunnelSpec.split(":", 3);
                 final int lport = Integer.parseInt(spec[0]);
                 final String rhost = spec[1];
                 final int rport = Integer.parseInt(spec[2]);
@@ -109,10 +108,9 @@ public class SSHSession extends SSHBase {
      * tunnel specifications
      */
     public void setRemotetunnels(final String tunnels) {
-        final String[] specs = tunnels.split(", ");
-        for (int i = 0; i < specs.length; i++) {
-            if (specs[i].length() > 0) {
-                final String[] spec = specs[i].split(":", 3);
+        for (String tunnelSpec : tunnels.split(", ")) {
+            if (tunnelSpec.length() > 0) {
+                final String[] spec = tunnelSpec.split(":", 3);
                 final int rport = Integer.parseInt(spec[0]);
                 final String lhost = spec[1];
                 final int lport = Integer.parseInt(spec[2]);

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java b/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
index 37a14cb..420597a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
@@ -206,8 +206,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
         Commandline cmd = new Commandline();
 
         if (options != null) {
-            for (int i = 0; i < options.length; i++) {
-                cmd.createArgument().setValue(options[i]);
+            for (String option : options) {
+                cmd.createArgument().setValue(option);
             }
         }
 
@@ -329,13 +329,12 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
      */
     protected String[] filterJvmCompilerArgs(String[] compilerArgs) {
         int len = compilerArgs.length;
-        List args = new ArrayList(len);
-        for (int i = 0; i < len; i++) {
-            String arg = compilerArgs[i];
-            if (!arg.startsWith("-J")) {
-                args.add(arg);
-            } else {
+        List<String> args = new ArrayList<String>(len);
+        for (String arg : compilerArgs) {
+            if (arg.startsWith("-J")) {
                 attributes.log("Dropping " + arg + " from compiler arguments");
+            } else {
+                args.add(arg);
             }
         }
         int count = args.size();

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
index f5f0bff..5b2233f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
@@ -60,15 +60,14 @@ public class KaffeRmic extends DefaultRmicAdapter {
 
         Class c = getRmicClass();
         if (c == null) {
-            StringBuffer buf = new StringBuffer("Cannot use Kaffe rmic, as it"
-                                                + " is not available.  None"
-                                                + " of ");
-            for (int i = 0; i < RMIC_CLASSNAMES.length; i++) {
-                if (i != 0) {
+            StringBuilder buf = new StringBuilder(
+                "Cannot use Kaffe rmic, as it is not available.  None of ");
+            for (String className : RMIC_CLASSNAMES) {
+                if (buf.length() > 0) {
                     buf.append(", ");
                 }
 
-                buf.append(RMIC_CLASSNAMES[i]);
+                buf.append(className);
             }
             buf.append(" have been found. A common solution is to set the"
                        + " environment variable JAVA_HOME or CLASSPATH.");
@@ -101,10 +100,10 @@ public class KaffeRmic extends DefaultRmicAdapter {
      *
      * @return null if neither class can get loaded.
      */
-    private static Class getRmicClass() {
-        for (int i = 0; i < RMIC_CLASSNAMES.length; i++) {
+    private static Class<?> getRmicClass() {
+        for (String className : RMIC_CLASSNAMES) {
             try {
-                return Class.forName(RMIC_CLASSNAMES[i]);
+                return Class.forName(className);
             } catch (ClassNotFoundException cnfe) {
                 // Ignore
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/AbstractFileSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/AbstractFileSet.java b/src/main/org/apache/tools/ant/types/AbstractFileSet.java
index 1dca341..f2764a5 100644
--- a/src/main/org/apache/tools/ant/types/AbstractFileSet.java
+++ b/src/main/org/apache/tools/ant/types/AbstractFileSet.java
@@ -277,8 +277,8 @@ public abstract class AbstractFileSet extends DataType
             throw tooManyAttributes();
         }
         if (includes != null) {
-            for (int i = 0; i < includes.length; i++) {
-                defaultPatterns.createInclude().setName(includes[i]);
+            for (String include : includes) {
+                defaultPatterns.createInclude().setName(include);
             }
             directoryScanner = null;
         }
@@ -312,8 +312,8 @@ public abstract class AbstractFileSet extends DataType
             throw tooManyAttributes();
         }
         if (excludes != null) {
-            for (int i = 0; i < excludes.length; i++) {
-                defaultPatterns.createExclude().setName(excludes[i]);
+            for (String exclude : excludes) {
+                defaultPatterns.createExclude().setName(exclude);
             }
             directoryScanner = null;
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/Commandline.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/Commandline.java b/src/main/org/apache/tools/ant/types/Commandline.java
index c8f4eaf..1b634ef 100644
--- a/src/main/org/apache/tools/ant/types/Commandline.java
+++ b/src/main/org/apache/tools/ant/types/Commandline.java
@@ -354,8 +354,8 @@ public class Commandline implements Cloneable {
      * @param line an array of arguments to append.
      */
     public void addArguments(String[] line) {
-        for (int i = 0; i < line.length; i++) {
-            createArgument().setValue(line[i]);
+        for (String l : line) {
+            createArgument().setValue(l);
         }
     }
 
@@ -398,13 +398,11 @@ public class Commandline implements Cloneable {
      * @since Ant 1.6
      */
     public void addArgumentsToList(ListIterator<String> list) {
-        final int size = arguments.size();
-        for (int i = 0; i < size; i++) {
-            Argument arg = arguments.get(i);
+        for (Argument arg : arguments) {
             String[] s = arg.getParts();
             if (s != null) {
-                for (int j = 0; j < s.length; j++) {
-                    list.add(s[j]);
+                for (String value : s) {
+                    list.add(value);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/CommandlineJava.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java
index e6f82cf..1771e3a 100644
--- a/src/main/org/apache/tools/ant/types/CommandlineJava.java
+++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java
@@ -108,8 +108,8 @@ public class CommandlineJava implements Cloneable {
         public void addDefinitionsToList(ListIterator<String> listIt) {
             String[] props = super.getVariables();
             if (props != null) {
-                for (int i = 0; i < props.length; i++) {
-                    listIt.add("-D" + props[i]);
+                for (String prop : props) {
+                    listIt.add("-D" + prop);
                 }
             }
             Properties propertySetProperties = mergePropertySets();

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/FilterChain.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/FilterChain.java b/src/main/org/apache/tools/ant/types/FilterChain.java
index da7d967..6bad602 100644
--- a/src/main/org/apache/tools/ant/types/FilterChain.java
+++ b/src/main/org/apache/tools/ant/types/FilterChain.java
@@ -17,7 +17,6 @@
  */
 package org.apache.tools.ant.types;
 
-import java.util.Iterator;
 import java.util.Stack;
 import java.util.Vector;
 
@@ -405,8 +404,7 @@ public class FilterChain extends DataType {
         if (isReference()) {
             super.dieOnCircularReference(stk, p);
         } else {
-            for (Iterator<Object> i = filterReaders.iterator(); i.hasNext();) {
-                Object o = i.next();
+            for (Object o : filterReaders) {
                 if (o instanceof DataType) {
                     pushAndInvokeCircularReferenceCheck((DataType) o, stk, p);
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/FilterSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java
index 2c1f2e7..fbfff11 100644
--- a/src/main/org/apache/tools/ant/types/FilterSet.java
+++ b/src/main/org/apache/tools/ant/types/FilterSet.java
@@ -228,9 +228,8 @@ public class FilterSet extends DataType implements Cloneable {
         //silly hack to avoid stack overflow...
         if (!readingFiles) {
             readingFiles = true;
-            final int size = filtersFiles.size();
-            for (int i = 0; i < size; i++) {
-                readFiltersFromFile(filtersFiles.get(i));
+            for (File filtersFile : filtersFiles) {
+                readFiltersFromFile(filtersFile);
             }
             filtersFiles.clear();
             readingFiles = false;

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/Path.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java
index 70358d8..deaad3e 100644
--- a/src/main/org/apache/tools/ant/types/Path.java
+++ b/src/main/org/apache/tools/ant/types/Path.java
@@ -20,6 +20,7 @@ package org.apache.tools.ant.types;
 
 import java.io.File;
 import java.lang.reflect.Method;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Locale;
@@ -326,17 +327,16 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
      * @param tryUserDir  if true try the user directory if the file is not present
      */
     public void addExisting(Path source, boolean tryUserDir) {
-        String[] list = source.list();
         File userDir = (tryUserDir) ? new File(System.getProperty("user.dir"))
                 : null;
 
-        for (int i = 0; i < list.length; i++) {
-            File f = resolveFile(getProject(), list[i]);
+        for (String name : source.list()) {
+            File f = resolveFile(getProject(), name);
 
             // probably not the best choice, but it solves the problem of
             // relative paths in CLASSPATH
             if (tryUserDir && !f.exists()) {
-                f = new File(userDir, list[i]);
+                f = new File(userDir, name);
             }
             if (f.exists()) {
                 setLocation(f);
@@ -624,28 +624,25 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
                                  + File.separator + "rt.jar"));
 
             // Sun's and Apple's 1.4 have JCE and JSSE in separate jars.
-            String[] secJars = {"jce", "jsse"};
-            for (int i = 0; i < secJars.length; i++) {
+            for (String secJar : Arrays.asList("jce", "jsse")) {
                 addExisting(new Path(null,
-                                     System.getProperty("java.home")
-                                     + File.separator + "lib"
-                                     + File.separator + secJars[i] + ".jar"));
+                        System.getProperty("java.home")
+                                + File.separator + "lib"
+                                + File.separator + secJar + ".jar"));
                 addExisting(new Path(null,
-                                     System.getProperty("java.home")
-                                     + File.separator + ".."
-                                     + File.separator + "Classes"
-                                     + File.separator + secJars[i] + ".jar"));
+                        System.getProperty("java.home")
+                                + File.separator + ".."
+                                + File.separator + "Classes"
+                                + File.separator + secJar + ".jar"));
             }
 
             // IBM's 1.4 has rt.jar split into 4 smaller jars and a combined
             // JCE/JSSE in security.jar.
-            String[] ibmJars
-                = {"core", "graphics", "security", "server", "xml"};
-            for (int i = 0; i < ibmJars.length; i++) {
+            for (String ibmJar : Arrays.asList("core", "graphics", "security", "server", "xml")) {
                 addExisting(new Path(null,
-                                     System.getProperty("java.home")
-                                     + File.separator + "lib"
-                                     + File.separator + ibmJars[i] + ".jar"));
+                        System.getProperty("java.home")
+                                + File.separator + "lib"
+                                + File.separator + ibmJar + ".jar"));
             }
 
             // Added for MacOS X
@@ -679,9 +676,8 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
             }
         }
 
-        String[] dirs = extdirs.list();
-        for (int i = 0; i < dirs.length; i++) {
-            File dir = resolveFile(getProject(), dirs[i]);
+        for (String d : extdirs.list()) {
+            File dir = resolveFile(getProject(), d);
             if (dir.exists() && dir.isDirectory()) {
                 FileSet fs = new FileSet();
                 fs.setDir(dir);

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/PatternSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/PatternSet.java b/src/main/org/apache/tools/ant/types/PatternSet.java
index cd5797b..6b0a52e 100644
--- a/src/main/org/apache/tools/ant/types/PatternSet.java
+++ b/src/main/org/apache/tools/ant/types/PatternSet.java
@@ -266,13 +266,13 @@ public class PatternSet extends DataType implements Cloneable {
         String[] nestedExcludes = p.getExcludePatterns(getProject());
 
         if (nestedIncludes != null) {
-            for (int i = 0; i < nestedIncludes.length; i++) {
-                createInclude().setName(nestedIncludes[i]);
+            for (String nestedInclude : nestedIncludes) {
+                createInclude().setName(nestedInclude);
             }
         }
         if (nestedExcludes != null) {
-            for (int i = 0; i < nestedExcludes.length; i++) {
-                createExclude().setName(nestedExcludes[i]);
+            for (String nestedExclude : nestedExcludes) {
+                createExclude().setName(nestedExclude);
             }
         }
     }
@@ -447,14 +447,14 @@ public class PatternSet extends DataType implements Cloneable {
         dieOnCircularReference(p);
         String[] incl = other.getIncludePatterns(p);
         if (incl != null) {
-            for (int i = 0; i < incl.length; i++) {
-                createInclude().setName(incl[i]);
+            for (String include : incl) {
+                createInclude().setName(include);
             }
         }
         String[] excl = other.getExcludePatterns(p);
         if (excl != null) {
-            for (int i = 0; i < excl.length; i++) {
-                createExclude().setName(excl[i]);
+            for (String exclude : excl) {
+                createExclude().setName(exclude);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/Quantifier.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/Quantifier.java b/src/main/org/apache/tools/ant/types/Quantifier.java
index fae3dc5..76b88d6 100644
--- a/src/main/org/apache/tools/ant/types/Quantifier.java
+++ b/src/main/org/apache/tools/ant/types/Quantifier.java
@@ -120,8 +120,8 @@ public class Quantifier extends EnumeratedAttribute {
      */
     public boolean evaluate(boolean[] b) {
         int t = 0;
-        for (int i = 0; i < b.length; i++) {
-            if (b[i]) {
+        for (boolean bn : b) {
+            if (bn) {
                 t++;
             }
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/RedirectorElement.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/RedirectorElement.java b/src/main/org/apache/tools/ant/types/RedirectorElement.java
index 79ab146..b57afec 100644
--- a/src/main/org/apache/tools/ant/types/RedirectorElement.java
+++ b/src/main/org/apache/tools/ant/types/RedirectorElement.java
@@ -573,12 +573,12 @@ public class RedirectorElement extends DataType {
         }
         //remove any null elements
         ArrayList<File> list = new ArrayList<File>(name.length);
-        for (int i = 0; i < name.length; i++) {
-            if (name[i] != null) {
-                list.add(getProject().resolveFile(name[i]));
+        for (String n : name) {
+            if (n != null) {
+                list.add(getProject().resolveFile(n));
             }
         }
-        return (File[]) (list.toArray(new File[list.size()]));
+        return list.toArray(new File[list.size()]);
     }
 
     /**
@@ -596,11 +596,10 @@ public class RedirectorElement extends DataType {
         if (isReference()) {
             super.dieOnCircularReference(stk, p);
         } else {
-            Mapper[] m = new Mapper[] {inputMapper, outputMapper, errorMapper};
-            for (int i = 0; i < m.length; i++) {
-                if (m[i] != null) {
-                    stk.push(m[i]);
-                    m[i].dieOnCircularReference(stk, p);
+            for (Mapper m : Arrays.asList(inputMapper, outputMapper, errorMapper)) {
+                if (m != null) {
+                    stk.push(m);
+                    m.dieOnCircularReference(stk, p);
                     stk.pop();
                 }
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/XMLCatalog.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/XMLCatalog.java b/src/main/org/apache/tools/ant/types/XMLCatalog.java
index 7001359..c857bd8 100644
--- a/src/main/org/apache/tools/ant/types/XMLCatalog.java
+++ b/src/main/org/apache/tools/ant/types/XMLCatalog.java
@@ -1105,14 +1105,13 @@ public class XMLCatalog extends DataType
                 if (catPath != null) {
                     log("Using catalogpath '" + getCatalogPath() + "'",
                         Project.MSG_DEBUG);
-                    String[] catPathList = getCatalogPath().list();
 
-                    for (int i = 0; i < catPathList.length; i++) {
-                        File catFile = new File(catPathList[i]);
+                    for (String catFileName : getCatalogPath().list()) {
+                        File catFile = new File(catFileName);
                         log("Parsing " + catFile, Project.MSG_DEBUG);
                         try {
                             parseCatalog.invoke(resolverImpl,
-                                    new Object[] {catFile.getPath()});
+                                    new Object[]{catFile.getPath()});
                         } catch (Exception ex) {
                             throw new BuildException(ex);
                         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java b/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
index f2fe69b..7fc8d3d 100644
--- a/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
+++ b/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
@@ -129,10 +129,9 @@ public class ClassfileSet extends FileSet {
         for (FileSet additionalRootSet : rootFileSets) {
             DirectoryScanner additionalScanner
                 = additionalRootSet.getDirectoryScanner(p);
-            String[] files = additionalScanner.getIncludedFiles();
-            for (int i = 0; i < files.length; ++i) {
-                if (files[i].endsWith(".class")) {
-                    String classFilePath = StringUtils.removeSuffix(files[i], ".class");
+            for (String file : additionalScanner.getIncludedFiles()) {
+                if (file.endsWith(".class")) {
+                    String classFilePath = StringUtils.removeSuffix(file, ".class");
                     String className
                         = classFilePath.replace('/', '.').replace('\\', '.');
                     allRootClasses.addElement(className);

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java b/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java
index 0c2dd4b..3527bf3 100644
--- a/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java
+++ b/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java
@@ -54,8 +54,8 @@ public class BZip2Resource extends CompressedResource {
      * @throws IOException if there is a problem.
      */
     protected InputStream wrapStream(InputStream in) throws IOException {
-        for (int i = 0; i < MAGIC.length; i++) {
-            if (in.read() != MAGIC[i]) {
+        for (char ch : MAGIC) {
+            if (in.read() != ch) {
                 throw new IOException("Invalid bz2 stream.");
             }
         }
@@ -69,8 +69,8 @@ public class BZip2Resource extends CompressedResource {
      * @throws IOException if there is a problem.
      */
     protected OutputStream wrapStream(OutputStream out) throws IOException {
-        for (int i = 0; i < MAGIC.length; i++) {
-            out.write(MAGIC[i]);
+        for (char ch : MAGIC) {
+            out.write(ch);
         }
         return new CBZip2OutputStream(out);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/resources/Files.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/Files.java b/src/main/org/apache/tools/ant/types/resources/Files.java
index a28e3a7..a66b8ad 100644
--- a/src/main/org/apache/tools/ant/types/resources/Files.java
+++ b/src/main/org/apache/tools/ant/types/resources/Files.java
@@ -181,8 +181,8 @@ public class Files extends AbstractSelectorContainer
     public synchronized void appendIncludes(String[] includes) {
         checkAttributesAllowed();
         if (includes != null) {
-            for (int i = 0; i < includes.length; i++) {
-                defaultPatterns.createInclude().setName(includes[i]);
+            for (String include : includes) {
+                defaultPatterns.createInclude().setName(include);
             }
             ds = null;
         }
@@ -211,8 +211,8 @@ public class Files extends AbstractSelectorContainer
     public synchronized void appendExcludes(String[] excludes) {
         checkAttributesAllowed();
         if (excludes != null) {
-            for (int i = 0; i < excludes.length; i++) {
-                defaultPatterns.createExclude().setName(excludes[i]);
+            for (String exclude : excludes) {
+                defaultPatterns.createExclude().setName(exclude);
             }
             ds = null;
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java b/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
index 7140b97..5b03e53 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
@@ -119,17 +119,16 @@ public class ContainsRegexpSelector extends BaseExtendSelector
     public void setParameters(Parameter[] parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
-            for (int i = 0; i < parameters.length; i++) {
-                String paramname = parameters[i].getName();
+            for (Parameter parameter : parameters) {
+                String paramname = parameter.getName();
                 if (EXPRESSION_KEY.equalsIgnoreCase(paramname)) {
-                    setExpression(parameters[i].getValue());
+                    setExpression(parameter.getValue());
                 } else if (CS_KEY.equalsIgnoreCase(paramname)) {
-                    setCaseSensitive(Project
-                                     .toBoolean(parameters[i].getValue()));
+                    setCaseSensitive(Project.toBoolean(parameter.getValue()));
                 } else if (ML_KEY.equalsIgnoreCase(paramname)) {
-                    setMultiLine(Project.toBoolean(parameters[i].getValue()));
+                    setMultiLine(Project.toBoolean(parameter.getValue()));
                 } else if (SL_KEY.equalsIgnoreCase(paramname)) {
-                    setSingleLine(Project.toBoolean(parameters[i].getValue()));
+                    setSingleLine(Project.toBoolean(parameter.getValue()));
                 } else {
                     setError("Invalid parameter " + paramname);
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java b/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
index a1004a8..d0a7a8f 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
@@ -120,16 +120,16 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele
     public void setParameters(Parameter[] parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
-            for (int i = 0; i < parameters.length; i++) {
-                String paramname = parameters[i].getName();
+            for (Parameter parameter : parameters) {
+                String paramname = parameter.getName();
                 if (CONTAINS_KEY.equalsIgnoreCase(paramname)) {
-                    setText(parameters[i].getValue());
+                    setText(parameter.getValue());
                 } else if (CASE_KEY.equalsIgnoreCase(paramname)) {
                     setCasesensitive(Project.toBoolean(
-                            parameters[i].getValue()));
+                            parameter.getValue()));
                 } else if (WHITESPACE_KEY.equalsIgnoreCase(paramname)) {
                     setIgnorewhitespace(Project.toBoolean(
-                            parameters[i].getValue()));
+                            parameter.getValue()));
                 } else {
                     setError("Invalid parameter " + paramname);
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/DateSelector.java b/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
index f8db485..bcbf11c 100644
--- a/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
@@ -169,30 +169,30 @@ public class DateSelector extends BaseExtendSelector {
     public void setParameters(Parameter[] parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
-            for (int i = 0; i < parameters.length; i++) {
-                String paramname = parameters[i].getName();
+            for (Parameter parameter : parameters) {
+                String paramname = parameter.getName();
                 if (MILLIS_KEY.equalsIgnoreCase(paramname)) {
                     try {
-                        setMillis(Long.parseLong(parameters[i].getValue()));
+                        setMillis(Long.parseLong(parameter.getValue()));
                     } catch (NumberFormatException nfe) {
                         setError("Invalid millisecond setting "
-                                + parameters[i].getValue());
+                                + parameter.getValue());
                     }
                 } else if (DATETIME_KEY.equalsIgnoreCase(paramname)) {
-                    setDatetime(parameters[i].getValue());
+                    setDatetime(parameter.getValue());
                 } else if (CHECKDIRS_KEY.equalsIgnoreCase(paramname)) {
-                    setCheckdirs(Project.toBoolean(parameters[i].getValue()));
+                    setCheckdirs(Project.toBoolean(parameter.getValue()));
                 } else if (GRANULARITY_KEY.equalsIgnoreCase(paramname)) {
                     try {
-                        setGranularity(Integer.parseInt(parameters[i].getValue()));
+                        setGranularity(Integer.parseInt(parameter.getValue()));
                     } catch (NumberFormatException nfe) {
                         setError("Invalid granularity setting "
-                            + parameters[i].getValue());
+                                + parameter.getValue());
                     }
                 } else if (WHEN_KEY.equalsIgnoreCase(paramname)) {
-                    setWhen(new TimeComparison(parameters[i].getValue()));
+                    setWhen(new TimeComparison(parameter.getValue()));
                 } else if (PATTERN_KEY.equalsIgnoreCase(paramname)) {
-                    setPattern(parameters[i].getValue());
+                    setPattern(parameter.getValue());
                 } else {
                     setError("Invalid parameter " + paramname);
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java b/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
index a80f9aa..a8a14d3 100644
--- a/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
@@ -92,21 +92,21 @@ public class DepthSelector extends BaseExtendSelector {
     public void setParameters(Parameter[] parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
-            for (int i = 0; i < parameters.length; i++) {
-                String paramname = parameters[i].getName();
+            for (Parameter parameter : parameters) {
+                String paramname = parameter.getName();
                 if (MIN_KEY.equalsIgnoreCase(paramname)) {
                     try {
-                        setMin(Integer.parseInt(parameters[i].getValue()));
+                        setMin(Integer.parseInt(parameter.getValue()));
                     } catch (NumberFormatException nfe1) {
                         setError("Invalid minimum value "
-                                + parameters[i].getValue());
+                                + parameter.getValue());
                     }
                 } else if (MAX_KEY.equalsIgnoreCase(paramname)) {
                     try {
-                        setMax(Integer.parseInt(parameters[i].getValue()));
+                        setMax(Integer.parseInt(parameter.getValue()));
                     } catch (NumberFormatException nfe1) {
                         setError("Invalid maximum value "
-                                + parameters[i].getValue());
+                                + parameter.getValue());
                     }
                 } else {
                     setError("Invalid parameter " + paramname);

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java b/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
index 1b998f9..ec34e23 100644
--- a/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
@@ -132,17 +132,17 @@ public class FilenameSelector extends BaseExtendSelector {
     public void setParameters(Parameter[] parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
-            for (int i = 0; i < parameters.length; i++) {
-                String paramname = parameters[i].getName();
+            for (Parameter parameter : parameters) {
+                String paramname = parameter.getName();
                 if (NAME_KEY.equalsIgnoreCase(paramname)) {
-                    setName(parameters[i].getValue());
+                    setName(parameter.getValue());
                 } else if (CASE_KEY.equalsIgnoreCase(paramname)) {
                     setCasesensitive(Project.toBoolean(
-                            parameters[i].getValue()));
+                            parameter.getValue()));
                 } else if (NEGATE_KEY.equalsIgnoreCase(paramname)) {
-                    setNegate(Project.toBoolean(parameters[i].getValue()));
+                    setNegate(Project.toBoolean(parameter.getValue()));
                 } else if (REGEX_KEY.equalsIgnoreCase(paramname)) {
-                    setRegex(parameters[i].getValue());
+                    setRegex(parameter.getValue());
                 } else {
                     setError("Invalid parameter " + paramname);
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java b/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
index 277470b..24630e8 100644
--- a/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
+++ b/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
@@ -369,8 +369,8 @@ public final class SelectorUtils {
         char ch;
 
         boolean containsStar = false;
-        for (int i = 0; i < patArr.length; i++) {
-            if (patArr[i] == '*') {
+        for (char ch : patArr) {
+            if (ch == '*') {
                 containsStar = true;
                 break;
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java b/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java
index 3157ee5..6f8d2d8 100644
--- a/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java
@@ -167,22 +167,22 @@ public class SizeSelector extends BaseExtendSelector {
     public void setParameters(Parameter[] parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
-            for (int i = 0; i < parameters.length; i++) {
-                String paramname = parameters[i].getName();
+            for (Parameter parameter : parameters) {
+                String paramname = parameter.getName();
                 if (SIZE_KEY.equalsIgnoreCase(paramname)) {
                     try {
-                        setValue(Long.parseLong(parameters[i].getValue()));
+                        setValue(Long.parseLong(parameter.getValue()));
                     } catch (NumberFormatException nfe) {
                         setError("Invalid size setting "
-                                + parameters[i].getValue());
+                                + parameter.getValue());
                     }
                 } else if (UNITS_KEY.equalsIgnoreCase(paramname)) {
                     ByteUnits units = new ByteUnits();
-                    units.setValue(parameters[i].getValue());
+                    units.setValue(parameter.getValue());
                     setUnits(units);
                 } else if (WHEN_KEY.equalsIgnoreCase(paramname)) {
                     SizeComparisons scmp = new SizeComparisons();
-                    scmp.setValue(parameters[i].getValue());
+                    scmp.setValue(parameter.getValue());
                     setWhen(scmp);
                 } else {
                     setError("Invalid parameter " + paramname);

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java b/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
index ed899e4..cd0770b 100644
--- a/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
+++ b/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
@@ -141,17 +141,17 @@ public class TokenizedPath {
      * @return boolean
      */
     public boolean isSymlink(File base) {
-        for (int i = 0; i < tokenizedPath.length; i++) {
+        for (String token : tokenizedPath) {
             try {
                 if ((base != null
-                     && SYMLINK_UTILS.isSymbolicLink(base, tokenizedPath[i]))
+                     && SYMLINK_UTILS.isSymbolicLink(base, token))
                     ||
                     (base == null
-                     && SYMLINK_UTILS.isSymbolicLink(tokenizedPath[i]))
+                     && SYMLINK_UTILS.isSymbolicLink(token))
                     ) {
                     return true;
                 }
-                base = new File(base, tokenizedPath[i]);
+                base = new File(base, token);
             } catch (java.io.IOException ioe) {
                 String msg = "IOException caught while checking "
                     + "for links, couldn't get canonical path!";
@@ -188,7 +188,7 @@ public class TokenizedPath {
      */
     private static File findFile(File base, final String[] pathElements,
                                  final boolean cs) {
-        for (int current = 0; current < pathElements.length; current++) {
+        for (String pathElement : pathElements) {
             if (!base.isDirectory()) {
                 return null;
             }
@@ -202,8 +202,8 @@ public class TokenizedPath {
             for (int i = 0; !found && i < matchCase.length; i++) {
                 for (int j = 0; !found && j < files.length; j++) {
                     if (matchCase[i]
-                        ? files[j].equals(pathElements[current])
-                        : files[j].equalsIgnoreCase(pathElements[current])) {
+                            ? files[j].equals(pathElement)
+                            : files[j].equalsIgnoreCase(pathElement)) {
                         base = new File(base, files[j]);
                         found = true;
                     }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java b/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java
index fd3684d..a9d8186 100644
--- a/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java
@@ -69,11 +69,11 @@ public class TypeSelector extends BaseExtendSelector {
     public void setParameters(Parameter[] parameters) {
         super.setParameters(parameters);
         if (parameters != null) {
-            for (int i = 0; i < parameters.length; i++) {
-                String paramname = parameters[i].getName();
+            for (Parameter parameter : parameters) {
+                String paramname = parameter.getName();
                 if (TYPE_KEY.equalsIgnoreCase(paramname)) {
                     FileType t = new FileType();
-                    t.setValue(parameters[i].getValue());
+                    t.setValue(parameter.getValue());
                     setType(t);
                 } else {
                     setError("Invalid parameter " + paramname);

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
index a4b2ffd..988a256 100644
--- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
+++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
@@ -153,12 +153,12 @@ public class DigestAlgorithm implements Algorithm {
      */
     // implementation adapted from ...taskdefs.Checksum, thanks to Magesh for hint
     public String getValue(File file) {
+        if (!file.canRead()) {
+            return null;
+        }
         initMessageDigest();
         String checksum = null;
         try {
-            if (!file.canRead()) {
-                return null;
-            }
             FileInputStream fis = null;
 
             byte[] buf = new byte[readBufferSize];

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/util/DOMElementWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/DOMElementWriter.java b/src/main/org/apache/tools/ant/util/DOMElementWriter.java
index 2dad80f..78a893b 100644
--- a/src/main/org/apache/tools/ant/util/DOMElementWriter.java
+++ b/src/main/org/apache/tools/ant/util/DOMElementWriter.java
@@ -576,8 +576,8 @@ public class DOMElementWriter {
         }
 
         String name = ent.substring(1, ent.length() - 1);
-        for (int i = 0; i < knownEntities.length; i++) {
-            if (name.equals(knownEntities[i])) {
+        for (String knownEntity : knownEntities) {
+            if (name.equals(knownEntity)) {
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
index e4b2675..2771073 100644
--- a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
+++ b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
@@ -543,8 +543,7 @@ public class LayoutPreservingProperties extends Properties {
         final String escaped = "tfrn\\:=#!";
         final StringBuffer buffy = new StringBuffer(s.length());
         boolean leadingSpace = true;
-        for (int i = 0; i < ch.length; i++) {
-            final char c = ch[i];
+        for (final char c : ch) {
             if (c == ' ') {
                 if (escapeAllSpaces || leadingSpace) {
                     buffy.append("\\");

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/util/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/ResourceUtils.java b/src/main/org/apache/tools/ant/util/ResourceUtils.java
index 004cb6c..c3b80d2 100644
--- a/src/main/org/apache/tools/ant/util/ResourceUtils.java
+++ b/src/main/org/apache/tools/ant/util/ResourceUtils.java
@@ -206,15 +206,13 @@ public class ResourceUtils {
                       Project.MSG_VERBOSE);
                 continue;
             }
-            for (int i = 0; i < targetnames.length; i++) {
-                if (targetnames[i] == null) {
-                    targetnames[i] = "(no name)";
-                }
-            }
             final Union targetColl = new Union();
-            for (int i = 0; i < targetnames.length; i++) {
+            for (String targetname : targetnames) {
+                if (targetname == null) {
+                    targetname = "(no name)";
+                }
                 targetColl.add(targets.getResource(
-                    targetnames[i].replace(File.separatorChar, '/')));
+                        targetname.replace(File.separatorChar, '/')));
             }
             //find the out-of-date targets:
             final Restrict r = new Restrict();

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/util/SplitClassLoader.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/SplitClassLoader.java b/src/main/org/apache/tools/ant/util/SplitClassLoader.java
index 9d657da..9857755 100644
--- a/src/main/org/apache/tools/ant/util/SplitClassLoader.java
+++ b/src/main/org/apache/tools/ant/util/SplitClassLoader.java
@@ -64,9 +64,9 @@ public final class SplitClassLoader extends AntClassLoader {
 
     private boolean isSplit(String classname) {
         String simplename = classname.substring(classname.lastIndexOf('.') + 1);
-        for (int i = 0; i < splitClasses.length; i++) {
-            if (simplename.equals(splitClasses[i])
-                || simplename.startsWith(splitClasses[i] + '$')) {
+        for (String splitClass : splitClasses) {
+            if (simplename.equals(splitClass)
+                    || simplename.startsWith(splitClass + '$')) {
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/util/StringTokenizer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/StringTokenizer.java b/src/main/org/apache/tools/ant/util/StringTokenizer.java
index 7addf31..1e3a8a9 100644
--- a/src/main/org/apache/tools/ant/util/StringTokenizer.java
+++ b/src/main/org/apache/tools/ant/util/StringTokenizer.java
@@ -144,8 +144,8 @@ public class StringTokenizer extends ProjectComponent implements Tokenizer {
         if (delims == null) {
             return Character.isWhitespace(ch);
         }
-        for (int i = 0; i < delims.length; ++i) {
-            if (delims[i] == ch) {
+        for (char delim : delims) {
+            if (delim == ch) {
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/util/WeakishReference.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/WeakishReference.java b/src/main/org/apache/tools/ant/util/WeakishReference.java
index 9568a28..816ee4e 100644
--- a/src/main/org/apache/tools/ant/util/WeakishReference.java
+++ b/src/main/org/apache/tools/ant/util/WeakishReference.java
@@ -37,7 +37,7 @@ import java.lang.ref.WeakReference;
 public class WeakishReference  {
 
 
-    private WeakReference weakref;
+    private WeakReference<Object> weakref;
 
     /**
      * create a new soft reference, which is bound to a
@@ -47,7 +47,7 @@ public class WeakishReference  {
      * @see java.lang.ref.WeakReference
      */
     WeakishReference(Object reference) {
-        this.weakref = new WeakReference(reference);
+        this.weakref = new WeakReference<Object>(reference);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java b/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
index b5ef999..a6e81f4 100644
--- a/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
+++ b/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
@@ -256,8 +256,8 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      */
     private File getResourceContainer(String resourceLocation, String[] paths)
          throws IOException {
-        for (int i = 0; i < paths.length; ++i) {
-            File element = new File(paths[i]);
+        for (String path : paths) {
+            File element = new File(path);
             if (!element.exists()) {
                 continue;
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/mail/MailMessage.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/mail/MailMessage.java b/src/main/org/apache/tools/mail/MailMessage.java
index b1ca493..0906fde 100644
--- a/src/main/org/apache/tools/mail/MailMessage.java
+++ b/src/main/org/apache/tools/mail/MailMessage.java
@@ -113,17 +113,17 @@ public class MailMessage {
     private String from;
 
     /** list of email addresses to reply to */
-    private Vector replyto;
+    private Vector<String> replyto = new Vector<String>();
 
     /** list of email addresses to send to */
-    private Vector to;
+    private Vector<String> to = new Vector<String>();
 
     /** list of email addresses to cc to */
-    private Vector cc;
+    private Vector<String> cc = new Vector<String>();
 
     /** headers to send in the mail */
-    private Vector headersKeys;
-    private Vector headersValues;
+    private Vector<String> headersKeys = new Vector<String>();
+    private Vector<String> headersValues = new Vector<String>();
 
     private MailPrintStream out;
 
@@ -139,46 +139,41 @@ public class MailMessage {
     private static final int OK_DOT = 250;
     private static final int OK_QUIT = 221;
 
-  /**
-   * Constructs a new MailMessage to send an email.
-   * Use localhost as the mail server with port 25.
-   *
-   * @exception IOException if there's any problem contacting the mail server
-   */
-  public MailMessage() throws IOException {
-    this(DEFAULT_HOST, DEFAULT_PORT);
-  }
-
-  /**
-   * Constructs a new MailMessage to send an email.
-   * Use the given host as the mail server with port 25.
-   *
-   * @param host the mail server to use
-   * @exception IOException if there's any problem contacting the mail server
-   */
-  public MailMessage(String host) throws IOException {
-    this(host, DEFAULT_PORT);
-  }
-
-  /**
-   * Constructs a new MailMessage to send an email.
-   * Use the given host and port as the mail server.
-   *
-   * @param host the mail server to use
-   * @param port the port to connect to
-   * @exception IOException if there's any problem contacting the mail server
-   */
-  public MailMessage(String host, int port) throws IOException {
-    this.port = port;
-    this.host = host;
-    replyto = new Vector();
-    to = new Vector();
-    cc = new Vector();
-    headersKeys = new Vector();
-    headersValues = new Vector();
-    connect();
-    sendHelo();
-  }
+    /**
+     * Constructs a new MailMessage to send an email.
+     * Use localhost as the mail server with port 25.
+     *
+     * @exception IOException if there's any problem contacting the mail server
+    */
+    public MailMessage() throws IOException {
+        this(DEFAULT_HOST, DEFAULT_PORT);
+    }
+
+    /**
+     * Constructs a new MailMessage to send an email.
+     * Use the given host as the mail server with port 25.
+     *
+     * @param host the mail server to use
+     * @exception IOException if there's any problem contacting the mail server
+     */
+    public MailMessage(String host) throws IOException {
+        this(host, DEFAULT_PORT);
+    }
+
+    /**
+     * Constructs a new MailMessage to send an email.
+     * Use the given host and port as the mail server.
+     *
+     * @param host the mail server to use
+     * @param port the port to connect to
+     * @exception IOException if there's any problem contacting the mail server
+     */
+    public MailMessage(String host, int port) throws IOException {
+        this.port = port;
+        this.host = host;
+        connect();
+        sendHelo();
+    }
 
     /**
      * Set the port to connect to the SMTP host.
@@ -208,231 +203,230 @@ public class MailMessage {
      *
      */
     public void replyto(String rto) {
-      this.replyto.addElement(rto);
-    }
-
-  /**
-   * Sets the to address.  Also sets the "To" header.  This method may be
-   * called multiple times.
-   *
-   * @param to the to address
-   * @exception IOException if there's any problem reported by the mail server
-   */
-  public void to(String to) throws IOException {
-    sendRcpt(to);
-    this.to.addElement(to);
-  }
-
-  /**
-   * Sets the cc address.  Also sets the "Cc" header.  This method may be
-   * called multiple times.
-   *
-   * @param cc the cc address
-   * @exception IOException if there's any problem reported by the mail server
-   */
-  public void cc(String cc) throws IOException {
-    sendRcpt(cc);
-    this.cc.addElement(cc);
-  }
-
-  /**
-   * Sets the bcc address.  Does NOT set any header since it's a *blind* copy.
-   * This method may be called multiple times.
-   *
-   * @param bcc the bcc address
-   * @exception IOException if there's any problem reported by the mail server
-   */
-  public void bcc(String bcc) throws IOException {
-    sendRcpt(bcc);
-    // No need to keep track of Bcc'd addresses
-  }
-
-  /**
-   * Sets the subject of the mail message.  Actually sets the "Subject"
-   * header.
-   * @param subj the subject of the mail message
-   */
-  public void setSubject(String subj) {
-    setHeader("Subject", subj);
-  }
-
-  /**
-   * Sets the named header to the given value.  RFC 822 provides the rules for
-   * what text may constitute a header name and value.
-   * @param name name of the header
-   * @param value contents of the header
-   */
-  public void setHeader(String name, String value) {
-    // Blindly trust the user doesn't set any invalid headers
-    headersKeys.add(name);
-    headersValues.add(value);
-  }
-
-  /**
-   * Returns a PrintStream that can be used to write the body of the message.
-   * A stream is used since email bodies are byte-oriented.  A writer can
-   * be wrapped on top if necessary for internationalization.
-   * This is actually done in Message.java
-   *
-   * @return a printstream containing the data and the headers of the email
-   * @exception IOException if there's any problem reported by the mail server
-   * @see org.apache.tools.ant.taskdefs.email.Message
-   */
-  public PrintStream getPrintStream() throws IOException {
-    setFromHeader();
-    setReplyToHeader();
-    setToHeader();
-    setCcHeader();
-    setHeader("X-Mailer", "org.apache.tools.mail.MailMessage (ant.apache.org)");
-    sendData();
-    flushHeaders();
-    return out;
-  }
-
-
-  // RFC 822 s4.1: "From:" header must be sent
-  // We rely on error checking by the MTA
-  void setFromHeader() {
-    setHeader("From", from);
-  }
-
-  // RFC 822 s4.1: "Reply-To:" header is optional
-  void setReplyToHeader() {
-    if (!replyto.isEmpty()) {
-      setHeader("Reply-To", vectorToList(replyto));
-    }
-  }
-
-  void setToHeader() {
-    if (!to.isEmpty()) {
-      setHeader("To", vectorToList(to));
-    }
-  }
-
-  void setCcHeader() {
-    if (!cc.isEmpty()) {
-      setHeader("Cc", vectorToList(cc));
-    }
-  }
-
-  String vectorToList(Vector v) {
-    StringBuffer buf = new StringBuffer();
-    Enumeration e = v.elements();
-    while (e.hasMoreElements()) {
-      buf.append(e.nextElement());
-      if (e.hasMoreElements()) {
-        buf.append(", ");
-      }
-    }
-    return buf.toString();
-  }
-
-  void flushHeaders() throws IOException {
-    // RFC 822 s4.1:
-    //   "Header fields are NOT required to occur in any particular order,
-    //    except that the message body MUST occur AFTER the headers"
-    // (the same section specifies a recommended order, which we ignore)
-   final int size = headersKeys.size();
-   for (int i = 0; i < size; i++) {
-      String name = (String) headersKeys.elementAt(i);
-      String value = (String) headersValues.elementAt(i);
-      out.println(name + ": " + value);
-    }
-    out.println();
-    out.flush();
-  }
-
-  /**
-   * Sends the message and closes the connection to the server.
-   * The MailMessage object cannot be reused.
-   *
-   * @exception IOException if there's any problem reported by the mail server
-   */
-  public void sendAndClose() throws IOException {
-      try {
-          sendDot();
-          sendQuit();
-      } finally {
-          disconnect();
-      }
-  }
-
-  // Make a limited attempt to extract a sanitized email address
-  // Prefer text in <brackets>, ignore anything in (parentheses)
-  static String sanitizeAddress(String s) {
-    int paramDepth = 0;
-    int start = 0;
-    int end = 0;
-    int len = s.length();
-
-    for (int i = 0; i < len; i++) {
-      char c = s.charAt(i);
-      if (c == '(') {
-        paramDepth++;
-        if (start == 0) {
-          end = i;  // support "address (name)"
+        this.replyto.addElement(rto);
+    }
+
+    /**
+     * Sets the to address.  Also sets the "To" header.  This method may be
+     * called multiple times.
+     *
+     * @param to the to address
+     * @exception IOException if there's any problem reported by the mail server
+     */
+    public void to(String to) throws IOException {
+        sendRcpt(to);
+        this.to.addElement(to);
+    }
+
+    /**
+     * Sets the cc address.  Also sets the "Cc" header.  This method may be
+     * called multiple times.
+     *
+     * @param cc the cc address
+     * @exception IOException if there's any problem reported by the mail server
+     */
+    public void cc(String cc) throws IOException {
+        sendRcpt(cc);
+        this.cc.addElement(cc);
+    }
+
+    /**
+     * Sets the bcc address.  Does NOT set any header since it's a *blind* copy.
+     * This method may be called multiple times.
+     *
+     * @param bcc the bcc address
+     * @exception IOException if there's any problem reported by the mail server
+     */
+    public void bcc(String bcc) throws IOException {
+        sendRcpt(bcc);
+        // No need to keep track of Bcc'd addresses
+    }
+
+    /**
+     * Sets the subject of the mail message.  Actually sets the "Subject"
+     * header.
+     * @param subj the subject of the mail message
+     */
+    public void setSubject(String subj) {
+        setHeader("Subject", subj);
+    }
+
+    /**
+     * Sets the named header to the given value.  RFC 822 provides the rules for
+     * what text may constitute a header name and value.
+     * @param name name of the header
+     * @param value contents of the header
+     */
+    public void setHeader(String name, String value) {
+        // Blindly trust the user doesn't set any invalid headers
+        headersKeys.add(name);
+        headersValues.add(value);
+    }
+
+    /**
+     * Returns a PrintStream that can be used to write the body of the message.
+     * A stream is used since email bodies are byte-oriented.  A writer can
+     * be wrapped on top if necessary for internationalization.
+     * This is actually done in Message.java
+     *
+     * @return a printstream containing the data and the headers of the email
+     * @exception IOException if there's any problem reported by the mail server
+     * @see org.apache.tools.ant.taskdefs.email.Message
+     */
+     public PrintStream getPrintStream() throws IOException {
+        setFromHeader();
+        setReplyToHeader();
+        setToHeader();
+        setCcHeader();
+        setHeader("X-Mailer", "org.apache.tools.mail.MailMessage (ant.apache.org)");
+        sendData();
+        flushHeaders();
+        return out;
+    }
+
+    // RFC 822 s4.1: "From:" header must be sent
+    // We rely on error checking by the MTA
+    void setFromHeader() {
+        setHeader("From", from);
+    }
+
+    // RFC 822 s4.1: "Reply-To:" header is optional
+    void setReplyToHeader() {
+        if (!replyto.isEmpty()) {
+            setHeader("Reply-To", vectorToList(replyto));
+        }
+    }
+
+    void setToHeader() {
+        if (!to.isEmpty()) {
+            setHeader("To", vectorToList(to));
+        }
+    }
+
+    void setCcHeader() {
+        if (!cc.isEmpty()) {
+            setHeader("Cc", vectorToList(cc));
+        }
+    }
+
+    String vectorToList(Vector v) {
+        StringBuffer buf = new StringBuffer();
+        Enumeration e = v.elements();
+        while (e.hasMoreElements()) {
+            buf.append(e.nextElement());
+            if (e.hasMoreElements()) {
+                buf.append(", ");
+            }
         }
-      } else if (c == ')') {
-        paramDepth--;
+        return buf.toString();
+    }
+
+    void flushHeaders() {
+         // RFC 822 s4.1:
+        //   "Header fields are NOT required to occur in any particular order,
+        //    except that the message body MUST occur AFTER the headers"
+        // (the same section specifies a recommended order, which we ignore)
+        final int size = headersKeys.size();
+        for (int i = 0; i < size; i++) {
+            String name = headersKeys.elementAt(i);
+            String value = headersValues.elementAt(i);
+            out.println(name + ": " + value);
+        }
+        out.println();
+        out.flush();
+    }
+
+    /**
+     * Sends the message and closes the connection to the server.
+     * The MailMessage object cannot be reused.
+     *
+     * @exception IOException if there's any problem reported by the mail server
+     */
+    public void sendAndClose() throws IOException {
+        try {
+            sendDot();
+            sendQuit();
+        } finally {
+            disconnect();
+        }
+    }
+
+    // Make a limited attempt to extract a sanitized email address
+    // Prefer text in <brackets>, ignore anything in (parentheses)
+    static String sanitizeAddress(String s) {
+        int paramDepth = 0;
+        int start = 0;
+        int end = 0;
+        int len = s.length();
+
+        for (int i = 0; i < len; i++) {
+            char c = s.charAt(i);
+            if (c == '(') {
+                paramDepth++;
+                if (start == 0) {
+                    end = i;  // support "address (name)"
+                }
+            } else if (c == ')') {
+                paramDepth--;
+                if (end == 0) {
+                    start = i + 1;  // support "(name) address"
+                }
+            } else if (paramDepth == 0 && c == '<') {
+                start = i + 1;
+            } else if (paramDepth == 0 && c == '>') {
+                end = i;
+            }
+        }
+
         if (end == 0) {
-          start = i + 1;  // support "(name) address"
+            end = len;
         }
-      } else if (paramDepth == 0 && c == '<') {
-        start = i + 1;
-      } else if (paramDepth == 0 && c == '>') {
-        end = i;
-      }
-    }
-
-    if (end == 0) {
-      end = len;
-    }
-
-    return s.substring(start, end);
-  }
-
-  // * * * * * Raw protocol methods below here * * * * *
-
-  void connect() throws IOException {
-    socket = new Socket(host, port);
-    out = new MailPrintStream(
-          new BufferedOutputStream(
-          socket.getOutputStream()));
-    in = new SmtpResponseReader(socket.getInputStream());
-    getReady();
-  }
-
-  void getReady() throws IOException {
-    String response = in.getResponse();
-    int[] ok = {OK_READY};
-    if (!isResponseOK(response, ok)) {
-      throw new IOException(
-        "Didn't get introduction from server: " + response);
-    }
-  }
-  void sendHelo() throws IOException {
-    String local = InetAddress.getLocalHost().getHostName();
-    int[] ok = {OK_HELO};
-    send("HELO " + local, ok);
-  }
-  void sendFrom(String from) throws IOException {
-    int[] ok = {OK_FROM};
-    send("MAIL FROM: " + "<" + sanitizeAddress(from) + ">", ok);
-  }
-  void sendRcpt(String rcpt) throws IOException {
-    int[] ok = {OK_RCPT_1, OK_RCPT_2};
-    send("RCPT TO: " + "<" + sanitizeAddress(rcpt) + ">", ok);
-  }
-
-  void sendData() throws IOException {
-    int[] ok = {OK_DATA};
-    send("DATA", ok);
-  }
-
-  void sendDot() throws IOException {
-    int[] ok = {OK_DOT};
-    send("\r\n.", ok);  // make sure dot is on new line
-  }
+
+        return s.substring(start, end);
+    }
+
+    // * * * * * Raw protocol methods below here * * * * *
+
+    void connect() throws IOException {
+        socket = new Socket(host, port);
+        out = new MailPrintStream(new BufferedOutputStream(socket.getOutputStream()));
+        in = new SmtpResponseReader(socket.getInputStream());
+        getReady();
+    }
+
+    void getReady() throws IOException {
+        String response = in.getResponse();
+        int[] ok = {OK_READY};
+        if (!isResponseOK(response, ok)) {
+            throw new IOException("Didn't get introduction from server: " + response);
+        }
+    }
+
+    void sendHelo() throws IOException {
+        String local = InetAddress.getLocalHost().getHostName();
+        int[] ok = {OK_HELO};
+         send("HELO " + local, ok);
+    }
+
+    void sendFrom(String from) throws IOException {
+        int[] ok = {OK_FROM};
+        send("MAIL FROM: " + "<" + sanitizeAddress(from) + ">", ok);
+    }
+
+    void sendRcpt(String rcpt) throws IOException {
+        int[] ok = {OK_RCPT_1, OK_RCPT_2};
+        send("RCPT TO: " + "<" + sanitizeAddress(rcpt) + ">", ok);
+    }
+
+    void sendData() throws IOException {
+        int[] ok = {OK_DATA};
+        send("DATA", ok);
+    }
+
+    void sendDot() throws IOException {
+        int[] ok = {OK_DOT};
+        send("\r\n.", ok);  // make sure dot is on new line
+    }
 
     void sendQuit() throws IOException {
         int[] ok = {OK_QUIT};
@@ -452,17 +446,17 @@ public class MailMessage {
         }
     }
 
-  boolean isResponseOK(String response, int[] ok) {
-    // Check that the response is one of the valid codes
-    for (int i = 0; i < ok.length; i++) {
-      if (response.startsWith("" + ok[i])) {
-        return true;
-      }
+    boolean isResponseOK(String response, int[] ok) {
+        // Check that the response is one of the valid codes
+        for (int status : ok) {
+            if (response.startsWith("" + status)) {
+                return true;
+            }
+        }
+        return false;
     }
-    return false;
-  }
 
-    void disconnect() throws IOException {
+    void disconnect() {
         if (out != null) {
             out.close();
         }
@@ -489,42 +483,40 @@ public class MailMessage {
 */
 class MailPrintStream extends PrintStream {
 
-  private int lastChar;
+    private int lastChar;
 
-  public MailPrintStream(OutputStream out) {
-    super(out, true);  // deprecated, but email is byte-oriented
-  }
+    public MailPrintStream(OutputStream out) {
+        super(out, true);  // deprecated, but email is byte-oriented
+    }
 
-  // Mac does \n\r, but that's tough to distinguish from Windows \r\n\r\n.
-  // Don't tackle that problem right now.
-  public void write(int b) {
-    if (b == '\n' && lastChar != '\r') {
-      rawWrite('\r');  // ensure always \r\n
-      rawWrite(b);
-    } else if (b == '.' && lastChar == '\n') {
-      rawWrite('.');  // add extra dot
-      rawWrite(b);
-    } else {
-      rawWrite(b);
+    // Mac does \n\r, but that's tough to distinguish from Windows \r\n\r\n.
+    // Don't tackle that problem right now.
+    public void write(int b) {
+        if (b == '\n' && lastChar != '\r') {
+            rawWrite('\r');  // ensure always \r\n
+            rawWrite(b);
+        } else if (b == '.' && lastChar == '\n') {
+            rawWrite('.');  // add extra dot
+            rawWrite(b);
+        } else {
+            rawWrite(b);
+        }
+        lastChar = b;
     }
-    lastChar = b;
-  }
 
-  public void write(byte[] buf, int off, int len) {
-    for (int i = 0; i < len; i++) {
-      write(buf[off + i]);
+    public void write(byte[] buf, int off, int len) {
+        for (int i = 0; i < len; i++) {
+            write(buf[off + i]);
+        }
     }
-  }
 
-  void rawWrite(int b) {
-    super.write(b);
-  }
+    void rawWrite(int b) {
+        super.write(b);
+    }
 
-  void rawPrint(String s) {
-    int len = s.length();
-    for (int i = 0; i < len; i++) {
-      rawWrite(s.charAt(i));
+    void rawPrint(String s) {
+        for (char ch : s.toCharArray()) {
+            rawWrite(ch);
+        }
     }
-  }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/tar/TarUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarUtils.java b/src/main/org/apache/tools/tar/TarUtils.java
index 93d1583..fcd0c4e 100644
--- a/src/main/org/apache/tools/tar/TarUtils.java
+++ b/src/main/org/apache/tools/tar/TarUtils.java
@@ -65,8 +65,7 @@ public class TarUtils {
                 final int length = buffer.length;
                 final StringBuilder result = new StringBuilder(length);
 
-                for (int i = 0; i < length; ++i) {
-                    final byte b = buffer[i];
+                for (final byte b : buffer) {
                     if (b == 0) { // Trailing null
                         break;
                     }

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java b/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
index 261beec..789c045 100644
--- a/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
+++ b/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
@@ -107,8 +107,8 @@ class Simple8BitZipEncoding implements ZipEncoding {
 
         byte code = 127;
 
-        for (int i = 0; i < this.highChars.length; ++i) {
-            temp.add(new Simple8BitChar(++code, this.highChars[i]));
+        for (char highChar : this.highChars) {
+            temp.add(new Simple8BitChar(++code, highChar));
         }
 
         Collections.sort(temp);

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
index b76ef1d..cc9a0fe 100644
--- a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
+++ b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
@@ -203,8 +203,8 @@ public class IntrospectionHelperTest {
         }
     }
 
-    private Map getExpectedNestedElements() {
-        Map elemMap = new Hashtable();
+    private Map<String, Class<?>> getExpectedNestedElements() {
+        Map<String, Class<?>> elemMap = new Hashtable<>();
         elemMap.put("six", String.class);
         elemMap.put("thirteen", StringBuffer.class);
         elemMap.put("fourteen", StringBuffer.class);
@@ -214,7 +214,7 @@ public class IntrospectionHelperTest {
 
     @Test
     public void testGetNestedElements() {
-        Map elemMap = getExpectedNestedElements();
+        Map<String, Class<?>> elemMap = getExpectedNestedElements();
         Enumeration e = ih.getNestedElements();
         while (e.hasMoreElements()) {
             String name = (String) e.nextElement();
@@ -229,12 +229,11 @@ public class IntrospectionHelperTest {
 
     @Test
     public void testGetNestedElementMap() {
-        Map elemMap = getExpectedNestedElements();
-        Map actualMap = ih.getNestedElementMap();
-        for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) {
-            Map.Entry entry = (Map.Entry) i.next();
+        Map<String, Class<?>> elemMap = getExpectedNestedElements();
+        Map<String, Class<?>> actualMap = ih.getNestedElementMap();
+        for (Map.Entry<String, Class<?>> entry : actualMap.entrySet()) {
             String elemName = (String) entry.getKey();
-            Class elemClass = (Class) elemMap.get(elemName);
+            Class<?> elemClass = (Class) elemMap.get(elemName);
             assertNotNull("Support for " + elemName +
                           " in IntrospectionHelperTest?", elemClass);
             assertEquals("Type of " + elemName, elemClass, entry.getValue());
@@ -506,10 +505,9 @@ public class IntrospectionHelperTest {
 
     @Test
     public void testGetAttributeMap() {
-        Map attrMap = getExpectedAttributes();
-        Map actualMap = ih.getAttributeMap();
-        for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) {
-            Map.Entry entry = (Map.Entry) i.next();
+        Map<String, Class<?>> attrMap = getExpectedAttributes();
+        Map<String, Class<?>> actualMap = ih.getAttributeMap();
+        for (Map.Entry<String, Class<?>> entry : actualMap.entrySet()) {
             String attrName = (String) entry.getKey();
             Class attrClass = (Class) attrMap.get(attrName);
             assertNotNull("Support for " + attrName +

http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java b/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java
index 1bad429..003f1a9 100644
--- a/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java
+++ b/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java
@@ -96,7 +96,7 @@ public class UnknownElementTest {
     }
 
     public static class Parent extends Task implements TaskContainer {
-        List children = new ArrayList();
+        List<Task> children = new ArrayList<>();
         public void addTask(Task t) {
             children.add(t);
         }
@@ -106,8 +106,8 @@ public class UnknownElementTest {
         }
 
         public void execute() {
-            for (Iterator i = children.iterator(); i.hasNext();) {
-                UnknownElement el = (UnknownElement) i.next();
+            for (Task task : children) {
+                UnknownElement el = (UnknownElement) task;
                 el.maybeConfigure();
                 Child child = (Child) el.getRealThing();
                 child.injectParent(this);