You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mb...@apache.org on 2017/04/13 15:16:02 UTC

[02/34] ant git commit: java 5-8

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java b/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
index 4765268..374da29 100644
--- a/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
+++ b/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
@@ -26,7 +26,6 @@ import java.io.Reader;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.tools.ant.BuildException;
@@ -65,7 +64,7 @@ public abstract class ScriptRunnerBase {
     private ClassLoader scriptLoader;
 
     /** Beans to be provided to the script */
-    private Map beans = new HashMap();
+    private final Map<String,Object> beans = new HashMap<>();
 
     /**
      * Add a list of named objects to the list to be exported to the script
@@ -73,19 +72,17 @@ public abstract class ScriptRunnerBase {
      * @param dictionary a map of objects to be placed into the script context
      *        indexed by String names.
      */
-    public void addBeans(Map dictionary) {
-        for (Iterator i = dictionary.keySet().iterator(); i.hasNext();) {
-            String key = (String) i.next();
+    public void addBeans(Map<String,?> dictionary) {
+        dictionary.forEach((k, v) -> {
             try {
-                Object val = dictionary.get(key);
-                addBean(key, val);
+                addBean(k, v);
             } catch (BuildException ex) {
                 // The key is in the dictionary but cannot be retrieved
                 // This is usually due references that refer to tasks
                 // that have not been taskdefed in the current run.
                 // Ignore
             }
-        }
+        });
     }
 
     /**
@@ -101,7 +98,6 @@ public abstract class ScriptRunnerBase {
         for (int i = 1; isValid && i < key.length(); i++) {
             isValid = Character.isJavaIdentifierPart(key.charAt(i));
         }
-
         if (isValid) {
             beans.put(key, bean);
         }
@@ -111,7 +107,7 @@ public abstract class ScriptRunnerBase {
      * Get the beans used for the script.
      * @return the map of beans.
      */
-    protected Map getBeans() {
+    protected Map<String, Object> getBeans() {
         return beans;
     }
 
@@ -226,29 +222,15 @@ public abstract class ScriptRunnerBase {
      */
     public void setSrc(File file) {
         String filename = file.getPath();
-        if (!file.exists()) {
-            throw new BuildException("file " + filename + " not found.");
-        }
-
-        InputStream in = null;
-        try {
-            in = Files.newInputStream(file.toPath());
-        } catch (IOException e) {
-            //this can only happen if the file got deleted a short moment ago
-            throw new BuildException("file " + filename + " not found.");
-        }
 
-        final Charset charset;
-        if (null == encoding) {
-            charset = null;
-        } else {
-            charset = Charset.forName(encoding);
-        }
+        try (InputStream in = Files.newInputStream(file.toPath())) {
+            final Charset charset = null == encoding ? Charset.defaultCharset()
+                : Charset.forName(encoding);
 
-        try {
             readSource(in, filename, charset);
-        } finally {
-            FileUtils.close(in);
+        } catch (IOException e) {
+            //this can only happen if the file got deleted a short moment ago
+            throw new BuildException("file " + filename + " not found.", e);
         }
     }
 
@@ -259,19 +241,11 @@ public abstract class ScriptRunnerBase {
      * @param charset the encoding for the reader, may be null.
      */
     private void readSource(InputStream in, String name, Charset charset) {
-        Reader reader = null;
-        try {
-            if (null == charset) {
-                reader = new InputStreamReader(in);
-            } else {
-                reader = new InputStreamReader(in, charset);
-            }
-            reader = new BufferedReader(reader);
+        try (Reader reader =
+            new BufferedReader(new InputStreamReader(in, charset))) {
             script += FileUtils.safeReadFully(reader);
         } catch (IOException ex) {
             throw new BuildException("Failed to read " + name, ex);
-        } finally {
-            FileUtils.close(reader);
         }
     }
 
@@ -292,21 +266,14 @@ public abstract class ScriptRunnerBase {
         }
 
         String name = sourceResource.toLongString();
-        InputStream in = null;
-        try {
-            in = sourceResource.getInputStream();
+        try (InputStream in = sourceResource.getInputStream()) {
+            readSource(in, name, Charset.defaultCharset());
         } catch (IOException e) {
             throw new BuildException("Failed to open " + name, e);
         } catch (UnsupportedOperationException e) {
             throw new BuildException(
                 "Failed to open " + name + " - it is not readable", e);
         }
-
-        try {
-            readSource(in, name, (Charset) null);
-        } finally {
-            FileUtils.close(in);
-        }
     }
 
     /**
@@ -316,9 +283,7 @@ public abstract class ScriptRunnerBase {
      * @throws BuildException if a resource cannot be read
      */
     public void loadResources(ResourceCollection collection) {
-        for (Resource resource : collection) {
-            loadResource(resource);
-        }
+        collection.forEach(this::loadResource);
     }
 
     /**
@@ -394,8 +359,7 @@ public abstract class ScriptRunnerBase {
      */
     protected void checkLanguage() {
         if (language == null) {
-            throw new BuildException(
-                "script language must be specified");
+            throw new BuildException("script language must be specified");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/SourceFileScanner.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/SourceFileScanner.java b/src/main/org/apache/tools/ant/util/SourceFileScanner.java
index c79f034..879da84 100644
--- a/src/main/org/apache/tools/ant/util/SourceFileScanner.java
+++ b/src/main/org/apache/tools/ant/util/SourceFileScanner.java
@@ -19,7 +19,7 @@
 package org.apache.tools.ant.util;
 
 import java.io.File;
-import java.util.Vector;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.types.Resource;
@@ -90,28 +90,21 @@ public class SourceFileScanner implements ResourceFactory {
                              FileNameMapper mapper, long granularity) {
         // record destdir for later use in getResource
         this.destDir = destDir;
-        Vector v = new Vector();
-        for (int i = 0; i < files.length; i++) {
-            final String name = files[i];
-            v.addElement(new FileResource(srcDir, name) {
+
+        Resource[] sourceResources =
+            Stream.of(files).map(f -> new FileResource(srcDir, f) {
+                @Override
                 public String getName() {
-                    return name;
+                    return f;
                 }
-            });
-        }
-        Resource[] sourceresources = new Resource[v.size()];
-        v.copyInto(sourceresources);
+            }).toArray(Resource[]::new);        
 
         // build the list of sources which are out of date with
         // respect to the target
-        Resource[] outofdate =
-            ResourceUtils.selectOutOfDateSources(task, sourceresources,
-                                                 mapper, this, granularity);
-        String[] result = new String[outofdate.length];
-        for (int counter = 0; counter < outofdate.length; counter++) {
-            result[counter] = outofdate[counter].getName();
-        }
-        return result;
+        return Stream
+            .of(ResourceUtils.selectOutOfDateSources(task, sourceResources,
+                mapper, this, granularity))
+            .map(Resource::getName).toArray(String[]::new);
     }
 
     /**
@@ -150,12 +143,8 @@ public class SourceFileScanner implements ResourceFactory {
      */
     public File[] restrictAsFiles(String[] files, File srcDir, File destDir,
                                   FileNameMapper mapper, long granularity) {
-        String[] res = restrict(files, srcDir, destDir, mapper, granularity);
-        File[] result = new File[res.length];
-        for (int i = 0; i < res.length; i++) {
-            result[i] = new File(srcDir, res[i]);
-        }
-        return result;
+        return Stream.of(restrict(files, srcDir, destDir, mapper, granularity))
+            .map(name -> new File(srcDir, name)).toArray(File[]::new);
     }
 
     /**
@@ -165,6 +154,7 @@ public class SourceFileScanner implements ResourceFactory {
      *
      * @since Ant 1.5.2
      */
+    @Override
     public Resource getResource(String name) {
         return new FileResource(destDir, name);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 f48d3d3..f2b5232 100644
--- a/src/main/org/apache/tools/ant/util/SplitClassLoader.java
+++ b/src/main/org/apache/tools/ant/util/SplitClassLoader.java
@@ -42,9 +42,10 @@ public final class SplitClassLoader extends AntClassLoader {
 
     // forceLoadClass is not convenient here since it would not
     // properly deal with inner classes of these classes.
-    protected synchronized Class loadClass(String classname, boolean resolve)
+    @Override
+    protected synchronized Class<?> loadClass(String classname, boolean resolve)
         throws ClassNotFoundException {
-        Class theClass = findLoadedClass(classname);
+        Class<?> theClass = findLoadedClass(classname);
         if (theClass != null) {
             return theClass;
         }
@@ -54,9 +55,8 @@ public final class SplitClassLoader extends AntClassLoader {
                 resolveClass(theClass);
             }
             return theClass;
-        } else {
-            return super.loadClass(classname, resolve);
         }
+        return super.loadClass(classname, resolve);
     }
 
     private boolean isSplit(String classname) {

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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..5835335 100644
--- a/src/main/org/apache/tools/ant/util/StringTokenizer.java
+++ b/src/main/org/apache/tools/ant/util/StringTokenizer.java
@@ -96,8 +96,8 @@ public class StringTokenizer extends ProjectComponent implements Tokenizer {
         }
         boolean inToken = true;
         intraString = "";
-        StringBuffer word = new StringBuffer();
-        StringBuffer padding = new StringBuffer();
+        StringBuilder word = new StringBuilder();
+        StringBuilder padding = new StringBuilder();
         while (ch != -1) {
             char c = (char) ch;
             boolean isDelim = isDelim(c);
@@ -116,13 +116,11 @@ public class StringTokenizer extends ProjectComponent implements Tokenizer {
                 } else {
                     word.append(c);
                 }
+            } else if (isDelim) {
+                padding.append(c);
             } else {
-                if (isDelim) {
-                    padding.append(c);
-                } else {
-                    pushed = ch;
-                    break;
-                }
+                pushed = ch;
+                break;
             }
             ch = in.read();
         }
@@ -136,6 +134,7 @@ public class StringTokenizer extends ProjectComponent implements Tokenizer {
     /**
      * @return the intratoken string
      */
+    @Override
     public String getPostToken() {
         return suppressDelims || includeDelims ? "" : intraString;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/StringUtils.java b/src/main/org/apache/tools/ant/util/StringUtils.java
index 6ee9c45..93b4f90 100644
--- a/src/main/org/apache/tools/ant/util/StringUtils.java
+++ b/src/main/org/apache/tools/ant/util/StringUtils.java
@@ -152,7 +152,7 @@ public final class StringUtils {
      * @since Ant 1.7
      */
     public static String resolveBackSlash(String input) {
-        StringBuffer b = new StringBuffer();
+        StringBuilder b = new StringBuilder();
         boolean backSlashSeen = false;
         for (int i = 0; i < input.length(); ++i) {
             char c = input.charAt(i);
@@ -255,9 +255,8 @@ public final class StringUtils {
     public static String removeSuffix(String string, String suffix) {
         if (string.endsWith(suffix)) {
             return string.substring(0, string.length() - suffix.length());
-        } else {
-            return string;
         }
+        return string;
     }
 
     /**
@@ -270,9 +269,8 @@ public final class StringUtils {
     public static String removePrefix(String string, String prefix) {
         if (string.startsWith(prefix)) {
             return string.substring(prefix.length());
-        } else {
-            return string;
         }
+        return string;
     }
     
     /**
@@ -286,7 +284,8 @@ public final class StringUtils {
         if (collection == null) {
             return "";
         }
-        return collection.stream().map( o -> String.valueOf(o) ).collect(joining(separator));
+        return collection.stream().map(String::valueOf)
+            .collect(joining(separator));
     }
 
     /**
@@ -307,7 +306,6 @@ public final class StringUtils {
         return separator == null ? Collectors.joining() : Collectors.joining(separator);
     }
 
-
     /**
      * @param inputString String to trim
      * @return null if the input string is null or empty or contain only empty spaces.
@@ -315,16 +313,11 @@ public final class StringUtils {
      *
      */
     public static String trimToNull(String inputString) {
-
         if (inputString == null) {
             return null;
         }
-
-       String tmpString = inputString.trim();
-        if ("".equals(tmpString)) {
-            return null;
-        }
-        return tmpString;
+        String tmpString = inputString.trim();
+        return tmpString.isEmpty() ? null : tmpString;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java b/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
index 62b7a3f..37a74be 100644
--- a/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
+++ b/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
@@ -19,7 +19,6 @@ package org.apache.tools.ant.util;
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
 import java.io.IOException;
 
 import org.apache.tools.ant.BuildException;
@@ -176,11 +175,7 @@ public class SymbolicLinkUtils {
         final File f = new File(parent, name);
         if (!f.exists()) {
             final String localName = f.getName();
-            final String[] c = parent.list(new FilenameFilter() {
-                    public boolean accept(final File d, final String n) {
-                        return localName.equals(n);
-                    }
-                });
+            final String[] c = parent.list((d, n) -> localName.equals(n));
             return c != null && c.length > 0;
         }
         return false;

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/TeeOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/TeeOutputStream.java b/src/main/org/apache/tools/ant/util/TeeOutputStream.java
index eb8da3f..44c2f4a 100644
--- a/src/main/org/apache/tools/ant/util/TeeOutputStream.java
+++ b/src/main/org/apache/tools/ant/util/TeeOutputStream.java
@@ -43,6 +43,7 @@ public class TeeOutputStream extends OutputStream {
      * Close both output streams.
      * @throws IOException on error.
      */
+    @Override
     public void close() throws IOException {
         try {
             left.close();
@@ -55,6 +56,7 @@ public class TeeOutputStream extends OutputStream {
      * Flush both output streams.
      * @throws IOException on error
      */
+    @Override
     public void flush() throws IOException {
         left.flush();
         right.flush();
@@ -65,6 +67,7 @@ public class TeeOutputStream extends OutputStream {
      * @param b an array of bytes.
      * @throws IOException on error.
      */
+    @Override
     public void write(byte[] b) throws IOException {
         left.write(b);
         right.write(b);
@@ -77,6 +80,7 @@ public class TeeOutputStream extends OutputStream {
      * @param len   the number of bytes to write.
      * @throws IOException on error.
      */
+    @Override
     public void write(byte[] b, int off, int len) throws IOException {
         left.write(b, off, len);
         right.write(b, off, len);
@@ -87,9 +91,9 @@ public class TeeOutputStream extends OutputStream {
      * @param b the byte to write.
      * @throws IOException on error.
      */
+    @Override
     public void write(int b) throws IOException {
         left.write(b);
         right.write(b);
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/UnPackageNameMapper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/UnPackageNameMapper.java b/src/main/org/apache/tools/ant/util/UnPackageNameMapper.java
index 1777279..36c7e40 100644
--- a/src/main/org/apache/tools/ant/util/UnPackageNameMapper.java
+++ b/src/main/org/apache/tools/ant/util/UnPackageNameMapper.java
@@ -39,6 +39,7 @@ public class UnPackageNameMapper extends GlobPatternMapper {
      *@param  name  Source filename
      *@return       Replaced variable part
      */
+    @Override
     protected String extractVariablePart(String name) {
         String var = name.substring(prefixLength,
                 name.length() - postfixLength);

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/VectorSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/VectorSet.java b/src/main/org/apache/tools/ant/util/VectorSet.java
index db13129..f1665c7 100644
--- a/src/main/org/apache/tools/ant/util/VectorSet.java
+++ b/src/main/org/apache/tools/ant/util/VectorSet.java
@@ -42,9 +42,13 @@ public final class VectorSet<E> extends Vector<E> {
 
     private final HashSet<E> set = new HashSet<E>();
 
-    public VectorSet() { super(); }
+    public VectorSet() {
+        super();
+    }
 
-    public VectorSet(int initialCapacity) { super(initialCapacity); }
+    public VectorSet(int initialCapacity) {
+        super(initialCapacity);
+    }
 
     public VectorSet(int initialCapacity, int capacityIncrement) {
         super(initialCapacity, capacityIncrement);
@@ -52,12 +56,11 @@ public final class VectorSet<E> extends Vector<E> {
 
     public VectorSet(Collection<? extends E> c) {
         if (c != null) {
-            for (E e : c) {
-                add(e);
-            }
+            c.forEach(this::add);
         }
     }
 
+    @Override
     public synchronized boolean add(E o) {
         if (!set.contains(o)) {
             doAdd(size(), o);
@@ -70,6 +73,7 @@ public final class VectorSet<E> extends Vector<E> {
      * This implementation may not add the element at the given index
      * if it is already contained in the collection.
      */
+    @Override
     public void add(int index, E o) {
         doAdd(index, o);
     }
@@ -89,10 +93,12 @@ public final class VectorSet<E> extends Vector<E> {
         }
     }
 
+    @Override
     public synchronized void addElement(E o) {
         doAdd(size(), o);
     }
 
+    @Override
     public synchronized boolean addAll(Collection<? extends E> c) {
         boolean changed = false;
         for (E e : c) {
@@ -105,8 +111,9 @@ public final class VectorSet<E> extends Vector<E> {
      * This implementation may not add all elements at the given index
      * if any of them are already contained in the collection.
      */
+    @Override
     public synchronized boolean addAll(int index, Collection<? extends E> c) {
-        LinkedList toAdd = new LinkedList();
+        LinkedList<E> toAdd = new LinkedList<>();
         for (E e : c) {
             if (set.add(e)) {
                 toAdd.add(e);
@@ -128,36 +135,43 @@ public final class VectorSet<E> extends Vector<E> {
         return true;
     }
 
+    @Override
     public synchronized void clear() {
         super.clear();
         set.clear();
     }
 
-    public Object clone() {
+    @Override
+    public VectorSet<E> clone() {
         @SuppressWarnings("unchecked")
         final VectorSet<E> vs = (VectorSet<E>) super.clone();
         vs.set.addAll(set);
         return vs;
     }
 
+    @Override
     public synchronized boolean contains(Object o) {
         return set.contains(o);
     }
 
+    @Override
     public synchronized boolean containsAll(Collection<?> c) {
         return set.containsAll(c);
     }
 
+    @Override
     public void insertElementAt(E o, int index) {
         doAdd(index, o);
     }
 
+    @Override
     public synchronized E remove(int index) {
         E o = get(index);
         remove(o);
         return o;
     }
 
+    @Override
     public boolean remove(Object o) {
         return doRemove(o);
     }
@@ -177,6 +191,7 @@ public final class VectorSet<E> extends Vector<E> {
         return false;
     }
 
+    @Override
     public synchronized boolean removeAll(Collection<?> c) {
         boolean changed = false;
         for (Object o : c) {
@@ -185,30 +200,35 @@ public final class VectorSet<E> extends Vector<E> {
         return changed;
     }
 
+    @Override
     public synchronized void removeAllElements() {
         set.clear();
         super.removeAllElements();
     }
 
+    @Override
     public boolean removeElement(Object o) {
         return doRemove(o);
     }
 
+    @Override
     public synchronized void removeElementAt(int index) {
         remove(get(index));
     }
 
+    @Override
     public synchronized void removeRange(final int fromIndex, int toIndex) {
         while (toIndex > fromIndex) {
             remove(--toIndex);
         }
     }
 
+    @Override
     public synchronized boolean retainAll(Collection<?> c) {
         if (!(c instanceof Set)) {
-            c = new HashSet<Object>(c);
+            c = new HashSet<>(c);
         }
-        LinkedList<E> l = new LinkedList<E>();
+        LinkedList<E> l = new LinkedList<>();
         for (E o : this) {
             if (!c.contains(o)) {
                 l.addLast(o);
@@ -221,6 +241,7 @@ public final class VectorSet<E> extends Vector<E> {
         return false;
     }
 
+    @Override
     public synchronized E set(int index, E o) {
         E orig = get(index);
         if (set.add(o)) {
@@ -235,6 +256,7 @@ public final class VectorSet<E> extends Vector<E> {
         return orig;
     }
 
+    @Override
     public void setElementAt(E o, int index) {
         set(index, o);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/Watchdog.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/Watchdog.java b/src/main/org/apache/tools/ant/util/Watchdog.java
index 318b526..67ebce6 100644
--- a/src/main/org/apache/tools/ant/util/Watchdog.java
+++ b/src/main/org/apache/tools/ant/util/Watchdog.java
@@ -18,8 +18,9 @@
 
 package org.apache.tools.ant.util;
 
-import java.util.Enumeration;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * Generalization of <code>ExecuteWatchdog</code>
@@ -31,18 +32,21 @@ import java.util.Vector;
  */
 public class Watchdog implements Runnable {
 
-    private Vector observers = new Vector(1);
+    /**
+     * Error string.
+     * {@value}
+     */
+    public static final String ERROR_INVALID_TIMEOUT = "timeout less than 1.";
+
+    private List<TimeoutObserver> observers =
+        Collections.synchronizedList(new ArrayList<>(1));
     private long timeout = -1;
+
     /**
      * marked as volatile to stop the compiler caching values or (in java1.5+,
      * reordering access)
      */
     private volatile boolean stopped = false;
-    /**
-     * Error string.
-     * {@value}
-     */
-    public static final String ERROR_INVALID_TIMEOUT = "timeout less than 1.";
 
     /**
      * Constructor for Watchdog.
@@ -60,8 +64,7 @@ public class Watchdog implements Runnable {
      * @param to the timeout observer to add.
      */
     public void addTimeoutObserver(TimeoutObserver to) {
-        //no need to synchronize, as Vector is always synchronized
-        observers.addElement(to);
+        observers.add(to);
     }
 
     /**
@@ -69,8 +72,7 @@ public class Watchdog implements Runnable {
      * @param to the timeout observer to remove.
      */
     public void removeTimeoutObserver(TimeoutObserver to) {
-        //no need to synchronize, as Vector is always synchronized
-        observers.removeElement(to);
+        observers.remove(to);
     }
 
     /**
@@ -78,10 +80,7 @@ public class Watchdog implements Runnable {
      * This happens in the watchdog thread.
      */
     protected final void fireTimeoutOccured() {
-        Enumeration e = observers.elements();
-        while (e.hasMoreElements()) {
-            ((TimeoutObserver) e.nextElement()).timeoutOccured(this);
-        }
+        observers.forEach(o -> o.timeoutOccured(this));
     }
 
     /**
@@ -108,6 +107,7 @@ public class Watchdog implements Runnable {
      * if the stop flag has not been set when the wait has returned or
      * has been interrupted, the watch dog listeners are informed.
      */
+    @Override
     public synchronized void run() {
         long now = System.currentTimeMillis();
         final long until = now + timeout;

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 92f322f..1c00102 100644
--- a/src/main/org/apache/tools/ant/util/WeakishReference.java
+++ b/src/main/org/apache/tools/ant/util/WeakishReference.java
@@ -34,6 +34,7 @@ import java.lang.ref.WeakReference;
  * @deprecated deprecated 1.7; will be removed in Ant1.8
  *             Just use {@link java.lang.ref.WeakReference} directly.
  */
+@Deprecated
 public class WeakishReference  {
 
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/XMLFragment.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/XMLFragment.java b/src/main/org/apache/tools/ant/util/XMLFragment.java
index 36a6158..3fe5ddd 100644
--- a/src/main/org/apache/tools/ant/util/XMLFragment.java
+++ b/src/main/org/apache/tools/ant/util/XMLFragment.java
@@ -74,9 +74,10 @@ public class XMLFragment extends ProjectComponent implements DynamicElementNS {
      * @param qName the qualified name of the nested element
      * @return an object that the element is applied to
      */
+    @Override
     public Object createDynamicElement(String uri, String name, String qName) {
-        Element e = null;
-        if (uri.equals("")) {
+        Element e;
+        if ("".equals(uri)) {
             e = doc.createElement(name);
         } else {
             e = doc.createElementNS(uri, qName);
@@ -93,7 +94,7 @@ public class XMLFragment extends ProjectComponent implements DynamicElementNS {
     private void addText(Node n, String s) {
         s = getProject().replaceProperties(s);
         //only text nodes that are non null after property expansion are added
-        if (s != null && !s.trim().equals("")) {
+        if (s != null && !s.trim().isEmpty()) {
             Text t = doc.createTextNode(s.trim());
             n.appendChild(t);
         }
@@ -124,9 +125,10 @@ public class XMLFragment extends ProjectComponent implements DynamicElementNS {
          * @param qName the qualified name of the attribute
          * @param value the value of the attribute
          */
+        @Override
         public void setDynamicAttribute(
             String uri, String name, String qName, String value) {
-            if (uri.equals("")) {
+            if ("".equals(uri)) {
                 e.setAttribute(name, value);
             } else {
                 e.setAttributeNS(uri, qName, value);
@@ -140,9 +142,10 @@ public class XMLFragment extends ProjectComponent implements DynamicElementNS {
          * @param qName the qualified name of the nested element
          * @return an object that the element is applied to
          */
+        @Override
         public Object createDynamicElement(String uri, String name, String qName) {
             Element e2 = null;
-            if (uri.equals("")) {
+            if ("".equals(uri)) {
                 e2 = doc.createElement(name);
             } else {
                 e2 = doc.createElementNS(uri, qName);

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/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 b05ed1f..3ec4146 100644
--- a/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
+++ b/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
@@ -42,7 +42,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
     private Path classPath = new Path(null);
 
     /** The list of root classes */
-    private final Vector<String> rootClasses = new VectorSet<String>();
+    private final Vector<String> rootClasses = new VectorSet<>();
 
     /** true if dependencies have been determined */
     private boolean determined = false;
@@ -68,6 +68,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      * @param closure true if dependencies should be traversed to determine
      *      indirect dependencies.
      */
+    @Override
     public void setClosure(boolean closure) {
         this.closure = closure;
     }
@@ -79,10 +80,11 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      *
      * @return an enumeration of File instances.
      */
+    @Override
     public Enumeration<File> getFileDependencies() {
         if (!supportsFileDependencies()) {
-            throw new BuildException("File dependencies are not supported "
-                + "by this analyzer");
+            throw new BuildException(
+                "File dependencies are not supported by this analyzer");
         }
         if (!determined) {
             determineDependencies(fileDependencies, classDependencies);
@@ -97,6 +99,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      * @return an enumeration of Strings, each being the name of a Java
      *      class in dot notation.
      */
+    @Override
     public Enumeration<String> getClassDependencies() {
         if (!determined) {
             determineDependencies(fileDependencies, classDependencies);
@@ -112,6 +115,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      *         class or null if the class could not be found.
      * @exception IOException if the files in the classpath cannot be read.
      */
+    @Override
     public File getClassContainer(String classname) throws IOException {
         String classLocation = classname.replace('.', '/') + ".class";
         // we look through the classpath elements. If the element is a dir
@@ -127,6 +131,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      *         source or null if the source for the class could not be found.
      * @exception IOException if the files in the sourcepath cannot be read.
      */
+    @Override
     public File getSourceContainer(String classname) throws IOException {
         String sourceLocation = classname.replace('.', '/') + ".java";
 
@@ -144,6 +149,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      * @param sourcePath The Path instance specifying the source path
      *      elements.
      */
+    @Override
     public void addSourcePath(Path sourcePath) {
         if (sourcePath == null) {
             return;
@@ -160,6 +166,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      *
      * @param classPath the Path instance specifying the classpath elements
      */
+    @Override
     public void addClassPath(Path classPath) {
         if (classPath == null) {
             return;
@@ -176,6 +183,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      *
      * @param className the name of the class in Java dot notation.
      */
+    @Override
     public void addRootClass(String className) {
         if (className == null) {
             return;
@@ -192,6 +200,7 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      * @param name the name of the aspect being configured
      * @param info the configuration info.
      */
+    @Override
     public void config(String name, Object info) {
         // do nothing by default
     }
@@ -200,11 +209,12 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer {
      * Reset the dependency list. This will reset the determined
      * dependencies and the also list of root classes.
      */
+    @Override
     public void reset() {
         rootClasses.removeAllElements();
         determined = false;
-        fileDependencies = new Vector<File>();
-        classDependencies = new Vector<String>();
+        fileDependencies = new Vector<>();
+        classDependencies = new Vector<>();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java b/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
index 613bc77..fa2e9ee 100644
--- a/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
+++ b/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
@@ -19,8 +19,10 @@ package org.apache.tools.ant.util.depend.bcel;
 import java.io.File;
 import java.io.IOException;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.Vector;
+
 import org.apache.bcel.classfile.ClassParser;
 import org.apache.bcel.classfile.JavaClass;
 import org.apache.tools.ant.BuildException;
@@ -61,33 +63,33 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
      * @param classes a vector to be populated with the names of the
      *      dependency classes.
      */
+    @Override
     protected void determineDependencies(Vector<File> files, Vector<String> classes) {
         // we get the root classes and build up a set of
         // classes upon which they depend
-        Hashtable<String, String> dependencies = new Hashtable<String, String>();
-        Hashtable<File, File> containers = new Hashtable<File, File>();
-        Hashtable<String, String> toAnalyze = new Hashtable<String, String>();
-        Hashtable<String, String> nextAnalyze = new Hashtable<String, String>();
+        Set<String> dependencies = new HashSet<>();
+        Set<File> containers = new HashSet<>();
+        Set<String> toAnalyze = new HashSet<>();
+        Set<String> nextAnalyze = new HashSet<>();
 
         for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) {
-            String classname = e.nextElement();
-            toAnalyze.put(classname, classname);
+            toAnalyze.add(e.nextElement());
         }
 
         int count = 0;
         int maxCount = isClosureRequired() ? MAX_LOOPS : 2;
-        while (toAnalyze.size() != 0 && count++ < maxCount) {
+        while (!toAnalyze.isEmpty() && count++ < maxCount) {
             nextAnalyze.clear();
-            for (String classname : toAnalyze.keySet()) {
-                dependencies.put(classname, classname);
+            for (String classname : toAnalyze) {
+                dependencies.add(classname);
                 try {
                     File container = getClassContainer(classname);
                     if (container == null) {
                         continue;
                     }
-                    containers.put(container, container);
+                    containers.add(container);
 
-                    ClassParser parser = null;
+                    ClassParser parser;
                     if (container.getName().endsWith(".class")) {
                         parser = new ClassParser(container.getPath());
                     } else {
@@ -96,18 +98,16 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
                     }
 
                     JavaClass javaClass = parser.parse();
-                    String[] interfaces = javaClass.getInterfaceNames();
-                    for (int i = 0; i < interfaces.length; ++i) {
-                        String interfaceName = interfaces[i];
-                        if (!dependencies.containsKey(interfaceName)) {
-                            nextAnalyze.put(interfaceName, interfaceName);
+                    for (String interfaceName : javaClass.getInterfaceNames()) {
+                        if (!dependencies.contains(interfaceName)) {
+                            nextAnalyze.add(interfaceName);
                         }
                     }
 
                     if (javaClass.isClass()) {
                         String superClass = javaClass.getSuperclassName();
-                        if (!dependencies.containsKey(superClass)) {
-                            nextAnalyze.put(superClass, superClass);
+                        if (!dependencies.contains(superClass)) {
+                            nextAnalyze.add(superClass);
                         }
                     }
                 } catch (IOException ioe) {
@@ -115,20 +115,16 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
                 }
             }
 
-            Hashtable<String, String> temp = toAnalyze;
+            Set<String> temp = toAnalyze;
             toAnalyze = nextAnalyze;
             nextAnalyze = temp;
         }
 
-        files.removeAllElements();
-        for (File f : containers.keySet()) {
-            files.add(f);
-        }
+        files.clear();
+        files.addAll(containers);
 
-        classes.removeAllElements();
-        for (String dependency : dependencies.keySet()) {
-            classes.add(dependency);
-        }
+        classes.clear();
+        classes.addAll(dependencies);
     }
 
     /**
@@ -136,6 +132,7 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
      *
      * @return true if the analyzer provides dependency file information.
      */
+    @Override
     protected boolean supportsFileDependencies() {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java b/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java
index d31d453..45be038 100644
--- a/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java
+++ b/src/main/org/apache/tools/ant/util/depend/bcel/DependencyVisitor.java
@@ -17,8 +17,10 @@
  */
 package org.apache.tools.ant.util.depend.bcel;
 
+import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import org.apache.bcel.classfile.ConstantClass;
@@ -35,7 +37,7 @@ import org.apache.bcel.classfile.Method;
  */
 public class DependencyVisitor extends EmptyVisitor {
     /** The collected dependencies */
-    private final Hashtable<String, String> dependencies = new Hashtable<String, String>();
+    private final Set<String> dependencies = new HashSet<>();
     /**
      * The current class's constant pool - used to determine class names
      * from class references.
@@ -49,7 +51,7 @@ public class DependencyVisitor extends EmptyVisitor {
      *      visited classes depend.
      */
     public Enumeration<String> getDependencies() {
-        return dependencies.keys();
+        return Collections.enumeration(dependencies);
     }
 
     /** Clear the current set of collected dependencies. */
@@ -62,6 +64,7 @@ public class DependencyVisitor extends EmptyVisitor {
      *
      * @param constantPool the constant pool of the class being visited.
      */
+    @Override
     public void visitConstantPool(final ConstantPool constantPool) {
         this.constantPool = constantPool;
     }
@@ -71,6 +74,7 @@ public class DependencyVisitor extends EmptyVisitor {
      *
      * @param constantClass the constantClass entry for the class reference
      */
+    @Override
     public void visitConstantClass(final ConstantClass constantClass) {
         final String classname
              = constantClass.getConstantValue(constantPool).toString();
@@ -84,18 +88,19 @@ public class DependencyVisitor extends EmptyVisitor {
      *
      * @param obj the name and type reference being visited.
      */
+    @Override
     public void visitConstantNameAndType(final ConstantNameAndType obj) {
         final String name = obj.getName(constantPool);
-        if (obj.getSignature(constantPool).equals("Ljava/lang/Class;")
+        if ("Ljava/lang/Class;".equals(obj.getSignature(constantPool))
                 && name.startsWith("class$")) {
             String classname
                 = name.substring("class$".length()).replace('$', '.');
             // does the class have a package structure
-            final int index = classname.lastIndexOf(".");
+            final int index = classname.lastIndexOf('.');
             if (index > 0) {
                 char start;
                 // check if the package structure is more than 1 level deep
-                final int index2 = classname.lastIndexOf(".", index - 1);
+                final int index2 = classname.lastIndexOf('.', index - 1);
                 if (index2 != -1) {
                     // class name has more than 1 package level 'com.company.Class'
                     start = classname.charAt(index2 + 1);
@@ -128,6 +133,7 @@ public class DependencyVisitor extends EmptyVisitor {
      *
      * @param field the field being visited
      */
+    @Override
     public void visitField(final Field field) {
         addClasses(field.getSignature());
     }
@@ -137,6 +143,7 @@ public class DependencyVisitor extends EmptyVisitor {
      *
      * @param javaClass the class being visited.
      */
+    @Override
     public void visitJavaClass(final JavaClass javaClass) {
         addClass(javaClass.getClassName());
     }
@@ -146,9 +153,10 @@ public class DependencyVisitor extends EmptyVisitor {
      *
      * @param method the method being visited.
      */
+    @Override
     public void visitMethod(final Method method) {
         final String signature = method.getSignature();
-        final int pos = signature.indexOf(")");
+        final int pos = signature.indexOf(')');
         addClasses(signature.substring(1, pos));
         addClasses(signature.substring(pos + 1));
     }
@@ -159,7 +167,7 @@ public class DependencyVisitor extends EmptyVisitor {
      * @param classname the class to be added to the list of dependencies.
      */
     void addClass(final String classname) {
-        dependencies.put(classname, classname);
+        dependencies.add(classname);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java b/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
index 3bd6c75..0c6af25 100644
--- a/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
+++ b/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
@@ -18,9 +18,12 @@
 package org.apache.tools.ant.util.depend.bcel;
 import java.io.File;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.Vector;
+
 import org.apache.bcel.classfile.ClassParser;
 import org.apache.bcel.classfile.DescendingVisitor;
 import org.apache.bcel.classfile.JavaClass;
@@ -60,31 +63,28 @@ public class FullAnalyzer extends AbstractAnalyzer {
      * @param classes a vector to be populated with the names of the
      *      dependency classes.
      */
+    @Override
     protected void determineDependencies(Vector<File> files, Vector<String> classes) {
         // we get the root classes and build up a set of
         // classes upon which they depend
-        Hashtable<String, String> dependencies = new Hashtable<String, String>();
-        Hashtable<File, File> containers = new Hashtable<File, File>();
-        Hashtable<String, String> toAnalyze = new Hashtable<String, String>();
-        for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) {
-            String classname = e.nextElement();
-            toAnalyze.put(classname, classname);
-        }
+        Set<String> dependencies = new HashSet<>();
+        Set<File> containers = new HashSet<>();
+        Set<String> toAnalyze = new HashSet<>(Collections.list(getRootClasses()));
 
         int count = 0;
         int maxCount = isClosureRequired() ? MAX_LOOPS : 2;
-        while (toAnalyze.size() != 0 && count++ < maxCount) {
+        while (!toAnalyze.isEmpty() && count++ < maxCount) {
             DependencyVisitor dependencyVisitor = new DependencyVisitor();
-            for (String classname : toAnalyze.keySet()) {
-                dependencies.put(classname, classname);
+            for (String classname : toAnalyze) {
+                dependencies.add(classname);
                 try {
                     File container = getClassContainer(classname);
                     if (container == null) {
                         continue;
                     }
-                    containers.put(container, container);
+                    containers.add(container);
 
-                    ClassParser parser = null;
+                    ClassParser parser;
                     if (container.getName().endsWith(".class")) {
                         parser = new ClassParser(container.getPath());
                     } else {
@@ -107,21 +107,17 @@ public class FullAnalyzer extends AbstractAnalyzer {
             Enumeration<String> depsEnum = dependencyVisitor.getDependencies();
             while (depsEnum.hasMoreElements()) {
                 String className = depsEnum.nextElement();
-                if (!dependencies.containsKey(className)) {
-                    toAnalyze.put(className, className);
+                if (!dependencies.contains(className)) {
+                    toAnalyze.add(className);
                 }
             }
         }
 
-        files.removeAllElements();
-        for (File f : containers.keySet()) {
-            files.add(f);
-        }
+        files.clear();
+        files.addAll(containers);
 
-        classes.removeAllElements();
-        for (String dependency : dependencies.keySet()) {
-            classes.add(dependency);
-        }
+        classes.clear();
+        classes.addAll(dependencies);
     }
 
     /**
@@ -129,6 +125,7 @@ public class FullAnalyzer extends AbstractAnalyzer {
      *
      * @return true if the analyzer provides dependency file information.
      */
+    @Override
     protected boolean supportsFileDependencies() {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java b/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
index 4fb4341..dd05c4b 100644
--- a/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
+++ b/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
@@ -20,6 +20,8 @@ package org.apache.tools.ant.util.facade;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
@@ -37,7 +39,7 @@ public class FacadeTaskHelper {
     /**
      * Command line arguments.
      */
-    private List<ImplementationSpecificArgument> args = new ArrayList<ImplementationSpecificArgument>();
+    private List<ImplementationSpecificArgument> args = new ArrayList<>();
 
     /**
      * The explicitly chosen implementation.
@@ -126,17 +128,10 @@ public class FacadeTaskHelper {
      * @return an array of command line arguments.
      */
     public String[] getArgs() {
-        List<String> tmp = new ArrayList<String>(args.size());
-        for (ImplementationSpecificArgument arg : args) {
-            String[] curr = arg.getParts(getImplementation());
-            if (curr != null) {
-                for (int i = 0; i < curr.length; i++) {
-                    tmp.add(curr[i]);
-                }
-            }
-        }
-        String[] res = new String[tmp.size()];
-        return (String[]) tmp.toArray(res);
+        String implementation = getImplementation();
+        return args.stream().map(arg -> arg.getParts(implementation))
+            .filter(Objects::nonNull).flatMap(Stream::of)
+            .toArray(String[]::new);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java b/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java
index ba7f14a..4af7f34 100644
--- a/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java
+++ b/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java
@@ -30,11 +30,6 @@ import org.apache.tools.ant.types.Commandline;
 public class ImplementationSpecificArgument extends Commandline.Argument {
     private String impl;
 
-    /** Constructor for ImplementationSpecificArgument. */
-    public ImplementationSpecificArgument() {
-        super();
-    }
-
     /**
      * Set the implementation this argument is for.
      * @param impl the implementation this command line argument is for.
@@ -54,8 +49,7 @@ public class ImplementationSpecificArgument extends Commandline.Argument {
     public final String[] getParts(String chosenImpl) {
         if (impl == null || impl.equals(chosenImpl)) {
             return super.getParts();
-        } else {
-            return new String[0];
         }
+        return new String[0];
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java b/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java
index e7412d6..97022ff 100644
--- a/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java
+++ b/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java
@@ -25,8 +25,6 @@ import java.net.ProxySelector;
 import java.net.SocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Iterator;
-import java.util.List;
 
 import org.apache.tools.ant.BuildException;
 
@@ -40,8 +38,6 @@ import org.apache.tools.ant.BuildException;
  */
 public class ProxyDiagnostics {
 
-    private String destination;
-
     private URI destURI;
 
     /** {@value} */
@@ -53,7 +49,6 @@ public class ProxyDiagnostics {
      * @throws BuildException if the URI is malformed.
      */
     public ProxyDiagnostics(String destination) {
-        this.destination = destination;
         try {
             this.destURI = new URI(destination);
         } catch (URISyntaxException e) {
@@ -73,35 +68,33 @@ public class ProxyDiagnostics {
      * Get the diagnostics for proxy information.
      * @return the information.
      */
+    @Override
     public String toString() {
         ProxySelector selector = ProxySelector.getDefault();
-        List list = selector.select(destURI);
-        StringBuffer result = new StringBuffer();
-        Iterator proxies = list.listIterator();
-        while (proxies.hasNext()) {
-            Proxy proxy = (Proxy) proxies.next();
+        StringBuilder result = new StringBuilder();
+        for (Proxy proxy : selector.select(destURI)) {
             SocketAddress address = proxy.address();
             if (address == null) {
                 result.append("Direct connection\n");
-            } else {
-                result.append(proxy.toString());
-                if (address instanceof InetSocketAddress) {
-                    InetSocketAddress ina = (InetSocketAddress) address;
-                    result.append(' ');
-                    result.append(ina.getHostName());
-                    result.append(':');
-                    result.append(ina.getPort());
-                    if (ina.isUnresolved()) {
-                        result.append(" [unresolved]");
-                    } else {
-                        InetAddress addr = ina.getAddress();
-                        result.append(" [");
-                        result.append(addr.getHostAddress());
-                        result.append(']');
-                    }
+                continue;
+            }
+            result.append(proxy);
+            if (address instanceof InetSocketAddress) {
+                InetSocketAddress ina = (InetSocketAddress) address;
+                result.append(' ');
+                result.append(ina.getHostName());
+                result.append(':');
+                result.append(ina.getPort());
+                if (ina.isUnresolved()) {
+                    result.append(" [unresolved]");
+                } else {
+                    InetAddress addr = ina.getAddress();
+                    result.append(" [");
+                    result.append(addr.getHostAddress());
+                    result.append(']');
                 }
-                result.append('\n');
             }
+            result.append('\n');
         }
         return result.toString();
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
index 997af7a..4676ab5 100644
--- a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
+++ b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
@@ -18,12 +18,21 @@
 
 package org.apache.tools.ant.util.optional;
 
-import java.util.Iterator;
+import java.util.function.BiConsumer;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import javax.script.Bindings;
+import javax.script.Compilable;
+import javax.script.CompiledScript;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.SimpleBindings;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.util.ReflectWrapper;
 import org.apache.tools.ant.util.ScriptRunnerBase;
 
 /**
@@ -31,20 +40,22 @@ import org.apache.tools.ant.util.ScriptRunnerBase;
  * @since Ant 1.7.0
  */
 public class JavaxScriptRunner extends ScriptRunnerBase {
-    private ReflectWrapper engine;
-    private ReflectWrapper compiledScript;
+    private ScriptEngine keptEngine;
+    private CompiledScript compiledScript;
 
     /**
      * Get the name of the manager prefix.
      * @return "javax"
      */
+    @Override
     public String getManagerName() {
         return "javax";
     }
 
     /** {@inheritDoc}. */
+    @Override
     public boolean supportsLanguage() {
-        if (engine != null) {
+        if (keptEngine != null) {
             return true;
         }
         checkLanguage();
@@ -66,6 +77,7 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
      *
      * @exception BuildException if something goes wrong executing the script.
      */
+    @Override
     public void executeScript(String execName) throws BuildException {
         evaluateScript(execName);
     }
@@ -82,70 +94,60 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
         checkLanguage();
         ClassLoader origLoader = replaceContextLoader();
         try {
-
             if (getCompiled()) {
-
-                final String compiledScriptRefName = MagicNames.SCRIPT_CACHE + "." + getLanguage() +
-                    "." + getScript().hashCode() + "." +
-                    (null == getClass().getClassLoader() ? 0 : getClass().getClassLoader().hashCode());
+                final String compiledScriptRefName =
+                    String.format("%s.%s.%d.%d", MagicNames.SCRIPT_CACHE,
+                        getLanguage(), Objects.hashCode(getScript()),
+                        Objects.hashCode(getClass().getClassLoader()));
 
                 if (null == compiledScript) {
                     compiledScript = getProject().getReference(compiledScriptRefName);
                 }
-
                 if (null == compiledScript) {
-
-                    final ReflectWrapper engine = createEngine();
+                    final ScriptEngine engine = createEngine();
                     if (engine == null) {
                         throw new BuildException(
-                            "Unable to create javax script engine for "
-                            + getLanguage());
+                            "Unable to create javax script engine for %s",
+                            getLanguage());
                     }
+                    if (Compilable.class.isInstance(engine)) {
+                        getProject().log("compile script " + execName,
+                            Project.MSG_VERBOSE);
 
-                    final Class engineClass = Class.forName("javax.script.ScriptEngine", true, getClass().getClassLoader());
-                    final Class compilableClass = Class.forName("javax.script.Compilable", true, getClass().getClassLoader());
-                    final Object wrappedObject = engine.getObject();
-
-                    if (engineClass.isAssignableFrom(wrappedObject.getClass()) &&
-                        compilableClass.isAssignableFrom(wrappedObject.getClass())) {
-
-                        getProject().log("compile script " + execName, Project.MSG_VERBOSE);
-
-                        final Object compiled = engine.invoke("compile", String.class, getScript());
-                        compiledScript = new ReflectWrapper(compiled);
-
+                        compiledScript =
+                            ((Compilable) engine).compile(getScript());
                     } else {
-                        getProject().log("script compilation not available for " + execName, Project.MSG_VERBOSE);
-                        compiledScript = new ReflectWrapper(null);
+                        getProject().log(
+                            "script compilation not available for " + execName,
+                            Project.MSG_VERBOSE);
+                        compiledScript = null;
                     }
-                    getProject().addReference(compiledScriptRefName, compiledScript);
+                    getProject().addReference(compiledScriptRefName,
+                        compiledScript);
                 }
+                if (null != compiledScript) {
+                    final Bindings bindings = new SimpleBindings();
 
-                if (null != compiledScript.getObject()) {
-
-                    final ReflectWrapper simpleBindings = new ReflectWrapper(getClass().getClassLoader(), "javax.script.SimpleBindings");
-
-                    applyBindings(simpleBindings);
-
-                    getProject().log("run compiled script " + compiledScriptRefName, Project.MSG_DEBUG);
+                    applyBindings(bindings::put);
 
-                    final Class bindingsClass  = Class.forName("javax.script.Bindings", true, getClass().getClassLoader());
+                    getProject().log(
+                        "run compiled script " + compiledScriptRefName,
+                        Project.MSG_DEBUG);
 
-                    return compiledScript.invoke("eval", bindingsClass, simpleBindings.getObject());
+                    return compiledScript.eval(bindings);
                 }
             }
 
-            ReflectWrapper engine = createEngine();
+            ScriptEngine engine = createEngine();
             if (engine == null) {
                 throw new BuildException(
                     "Unable to create javax script engine for "
-                    + getLanguage());
+                        + getLanguage());
             }
 
-            applyBindings(engine);
+            applyBindings(engine::put);
 
-            // execute the script
-            return engine.invoke("eval", String.class, getScript());
+            return engine.eval(getScript());
 
         } catch (BuildException be) {
             //catch and rethrow build exceptions
@@ -160,7 +162,7 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
             Throwable t = be;
             Throwable te = be.getCause();
             if (te != null) {
-                if  (te instanceof BuildException) {
+                if (te instanceof BuildException) {
                     throw (BuildException) te;
                 } else {
                     t = te;
@@ -172,33 +174,29 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
         }
     }
 
-    private void applyBindings(ReflectWrapper engine) {
-        for (Iterator i = getBeans().keySet().iterator(); i.hasNext();) {
-            String key = (String) i.next();
-            Object value = getBeans().get(key);
-            if ("FX".equalsIgnoreCase(getLanguage())) {
-                key += ":" + value.getClass().getName(); 
-            }
-            engine.invoke("put", String.class, key, Object.class, value);
+    private void applyBindings(BiConsumer<String, Object> target) {
+        Map<String, Object> source = getBeans();
+
+        if ("FX".equalsIgnoreCase(getLanguage())) {
+            source = source.entrySet().stream()
+                .collect(Collectors.toMap(
+                    e -> String.format("%s:%s", e.getKey(),
+                        e.getValue().getClass().getName()),
+                    Map.Entry::getValue));
         }
+        source.forEach(target::accept);
     }
 
-    private ReflectWrapper createEngine() {
-        if (engine != null) {
-            return engine;
-        }
-        ReflectWrapper manager = new ReflectWrapper(
-            getClass().getClassLoader(), "javax.script.ScriptEngineManager");
-        Object e = manager.invoke(
-            "getEngineByName", String.class, getLanguage());
-        if (e == null) {
-            return null;
+    private ScriptEngine createEngine() {
+        if (keptEngine != null) {
+            return keptEngine;
         }
-        ReflectWrapper ret = new ReflectWrapper(e);
-        if (getKeepEngine()) {
-            this.engine = ret;
+        ScriptEngine result =
+            new ScriptEngineManager().getEngineByName(getLanguage());
+        if (result != null && getKeepEngine()) {
+            this.keptEngine = result;
         }
-        return ret;
+        return result;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/optional/NoExitSecurityManager.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/optional/NoExitSecurityManager.java b/src/main/org/apache/tools/ant/util/optional/NoExitSecurityManager.java
index e704ab2..f1ccac8 100644
--- a/src/main/org/apache/tools/ant/util/optional/NoExitSecurityManager.java
+++ b/src/main/org/apache/tools/ant/util/optional/NoExitSecurityManager.java
@@ -36,6 +36,7 @@ public class NoExitSecurityManager extends SecurityManager {
      * This throws an ExitException(status) exception.
      * @param status the exit status
      */
+    @Override
     public void checkExit(int status) {
         throw new ExitException(status);
     }
@@ -45,6 +46,7 @@ public class NoExitSecurityManager extends SecurityManager {
      * This does nothing.
      * @param perm the requested permission.
      */
+    @Override
     public void checkPermission(Permission perm) {
         // no permission here
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java b/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java
index 0f4cd1f..39439ae 100644
--- a/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java
+++ b/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java
@@ -17,8 +17,7 @@
  */
 package org.apache.tools.ant.util.optional;
 
-import java.util.Hashtable;
-import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.bsf.BSFEngine;
 import org.apache.bsf.BSFException;
@@ -49,6 +48,7 @@ public class ScriptRunner extends ScriptRunnerBase {
      * Get the name of the manager prefix.
      * @return "bsf"
      */
+    @Override
     public String getManagerName() {
         return "bsf";
     }
@@ -57,10 +57,11 @@ public class ScriptRunner extends ScriptRunnerBase {
      * Check if bsf supports the language.
      * @return true if bsf can create an engine for this language.
      */
+    @Override
     public boolean supportsLanguage() {
-        Hashtable table = (Hashtable) ReflectUtil.getField(
-            new BSFManager(), "registeredEngines");
-        String engineClassName = (String) table.get(getLanguage());
+        Map<String, String> table =
+            ReflectUtil.getField(new BSFManager(), "registeredEngines");
+        String engineClassName = table.get(getLanguage());
         if (engineClassName == null) {
             getProject().log(
                 "This is no BSF engine class for language '"
@@ -87,6 +88,7 @@ public class ScriptRunner extends ScriptRunnerBase {
      * @param execName the name that will be passed to BSF for this script execution.
      * @exception BuildException if something goes wrong executing the script.
      */
+    @Override
     public void executeScript(String execName) throws BuildException {
         checkLanguage();
         ClassLoader origLoader = replaceContextLoader();
@@ -113,6 +115,7 @@ public class ScriptRunner extends ScriptRunnerBase {
      * @return the result of the evaluation
      * @exception BuildException if something goes wrong executing the script.
      */
+    @Override
     public Object evaluateScript(String execName) throws BuildException {
         checkLanguage();
         ClassLoader origLoader = replaceContextLoader();
@@ -146,8 +149,7 @@ public class ScriptRunner extends ScriptRunnerBase {
     }
 
     private void declareBeans(BSFManager m) throws BSFException {
-        for (Iterator i = getBeans().keySet().iterator(); i.hasNext();) {
-            String key = (String) i.next();
+        for (String key : getBeans().keySet()) {
             Object value = getBeans().get(key);
             if (value != null) {
                 m.declareBean(key, value, value.getClass());

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java b/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java
index 4cd1278..89f8672 100644
--- a/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java
+++ b/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java
@@ -30,6 +30,7 @@ import org.apache.tools.ant.util.WeakishReference;
  * WeakishReference(Object) constructor, and both that and this are thin
  * facades on the underlying no-longer-abstract base class.
  */
+@Deprecated
 public class WeakishReference12 extends WeakishReference.HardReference  {
 
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java b/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
index 5c43376..24ca761 100644
--- a/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
+++ b/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
@@ -40,15 +40,10 @@ public class JakartaOroMatcher implements RegexpMatcher {
     // CheckStyle:VisibilityModifier ON
 
     /**
-     * Constructor for JakartaOroMatcher.
-     */
-    public JakartaOroMatcher() {
-    }
-
-    /**
      * Set the regexp pattern from the String description.
      * @param pattern the pattern to match
      */
+    @Override
     public void setPattern(final String pattern) {
         this.pattern = pattern;
     }
@@ -57,6 +52,7 @@ public class JakartaOroMatcher implements RegexpMatcher {
      * Get a String representation of the regexp pattern
      * @return the pattern
      */
+    @Override
     public String getPattern() {
         return this.pattern;
     }
@@ -71,8 +67,7 @@ public class JakartaOroMatcher implements RegexpMatcher {
         throws BuildException {
         try {
             // compute the compiler options based on the input options first
-            final Pattern p = compiler.compile(pattern, getCompilerOptions(options));
-            return p;
+            return compiler.compile(pattern, getCompilerOptions(options));
         } catch (final Exception e) {
             throw new BuildException(e);
         }
@@ -84,6 +79,7 @@ public class JakartaOroMatcher implements RegexpMatcher {
      * @return true if the pattern matches
      * @throws BuildException on error
      */
+    @Override
     public boolean matches(final String argument) throws BuildException {
         return matches(argument, MATCH_DEFAULT);
     }
@@ -95,10 +91,10 @@ public class JakartaOroMatcher implements RegexpMatcher {
      * @return true if the pattern matches
      * @throws BuildException on error
      */
+    @Override
     public boolean matches(final String input, final int options)
         throws BuildException {
-        final Pattern p = getCompiledPattern(options);
-        return matcher.contains(input, p);
+        return matcher.contains(input, getCompiledPattern(options));
     }
 
     /**
@@ -112,7 +108,8 @@ public class JakartaOroMatcher implements RegexpMatcher {
      * @return the vector of groups
      * @throws BuildException on error
      */
-    public Vector getGroups(final String argument) throws BuildException {
+    @Override
+    public Vector<String> getGroups(final String argument) throws BuildException {
         return getGroups(argument, MATCH_DEFAULT);
     }
 
@@ -127,12 +124,13 @@ public class JakartaOroMatcher implements RegexpMatcher {
      * @return the vector of groups
      * @throws BuildException on error
      */
-    public Vector getGroups(final String input, final int options)
+    @Override
+    public Vector<String> getGroups(final String input, final int options)
         throws BuildException {
         if (!matches(input, options)) {
             return null;
         }
-        final Vector v = new Vector();
+        final Vector<String> v = new Vector<>();
         final MatchResult mr = matcher.getMatch();
         final int cnt = mr.groups();
         for (int i = 0; i < cnt; i++) {
@@ -141,7 +139,7 @@ public class JakartaOroMatcher implements RegexpMatcher {
             if (match == null) {
                 match = "";
             }
-            v.addElement(match);
+            v.add(match);
         }
         return v;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java b/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java
index 529a78a..928939f 100644
--- a/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java
+++ b/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java
@@ -29,11 +29,6 @@ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp {
 
     private static final int DECIMAL = 10;
 
-    /** Constructor for JakartaOroRegexp */
-    public JakartaOroRegexp() {
-        super();
-    }
-
     /**
      * Perform a substitution on the regular expression.
      * @param input The string to substitute on
@@ -45,7 +40,7 @@ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp {
     public String substitute(final String input, final String argument, final int options)
         throws BuildException {
         // translate \1 to $1 so that the Perl5Substitution will work
-        final StringBuffer subst = new StringBuffer();
+        final StringBuilder subst = new StringBuilder();
         for (int i = 0; i < argument.length(); i++) {
             char c = argument.charAt(i);
             if (c == '$') {
@@ -56,7 +51,7 @@ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp {
                     c = argument.charAt(i);
                     final int value = Character.digit(c, DECIMAL);
                     if (value > -1) {
-                        subst.append("$").append(value);
+                        subst.append('$').append(value);
                     } else {
                         subst.append(c);
                     }
@@ -87,12 +82,8 @@ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp {
      * @return the oro substition options
      */
     protected int getSubsOptions(final int options) {
-        final boolean replaceAll = RegexpUtil.hasFlag(options, REPLACE_ALL);
-        int subsOptions = 1;
-        if (replaceAll) {
-            subsOptions = Util.SUBSTITUTE_ALL;
-        }
-        return subsOptions;
+        return RegexpUtil.hasFlag(options, REPLACE_ALL) ? Util.SUBSTITUTE_ALL
+            : 1;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java b/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
index 3e14415..4b02c5b 100644
--- a/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
+++ b/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
@@ -35,6 +35,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
      * Set the regexp pattern from the String description.
      * @param pattern the pattern to match
      */
+    @Override
     public void setPattern(String pattern) {
         this.pattern = pattern;
     }
@@ -43,6 +44,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
      * Get a String representation of the regexp pattern
      * @return the pattern
      */
+    @Override
     public String getPattern() {
         return pattern;
     }
@@ -72,6 +74,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
      * @return true if the pattern matches
      * @throws BuildException on error
      */
+    @Override
     public boolean matches(String argument) throws BuildException {
         return matches(argument, MATCH_DEFAULT);
     }
@@ -83,6 +86,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
      * @return true if the pattern matches
      * @throws BuildException on error
      */
+    @Override
     public boolean matches(String input, int options)
         throws BuildException {
         return matches(input, getCompiledPattern(options));
@@ -103,7 +107,8 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
      * @return the vector of groups
      * @throws BuildException on error
      */
-    public Vector getGroups(String argument) throws BuildException {
+    @Override
+    public Vector<String> getGroups(String argument) throws BuildException {
         return getGroups(argument, MATCH_DEFAULT);
     }
 
@@ -118,13 +123,14 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
      * @return the vector of groups
      * @throws BuildException on error
      */
-    public Vector getGroups(String input, int options)
+    @Override
+    public Vector<String> getGroups(String input, int options)
         throws BuildException {
         RE reg = getCompiledPattern(options);
         if (!matches(input, reg)) {
             return null;
         }
-        Vector v = new Vector();
+        Vector<String> v = new Vector<>();
         int cnt = reg.getParenCount();
         for (int i = 0; i < cnt; i++) {
             String match = reg.getParen(i);
@@ -132,7 +138,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher {
             if (match == null) {
                 match = "";
             }
-            v.addElement(match);
+            v.add(match);
         }
         return v;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java b/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java
index 865f424..b497b78 100644
--- a/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java
+++ b/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java
@@ -29,11 +29,6 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher
 
     private static final int DECIMAL = 10;
 
-    /** Constructor for JakartaRegexpRegexp */
-    public JakartaRegexpRegexp() {
-        super();
-    }
-
     /**
      * Convert ant regexp substitution option to apache regex options.
      *
@@ -56,12 +51,13 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher
      * @return the result of the operation
      * @throws BuildException on error
      */
+    @Override
     public String substitute(String input, String argument, int options)
         throws BuildException {
-        Vector v = getGroups(input, options);
+        Vector<String> v = getGroups(input, options);
 
         // replace \1 with the corresponding group
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         for (int i = 0; i < argument.length(); i++) {
             char c = argument.charAt(i);
             if (c == '\\') {
@@ -81,10 +77,8 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher
                 result.append(c);
             }
         }
-        argument = result.toString();
-
         RE reg = getCompiledPattern(options);
         int sOptions = getSubsOptions(options);
-        return reg.subst(input, argument, sOptions);
+        return reg.subst(input, result.toString(), sOptions);
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java b/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java
index 8c241d4..ac27b99 100644
--- a/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java
+++ b/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java
@@ -34,14 +34,11 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
 
     private String pattern;
 
-    /** Constructor for JakartaOroRegexp */
-    public Jdk14RegexpMatcher() {
-    }
-
     /**
      * Set the regexp pattern from the String description.
      * @param pattern the pattern to match
      */
+    @Override
     public void setPattern(String pattern) {
         this.pattern = pattern;
     }
@@ -51,6 +48,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
      * @return the pattern
      * @throws BuildException on error
      */
+    @Override
     public String getPattern() {
         return pattern;
     }
@@ -65,8 +63,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
         throws BuildException {
         int cOptions = getCompilerOptions(options);
         try {
-            Pattern p = Pattern.compile(this.pattern, cOptions);
-            return p;
+            return Pattern.compile(this.pattern, cOptions);
         } catch (PatternSyntaxException e) {
             throw new BuildException(e);
         }
@@ -78,6 +75,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
      * @return true if the pattern matches
      * @throws BuildException on error
      */
+    @Override
     public boolean matches(String argument) throws BuildException {
         return matches(argument, MATCH_DEFAULT);
     }
@@ -89,11 +87,11 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
      * @return true if the pattern matches
      * @throws BuildException on error
      */
+    @Override
     public boolean matches(String input, int options)
         throws BuildException {
         try {
-            Pattern p = getCompiledPattern(options);
-            return p.matcher(input).find();
+            return getCompiledPattern(options).matcher(input).find();
         } catch (Exception e) {
             throw new BuildException(e);
         }
@@ -110,7 +108,8 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
      * @return the vector of groups
      * @throws BuildException on error
      */
-    public Vector getGroups(String argument) throws BuildException {
+    @Override
+    public Vector<String> getGroups(String argument) throws BuildException {
         return getGroups(argument, MATCH_DEFAULT);
     }
 
@@ -125,14 +124,15 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
      * @return the vector of groups
      * @throws BuildException on error
      */
-    public Vector getGroups(String input, int options)
+    @Override
+    public Vector<String> getGroups(String input, int options)
         throws BuildException {
         Pattern p = getCompiledPattern(options);
         Matcher matcher = p.matcher(input);
         if (!matcher.find()) {
             return null;
         }
-        Vector v = new Vector();
+        Vector<String> v = new Vector<>();
         int cnt = matcher.groupCount();
         for (int i = 0; i <= cnt; i++) {
             String match = matcher.group(i);
@@ -140,7 +140,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher {
             if (match == null) {
                 match = "";
             }
-            v.addElement(match);
+            v.add(match);
         }
         return v;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java b/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java
index 3ca8070..76d2789 100644
--- a/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java
+++ b/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java
@@ -29,11 +29,6 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp {
 
     private static final int DECIMAL = 10;
 
-    /** Constructor for Jdk14RegexpRegexp */
-    public Jdk14RegexpRegexp() {
-        super();
-    }
-
     /**
      * Convert ant regexp substitution option to jdk1.4 options.
      *
@@ -56,10 +51,11 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp {
      * @return the result of the operation
      * @throws BuildException on error
      */
+    @Override
     public String substitute(String input, String argument, int options)
         throws BuildException {
         // translate \1 to $(1) so that the Matcher will work
-        StringBuffer subst = new StringBuffer();
+        StringBuilder subst = new StringBuilder();
         for (int i = 0; i < argument.length(); i++) {
             char c = argument.charAt(i);
             if (c == '$') {
@@ -70,7 +66,7 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp {
                     c = argument.charAt(i);
                     int value = Character.digit(c, DECIMAL);
                     if (value > -1) {
-                        subst.append("$").append(value);
+                        subst.append('$').append(value);
                     } else {
                         subst.append(c);
                     }
@@ -82,7 +78,6 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp {
                 subst.append(c);
             }
         }
-        argument = subst.toString();
 
         int sOptions = getSubsOptions(options);
         Pattern p = getCompiledPattern(options);
@@ -90,15 +85,12 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp {
 
         Matcher m = p.matcher(input);
         if (RegexpUtil.hasFlag(sOptions, REPLACE_ALL)) {
-            sb.append(m.replaceAll(argument));
+            sb.append(m.replaceAll(subst.toString()));
+        } else if (m.find()) {
+            m.appendReplacement(sb, subst.toString());
+            m.appendTail(sb);
         } else {
-            boolean res = m.find();
-            if (res) {
-                m.appendReplacement(sb, argument);
-                m.appendTail(sb);
-            } else {
-                sb.append(input);
-            }
+            sb.append(input);
         }
         return sb.toString();
     }