ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [09/34] ant git commit: java 5-8
Date Tue, 18 Apr 2017 14:53:11 GMT
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
index a45b74f..606a2b3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
@@ -35,14 +35,16 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.nio.file.Files;
 import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 import java.util.Properties;
-import java.util.Vector;
+import java.util.Set;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
@@ -119,7 +121,7 @@ public class Symlink extends DispatchTask {
 
     private String resource;
     private String link;
-    private Vector fileSets = new Vector();
+    private List<FileSet> fileSets = new ArrayList<>();
     private String linkFileName;
     private boolean overwrite;
     private boolean failonerror;
@@ -189,8 +191,6 @@ public class Symlink extends DispatchTask {
             SYMLINK_UTILS.deleteSymbolicLink(FILE_UTILS
                                              .resolveFile(new File("."), link),
                                              this);
-        } catch (FileNotFoundException fnfe) {
-            handleError(fnfe.toString());
         } catch (IOException ioe) {
             handleError(ioe.toString());
         } finally {
@@ -206,14 +206,13 @@ public class Symlink extends DispatchTask {
     public void recreate() throws BuildException {
         try {
             if (fileSets.isEmpty()) {
-                handleError("File set identifying link file(s) "
-                            + "required for action recreate");
+                handleError(
+                    "File set identifying link file(s) required for action recreate");
                 return;
             }
             Properties links = loadLinks(fileSets);
 
-            for (Iterator kitr = links.keySet().iterator(); kitr.hasNext();) {
-                String lnk = (String) kitr.next();
+            for (String lnk : links.stringPropertyNames()) {
                 String res = links.getProperty(lnk);
                 // handle the case where lnk points to a directory (bug 25181)
                 try {
@@ -249,30 +248,20 @@ public class Symlink extends DispatchTask {
                 handleError("Name of file to record links in required");
                 return;
             }
-            // create a hashtable to group them by parent directory:
-            Hashtable byDir = new Hashtable();
+            // create a map to group them by parent directory:
+            Map<File, List<File>> byDir = new HashMap<>();
 
             // get an Iterator of file objects representing links (canonical):
-            for (Iterator litr = findLinks(fileSets).iterator();
-                litr.hasNext();) {
-                File thisLink = (File) litr.next();
-                File parent = thisLink.getParentFile();
-                Vector v = (Vector) byDir.get(parent);
-                if (v == null) {
-                    v = new Vector();
-                    byDir.put(parent, v);
-                }
-                v.addElement(thisLink);
-            }
+            findLinks(fileSets).forEach(lnk -> byDir
+                .computeIfAbsent(lnk.getParentFile(), k -> new ArrayList<>())
+                .add(lnk));
+
             // write a Properties file in each directory:
-            for (Iterator dirs = byDir.keySet().iterator(); dirs.hasNext();) {
-                File dir = (File) dirs.next();
-                Vector linksInDir = (Vector) byDir.get(dir);
+            byDir.forEach((dir, linksInDir) -> {
                 Properties linksToStore = new Properties();
 
                 // fill up a Properties object with link and resource names:
-                for (Iterator dlnk = linksInDir.iterator(); dlnk.hasNext();) {
-                    File lnk = (File) dlnk.next();
+                for (File lnk : linksInDir) {
                     try {
                         linksToStore.put(lnk.getName(), lnk.getCanonicalPath());
                     } catch (IOException ioe) {
@@ -280,7 +269,7 @@ public class Symlink extends DispatchTask {
                     }
                 }
                 writePropertyFile(linksToStore, dir);
-            }
+            });
         } finally {
             setDefaults();
         }
@@ -367,7 +356,7 @@ public class Symlink extends DispatchTask {
      * @param set      The fileset to add.
      */
     public void addFileset(FileSet set) {
-        fileSets.addElement(set);
+        fileSets.add(set);
     }
 
     /**
@@ -434,15 +423,11 @@ public class Symlink extends DispatchTask {
      */
     private void writePropertyFile(Properties properties, File dir)
         throws BuildException {
-        BufferedOutputStream bos = null;
-        try {
-            bos = new BufferedOutputStream(
-                Files.newOutputStream(new File(dir, linkFileName).toPath()));
+        try (BufferedOutputStream bos = new BufferedOutputStream(
+            Files.newOutputStream(new File(dir, linkFileName).toPath()))) {
             properties.store(bos, "Symlinks from " + dir);
         } catch (IOException ioe) {
             throw new BuildException(ioe, getLocation());
-        } finally {
-            FileUtils.close(bos);
         }
     }
 
@@ -485,16 +470,14 @@ public class Symlink extends DispatchTask {
                 }
             }
         }
-        String[] cmd = new String[] {"ln", options, res, lnk};
         try {
-            Execute.runCommand(this, cmd);
+            Execute.runCommand(this, "ln", options, res, lnk);
         } catch (BuildException failedToExecute) {
             if (failonerror) {
                 throw failedToExecute;
-            } else {
-                //log at the info level, and keep going.
-                log(failedToExecute.getMessage(), failedToExecute, Project.MSG_INFO);
             }
+            //log at the info level, and keep going.
+            log(failedToExecute.getMessage(), failedToExecute, Project.MSG_INFO);
         }
     }
 
@@ -505,33 +488,30 @@ public class Symlink extends DispatchTask {
      * &quot;record&quot;. This means that filesets are interpreted
      * as the directories in which links may be found.
      *
-     * @param v   The filesets specified by the user.
+     * @param fileSets   The filesets specified by the user.
      * @return A HashSet of <code>File</code> objects containing the
      *         links (with canonical parent directories).
      */
-    private HashSet findLinks(Vector v) {
-        HashSet result = new HashSet();
-        final int size = v.size();
-        for (int i = 0; i < size; i++) {
-            FileSet fs = (FileSet) v.get(i);
+    private Set<File> findLinks(List<FileSet> fileSets) {
+        Set<File> result = new HashSet<>();
+        for (FileSet fs : fileSets) {
             DirectoryScanner ds = fs.getDirectoryScanner(getProject());
-            String[][] fnd = new String[][]
-                {ds.getIncludedFiles(), ds.getIncludedDirectories()};
+
             File dir = fs.getDir(getProject());
-            for (int j = 0; j < fnd.length; j++) {
-                for (int k = 0; k < fnd[j].length; k++) {
+
+            Stream.of(ds.getIncludedFiles(), ds.getIncludedDirectories())
+                .flatMap(Stream::of).forEach(path -> {
                     try {
-                        File f = new File(dir, fnd[j][k]);
+                        File f = new File(dir, path);
                         File pf = f.getParentFile();
                         String name = f.getName();
                         if (SYMLINK_UTILS.isSymbolicLink(pf, name)) {
                             result.add(new File(pf.getCanonicalFile(), name));
                         }
                     } catch (IOException e) {
-                        handleError("IOException: " + fnd[j][k] + " omitted");
+                        handleError("IOException: " + path + " omitted");
                     }
-                }
-            }
+                });
         }
         return result;
     }
@@ -544,41 +524,35 @@ public class Symlink extends DispatchTask {
      * names of the property files with the link information and the
      * subdirectories in which to look for them.
      *
-     * @param v    The <code>FileSet</code>s for this task.
+     * @param fileSets    The <code>FileSet</code>s for this task.
      * @return            The links to be made.
      */
-    private Properties loadLinks(Vector v) {
+    private Properties loadLinks(List<FileSet> fileSets) {
         Properties finalList = new Properties();
         // loop through the supplied file sets:
-        final int size = v.size();
-        for (int i = 0; i < size; i++) {
-            FileSet fs = (FileSet) v.elementAt(i);
+        for (FileSet fs : fileSets) {
             DirectoryScanner ds = new DirectoryScanner();
             fs.setupDirectoryScanner(ds, getProject());
             ds.setFollowSymlinks(false);
             ds.scan();
-            String[] incs = ds.getIncludedFiles();
             File dir = fs.getDir(getProject());
 
             // load included files as properties files:
-            for (int j = 0; j < incs.length; j++) {
-                File inc = new File(dir, incs[j]);
+            for (String name : ds.getIncludedFiles()) {
+                File inc = new File(dir, name);
                 File pf = inc.getParentFile();
                 Properties lnks = new Properties();
-                InputStream is = null;
-                try {
-                    is = new BufferedInputStream(Files.newInputStream(inc.toPath()));
+                try (InputStream is = new BufferedInputStream(
+                    Files.newInputStream(inc.toPath()))) {
                     lnks.load(is);
                     pf = pf.getCanonicalFile();
                 } catch (FileNotFoundException fnfe) {
-                    handleError("Unable to find " + incs[j] + "; skipping it.");
+                    handleError("Unable to find " + name + "; skipping it.");
                     continue;
                 } catch (IOException ioe) {
-                    handleError("Unable to open " + incs[j]
-                                + " or its parent dir; skipping it.");
+                    handleError("Unable to open " + name
+                        + " or its parent dir; skipping it.");
                     continue;
-                } finally {
-                    FileUtils.close(is);
                 }
                 lnks.list(new PrintStream(
                     new LogOutputStream(this, Project.MSG_INFO)));
@@ -586,8 +560,7 @@ public class Symlink extends DispatchTask {
                 // This method assumes that all links are defined in
                 // terms of absolute paths, or paths relative to the
                 // working directory:
-                for (Iterator kitr = lnks.keySet().iterator(); kitr.hasNext();) {
-                    String key = (String) kitr.next();
+                for (String key : lnks.stringPropertyNames()) {
                     finalList.put(new File(pf, key).getAbsolutePath(),
                         lnks.getProperty(key));
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java b/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java
index e029191..7fe1351 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java
@@ -93,6 +93,7 @@ public class Attrib extends ExecuteOn {
     /**
      * Check the attributes.
      */
+    @Override
     protected void checkConfiguration() {
         if (!haveAttr()) {
             throw new BuildException("Missing attribute parameter",
@@ -107,6 +108,7 @@ public class Attrib extends ExecuteOn {
      * @param e ignored
      * @ant.attribute ignore="true"
      */
+    @Override
     public void setExecutable(String e) {
         throw new BuildException(getTaskType()
             + " doesn\'t support the executable attribute", getLocation());
@@ -129,6 +131,7 @@ public class Attrib extends ExecuteOn {
      * @param b ignored
      * @ant.attribute ignore="true"
      */
+    @Override
     public void setAddsourcefile(boolean b) {
         throw new BuildException(getTaskType()
             + " doesn\'t support the addsourcefile attribute", getLocation());
@@ -140,6 +143,7 @@ public class Attrib extends ExecuteOn {
      * @param skip ignored
      * @ant.attribute ignore="true"
      */
+    @Override
     public void setSkipEmptyFilesets(boolean skip) {
         throw new BuildException(getTaskType() + " doesn\'t support the "
                                  + "skipemptyfileset attribute",
@@ -152,6 +156,7 @@ public class Attrib extends ExecuteOn {
      * @param parallel ignored
      * @ant.attribute ignore="true"
      */
+    @Override
     public void setParallel(boolean parallel) {
         throw new BuildException(getTaskType()
                                  + " doesn\'t support the parallel attribute",
@@ -164,6 +169,7 @@ public class Attrib extends ExecuteOn {
      * @param max ignored
      * @ant.attribute ignore="true"
      */
+    @Override
     public void setMaxParallel(int max) {
         throw new BuildException(getTaskType()
                                  + " doesn\'t support the maxparallel attribute",
@@ -175,13 +181,14 @@ public class Attrib extends ExecuteOn {
      * Default is to allow windows
      * @return true if the os is valid.
      */
+    @Override
     protected boolean isValidOs() {
         return getOs() == null && getOsFamily() == null ?
             Os.isFamily(Os.FAMILY_WINDOWS) : super.isValidOs();
     }
 
     private static String getSignString(boolean attr) {
-        return (attr ? SET : UNSET);
+        return attr ? SET : UNSET;
     }
 
     private void addArg(boolean sign, String attribute) {

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java
index f55fb7c..4502d07 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Unxz.java
@@ -19,13 +19,11 @@
 package org.apache.tools.ant.taskdefs.optional.xz;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.taskdefs.Unpack;
-import org.apache.tools.ant.util.FileUtils;
 import org.tukaani.xz.XZInputStream;
 
 /**
@@ -46,6 +44,7 @@ public class Unxz extends Unpack {
      * Get the default extension.
      * @return the value ".xz"
      */
+    @Override
     protected String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
@@ -53,18 +52,15 @@ public class Unxz extends Unpack {
     /**
      * Implement the gunzipping.
      */
+    @Override
     protected void extract() {
         if (srcResource.getLastModified() > dest.lastModified()) {
             log("Expanding " + srcResource.getName() + " to "
                         + dest.getAbsolutePath());
 
-            OutputStream out = null;
-            XZInputStream zIn = null;
-            InputStream fis = null;
-            try {
-                out = Files.newOutputStream(dest.toPath());
-                fis = srcResource.getInputStream();
-                zIn = new XZInputStream(fis);
+            try (XZInputStream zIn =
+                new XZInputStream(srcResource.getInputStream());
+                    OutputStream out = Files.newOutputStream(dest.toPath())) {
                 byte[] buffer = new byte[BUFFER_SIZE];
                 int count = 0;
                 do {
@@ -74,10 +70,6 @@ public class Unxz extends Unpack {
             } catch (IOException ioe) {
                 String msg = "Problem expanding xz " + ioe.getMessage();
                 throw new BuildException(msg, ioe, getLocation());
-            } finally {
-                FileUtils.close(fis);
-                FileUtils.close(out);
-                FileUtils.close(zIn);
             }
         }
     }
@@ -88,6 +80,7 @@ public class Unxz extends Unpack {
      * <p>This implementation returns true only.</p>
      * @return true
      */
+    @Override
     protected boolean supportsNonFileResources() {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java
index 7603192..58cff61 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/xz/Xz.java
@@ -18,12 +18,10 @@
 
 package org.apache.tools.ant.taskdefs.optional.xz;
 
-import java.io.BufferedOutputStream;
 import java.io.IOException;
 import java.nio.file.Files;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.taskdefs.Pack;
 import org.tukaani.xz.LZMA2Options;
 import org.tukaani.xz.XZOutputStream;
@@ -41,17 +39,14 @@ public class Xz extends Pack {
     /**
      * Compress the zipFile.
      */
+    @Override
     protected void pack() {
-        XZOutputStream zOut = null;
-        try {
-            zOut = new XZOutputStream(Files.newOutputStream(zipFile.toPath()),
-                                      new LZMA2Options());
+        try (XZOutputStream zOut = new XZOutputStream(
+            Files.newOutputStream(zipFile.toPath()), new LZMA2Options())) {
             zipResource(getSrcResource(), zOut);
         } catch (IOException ioe) {
             String msg = "Problem creating xz " + ioe.getMessage();
             throw new BuildException(msg, ioe, getLocation());
-        } finally {
-            FileUtils.close(zOut);
         }
     }
 
@@ -61,6 +56,7 @@ public class Xz extends Pack {
      * <p>This implementation always returns true only.</p>
      * @return true
      */
+    @Override
     protected boolean supportsNonFileResources() {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 d4483d9..0ed2639 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 import java.util.Vector;
+import java.util.stream.Collectors;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -42,8 +43,6 @@ import org.apache.tools.ant.util.StringUtils;
  */
 public abstract class DefaultRmicAdapter implements RmicAdapter {
 
-    private Rmic attributes;
-    private FileNameMapper mapper;
     private static final Random RAND = new Random();
     /** suffix denoting a stub file: {@value} */
     public static final String RMI_STUB_SUFFIX = "_Stub";
@@ -71,16 +70,14 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
      */
     public static final String STUB_OPTION_COMPAT = "compat";
 
-    /**
-     * Default constructor
-     */
-    public DefaultRmicAdapter() {
-    }
+    private Rmic attributes;
+    private FileNameMapper mapper;
 
     /**
      * Sets Rmic attributes
      * @param attributes the rmic attributes
      */
+    @Override
     public void setRmic(final Rmic attributes) {
         this.attributes = attributes;
         mapper = new RmicFileNameMapper();
@@ -135,6 +132,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
      * </ul>
      * @return a <code>FileNameMapper</code>
      */
+    @Override
     public FileNameMapper getMapper() {
         return mapper;
     }
@@ -143,6 +141,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
      * Gets the CLASSPATH this rmic process will use.
      * @return the classpath
      */
+    @Override
     public Path getClasspath() {
         return getCompileClasspath();
     }
@@ -311,17 +310,16 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
      */
     protected String[] filterJvmCompilerArgs(String[] compilerArgs) {
         int len = compilerArgs.length;
-        List args = new ArrayList(len);
+        List<String> args = new ArrayList<>(len);
         for (int i = 0; i < len; i++) {
             String arg = compilerArgs[i];
-            if (!arg.startsWith("-J")) {
-                args.add(arg);
-            } else {
+            if (arg.startsWith("-J")) {
                 attributes.log("Dropping " + arg + " from compiler arguments");
+            } else {
+                args.add(arg);
             }
         }
-        int count = args.size();
-        return (String[]) args.toArray(new String[count]);
+        return args.toArray(new String[args.size()]);
     }
 
 
@@ -331,24 +329,18 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
      * @param cmd the commandline args
      */
     protected void logAndAddFilesToCompile(Commandline cmd) {
-        Vector compileList = attributes.getCompileList();
+        Vector<String> compileList = attributes.getCompileList();
 
         attributes.log("Compilation " + cmd.describeArguments(),
                        Project.MSG_VERBOSE);
 
-        StringBuffer niceSourceList = new StringBuffer("File");
-        int cListSize = compileList.size();
-        if (cListSize != 1) {
-            niceSourceList.append("s");
-        }
-        niceSourceList.append(" to be compiled:");
+        StringBuilder niceSourceList =
+            new StringBuilder(compileList.size() == 1 ? "File" : "Files")
+                .append(" to be compiled:");
 
-        for (int i = 0; i < cListSize; i++) {
-            String arg = (String) compileList.elementAt(i);
-            cmd.createArgument().setValue(arg);
-            niceSourceList.append("    ");
-            niceSourceList.append(arg);
-        }
+        niceSourceList.append(
+            compileList.stream().peek(arg -> cmd.createArgument().setValue(arg))
+                .collect(Collectors.joining("    ")));
 
         attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
     }
@@ -380,20 +372,20 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
      */
     private class RmicFileNameMapper implements FileNameMapper {
 
-        RmicFileNameMapper() {
-        }
-
         /**
          * Empty implementation.
          */
+        @Override
         public void setFrom(String s) {
         }
         /**
          * Empty implementation.
          */
+        @Override
         public void setTo(String s) {
         }
 
+        @Override
         public String[] mapFileName(String name) {
             if (name == null
                 || !name.endsWith(".class")
@@ -421,7 +413,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
              * This is supposed to make Ant always recompile the
              * class, as a file of that name should not exist.
              */
-            String[] target = new String[] {name + ".tmp." + RAND.nextLong()};
+            String[] target = new String[] { name + ".tmp." + RAND.nextLong() };
 
             if (!attributes.getIiop() && !attributes.getIdl()) {
                 // JRMP with simple naming convention
@@ -438,7 +430,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
             } else if (!attributes.getIdl()) {
                 int lastSlash = base.lastIndexOf(File.separatorChar);
 
-                String dirname = "";
+                String dirname;
                 /*
                  * I know, this is not necessary, but I prefer it explicit (SB)
                  */
@@ -446,6 +438,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
                 if (lastSlash == -1) {
                     // no package
                     index = 0;
+                    dirname = "";
                 } else {
                     index = lastSlash + 1;
                     dirname = base.substring(0, index);
@@ -454,7 +447,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
                 String filename = base.substring(index);
 
                 try {
-                    Class c = attributes.getLoader().loadClass(classname);
+                    Class<?> c = attributes.getLoader().loadClass(classname);
 
                     if (c.isInterface()) {
                         // only stub, no tie
@@ -467,14 +460,15 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
                          * stub is derived from implementation,
                          * tie from interface name.
                          */
-                        Class interf = attributes.getRemoteInterface(c);
+                        Class<?> interf = attributes.getRemoteInterface(c);
                         String iName = interf.getName();
-                        String iDir = "";
-                        int iIndex = -1;
-                        int lastDot = iName.lastIndexOf(".");
+                        String iDir;
+                        int iIndex;
+                        int lastDot = iName.lastIndexOf('.');
                         if (lastDot == -1) {
                             // no package
                             iIndex = 0;
+                            iDir = "";
                         } else {
                             iIndex = lastDot + 1;
                             iDir = iName.substring(0, iIndex);

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java
index 81bd797..7f67009 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java
@@ -50,6 +50,7 @@ public class ForkingSunRmic extends DefaultRmicAdapter {
      * @return true if the command ran successfully
      * @throws BuildException on error
      */
+    @Override
     public boolean execute() throws BuildException {
         Rmic owner = getRmic();
         Commandline cmd = setupRmicCommand();

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 ff72ad4..018ba95 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
@@ -44,15 +44,15 @@ public class KaffeRmic extends DefaultRmicAdapter {
     public static final String COMPILER_NAME = "kaffe";
 
     /** {@inheritDoc} */
+    @Override
     public boolean execute() throws BuildException {
         getRmic().log("Using Kaffe rmic", Project.MSG_VERBOSE);
         Commandline cmd = setupRmicCommand();
 
-        Class c = getRmicClass();
+        Class<?> c = getRmicClass();
         if (c == null) {
-            StringBuffer buf = new StringBuffer("Cannot use Kaffe rmic, as it"
-                                                + " is not available.  None"
-                                                + " of ");
+            StringBuilder buf = new StringBuilder(
+                "Cannot use Kaffe rmic, as it is not available.  None of ");
             for (int i = 0; i < RMIC_CLASSNAMES.length; i++) {
                 if (i != 0) {
                     buf.append(", ");
@@ -60,8 +60,8 @@ public class KaffeRmic extends DefaultRmicAdapter {
 
                 buf.append(RMIC_CLASSNAMES[i]);
             }
-            buf.append(" have been found. A common solution is to set the"
-                       + " environment variable JAVA_HOME or CLASSPATH.");
+            buf.append(
+                " have been found. A common solution is to set the environment variable JAVA_HOME or CLASSPATH.");
             throw new BuildException(buf.toString(),
                                      getRmic().getLocation());
         }
@@ -91,7 +91,7 @@ public class KaffeRmic extends DefaultRmicAdapter {
      *
      * @return null if neither class can get loaded.
      */
-    private static Class getRmicClass() {
+    private static Class<?> getRmicClass() {
         for (int i = 0; i < RMIC_CLASSNAMES.length; i++) {
             try {
                 return Class.forName(RMIC_CLASSNAMES[i]);

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
index a604144..d7c4a4a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
@@ -106,13 +106,17 @@ public final class RmicAdapterFactory {
         }
         if (SunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
             return new SunRmic();
-        } else if (KaffeRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
+        }
+        if (KaffeRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
             return new KaffeRmic();
-        } else if (WLRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
+        }
+        if (WLRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
             return new WLRmic();
-        } else if (ForkingSunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
+        }
+        if (ForkingSunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
             return new ForkingSunRmic();
-        } else if (XNewRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
+        }
+        if (XNewRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
             return new XNewRmic();
         }
         //no match?
@@ -133,7 +137,7 @@ public final class RmicAdapterFactory {
     private static RmicAdapter resolveClassName(String className,
                                                 ClassLoader loader)
             throws BuildException {
-        return (RmicAdapter) ClasspathUtils.newInstance(className,
+        return ClasspathUtils.newInstance(className,
                 loader != null ? loader :
                 RmicAdapterFactory.class.getClassLoader(), RmicAdapter.class);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
index 7281252..4af9c72 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
@@ -51,13 +51,10 @@ public class SunRmic extends DefaultRmicAdapter {
      */
     public static final String RMIC_EXECUTABLE = "rmic";
     /** Error message to use with the sun rmic is not the classpath. */
-    public static final String ERROR_NO_RMIC_ON_CLASSPATH = "Cannot use SUN rmic, as it is not "
-                                         + "available.  A common solution is to "
-                                         + "set the environment variable "
-                                         + "JAVA_HOME";
-    public static final String ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9 = "Cannot use SUN rmic, as it is not "
-                                         + "available.  The class we try to use is part of the jdk.rmic module which may not be. "
-                                         + "Please use the 'forking' compiler for JDK 9+";
+    public static final String ERROR_NO_RMIC_ON_CLASSPATH =
+        "Cannot use SUN rmic, as it is not available.  A common solution is to set the environment variable JAVA_HOME";
+    public static final String ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9 =
+        "Cannot use SUN rmic, as it is not available.  The class we try to use is part of the jdk.rmic module which may not be. Please use the 'forking' compiler for JDK 9+";
     /** Error message to use when there is an error starting the sun rmic compiler */
     public static final String ERROR_RMIC_FAILED = "Error starting SUN rmic: ";
 
@@ -66,29 +63,28 @@ public class SunRmic extends DefaultRmicAdapter {
      * @return true if the compilation succeeded
      * @throws BuildException on error
      */
+    @Override
     public boolean execute() throws BuildException {
         getRmic().log("Using SUN rmic compiler", Project.MSG_VERBOSE);
         Commandline cmd = setupRmicCommand();
 
         // Create an instance of the rmic, redirecting output to
         // the project log
-        LogOutputStream logstr = new LogOutputStream(getRmic(),
-                                                     Project.MSG_WARN);
+        LogOutputStream logstr =
+            new LogOutputStream(getRmic(), Project.MSG_WARN);
 
         boolean success = false;
         try {
-            Class c = Class.forName(RMIC_CLASSNAME);
-            Constructor cons
-                = c.getConstructor(new Class[]  {OutputStream.class, String.class});
-            Object rmic = cons.newInstance(new Object[] {logstr, "rmic"});
+            Class<?> c = Class.forName(RMIC_CLASSNAME);
+            Constructor<?> cons =
+                c.getConstructor(OutputStream.class, String.class);
+            Object rmic = cons.newInstance(logstr, "rmic");
 
-            Method doRmic = c.getMethod("compile",
-                                        new Class [] {String[].class});
-            Boolean ok =
-                (Boolean) doRmic.invoke(rmic,
-                                       (new Object[] {cmd.getArguments()}));
+            Method doRmic = c.getMethod("compile", String[].class);
+            boolean ok = Boolean.TRUE
+                .equals(doRmic.invoke(rmic, (Object) cmd.getArguments()));
             success = true;
-            return ok.booleanValue();
+            return ok;
         } catch (ClassNotFoundException ex) {
             if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
                 throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9,
@@ -99,10 +95,9 @@ public class SunRmic extends DefaultRmicAdapter {
         } catch (Exception ex) {
             if (ex instanceof BuildException) {
                 throw (BuildException) ex;
-            } else {
-                throw new BuildException(ERROR_RMIC_FAILED,
-                                         ex, getRmic().getLocation());
             }
+            throw new BuildException(ERROR_RMIC_FAILED,
+                                     ex, getRmic().getLocation());
         } finally {
             try {
                 logstr.close();
@@ -122,6 +117,7 @@ public class SunRmic extends DefaultRmicAdapter {
      * @param compilerArgs the original compiler arguments
      * @return the filtered set.
      */
+    @Override
     protected String[] preprocessCompilerArgs(String[] compilerArgs) {
         return filterJvmCompilerArgs(compilerArgs);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
index 3b1f2a1..17a7650 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
@@ -40,8 +40,7 @@ public class WLRmic extends DefaultRmicAdapter {
 
     /** The error string to use if not able to find the weblogic rmic */
     public static final String ERROR_NO_WLRMIC_ON_CLASSPATH =
-        "Cannot use WebLogic rmic, as it is not "
-        + "available. Add it to Ant's classpath with the -lib option";
+        "Cannot use WebLogic rmic, as it is not available. Add it to Ant's classpath with the -lib option";
 
     /** The error string to use if not able to start the weblogic rmic */
     public static final String ERROR_WLRMIC_FAILED = "Error starting WebLogic rmic: ";
@@ -57,6 +56,7 @@ public class WLRmic extends DefaultRmicAdapter {
      * @return true if the compilation succeeded
      * @throws  BuildException on error
      */
+    @Override
     public boolean execute() throws BuildException {
         getRmic().log("Using WebLogic rmic", Project.MSG_VERBOSE);
         Commandline cmd = setupRmicCommand(new String[] {"-noexit"});
@@ -64,7 +64,7 @@ public class WLRmic extends DefaultRmicAdapter {
         AntClassLoader loader = null;
         try {
             // Create an instance of the rmic
-            Class c = null;
+            Class<?> c;
             if (getRmic().getClasspath() == null) {
                 c = Class.forName(WLRMIC_CLASSNAME);
             } else {
@@ -72,9 +72,8 @@ public class WLRmic extends DefaultRmicAdapter {
                     = getRmic().getProject().createClassLoader(getRmic().getClasspath());
                 c = Class.forName(WLRMIC_CLASSNAME, true, loader);
             }
-            Method doRmic = c.getMethod("main",
-                                        new Class [] {String[].class});
-            doRmic.invoke(null, new Object[] {cmd.getArguments()});
+            Method doRmic = c.getMethod("main", String[].class);
+            doRmic.invoke(null, (Object) cmd.getArguments());
             return true;
         } catch (ClassNotFoundException ex) {
             throw new BuildException(ERROR_NO_WLRMIC_ON_CLASSPATH, getRmic().getLocation());
@@ -96,6 +95,7 @@ public class WLRmic extends DefaultRmicAdapter {
      * Get the suffix for the rmic stub classes
      * @return the stub suffix
      */
+    @Override
     public String getStubClassSuffix() {
         return WL_RMI_STUB_SUFFIX;
     }
@@ -104,6 +104,7 @@ public class WLRmic extends DefaultRmicAdapter {
      * Get the suffix for the rmic skeleton classes
      * @return the skeleton suffix
      */
+    @Override
     public String getSkelClassSuffix() {
         return WL_RMI_SKEL_SUFFIX;
     }
@@ -114,6 +115,7 @@ public class WLRmic extends DefaultRmicAdapter {
      * @param compilerArgs the original compiler arguments
      * @return the filtered set.
      */
+    @Override
     protected String[] preprocessCompilerArgs(String[] compilerArgs) {
         return filterJvmCompilerArgs(compilerArgs);
     }
@@ -123,6 +125,7 @@ public class WLRmic extends DefaultRmicAdapter {
      * stub option is set, a warning is printed.
      * @return null, for no stub version
      */
+    @Override
     protected String addStubVersionOptions() {
         //handle the many different stub options.
         String stubVersion = getRmic().getStubVersion();

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java
index 559c769..0b43e74 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java
@@ -33,14 +33,11 @@ public class XNewRmic extends ForkingSunRmic {
      */
     public static final String COMPILER_NAME = "xnew";
 
-    /** No-arg constructor. */
-    public XNewRmic() {
-    }
-
     /**
      * Create a normal command line, then with -Xnew at the front
      * @return a command line that hands off to thw
      */
+    @Override
     protected Commandline setupRmicCommand() {
         String[] options = new String[] {
                 "-Xnew"

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 92d5ace..58e7c16 100644
--- a/src/main/org/apache/tools/ant/types/AbstractFileSet.java
+++ b/src/main/org/apache/tools/ant/types/AbstractFileSet.java
@@ -23,6 +23,8 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Stack;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
@@ -66,8 +68,8 @@ public abstract class AbstractFileSet extends DataType
     implements Cloneable, SelectorContainer {
 
     private PatternSet defaultPatterns = new PatternSet();
-    private List<PatternSet> additionalPatterns = new ArrayList<PatternSet>();
-    private List<FileSelector> selectors = new ArrayList<FileSelector>();
+    private List<PatternSet> additionalPatterns = new ArrayList<>();
+    private List<FileSelector> selectors = new ArrayList<>();
 
     private File dir;
     private boolean fileAttributeUsed;
@@ -113,6 +115,7 @@ public abstract class AbstractFileSet extends DataType
      * @param r the <code>Reference</code> to use.
      * @throws BuildException on error
      */
+    @Override
     public void setRefid(Reference r) throws BuildException {
         if (dir != null || defaultPatterns.hasPatterns(getProject())) {
             throw tooManyAttributes();
@@ -482,14 +485,14 @@ public abstract class AbstractFileSet extends DataType
             return getRef(p).getDirectoryScanner(p);
         }
         dieOnCircularReference();
-        DirectoryScanner ds = null;
+        final DirectoryScanner ds;
         synchronized (this) {
             if (directoryScanner != null && p == getProject()) {
                 ds = directoryScanner;
             } else {
                 if (dir == null) {
-                    throw new BuildException("No directory specified for "
-                                             + getDataTypeName() + ".");
+                    throw new BuildException("No directory specified for %s.",
+                        getDataTypeName());
                 }
                 if (!dir.exists() && errorOnMissingDir) {
                     throw new BuildException(dir.getAbsolutePath()
@@ -497,8 +500,8 @@ public abstract class AbstractFileSet extends DataType
                                              .DOES_NOT_EXIST_POSTFIX);
                 }
                 if (!dir.isDirectory() && dir.exists()) {
-                    throw new BuildException(dir.getAbsolutePath()
-                                             + " is not a directory.");
+                    throw new BuildException("%s is not a directory.",
+                        dir.getAbsolutePath());
                 }
                 ds = new DirectoryScanner();
                 setupDirectoryScanner(ds, p);
@@ -570,6 +573,7 @@ public abstract class AbstractFileSet extends DataType
      *
      * @return whether any selectors are in this container.
      */
+    @Override
     public synchronized boolean hasSelectors() {
         if (isReference()) {
             return getRef(getProject()).hasSelectors();
@@ -591,12 +595,7 @@ public abstract class AbstractFileSet extends DataType
         if (defaultPatterns.hasPatterns(getProject())) {
             return true;
         }
-        for (PatternSet ps : additionalPatterns) {
-            if (ps.hasPatterns(getProject())) {
-                return true;
-            }
-        }
-        return false;
+        return additionalPatterns.stream().anyMatch(ps -> ps.hasPatterns(getProject()));
     }
 
     /**
@@ -604,6 +603,7 @@ public abstract class AbstractFileSet extends DataType
      *
      * @return the number of selectors in this container as an <code>int</code>.
      */
+    @Override
     public synchronized int selectorCount() {
         if (isReference()) {
             return getRef(getProject()).selectorCount();
@@ -617,13 +617,13 @@ public abstract class AbstractFileSet extends DataType
      * @param p the current project
      * @return a <code>FileSelector[]</code> of the selectors in this container.
      */
+    @Override
     public synchronized FileSelector[] getSelectors(Project p) {
         if (isReference()) {
             return getRef(getProject()).getSelectors(p);
         }
         dieOnCircularReference(p);
-        return (FileSelector[]) (selectors.toArray(
-            new FileSelector[selectors.size()]));
+        return selectors.toArray(new FileSelector[selectors.size()]);
     }
 
     /**
@@ -631,6 +631,7 @@ public abstract class AbstractFileSet extends DataType
      *
      * @return an <code>Enumeration</code> of selectors.
      */
+    @Override
     public synchronized Enumeration<FileSelector> selectorElements() {
         if (isReference()) {
             return getRef(getProject()).selectorElements();
@@ -644,6 +645,7 @@ public abstract class AbstractFileSet extends DataType
      *
      * @param selector the new <code>FileSelector</code> to add.
      */
+    @Override
     public synchronized void appendSelector(FileSelector selector) {
         if (isReference()) {
             throw noChildrenAllowed();
@@ -659,6 +661,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a "Select" selector entry on the selector list.
      * @param selector the <code>SelectSelector</code> to add.
      */
+    @Override
     public void addSelector(SelectSelector selector) {
         appendSelector(selector);
     }
@@ -667,6 +670,7 @@ public abstract class AbstractFileSet extends DataType
      * Add an "And" selector entry on the selector list.
      * @param selector the <code>AndSelector</code> to add.
      */
+    @Override
     public void addAnd(AndSelector selector) {
         appendSelector(selector);
     }
@@ -675,6 +679,7 @@ public abstract class AbstractFileSet extends DataType
      * Add an "Or" selector entry on the selector list.
      * @param selector the <code>OrSelector</code> to add.
      */
+    @Override
     public void addOr(OrSelector selector) {
         appendSelector(selector);
     }
@@ -683,6 +688,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a "Not" selector entry on the selector list.
      * @param selector the <code>NotSelector</code> to add.
      */
+    @Override
     public void addNot(NotSelector selector) {
         appendSelector(selector);
     }
@@ -691,6 +697,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a "None" selector entry on the selector list.
      * @param selector the <code>NoneSelector</code> to add.
      */
+    @Override
     public void addNone(NoneSelector selector) {
         appendSelector(selector);
     }
@@ -699,6 +706,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a majority selector entry on the selector list.
      * @param selector the <code>MajoritySelector</code> to add.
      */
+    @Override
     public void addMajority(MajoritySelector selector) {
         appendSelector(selector);
     }
@@ -707,6 +715,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a selector date entry on the selector list.
      * @param selector the <code>DateSelector</code> to add.
      */
+    @Override
     public void addDate(DateSelector selector) {
         appendSelector(selector);
     }
@@ -715,6 +724,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a selector size entry on the selector list.
      * @param selector the <code>SizeSelector</code> to add.
      */
+    @Override
     public void addSize(SizeSelector selector) {
         appendSelector(selector);
     }
@@ -723,6 +733,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a DifferentSelector entry on the selector list.
      * @param selector the <code>DifferentSelector</code> to add.
      */
+    @Override
     public void addDifferent(DifferentSelector selector) {
         appendSelector(selector);
     }
@@ -731,6 +742,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a selector filename entry on the selector list.
      * @param selector the <code>FilenameSelector</code> to add.
      */
+    @Override
     public void addFilename(FilenameSelector selector) {
         appendSelector(selector);
     }
@@ -739,6 +751,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a selector type entry on the selector list.
      * @param selector the <code>TypeSelector</code> to add.
      */
+    @Override
     public void addType(TypeSelector selector) {
         appendSelector(selector);
     }
@@ -747,6 +760,7 @@ public abstract class AbstractFileSet extends DataType
      * Add an extended selector entry on the selector list.
      * @param selector the <code>ExtendSelector</code> to add.
      */
+    @Override
     public void addCustom(ExtendSelector selector) {
         appendSelector(selector);
     }
@@ -755,6 +769,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a contains selector entry on the selector list.
      * @param selector the <code>ContainsSelector</code> to add.
      */
+    @Override
     public void addContains(ContainsSelector selector) {
         appendSelector(selector);
     }
@@ -763,6 +778,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a present selector entry on the selector list.
      * @param selector the <code>PresentSelector</code> to add.
      */
+    @Override
     public void addPresent(PresentSelector selector) {
         appendSelector(selector);
     }
@@ -771,6 +787,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a depth selector entry on the selector list.
      * @param selector the <code>DepthSelector</code> to add.
      */
+    @Override
     public void addDepth(DepthSelector selector) {
         appendSelector(selector);
     }
@@ -779,6 +796,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a depends selector entry on the selector list.
      * @param selector the <code>DependSelector</code> to add.
      */
+    @Override
     public void addDepend(DependSelector selector) {
         appendSelector(selector);
     }
@@ -787,6 +805,7 @@ public abstract class AbstractFileSet extends DataType
      * Add a regular expression selector entry on the selector list.
      * @param selector the <code>ContainsRegexpSelector</code> to add.
      */
+    @Override
     public void addContainsRegexp(ContainsRegexpSelector selector) {
         appendSelector(selector);
     }
@@ -796,6 +815,7 @@ public abstract class AbstractFileSet extends DataType
      * @param selector the <code>ModifiedSelector</code> to add.
      * @since ant 1.6
      */
+    @Override
     public void addModified(ModifiedSelector selector) {
         appendSelector(selector);
     }
@@ -834,6 +854,7 @@ public abstract class AbstractFileSet extends DataType
      * @param selector the <code>FileSelector</code> to add.
      * @since Ant 1.6
      */
+    @Override
     public void add(FileSelector selector) {
         appendSelector(selector);
     }
@@ -843,22 +864,14 @@ public abstract class AbstractFileSet extends DataType
      *
      * @return a <code>String</code> of included filenames.
      */
+    @Override
     public String toString() {
         if (isReference()) {
             return getRef(getProject()).toString();
         }
         dieOnCircularReference();
         DirectoryScanner ds = getDirectoryScanner(getProject());
-        String[] files = ds.getIncludedFiles();
-        StringBuffer sb = new StringBuffer();
-
-        for (int i = 0; i < files.length; i++) {
-            if (i > 0) {
-                sb.append(';');
-            }
-            sb.append(files[i]);
-        }
-        return sb.toString();
+        return Stream.of(ds.getIncludedFiles()).collect(Collectors.joining(File.pathSeparator));
     }
 
     /**
@@ -868,22 +881,20 @@ public abstract class AbstractFileSet extends DataType
      * @return the cloned object
      * @since Ant 1.6
      */
-    public synchronized Object clone() {
+    @Override
+    public synchronized AbstractFileSet clone() {
         if (isReference()) {
             return (getRef(getProject())).clone();
-        } else {
-            try {
-                AbstractFileSet fs = (AbstractFileSet) super.clone();
-                fs.defaultPatterns = (PatternSet) defaultPatterns.clone();
-                fs.additionalPatterns = new ArrayList<PatternSet>(additionalPatterns.size());
-                for (PatternSet ps : additionalPatterns) {
-                    fs.additionalPatterns.add((PatternSet) ps.clone());
-                }
-                fs.selectors = new ArrayList<FileSelector>(selectors);
-                return fs;
-            } catch (CloneNotSupportedException e) {
-                throw new BuildException(e);
-            }
+        }
+        try {
+            AbstractFileSet fs = (AbstractFileSet) super.clone();
+            fs.defaultPatterns = defaultPatterns.clone();
+            fs.additionalPatterns = additionalPatterns.stream().map(
+                    PatternSet::clone).map(PatternSet.class::cast).collect(Collectors.toList());
+            fs.selectors = new ArrayList<>(selectors);
+            return fs;
+        } catch (CloneNotSupportedException e) {
+            throw new BuildException(e);
         }
     }
 
@@ -924,14 +935,12 @@ public abstract class AbstractFileSet extends DataType
             return getRef(p).mergePatterns(p);
         }
         dieOnCircularReference();
-        PatternSet ps = (PatternSet) defaultPatterns.clone();
-        final int count = additionalPatterns.size();
-        for (int i = 0; i < count; i++) {
-            ps.append(additionalPatterns.get(i), p);
-        }
+        PatternSet ps = defaultPatterns.clone();
+        additionalPatterns.forEach(pat -> ps.append(pat, p));
         return ps;
     }
 
+    @Override
     protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p)
         throws BuildException {
         if (isChecked()) {
@@ -940,11 +949,9 @@ public abstract class AbstractFileSet extends DataType
         if (isReference()) {
             super.dieOnCircularReference(stk, p);
         } else {
-            for (FileSelector fileSelector : selectors) {
-                if (fileSelector instanceof DataType) {
-                    pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p);
-                }
-            }
+            selectors.stream().filter(DataType.class::isInstance).forEach(fileSelector -> 
+                pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p)
+            );
             for (PatternSet ps : additionalPatterns) {
                 pushAndInvokeCircularReferenceCheck(ps, stk, p);
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/AntFilterReader.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/AntFilterReader.java b/src/main/org/apache/tools/ant/types/AntFilterReader.java
index bdc1c31..154b860 100644
--- a/src/main/org/apache/tools/ant/types/AntFilterReader.java
+++ b/src/main/org/apache/tools/ant/types/AntFilterReader.java
@@ -17,8 +17,9 @@
  */
 package org.apache.tools.ant.types;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Stack;
-import java.util.Vector;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -31,7 +32,7 @@ public final class AntFilterReader extends DataType {
 
     private String className;
 
-    private final Vector<Parameter> parameters = new Vector<Parameter>();
+    private final List<Parameter> parameters = new ArrayList<>();
 
     private Path classpath;
 
@@ -69,7 +70,7 @@ public final class AntFilterReader extends DataType {
         if (isReference()) {
             throw noChildrenAllowed();
         }
-        parameters.addElement(param);
+        parameters.add(param);
     }
 
     /**
@@ -137,9 +138,7 @@ public final class AntFilterReader extends DataType {
             ((AntFilterReader) getCheckedRef()).getParams();
         }
         dieOnCircularReference();
-        Parameter[] params = new Parameter[parameters.size()];
-        parameters.copyInto(params);
-        return params;
+        return parameters.toArray(new Parameter[parameters.size()]);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
index e9a0730..c34f213 100644
--- a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
+++ b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
@@ -110,6 +110,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @param dir the directory for the fileset
      * @throws BuildException on error
      */
+    @Override
     public void setDir(File dir) throws BuildException {
         checkAttributesAllowed();
         if (src != null) {
@@ -191,13 +192,10 @@ public abstract class ArchiveFileSet extends FileSet {
             return ((ArchiveFileSet) getCheckedRef()).getSrc();
         }
         dieOnCircularReference();
-        if (src != null) {
-            FileProvider fp = src.as(FileProvider.class);
-            if (fp != null) {
-                return fp.getFile();
-            }
+        if (src == null) {
+            return null;
         }
-        return null;
+        return src.asOptional(FileProvider.class).map(FileProvider::getFile).orElse(null);
     }
 
     /**
@@ -212,6 +210,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @since Ant 1.8
      */
     // TODO is the above true? AFAICT the calls look circular :/
+    @Override
     protected Object getCheckedRef(Project p) {
         return getRef(p);
     }
@@ -288,11 +287,7 @@ public abstract class ArchiveFileSet extends FileSet {
     public String getEncoding() {
         if (isReference()) {
             AbstractFileSet ref = getRef(getProject());
-            if (ref instanceof ArchiveFileSet) {
-                return ((ArchiveFileSet) ref).getEncoding();
-            } else {
-                return null;
-            }
+            return ref instanceof ArchiveFileSet ? ((ArchiveFileSet) ref).getEncoding() : null;
         }
         return encoding;
     }
@@ -310,6 +305,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @param p the project to use
      * @return a directory scanner
      */
+    @Override
     public DirectoryScanner getDirectoryScanner(Project p) {
         if (isReference()) {
             return getRef(p).getDirectoryScanner(p);
@@ -340,6 +336,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return Iterator of Resources.
      * @since Ant 1.7
      */
+    @Override
     public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((ResourceCollection) (getRef(getProject()))).iterator();
@@ -356,6 +353,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return size of the collection as int.
      * @since Ant 1.7
      */
+    @Override
     public int size() {
         if (isReference()) {
             return ((ResourceCollection) (getRef(getProject()))).size();
@@ -375,6 +373,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return whether this is a filesystem-only resource collection.
      * @since Ant 1.7
      */
+    @Override
     public boolean isFilesystemOnly() {
         if (isReference()) {
             return ((ArchiveFileSet) getCheckedRef()).isFilesystemOnly();
@@ -505,11 +504,13 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return the cloned archiveFileSet
      * @since Ant 1.6
      */
-    public Object clone() {
+    @Override
+    public ArchiveFileSet clone() {
         if (isReference()) {
-            return getCheckedRef(ArchiveFileSet.class, getDataTypeName(), getProject()).clone();
+            return getCheckedRef(ArchiveFileSet.class, getDataTypeName(),
+                getProject()).clone();
         }
-        return super.clone();
+        return (ArchiveFileSet) super.clone();
     }
 
     /**
@@ -518,6 +519,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return for file based archivefilesets, included files as a list
      * of semicolon-separated filenames. else just the name of the zip.
      */
+    @Override
     public String toString() {
         if (hasDir && getProject() != null) {
             return super.toString();
@@ -530,6 +532,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return the prefix.
      * @deprecated since 1.7.
      */
+    @Deprecated
     public String getPrefix() {
         return prefix;
     }
@@ -539,6 +542,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return the full pathname.
      * @deprecated since 1.7.
      */
+    @Deprecated
     public String getFullpath() {
         return fullpath;
     }
@@ -547,6 +551,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return the file mode.
      * @deprecated since 1.7.
      */
+    @Deprecated
     public int getFileMode() {
         return fileMode;
     }
@@ -555,6 +560,7 @@ public abstract class ArchiveFileSet extends FileSet {
      * @return the dir mode.
      * @deprecated since 1.7.
      */
+    @Deprecated
     public int getDirMode() {
         return dirMode;
     }
@@ -577,6 +583,7 @@ public abstract class ArchiveFileSet extends FileSet {
         }
     }
 
+    @Override
     protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p)
         throws BuildException {
         if (isChecked()) {

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/ArchiveScanner.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/ArchiveScanner.java b/src/main/org/apache/tools/ant/types/ArchiveScanner.java
index db5a8d4..90e91e8 100644
--- a/src/main/org/apache/tools/ant/types/ArchiveScanner.java
+++ b/src/main/org/apache/tools/ant/types/ArchiveScanner.java
@@ -272,11 +272,12 @@ public abstract class ArchiveScanner extends DirectoryScanner {
      * @return the resource
      * @since Ant 1.5.2
      */
+    @Override
     public Resource getResource(String name) {
         if (src == null) {
             return super.getResource(name);
         }
-        if (name.equals("")) {
+        if ("".equals(name)) {
             // special case in ZIPs, we do not want this thing included
             return new Resource("", true, Long.MAX_VALUE, true);
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/Assertions.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/Assertions.java b/src/main/org/apache/tools/ant/types/Assertions.java
index a54db50..6be6569 100644
--- a/src/main/org/apache/tools/ant/types/Assertions.java
+++ b/src/main/org/apache/tools/ant/types/Assertions.java
@@ -117,7 +117,7 @@ public class Assertions extends DataType implements Cloneable {
      * @param ref the reference to use
      */
     public void setRefid(Reference ref) {
-        if (assertionList.size() > 0 || enableSystemAssertions != null) {
+        if (!assertionList.isEmpty() || enableSystemAssertions != null) {
             throw tooManyAttributes();
         }
         super.setRefid(ref);
@@ -130,13 +130,12 @@ public class Assertions extends DataType implements Cloneable {
     private Assertions getFinalReference() {
         if (getRefid() == null) {
             return this;
-        } else {
-            Object o = getRefid().getReferencedObject(getProject());
-            if (!(o instanceof Assertions)) {
-                throw new BuildException("reference is of wrong type");
-            }
-            return (Assertions) o;
         }
+        Object o = getRefid().getReferencedObject(getProject());
+        if (!(o instanceof Assertions)) {
+            throw new BuildException("reference is of wrong type");
+        }
+        return (Assertions) o;
     }
 
     /**
@@ -245,16 +244,16 @@ public class Assertions extends DataType implements Cloneable {
      * @return a cli
      * @throws CloneNotSupportedException if the super class does not support cloning
      */
+    @Override
     public Object clone() throws CloneNotSupportedException {
         Assertions that = (Assertions) super.clone();
-        that.assertionList = new ArrayList<BaseAssertion>(assertionList);
+        that.assertionList = new ArrayList<>(assertionList);
         return that;
     }
 
     /**
      * base class for our assertion elements.
      */
-
     public abstract static class BaseAssertion {
         private String packageName;
         private String className;
@@ -309,7 +308,7 @@ public class Assertions extends DataType implements Cloneable {
             if (getPackageName() != null && getClassName() != null) {
                 throw new BuildException("Both package and class have been set");
             }
-            StringBuffer command = new StringBuffer(getCommandPrefix());
+            StringBuilder command = new StringBuilder(getCommandPrefix());
             //see if it is a package or a class
             if (getPackageName() != null) {
                 //packages get a ... prefix
@@ -337,6 +336,7 @@ public class Assertions extends DataType implements Cloneable {
          * get the prefix used to begin the command; -ea or -da.
          * @return prefix
          */
+        @Override
         public String getCommandPrefix() {
             return "-ea";
         }
@@ -351,6 +351,7 @@ public class Assertions extends DataType implements Cloneable {
          * get the prefix used to begin the command; -ea or -da.
          * @return prefix
          */
+        @Override
         public String getCommandPrefix() {
             return "-da";
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 a417a0c..a996f91 100644
--- a/src/main/org/apache/tools/ant/types/Commandline.java
+++ b/src/main/org/apache/tools/ant/types/Commandline.java
@@ -25,6 +25,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.StringTokenizer;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.ProjectComponent;
@@ -229,11 +230,9 @@ public class Commandline implements Cloneable {
          */
         public int getPosition() {
             if (realPos == -1) {
-                realPos = (executable == null ? 0 : 1);
-                for (int i = 0; i < position; i++) {
-                    Argument arg = (Argument) arguments.get(i);
-                    realPos += arg.getParts().length;
-                }
+                realPos = (executable == null ? 0 : 1) + (int)
+                arguments.stream().limit(position).map(Argument::getParts)
+                    .flatMap(Stream::of).count();
             }
             return realPos;
         }
@@ -385,7 +384,7 @@ public class Commandline implements Cloneable {
      * @return the arguments as an array of strings.
      */
     public String[] getArguments() {
-        List<String> result = new ArrayList<String>(arguments.size() * 2);
+        List<String> result = new ArrayList<>(arguments.size() * 2);
         addArgumentsToList(result.listIterator());
         return result.toArray(new String[result.size()]);
     }
@@ -412,6 +411,7 @@ public class Commandline implements Cloneable {
      * Return the command line as a string.
      * @return the command line.
      */
+    @Override
     public String toString() {
         return toString(getCommandline());
     }
@@ -432,17 +432,16 @@ public class Commandline implements Cloneable {
             if (argument.indexOf("\'") > -1) {
                 throw new BuildException("Can\'t handle single and double"
                         + " quotes in same argument");
-            } else {
-                return '\'' + argument + '\'';
             }
-        } else if (argument.indexOf("\'") > -1
-                   || argument.indexOf(" ") > -1
-                   // WIN9x uses a bat file for executing commands
-                   || (IS_WIN_9X && argument.indexOf(';') != -1)) {
+            return '\'' + argument + '\'';
+        }
+        if (argument.indexOf("\'") > -1
+               || argument.indexOf(" ") > -1
+               // WIN9x uses a bat file for executing commands
+               || (IS_WIN_9X && argument.indexOf(';') != -1)) {
             return '\"' + argument + '\"';
-        } else {
-            return argument;
         }
+        return argument;
     }
 
     /**
@@ -486,7 +485,7 @@ public class Commandline implements Cloneable {
         final int inDoubleQuote = 2;
         int state = normal;
         final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true);
-        final ArrayList<String> result = new ArrayList<String>();
+        final ArrayList<String> result = new ArrayList<>();
         final StringBuilder current = new StringBuilder();
         boolean lastTokenHasBeenQuoted = false;
 
@@ -548,10 +547,11 @@ public class Commandline implements Cloneable {
      * Generate a deep clone of the contained object.
      * @return a clone of the contained object
      */
-    public Object clone() {
+    @Override
+    public Commandline clone() {
         try {
             Commandline c = (Commandline) super.clone();
-            c.arguments = new ArrayList<Argument>(arguments);
+            c.arguments = new ArrayList<>(arguments);
             return c;
         } catch (CloneNotSupportedException e) {
             throw new BuildException(e);
@@ -642,9 +642,8 @@ public class Commandline implements Cloneable {
         if (args == null || args.length == 0) {
             return "";
         }
-        StringBuffer buf = new StringBuffer("Executing \'");
-        buf.append(args[0]);
-        buf.append("\'");
+        StringBuilder buf = new StringBuilder("Executing \'")
+            .append(args[0]).append("\'");
         if (args.length > 1) {
             buf.append(" with ");
             buf.append(describeArguments(args, 1));
@@ -679,7 +678,7 @@ public class Commandline implements Cloneable {
         if (args == null || args.length <= offset) {
             return "";
         }
-        StringBuffer buf = new StringBuffer("argument");
+        StringBuilder buf = new StringBuilder("argument");
         if (args.length > offset) {
             buf.append("s");
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 d811633..a14c38e 100644
--- a/src/main/org/apache/tools/ant/types/CommandlineJava.java
+++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java
@@ -82,7 +82,7 @@ public class CommandlineJava implements Cloneable {
         /** the system properties. */
         Properties sys = null;
         // CheckStyle:VisibilityModifier ON
-        private Vector<PropertySet> propertySets = new Vector<PropertySet>();
+        private Vector<PropertySet> propertySets = new Vector<>();
 
         /**
          * Get the properties as an array; this is an override of the
@@ -90,15 +90,15 @@ public class CommandlineJava implements Cloneable {
          * @return the array of definitions; may be null.
          * @throws BuildException on error.
          */
+        @Override
         public String[] getVariables() throws BuildException {
 
-            List<String> definitions = new LinkedList<String>();
+            List<String> definitions = new LinkedList<>();
             addDefinitionsToList(definitions.listIterator());
-            if (definitions.size() == 0) {
+            if (definitions.isEmpty()) {
                 return null;
-            } else {
-                return definitions.toArray(new String[definitions.size()]);
             }
+            return definitions.toArray(new String[definitions.size()]);
         }
 
         /**
@@ -182,6 +182,7 @@ public class CommandlineJava implements Cloneable {
          * @exception CloneNotSupportedException for signature.
          */
         @SuppressWarnings("unchecked")
+        @Override
         public Object clone() throws CloneNotSupportedException {
             try {
                 SysProperties c = (SysProperties) super.clone();
@@ -366,6 +367,7 @@ public class CommandlineJava implements Cloneable {
                     return javaCommand.getExecutable();
                 case MODULE:
                     return parseClassFromModuleClassPair(javaCommand.getExecutable());
+                default:
             }
         }
         return null;
@@ -395,6 +397,7 @@ public class CommandlineJava implements Cloneable {
                             parseClassFromModuleClassPair(javaCommand.getExecutable())),
                                               false);
                     break;
+                default:
             }
         }
         executableType = ExecutableType.MODULE;
@@ -479,7 +482,7 @@ public class CommandlineJava implements Cloneable {
      */
     public String[] getCommandline() {
         //create the list
-        List<String> commands = new LinkedList<String>();
+        List<String> commands = new LinkedList<>();
         //fill it
         addCommandsToList(commands.listIterator());
         //convert to an array
@@ -562,6 +565,7 @@ public class CommandlineJava implements Cloneable {
      * Get a string description.
      * @return the command line as a string.
      */
+    @Override
     public String toString() {
         return Commandline.toString(getCommandline());
     }
@@ -613,6 +617,7 @@ public class CommandlineJava implements Cloneable {
      *             Please dont use this, it effectively creates the
      *             entire command.
      */
+    @Deprecated
     public int size() {
         int size = getActualVMCommand().size() + javaCommand.size()
             + sysProperties.size();
@@ -721,7 +726,8 @@ public class CommandlineJava implements Cloneable {
      * @throws BuildException if anything went wrong.
      * @throws CloneNotSupportedException never.
      */
-    public Object clone() throws CloneNotSupportedException {
+    @Override
+    public CommandlineJava clone() throws CloneNotSupportedException {
         try {
             CommandlineJava c = (CommandlineJava) super.clone();
             c.vmCommand = (Commandline) vmCommand.clone();
@@ -791,7 +797,7 @@ public class CommandlineJava implements Cloneable {
         Path fullClasspath = modulepath != null
             ? modulepath.concatSystemClasspath("ignore") : null;
         return fullClasspath != null
-            && fullClasspath.toString().trim().length() > 0;
+            && !fullClasspath.toString().trim().isEmpty();
     }
 
     /**
@@ -803,7 +809,7 @@ public class CommandlineJava implements Cloneable {
         Path fullClasspath = upgrademodulepath != null
             ? upgrademodulepath.concatSystemClasspath("ignore") : null;
         return fullClasspath != null
-            && fullClasspath.toString().trim().length() > 0;
+            && !fullClasspath.toString().trim().isEmpty();
     }
 
     /**
@@ -840,7 +846,7 @@ public class CommandlineJava implements Cloneable {
      */
     private boolean isCloneVm() {
         return cloneVm
-            || "true".equals(System.getProperty("ant.build.clonevm"));
+            || Boolean.parseBoolean(System.getProperty("ant.build.clonevm"));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/DataType.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/DataType.java b/src/main/org/apache/tools/ant/types/DataType.java
index fda4af6..24f7682 100644
--- a/src/main/org/apache/tools/ant/types/DataType.java
+++ b/src/main/org/apache/tools/ant/types/DataType.java
@@ -340,6 +340,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable {
      * Basic DataType toString().
      * @return this DataType formatted as a String.
      */
+    @Override
     public String toString() {
         String d = getDescription();
         return d == null ? getDataTypeName() : getDataTypeName() + " " + d;
@@ -350,6 +351,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable {
      * @return a shallow copy of this DataType.
      * @throws CloneNotSupportedException if there is a problem.
      */
+    @Override
     public Object clone() throws CloneNotSupportedException {
         DataType dt = (DataType) super.clone();
         dt.setDescription(getDescription());

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/Description.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/Description.java b/src/main/org/apache/tools/ant/types/Description.java
index d23f1d8..822697b 100644
--- a/src/main/org/apache/tools/ant/types/Description.java
+++ b/src/main/org/apache/tools/ant/types/Description.java
@@ -17,8 +17,9 @@
  */
 package org.apache.tools.ant.types;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.ProjectHelper;
@@ -90,7 +91,7 @@ public class Description extends DataType {
         if (t == null) {
             return;
         }
-        for (Task task : findElementInTarget(project, t, "description")) {
+        for (Task task : findElementInTarget(t, "description")) {
             if (!(task instanceof UnknownElement)) {
                 continue;
             }
@@ -102,15 +103,10 @@ public class Description extends DataType {
         }
     }
 
-    private static List<Task> findElementInTarget(Project project,
-                                              Target t, String name) {
-        final List<Task> elems = new ArrayList<Task>();
-        for (Task task : t.getTasks()) {
-            if (name.equals(task.getTaskName())) {
-                elems.add(task);
-            }
-        }
-        return elems;
+    private static List<Task> findElementInTarget(Target t, String name) {
+        return Stream.of(t.getTasks())
+            .filter(task -> name.equals(task.getTaskName()))
+            .collect(Collectors.toList());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/DirSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/DirSet.java b/src/main/org/apache/tools/ant/types/DirSet.java
index 35c0231..12d9414 100644
--- a/src/main/org/apache/tools/ant/types/DirSet.java
+++ b/src/main/org/apache/tools/ant/types/DirSet.java
@@ -19,6 +19,8 @@
 package org.apache.tools.ant.types;
 
 import java.util.Iterator;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.types.resources.FileResourceIterator;
@@ -51,12 +53,12 @@ public class DirSet extends AbstractFileSet implements ResourceCollection {
      * as this one.
      * @return the cloned dirset.
      */
-    public Object clone() {
+    @Override
+    public DirSet clone() {
         if (isReference()) {
             return ((DirSet) getRef(getProject())).clone();
-        } else {
-            return super.clone();
         }
+        return (DirSet) super.clone();
     }
 
     /**
@@ -64,6 +66,7 @@ public class DirSet extends AbstractFileSet implements ResourceCollection {
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
+    @Override
     public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((DirSet) getRef(getProject())).iterator();
@@ -77,6 +80,7 @@ public class DirSet extends AbstractFileSet implements ResourceCollection {
      * @return number of elements as int.
      * @since Ant 1.7
      */
+    @Override
     public int size() {
         if (isReference()) {
             return ((DirSet) getRef(getProject())).size();
@@ -89,6 +93,7 @@ public class DirSet extends AbstractFileSet implements ResourceCollection {
      * @return true indicating that all elements will be FileResources.
      * @since Ant 1.7
      */
+    @Override
     public boolean isFilesystemOnly() {
         return true;
     }
@@ -98,18 +103,10 @@ public class DirSet extends AbstractFileSet implements ResourceCollection {
      *
      * @return a <code>String</code> of included directories.
      */
+    @Override
     public String toString() {
         DirectoryScanner ds = getDirectoryScanner(getProject());
-        String[] dirs = ds.getIncludedDirectories();
-        StringBuffer sb = new StringBuffer();
-
-        for (int i = 0; i < dirs.length; i++) {
-            if (i > 0) {
-                sb.append(';');
-            }
-            sb.append(dirs[i]);
-        }
-        return sb.toString();
+        return Stream.of(ds.getIncludedDirectories()).collect(Collectors.joining(";"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
index bc893d8..23ea205 100644
--- a/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
+++ b/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java
@@ -73,7 +73,7 @@ public abstract class EnumeratedAttribute {
             throw new BuildException(
                 "You have to provide a subclass from EnumeratedAttribut as clazz-parameter.");
         }
-        EnumeratedAttribute ea = null;
+        EnumeratedAttribute ea;
         try {
             ea = clazz.newInstance();
         } catch (Exception e) {
@@ -146,6 +146,7 @@ public abstract class EnumeratedAttribute {
      *
      * @return the string form of the value.
      */
+    @Override
     public String toString() {
         return getValue();
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/types/Environment.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/Environment.java b/src/main/org/apache/tools/ant/types/Environment.java
index 5bc6d79..3f33c74 100644
--- a/src/main/org/apache/tools/ant/types/Environment.java
+++ b/src/main/org/apache/tools/ant/types/Environment.java
@@ -115,9 +115,8 @@ public class Environment {
          */
         public String getContent() throws BuildException {
             validate();
-            StringBuffer sb = new StringBuffer(key.trim());
-            sb.append("=").append(value.trim());
-            return sb.toString();
+            return new StringBuilder(key.trim()).append("=")
+                .append(value.trim()).toString();
         }
 
         /**
@@ -126,8 +125,8 @@ public class Environment {
          */
         public void validate() {
             if (key == null || value == null) {
-                throw new BuildException("key and value must be specified "
-                    + "for environment variables.");
+                throw new BuildException(
+                    "key and value must be specified for environment variables.");
             }
         }
     }
@@ -136,7 +135,7 @@ public class Environment {
      * constructor
      */
     public Environment() {
-        variables = new Vector<Variable>();
+        variables = new Vector<>();
     }
 
     /**
@@ -155,14 +154,10 @@ public class Environment {
      * @throws BuildException if any variable is misconfigured
      */
     public String[] getVariables() throws BuildException {
-        if (variables.size() == 0) {
+        if (variables.isEmpty()) {
             return null;
         }
-        String[] result = new String[variables.size()];
-        for (int i = 0; i < result.length; i++) {
-            result[i] = ((Variable) variables.elementAt(i)).getContent();
-        }
-        return result;
+        return variables.stream().map(Variable::getContent).toArray(String[]::new);
     }
 
     /**


Mime
View raw message