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:23 UTC

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

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
index acb6a7f..913fefa 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
@@ -44,27 +44,25 @@ public class Javac13 extends DefaultCompilerAdapter {
      * @return true if the compiler ran with a zero exit result (ok)
      * @exception BuildException if the compilation has problems.
      */
+    @Override
     public boolean execute() throws BuildException {
         attributes.log("Using modern compiler", Project.MSG_VERBOSE);
         Commandline cmd = setupModernJavacCommand();
 
         // Use reflection to be able to build on all JDKs >= 1.1:
         try {
-            Class c = Class.forName ("com.sun.tools.javac.Main");
-            Object compiler = c.newInstance ();
-            Method compile = c.getMethod ("compile",
-                new Class [] {(new String [] {}).getClass ()});
-            int result = ((Integer) compile.invoke
-                          (compiler, new Object[] {cmd.getArguments()}))
-                .intValue ();
-            return (result == MODERN_COMPILER_SUCCESS);
+            Class<?> c = Class.forName ("com.sun.tools.javac.Main");
+            Object compiler = c.newInstance();
+            Method compile = c.getMethod("compile", String[].class);
+            int result = ((Integer) compile.invoke(compiler,
+                (Object) cmd.getArguments())).intValue();
+            return result == MODERN_COMPILER_SUCCESS;
         } catch (Exception ex) {
             if (ex instanceof BuildException) {
                 throw (BuildException) ex;
-            } else {
-                throw new BuildException("Error starting modern compiler",
-                                         ex, location);
             }
+            throw new BuildException("Error starting modern compiler",
+                                     ex, location);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java b/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java
index ab28454..6a03709 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java
@@ -40,6 +40,7 @@ public class JavacExternal extends DefaultCompilerAdapter {
      * @return true if the compilation succeeded
      * @throws BuildException on error
      */
+    @Override
     public boolean execute() throws BuildException {
         attributes.log("Using external javac compiler", Project.MSG_VERBOSE);
 
@@ -82,7 +83,8 @@ public class JavacExternal extends DefaultCompilerAdapter {
                             true);
 
         } catch (IOException e) {
-            throw new BuildException("Failed to create a temporary file for \"-V\" switch");
+            throw new BuildException(
+                "Failed to create a temporary file for \"-V\" switch");
         } finally {
             FileUtils.delete(vmsFile);
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
index eac1bcf..cb9385c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
@@ -43,6 +43,7 @@ public class Jikes extends DefaultCompilerAdapter {
      * @return true if the compilation succeeded
      * @throws BuildException on error
      */
+    @Override
     public boolean execute() throws BuildException {
         attributes.log("Using jikes compiler", Project.MSG_VERBOSE);
 
@@ -50,7 +51,7 @@ public class Jikes extends DefaultCompilerAdapter {
 
         // For -sourcepath, use the "sourcepath" value if present.
         // Otherwise default to the "srcdir" value.
-        Path sourcepath = null;
+        Path sourcepath;
         if (compileSourcepath != null) {
             sourcepath = compileSourcepath;
         } else {
@@ -58,14 +59,14 @@ public class Jikes extends DefaultCompilerAdapter {
         }
         // If the buildfile specifies sourcepath="", then don't
         // output any sourcepath.
-        if (sourcepath.size() > 0) {
+        if (!sourcepath.isEmpty()) {
             cmd.createArgument().setValue("-sourcepath");
             cmd.createArgument().setPath(sourcepath);
         }
 
         Path classpath = new Path(project);
 
-        if (bootclasspath == null || bootclasspath.size() == 0) {
+        if (bootclasspath == null || bootclasspath.isEmpty()) {
             // no bootclasspath, therefore, get one from the java runtime
             includeJavaRuntime = true;
         } else {
@@ -82,7 +83,7 @@ public class Jikes extends DefaultCompilerAdapter {
             classpath.append(new Path(project, jikesPath));
         }
 
-        if (extdirs != null && extdirs.size() > 0) {
+        if (!(extdirs == null || extdirs.isEmpty())) {
             cmd.createArgument().setValue("-extdirs");
             cmd.createArgument().setPath(extdirs);
         }
@@ -136,7 +137,7 @@ public class Jikes extends DefaultCompilerAdapter {
         if (attributes.getSource() != null) {
             cmd.createArgument().setValue("-source");
             String source = attributes.getSource();
-            if (source.equals("1.1") || source.equals("1.2")) {
+            if ("1.1".equals(source) || "1.2".equals(source)) {
                 // support for -source 1.1 and -source 1.2 has been
                 // added with JDK 1.4.2, Jikes doesn't like it
                 attributes.log("Jikes doesn't support '-source " + source
@@ -151,7 +152,7 @@ public class Jikes extends DefaultCompilerAdapter {
         int firstFileName = cmd.size();
 
         Path boot = getBootClassPath();
-        if (boot.size() > 0) {
+        if (!boot.isEmpty()) {
             cmd.createArgument().setValue("-bootclasspath");
             cmd.createArgument().setPath(boot);
         }
@@ -161,7 +162,7 @@ public class Jikes extends DefaultCompilerAdapter {
     }
 
     private void addPropertyParams(Commandline cmd) {
-        /**
+        /*
          * TODO
          * Perhaps we shouldn't use properties for these
          * three options (emacs mode, warnings and pedantic),

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java
index 85ec479..b56089a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java
@@ -37,6 +37,7 @@ public class Jvc extends DefaultCompilerAdapter {
      * @return true if the compiler ran with a zero exit result (ok)
      * @exception BuildException if the compilation has problems.
      */
+    @Override
     public boolean execute() throws BuildException {
         attributes.log("Using jvc compiler", Project.MSG_VERBOSE);
 
@@ -45,7 +46,7 @@ public class Jvc extends DefaultCompilerAdapter {
         // jvc doesn't support bootclasspath dir (-bootclasspath)
         // so we'll emulate it for compatibility and convenience.
         Path p = getBootClassPath();
-        if (p.size() > 0) {
+        if (!p.isEmpty()) {
             classpath.append(p);
         }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
index 68b5ba1..d3c87f9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
@@ -38,6 +38,7 @@ public class Kjc extends DefaultCompilerAdapter {
      * @return true if the compilation succeeded
      * @exception BuildException if the compilation has problems.
      */
+    @Override
     public boolean execute() throws BuildException {
         attributes.log("Using kjc compiler", Project.MSG_VERBOSE);
         Commandline cmd = setupKjcCommand();
@@ -73,7 +74,7 @@ public class Kjc extends DefaultCompilerAdapter {
 
         // kjc don't have bootclasspath option.
         Path p = getBootClassPath();
-        if (p.size() > 0) {
+        if (!p.isEmpty()) {
             cp.append(p);
         }
 
@@ -115,5 +116,3 @@ public class Kjc extends DefaultCompilerAdapter {
         return cmd;
     }
 }
-
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java
index 0dcc0e4..b31712b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java
@@ -35,6 +35,7 @@ public class Sj extends DefaultCompilerAdapter {
      * @return true if the compilation succeeded
      * @throws BuildException on error
      */
+    @Override
     public boolean execute() throws BuildException {
         attributes.log("Using symantec java compiler", Project.MSG_VERBOSE);
 
@@ -54,8 +55,8 @@ public class Sj extends DefaultCompilerAdapter {
      * @return null.
      * @since Ant 1.6.3
      */
+    @Override
     protected String getNoDebugArgument() {
         return null;
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/And.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/And.java b/src/main/org/apache/tools/ant/taskdefs/condition/And.java
index 91b34c8..5ec6608 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/And.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/And.java
@@ -36,11 +36,11 @@ public class And extends ConditionBase implements Condition {
      * @return true if all the contained conditions evaluates to true
      * @exception BuildException if an error occurs
      */
+    @Override
     public boolean eval() throws BuildException {
-        Enumeration e = getConditions();
+        Enumeration<Condition> e = getConditions();
         while (e.hasMoreElements()) {
-            Condition c = (Condition) e.nextElement();
-            if (!c.eval()) {
+            if (!e.nextElement().eval()) {
                 return false;
             }
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java b/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
index ec21d4b..1c5fd82 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
@@ -36,6 +36,7 @@ public class AntVersion extends Task implements Condition {
      * Run as a task.
      * @throws BuildException if an error occurs.
      */
+    @Override
     public void execute() throws BuildException {
         if (propertyname == null) {
             throw new BuildException("'property' must be set.");
@@ -56,6 +57,7 @@ public class AntVersion extends Task implements Condition {
      * @return true if the condition is true.
      * @throws BuildException if an error occurs.
      */
+    @Override
     public boolean eval() throws BuildException {
         validate();
         DeweyDecimal actual = getVersion();
@@ -82,8 +84,8 @@ public class AntVersion extends Task implements Condition {
                 new DeweyDecimal(atLeast); //NOSONAR
             } catch (NumberFormatException e) {
                 throw new BuildException(
-                    "The 'atleast' attribute is not a Dewey Decimal eg 1.1.0 : "
-                    + atLeast);
+                    "The 'atleast' attribute is not a Dewey Decimal eg 1.1.0 : %s",
+                    atLeast);
             }
         } else {
             try {
@@ -91,8 +93,8 @@ public class AntVersion extends Task implements Condition {
                 new DeweyDecimal(exactly); //NOSONAR
             } catch (NumberFormatException e) {
                 throw new BuildException(
-                    "The 'exactly' attribute is not a Dewey Decimal eg 1.1.0 : "
-                    + exactly);
+                    "The 'exactly' attribute is not a Dewey Decimal eg 1.1.0 : %s",
+                    exactly);
             }
         }
     }
@@ -101,7 +103,7 @@ public class AntVersion extends Task implements Condition {
         Project p = new Project();
         p.init();
         char[] versionString = p.getProperty("ant.version").toCharArray();
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         boolean foundFirstDigit = false;
         for (int i = 0; i < versionString.length; i++) {
             if (Character.isDigit(versionString[i])) {

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java b/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java
index 62adbf3..c10cb6f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java
@@ -32,4 +32,3 @@ public interface Condition {
      */
     boolean eval() throws BuildException;
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java b/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
index d057b46..e1fc93d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
@@ -18,7 +18,9 @@
 
 package org.apache.tools.ant.taskdefs.condition;
 
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Vector;
 
 import org.apache.tools.ant.ProjectComponent;
@@ -43,7 +45,7 @@ public abstract class ConditionBase extends ProjectComponent {
     /**
      *
      */
-    private Vector conditions = new Vector();
+    private List<Condition> conditions = new Vector<>();
 
     /**
      * Simple constructor.
@@ -77,8 +79,8 @@ public abstract class ConditionBase extends ProjectComponent {
      * @return an enumeration to use for iteration
      * @since 1.1
      */
-    protected final Enumeration getConditions() {
-        return conditions.elements();
+    protected final Enumeration<Condition> getConditions() {
+        return Collections.enumeration(conditions);
     }
 
     /**
@@ -108,7 +110,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.1
      */
     public void addAvailable(Available a) {
-        conditions.addElement(a);
+        conditions.add(a);
     }
 
     /**
@@ -118,7 +120,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.4, Ant 1.5
      */
     public void addChecksum(Checksum c) {
-        conditions.addElement(c);
+        conditions.add(c);
     }
 
     /**
@@ -128,7 +130,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.1
      */
     public void addUptodate(UpToDate u) {
-        conditions.addElement(u);
+        conditions.add(u);
     }
 
     /**
@@ -138,7 +140,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.1
      */
     public void addNot(Not n) {
-        conditions.addElement(n);
+        conditions.add(n);
     }
 
     /**
@@ -148,7 +150,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.1
      */
     public void addAnd(And a) {
-        conditions.addElement(a);
+        conditions.add(a);
     }
 
     /**
@@ -158,7 +160,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.1
      */
     public void addOr(Or o) {
-        conditions.addElement(o);
+        conditions.add(o);
     }
 
     /**
@@ -168,7 +170,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.1
      */
     public void addEquals(Equals e) {
-        conditions.addElement(e);
+        conditions.add(e);
     }
 
     /**
@@ -178,7 +180,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since 1.1
      */
     public void addOs(Os o) {
-        conditions.addElement(o);
+        conditions.add(o);
     }
 
     /**
@@ -188,7 +190,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.5
      */
     public void addIsSet(IsSet i) {
-        conditions.addElement(i);
+        conditions.add(i);
     }
 
     /**
@@ -198,7 +200,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.5
      */
     public void addHttp(Http h) {
-        conditions.addElement(h);
+        conditions.add(h);
     }
 
     /**
@@ -208,7 +210,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.5
      */
     public void addSocket(Socket s) {
-        conditions.addElement(s);
+        conditions.add(s);
     }
 
     /**
@@ -218,7 +220,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.5
      */
     public void addFilesMatch(FilesMatch test) {
-        conditions.addElement(test);
+        conditions.add(test);
     }
 
     /**
@@ -228,7 +230,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.5
      */
     public void addContains(Contains test) {
-        conditions.addElement(test);
+        conditions.add(test);
     }
 
     /**
@@ -238,7 +240,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.5
      */
     public void addIsTrue(IsTrue test) {
-        conditions.addElement(test);
+        conditions.add(test);
     }
 
     /**
@@ -248,7 +250,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.5
      */
     public void addIsFalse(IsFalse test) {
-        conditions.addElement(test);
+        conditions.add(test);
     }
 
     /**
@@ -258,7 +260,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.6
      */
     public void addIsReference(IsReference i) {
-        conditions.addElement(i);
+        conditions.add(i);
     }
 
     /**
@@ -266,7 +268,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @param test the condition
      */
     public void addIsFileSelected(IsFileSelected test) {
-        conditions.addElement(test);
+        conditions.add(test);
     }
 
     /**
@@ -275,7 +277,7 @@ public abstract class ConditionBase extends ProjectComponent {
      * @since Ant 1.6
      */
     public void add(Condition c) {
-        conditions.addElement(c);
+        conditions.add(c);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
index 8830a39..79cf698 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
@@ -63,10 +63,11 @@ public class Contains implements Condition {
      * @return true if the substring is within the string
      * @exception BuildException if the attributes are not set correctly
      */
+    @Override
     public boolean eval() throws BuildException {
         if (string == null || subString == null) {
-            throw new BuildException("both string and substring are required "
-                                     + "in contains");
+            throw new BuildException(
+                "both string and substring are required in contains");
         }
 
         return caseSensitive

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
index 5e99398..74c2b30 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
@@ -44,7 +44,6 @@ public class FilesMatch implements Condition {
 
     private boolean textfile = false;
 
-
     /**
      * Sets the File1 attribute
      *
@@ -54,7 +53,6 @@ public class FilesMatch implements Condition {
         this.file1 = file1;
     }
 
-
     /**
      * Sets the File2 attribute
      *
@@ -78,13 +76,14 @@ public class FilesMatch implements Condition {
      * @return true if the files are equal
      * @exception BuildException if it all went pear-shaped
      */
+    @Override
     public boolean eval()
         throws BuildException {
 
         //validate
         if (file1 == null || file2 == null) {
-            throw new BuildException("both file1 and file2 are required in "
-                                     + "filesmatch");
+            throw new BuildException(
+                "both file1 and file2 are required in filesmatch");
         }
 
         //#now match the files
@@ -98,4 +97,3 @@ public class FilesMatch implements Condition {
         return matches;
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java b/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
index 420c189..c41e1ee 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
@@ -41,6 +41,7 @@ public class HasFreeSpace implements Condition {
      * @return true if there enough free space.
      * @throws BuildException if there is a problem.
      */
+    @Override
     public boolean eval() throws BuildException {
         validate();
         try {
@@ -48,11 +49,11 @@ public class HasFreeSpace implements Condition {
                 //reflection to avoid bootstrap/build problems
                 File fs = new File(partition);
                 ReflectWrapper w = new ReflectWrapper(fs);
-                long free = ((Long) w.invoke("getFreeSpace")).longValue();
+                long free = w.<Long> invoke("getFreeSpace").longValue();
                 return free >= StringUtils.parseHumanSizes(needed);
-            } else {
-                throw new BuildException("HasFreeSpace condition not supported on Java5 or less.");
             }
+            throw new BuildException(
+                "HasFreeSpace condition not supported on Java5 or less.");
         } catch (Exception e) {
             throw new BuildException(e);
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java b/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
index 002af7a..1c338f8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
@@ -37,7 +37,6 @@ public class HasMethod extends ProjectComponent implements Condition {
     private AntClassLoader loader;
     private boolean ignoreSystemClasses = false;
 
-
     /**
      * Set the classpath to be used when searching for classes and resources.
      *
@@ -104,7 +103,7 @@ public class HasMethod extends ProjectComponent implements Condition {
     /**
      * Check if a given class can be loaded.
      */
-    private Class loadClass(String classname) {
+    private Class<?> loadClass(String classname) {
         try {
             if (ignoreSystemClasses) {
                 loader = getProject().createClassLoader(classpath);
@@ -114,25 +113,23 @@ public class HasMethod extends ProjectComponent implements Condition {
                     return loader.findClass(classname);
                 } catch (SecurityException se) {
                     // class found but restricted name
-                    throw new BuildException("class \"" + classname
-                                             + "\" was found but a"
-                                             + " SecurityException has been"
-                                             + " raised while loading it",
-                                             se);
+                    throw new BuildException(
+                        "class \"" + classname
+                            + "\" was found but a SecurityException has been raised while loading it",
+                        se);
                 }
-            } else if (loader != null) {
+            }
+            if (loader != null) {
                 // How do we ever get here?
                 return loader.loadClass(classname);
-            } else {
-                ClassLoader l = this.getClass().getClassLoader();
-                // Can return null to represent the bootstrap class loader.
-                // see API docs of Class.getClassLoader.
-                if (l != null) {
-                    return Class.forName(classname, true, l);
-                } else {
-                    return Class.forName(classname);
-                }
             }
+            ClassLoader l = this.getClass().getClassLoader();
+            // Can return null to represent the bootstrap class loader.
+            // see API docs of Class.getClassLoader.
+            if (l != null) {
+                return Class.forName(classname, true, l);
+            }
+            return Class.forName(classname);
         } catch (ClassNotFoundException e) {
             throw new BuildException("class \"" + classname
                                      + "\" was not found");
@@ -143,15 +140,15 @@ public class HasMethod extends ProjectComponent implements Condition {
         }
     }
 
-
     /** {@inheritDoc}. */
+    @Override
     public boolean eval() throws BuildException {
         if (classname == null) {
             throw new BuildException("No classname defined");
         }
         ClassLoader preLoadClass = loader;
         try {
-            Class clazz = loadClass(classname);
+            Class<?> clazz = loadClass(classname);
             if (method != null) {
                 return isMethodFound(clazz);
             }
@@ -167,7 +164,7 @@ public class HasMethod extends ProjectComponent implements Condition {
         }
     }
 
-    private boolean isFieldFound(Class clazz) {
+    private boolean isFieldFound(Class<?> clazz) {
         Field[] fields = clazz.getDeclaredFields();
         for (int i = 0; i < fields.length; i++) {
             Field fieldEntry = fields[i];
@@ -178,7 +175,7 @@ public class HasMethod extends ProjectComponent implements Condition {
         return false;
     }
 
-    private boolean isMethodFound(Class clazz) {
+    private boolean isMethodFound(Class<?> clazz) {
         Method[] methods = clazz.getDeclaredMethods();
         for (int i = 0; i < methods.length; i++) {
             Method methodEntry = methods[i];

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
index 4c04278..a475e07 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
@@ -18,6 +18,7 @@
 
 package org.apache.tools.ant.taskdefs.condition;
 
+import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -43,6 +44,8 @@ public class Http extends ProjectComponent implements Condition {
     private String requestMethod = DEFAULT_REQUEST_METHOD;
     private boolean followRedirects = true;
 
+    private int errorsBeginAt = ERROR_BEGINS;
+    
     /**
      * Set the url attribute
      * @param url the url of the request
@@ -51,8 +54,6 @@ public class Http extends ProjectComponent implements Condition {
         spec = url;
     }
 
-    private int errorsBeginAt = ERROR_BEGINS;
-
     /**
      * Set the errorsBeginAt attribute
      * @param errorsBeginAt number at which errors begin at, default is
@@ -92,6 +93,7 @@ public class Http extends ProjectComponent implements Condition {
      * @return true if the HTTP request succeeds
      * @exception BuildException if an error occurs
      */
+    @Override
     public boolean eval() throws BuildException {
         if (spec == null) {
             throw new BuildException("No url specified in http condition");
@@ -116,7 +118,7 @@ public class Http extends ProjectComponent implements Condition {
             } catch (java.net.ProtocolException pe) {
                 throw new BuildException("Invalid HTTP protocol: "
                                          + requestMethod, pe);
-            } catch (java.io.IOException e) {
+            } catch (IOException e) {
                 return false;
             }
         } catch (MalformedURLException e) {

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java
index ddacd99..51471c8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java
@@ -69,9 +69,11 @@ public class IsLastModified extends ProjectComponent implements Condition {
      */
     public void setPattern(final String pattern) {
         dfFactory = new Touch.DateFormatFactory() {
+            @Override
             public DateFormat getPrimaryFormat() {
                 return new SimpleDateFormat(pattern);
             }
+            @Override
             public DateFormat getFallbackFormat() {
                 return null;
             }
@@ -104,8 +106,8 @@ public class IsLastModified extends ProjectComponent implements Condition {
      */
     protected void validate() throws BuildException {
         if (millis >= 0 && dateTime != null) {
-            throw new BuildException("Only one of dateTime and millis can be"
-                                     + " set");
+            throw new BuildException(
+                "Only one of dateTime and millis can be set");
         }
         if (millis < 0 && dateTime == null) {
             throw new BuildException("millis or dateTime is required");
@@ -129,7 +131,7 @@ public class IsLastModified extends ProjectComponent implements Condition {
             return System.currentTimeMillis();
         }
         DateFormat df = dfFactory.getPrimaryFormat();
-        ParseException pe = null;
+        ParseException pe;
         try {
             return df.parse(dateTime).getTime();
         } catch (ParseException peOne) {
@@ -144,11 +146,7 @@ public class IsLastModified extends ProjectComponent implements Condition {
                 }
             }
         }
-        if (pe != null) {
-            throw new BuildException(pe.getMessage(), pe, getLocation());
-        }
-        /* NOTREACHED */
-        return 0;
+        throw new BuildException(pe.getMessage(), pe, getLocation());
     }
 
     /**
@@ -156,6 +154,7 @@ public class IsLastModified extends ProjectComponent implements Condition {
      * @return true or false depending on the compoarison mode and the time of the resource
      * @throws BuildException
      */
+    @Override
     public boolean eval() throws BuildException {
         validate();
         long expected = getMillis();
@@ -209,6 +208,7 @@ public class IsLastModified extends ProjectComponent implements Condition {
             setValue(s);
         }
 
+        @Override
         public String[] getValues() {
             return new String[] {
                 EQUALS_TEXT, BEFORE_TEXT, AFTER_TEXT, NOT_BEFORE_TEXT,

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
index e699da1..de3f811 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
@@ -52,16 +52,13 @@ import org.apache.tools.ant.ProjectComponent;
  * @since Ant 1.7
  */
 public class IsReachable extends ProjectComponent implements Condition {
-
-    private static final int SECOND = 1000; // millis per second
-    private String host;
-    private String url;
-
     /**
      * The default timeout.
      */
     public static final int DEFAULT_TIMEOUT = 30;
-    private int timeout = DEFAULT_TIMEOUT;
+
+    private static final int SECOND = 1000; // millis per second
+
     /**
      * Error when no hostname is defined
      */
@@ -91,6 +88,11 @@ public class IsReachable extends ProjectComponent implements Condition {
     /** The method name to look for in InetAddress */
     public static final String METHOD_NAME = "isReachable";
 
+    private String host;
+    private String url;
+
+    private int timeout = DEFAULT_TIMEOUT;
+
     /**
      * Set the host to ping.
      *
@@ -129,8 +131,6 @@ public class IsReachable extends ProjectComponent implements Condition {
         return string == null || string.length() == 0;
     }
 
-    private static Class[] parameterTypes = {Integer.TYPE};
-
     /**
      * Evaluate the condition.
      *
@@ -139,6 +139,7 @@ public class IsReachable extends ProjectComponent implements Condition {
      * @throws org.apache.tools.ant.BuildException
      *          if an error occurs
      */
+    @Override
     public boolean eval() throws BuildException {
         if (empty(host) && empty(url)) {
             throw new BuildException(ERROR_NO_HOSTNAME);
@@ -174,15 +175,12 @@ public class IsReachable extends ProjectComponent implements Condition {
                 Project.MSG_VERBOSE);
         boolean reachable;
         //Java1.5: reachable = address.isReachable(timeout * 1000);
-        Method reachableMethod = null;
         try {
-            reachableMethod = InetAddress.class.getMethod(METHOD_NAME,
-                    parameterTypes);
-            final Object[] params = new Object[1];
-            params[0] = new Integer(timeout * SECOND);
+            Method reachableMethod =
+                InetAddress.class.getMethod(METHOD_NAME, Integer.class);
             try {
-                reachable = ((Boolean) reachableMethod.invoke(address, params))
-                        .booleanValue();
+                reachable = ((Boolean) reachableMethod.invoke(address,
+                    Integer.valueOf(timeout * SECOND))).booleanValue();
             } catch (final IllegalAccessException e) {
                 //utterly implausible, but catered for anyway
                 throw new BuildException("When calling " + reachableMethod);
@@ -198,7 +196,6 @@ public class IsReachable extends ProjectComponent implements Condition {
             log("Not found: InetAddress." + METHOD_NAME, Project.MSG_VERBOSE);
             log(MSG_NO_REACHABLE_TEST);
             reachable = true;
-
         }
 
         log("host is" + (reachable ? "" : " not") + " reachable", Project.MSG_VERBOSE);

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java
index f172849..30e2573 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsReference.java
@@ -56,34 +56,35 @@ public class IsReference extends ProjectComponent implements Condition {
      *              the reference is the same type
      * @exception BuildException if an error occurs
      */
+    @Override
     public boolean eval() throws BuildException {
         if (ref == null) {
-            throw new BuildException("No reference specified for isreference "
-                                     + "condition");
+            throw new BuildException(
+                "No reference specified for isreference condition");
         }
 
         String key = ref.getRefId();
         if (!getProject().hasReference(key)) {
             return false;
-        } else if (type == null) {
+        }
+        if (type == null) {
             return true;
-        } else {
-            Object o = getProject().getReference(key);
-            Class typeClass =
-                (Class) getProject().getDataTypeDefinitions().get(type);
-
-            if (typeClass == null) {
-                typeClass =
-                    (Class) getProject().getTaskDefinitions().get(type);
-            }
+        }
+        Object o = getProject().getReference(key);
+        Class<?> typeClass =
+            getProject().getDataTypeDefinitions().get(type);
 
-            if (typeClass == null) {
-                // don't know the type, should throw exception instead?
-                return false;
-            }
+        if (typeClass == null) {
+            typeClass =
+                getProject().getTaskDefinitions().get(type);
+        }
 
-            return typeClass.isAssignableFrom(o.getClass());
+        if (typeClass == null) {
+            // don't know the type, should throw exception instead?
+            return false;
         }
+
+        return typeClass.isAssignableFrom(o.getClass());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
index d4a5914..1474a0b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
@@ -41,9 +41,11 @@ public class IsSet extends ProjectComponent implements Condition {
      * @return true if the property exists
      * @exception BuildException if the property attribute is not set
      */
+    @Override
     public boolean eval() throws BuildException {
         if (property == null) {
-            throw new BuildException("No property specified for isset " + "condition");
+            throw new BuildException(
+                "No property specified for isset condition");
         }
         return getProject().getProperty(property) != null;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
index 585fb3a..267ff19 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
@@ -71,13 +71,11 @@ public class IsSigned extends DataType implements Condition {
      */
     public static boolean isSigned(File zipFile, String name)
         throws IOException {
-        ZipFile jarFile = null;
-        try {
-            jarFile = new ZipFile(zipFile);
+        try (ZipFile jarFile = new ZipFile(zipFile)) {
             if (null == name) {
-                Enumeration entries = jarFile.getEntries();
+                Enumeration<ZipEntry> entries = jarFile.getEntries();
                 while (entries.hasMoreElements()) {
-                    String eName = ((ZipEntry) entries.nextElement()).getName();
+                    String eName = entries.nextElement().getName();
                     if (eName.startsWith(SIG_START)
                         && eName.endsWith(SIG_END)) {
                         return true;
@@ -98,8 +96,6 @@ public class IsSigned extends DataType implements Condition {
             }
 
             return shortSig || longSig;
-        } finally {
-            ZipFile.closeQuietly(jarFile);
         }
     }
 
@@ -109,6 +105,7 @@ public class IsSigned extends DataType implements Condition {
      * specified, if the file contains a signature.
      * @return true if the file is signed.
      */
+    @Override
     public boolean eval() {
         if (file == null) {
             throw new BuildException("The file attribute must be set.");
@@ -135,7 +132,7 @@ public class IsSigned extends DataType implements Condition {
     }
 
     private static String replaceInvalidChars(final String name) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         final int len = name.length();
         boolean changes = false;
         for (int i = 0; i < len; i++) {

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java
index 753b441..e64d9ac 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsTrue.java
@@ -44,6 +44,7 @@ public class IsTrue extends ProjectComponent implements Condition {
      * @return the value
      * @throws BuildException if someone forgot to spec a value
      */
+    @Override
     public boolean eval() throws BuildException {
         if (value == null) {
             throw new BuildException("Nothing to test for truth");
@@ -52,4 +53,3 @@ public class IsTrue extends ProjectComponent implements Condition {
     }
 
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Not.java b/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
index a39dcbb..453be71 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
@@ -36,15 +36,16 @@ public class Not extends ConditionBase implements Condition {
      * @return true if the condition is true.
      * @throws BuildException if the condition is not configured correctly.
      */
+    @Override
     public boolean eval() throws BuildException {
         if (countConditions() > 1) {
-            throw new BuildException("You must not nest more than one "
-                + "condition into <not>");
+            throw new BuildException(
+                "You must not nest more than one condition into <not>");
         }
         if (countConditions() < 1) {
             throw new BuildException("You must nest a condition into <not>");
         }
-        return !((Condition) getConditions().nextElement()).eval();
+        return !getConditions().nextElement().eval();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
index aedfe74..c16f89f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
@@ -36,10 +36,11 @@ public class Or extends ConditionBase implements Condition {
      * @return true if any of the contained conditions evaluate to true
      * @exception BuildException if an error occurs
      */
+    @Override
     public boolean eval() throws BuildException {
-        Enumeration e = getConditions();
+        Enumeration<Condition> e = getConditions();
         while (e.hasMoreElements()) {
-            Condition c = (Condition) e.nextElement();
+            Condition c = e.nextElement();
             if (c.eval()) {
                 return true;
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
index 974c396..07ccb59 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
@@ -38,22 +38,6 @@ public class Os implements Condition {
         System.getProperty("path.separator");
 
     /**
-     * OS family to look for
-     */
-    private String family;
-    /**
-     * Name of OS
-     */
-    private String name;
-    /**
-     * version of OS
-     */
-    private String version;
-    /**
-     * OS architecture
-     */
-    private String arch;
-    /**
      * OS family that can be tested for. {@value}
      */
     public static final String FAMILY_WINDOWS = "windows";
@@ -108,6 +92,23 @@ public class Os implements Condition {
     private static final String DARWIN = "darwin";
 
     /**
+     * OS family to look for
+     */
+    private String family;
+    /**
+     * Name of OS
+     */
+    private String name;
+    /**
+     * version of OS
+     */
+    private String version;
+    /**
+     * OS architecture
+     */
+    private String arch;
+
+    /**
      * Default constructor
      *
      */
@@ -179,6 +180,7 @@ public class Os implements Condition {
      * @throws BuildException if there is an error.
      * @see Os#setFamily(String)
      */
+    @Override
     public boolean eval() throws BuildException {
         return isOs(family, name, arch, version);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java b/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java
index d283401..21a5c19 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/ParserSupports.java
@@ -31,9 +31,6 @@ import org.xml.sax.XMLReader;
  */
 public class ParserSupports extends ProjectComponent implements Condition {
 
-    private String feature;
-    private String property;
-    private String value;
     // Error messages
     /** error - combined attributes not allowed */
     public static final String ERROR_BOTH_ATTRIBUTES =
@@ -56,6 +53,10 @@ public class ParserSupports extends ProjectComponent implements Condition {
     public static final String ERROR_NO_VALUE =
         "A value is needed when testing for property support";
 
+    private String feature;
+    private String property;
+    private String value;
+
     /**
      * Feature to probe for.
      * @param feature the feature to probe for.
@@ -82,6 +83,7 @@ public class ParserSupports extends ProjectComponent implements Condition {
     }
 
     /** {@inheritDoc}. */
+    @Override
     public boolean eval() throws BuildException {
         if (feature != null && property != null) {
             throw new BuildException(ERROR_BOTH_ATTRIBUTES);

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java b/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
index 76a9ad3..ae7e1f5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
@@ -88,8 +88,8 @@ public class ResourceContains implements Condition {
                         o = rc.iterator().next();
                     }
                 } else {
-                    throw new BuildException(
-                        "Illegal value at '" + refid + "': " + String.valueOf(o));
+                    throw new BuildException("Illegal value at '%s': %s", refid,
+                        o);
                 }
             }
             this.resource = (Resource) o;
@@ -122,8 +122,8 @@ public class ResourceContains implements Condition {
             resolveRefid();
         }
         if (resource == null || substring == null) {
-            throw new BuildException("both resource and substring are required "
-                                     + "in <resourcecontains>");
+            throw new BuildException(
+                "both resource and substring are required in <resourcecontains>");
         }
     }
 
@@ -132,6 +132,7 @@ public class ResourceContains implements Condition {
      * @return true if the substring is contained in the resource
      * @throws BuildException if there is a problem.
      */
+    @Override
     public synchronized boolean eval() throws BuildException {
         validate();
 
@@ -146,9 +147,8 @@ public class ResourceContains implements Condition {
             return false;
         }
 
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));
+        try (BufferedReader reader = new BufferedReader(
+            new InputStreamReader(resource.getInputStream()))) {
             String contents = FileUtils.safeReadFully(reader);
             String sub = substring;
             if (!casesensitive) {
@@ -158,8 +158,6 @@ public class ResourceContains implements Condition {
             return contents.indexOf(sub) >= 0;
         } catch (IOException e) {
             throw new BuildException("There was a problem accessing resource : " + resource);
-        } finally {
-            FileUtils.close(reader);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java b/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java
index 29e3e80..5a1282d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java
@@ -65,6 +65,7 @@ public class ResourcesMatch implements Condition {
      * @return true if all resources are equal.
      * @exception BuildException if there is an error.
      */
+    @Override
     public boolean eval() throws BuildException {
         if (resources == null) {
             throw new BuildException(
@@ -72,11 +73,11 @@ public class ResourcesMatch implements Condition {
         }
         if (resources.size() > 1) {
             Iterator<Resource> i = resources.iterator();
-            Resource r1 = (Resource) i.next();
-            Resource r2 = null;
+            Resource r1 = i.next();
+            Resource r2;
 
             while (i.hasNext()) {
-                r2 = (Resource) i.next();
+                r2 = i.next();
                 try {
                     if (!ResourceUtils.contentEquals(r1, r2, asText)) {
                         return false;

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
index 43a40e0..6801b5c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.ProjectComponent;
-import org.apache.tools.ant.util.FileUtils;
 
 /**
  * Condition to wait for a TCP/IP socket to have a listener. Its attributes are:
@@ -58,25 +57,21 @@ public class Socket extends ProjectComponent implements Condition {
      * @return true if a socket can be created
      * @exception BuildException if the attributes are not set
      */
+    @Override
     public boolean eval() throws BuildException {
         if (server == null) {
-            throw new BuildException("No server specified in socket "
-                                     + "condition");
+            throw new BuildException("No server specified in socket condition");
         }
         if (port == 0) {
             throw new BuildException("No port specified in socket condition");
         }
         log("Checking for listener at " + server + ":" + port,
             Project.MSG_VERBOSE);
-        java.net.Socket s = null;
-        try {
-            s = new java.net.Socket(server, port);
+        try (java.net.Socket s = new java.net.Socket(server, port)) {
+            return true;
         } catch (IOException e) {
             return false;
-        } finally {
-            FileUtils.close(s);
         }
-        return true;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java b/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java
index f97c7f4..f51e02d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java
@@ -58,7 +58,6 @@ public class TypeFound extends ProjectComponent implements Condition {
      * @return true if the typename exists
      */
     protected boolean doesTypeExist(String typename) {
-
         ComponentHelper helper =
             ComponentHelper.getComponentHelper(getProject());
         String componentName = ProjectHelper.genComponentName(uri, typename);
@@ -81,6 +80,7 @@ public class TypeFound extends ProjectComponent implements Condition {
      * @return true if the condition is true
      * @exception BuildException if an error occurs
      */
+    @Override
     public boolean eval() throws BuildException {
         if (name == null) {
             throw new BuildException("No type specified");

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java b/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
index a2e675c..4478f33 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
@@ -34,12 +34,13 @@ public class Xor extends ConditionBase implements Condition {
      * @throws org.apache.tools.ant.BuildException
      *          if an error occurs.
      */
+    @Override
     public boolean eval() throws BuildException {
-        Enumeration e = getConditions();
+        Enumeration<Condition> e = getConditions();
         //initial state is false.
         boolean state = false;
         while (e.hasMoreElements()) {
-            Condition c = (Condition) e.nextElement();
+            Condition c = e.nextElement();
             //every condition is xored against the previous one
             state ^= c.eval();
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java
index b1a9a12..6f16f08 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/CVSEntry.java
@@ -28,7 +28,7 @@ public class CVSEntry {
     private Date date;
     private String author;
     private final String comment;
-    private final Vector files = new Vector();
+    private final Vector<RCSFile> files = new Vector<>();
 
     /**
      * Creates a new instance of a CVSEntry
@@ -48,7 +48,7 @@ public class CVSEntry {
      * @param revision the revision
      */
     public void addFile(final String file, final String revision) {
-        files.addElement(new RCSFile(file, revision));
+        files.add(new RCSFile(file, revision));
     }
 
     /**
@@ -58,7 +58,7 @@ public class CVSEntry {
      * @param previousRevision the previous revision
      */
     public void addFile(final String file, final String revision, final String previousRevision) {
-        files.addElement(new RCSFile(file, revision, previousRevision));
+        files.add(new RCSFile(file, revision, previousRevision));
     }
 
     /**
@@ -97,7 +97,7 @@ public class CVSEntry {
      * Gets the files in this CVSEntry
      * @return the files
      */
-    public Vector getFiles() {
+    public Vector<RCSFile> getFiles() {
         return files;
     }
 
@@ -105,6 +105,7 @@ public class CVSEntry {
      * Gets a String containing author, date, files and comment
      * @return a string representation of this CVSEntry
      */
+    @Override
     public String toString() {
         return getAuthor() + "\n" + getDate() + "\n" + getFiles() + "\n"
             + getComment();

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
index b088107..10a9bc4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParser.java
@@ -20,24 +20,23 @@ package org.apache.tools.ant.taskdefs.cvslib;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
-import java.util.Enumeration;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.TimeZone;
 
 import org.apache.tools.ant.taskdefs.AbstractCvsTask;
-import org.apache.tools.ant.util.CollectionUtils;
+import org.apache.tools.ant.taskdefs.AbstractCvsTask.Module;
 
 /**
  * A class used to parse the output of the CVS log command.
  *
  */
 class ChangeLogParser {
-    //private static final int GET_ENTRY = 0;
     private static final int GET_FILE = 1;
     private static final int GET_DATE = 2;
     private static final int GET_COMMENT = 3;
@@ -53,9 +52,6 @@ class ChangeLogParser {
     private final SimpleDateFormat cvs1129InputDate =
         new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US);
 
-    static {
-    }
-
     //The following is data used while processing stdout of CVS command
     private String file;
     private String date;
@@ -67,32 +63,29 @@ class ChangeLogParser {
     private int status = GET_FILE;
 
     /** rcs entries */
-    private final Hashtable entries = new Hashtable();
+    private final Map<String, CVSEntry> entries = new Hashtable<>();
 
     private final boolean remote;
     private final String[] moduleNames;
     private final int[] moduleNameLengths;
 
     public ChangeLogParser() {
-        this(false, "", CollectionUtils.EMPTY_LIST);
+        this(false, "", Collections.emptyList());
     }
 
-    public ChangeLogParser(boolean remote, String packageName, List modules) {
+    public ChangeLogParser(boolean remote, String packageName, List<AbstractCvsTask.Module> modules) {
         this.remote = remote;
 
-        ArrayList names = new ArrayList();
+        List<String> names = new ArrayList<>();
         if (packageName != null) {
             for (StringTokenizer tok = new StringTokenizer(packageName);
                  tok.hasMoreTokens();) {
                 names.add(tok.nextToken());
             }
         }
-        for (Iterator iter = modules.iterator(); iter.hasNext();) {
-            AbstractCvsTask.Module m = (AbstractCvsTask.Module) iter.next();
-            names.add(m.getName());
-        }
+        modules.stream().map(Module::getName).forEach(names::add);
 
-        moduleNames = (String[]) names.toArray(new String[names.size()]);
+        moduleNames = names.toArray(new String[names.size()]);
         moduleNameLengths = new int[moduleNames.length];
         for (int i = 0; i < moduleNames.length; i++) {
             moduleNameLengths[i] = moduleNames[i].length();
@@ -109,12 +102,7 @@ class ChangeLogParser {
      * @return a list of rcs entries as an array
      */
     public CVSEntry[] getEntrySetAsArray() {
-        final CVSEntry[] array = new CVSEntry[ entries.size() ];
-        int i = 0;
-        for (Enumeration e = entries.elements(); e.hasMoreElements();) {
-            array[i++] = (CVSEntry) e.nextElement();
-        }
-        return array;
+        return entries.values().toArray(new CVSEntry[entries.size()]);
     }
 
     /**
@@ -123,7 +111,7 @@ class ChangeLogParser {
      * @param line the line to process
      */
     public void stdout(final String line) {
-        switch(status) {
+        switch (status) {
             case GET_FILE:
                 // make sure attributes are reset when
                 // working on a 'new' file.
@@ -159,8 +147,8 @@ class ChangeLogParser {
      */
     private void processComment(final String line) {
         final String lineSeparator = System.getProperty("line.separator");
-        if (line.equals(
-                "=============================================================================")) {
+        if ("============================================================================="
+            .equals(line)) {
             //We have ended changelog for that particular file
             //so we can save it
             final int end
@@ -168,7 +156,7 @@ class ChangeLogParser {
             comment = comment.substring(0, end);
             saveEntry();
             status = GET_FILE;
-        } else if (line.equals("----------------------------")) {
+        } else if ("----------------------------".equals(line)) {
             final int end
                 = comment.length() - lineSeparator.length(); //was -1
             comment = comment.substring(0, end);
@@ -275,17 +263,9 @@ class ChangeLogParser {
      * Utility method that saves the current entry.
      */
     private void saveEntry() {
-        final String entryKey = date + author + comment;
-        CVSEntry entry;
-        if (!entries.containsKey(entryKey)) {
-            Date dateObject = parseDate(date);
-            entry = new CVSEntry(dateObject, author, comment);
-            entries.put(entryKey, entry);
-        } else {
-            entry = (CVSEntry) entries.get(entryKey);
-        }
-
-        entry.addFile(file, revision, previousRevision);
+        entries.computeIfAbsent(date + author + comment, k -> {
+            return new CVSEntry(parseDate(date), author, comment);
+        }).addFile(file, revision, previousRevision);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
index 63cf657..6ef730e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
@@ -19,14 +19,14 @@ package org.apache.tools.ant.taskdefs.cvslib;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.nio.file.Files;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
-import java.util.Enumeration;
+import java.util.List;
 import java.util.Properties;
 import java.util.Vector;
 
@@ -35,7 +35,6 @@ import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.AbstractCvsTask;
 import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.util.FileUtils;
 
 /**
  * Examines the output of cvs log and group related changes together.
@@ -82,7 +81,7 @@ public class ChangeLogTask extends AbstractCvsTask {
     private File usersFile;
 
     /** User list */
-    private Vector cvsUsers = new Vector();
+    private List<CvsUser> cvsUsers = new Vector<>();
 
     /** Input dir */
     private File inputDir;
@@ -110,8 +109,7 @@ public class ChangeLogTask extends AbstractCvsTask {
      * performed. If empty then all files in the working directory will
      * be checked.
      */
-    private final Vector filesets = new Vector();
-
+    private final List<FileSet> filesets = new Vector<>();
 
     /**
      * Set the base dir for cvs.
@@ -122,7 +120,6 @@ public class ChangeLogTask extends AbstractCvsTask {
         this.inputDir = inputDir;
     }
 
-
     /**
      * Set the output file for the log.
      *
@@ -132,7 +129,6 @@ public class ChangeLogTask extends AbstractCvsTask {
         this.destFile = destFile;
     }
 
-
     /**
      * Set a lookup list of user names &amp; addresses
      *
@@ -142,17 +138,15 @@ public class ChangeLogTask extends AbstractCvsTask {
         this.usersFile = usersFile;
     }
 
-
     /**
      * Add a user to list changelog knows about.
      *
      * @param user the user
      */
     public void addUser(final CvsUser user) {
-        cvsUsers.addElement(user);
+        cvsUsers.add(user);
     }
 
-
     /**
      * Set the date at which the changelog should start.
      *
@@ -162,7 +156,6 @@ public class ChangeLogTask extends AbstractCvsTask {
         this.startDate = start;
     }
 
-
     /**
      * Set the date at which the changelog should stop.
      *
@@ -172,7 +165,6 @@ public class ChangeLogTask extends AbstractCvsTask {
         this.endDate = endDate;
     }
 
-
     /**
      * Set the number of days worth of log entries to process.
      *
@@ -206,7 +198,6 @@ public class ChangeLogTask extends AbstractCvsTask {
         this.startTag = start;
     }
 
-
     /**
      * Set the tag at which the changelog should stop.
      *
@@ -222,29 +213,26 @@ public class ChangeLogTask extends AbstractCvsTask {
      * @param fileSet a set of files about which cvs logs will be generated.
      */
     public void addFileset(final FileSet fileSet) {
-        filesets.addElement(fileSet);
+        filesets.add(fileSet);
     }
 
-
     /**
      * Execute task
      *
      * @exception BuildException if something goes wrong executing the
      *            cvs command
      */
+    @Override
     public void execute() throws BuildException {
         File savedDir = inputDir; // may be altered in validate
 
         try {
-
             validate();
             final Properties userList = new Properties();
 
             loadUserlist(userList);
 
-            final int size = cvsUsers.size();
-            for (int i = 0; i < size; i++) {
-                final CvsUser user = (CvsUser) cvsUsers.get(i);
+            for (CvsUser user : cvsUsers) {
                 user.validate();
                 userList.put(user.getUserID(), user.getDisplayname());
             }
@@ -294,18 +282,11 @@ public class ChangeLogTask extends AbstractCvsTask {
             }
 
             // Check if list of files to check has been specified
-            if (!filesets.isEmpty()) {
-                final Enumeration e = filesets.elements();
-
-                while (e.hasMoreElements()) {
-                    final FileSet fileSet = (FileSet) e.nextElement();
-                    final DirectoryScanner scanner =
-                        fileSet.getDirectoryScanner(getProject());
-                    final String[] files = scanner.getIncludedFiles();
-
-                    for (int i = 0; i < files.length; i++) {
-                        addCommandArgument(files[i]);
-                    }
+            for (FileSet fileSet : filesets) {
+                final DirectoryScanner scanner =
+                    fileSet.getDirectoryScanner(getProject());
+                for (String file : scanner.getIncludedFiles()) {
+                    addCommandArgument(file);
                 }
             }
 
@@ -351,27 +332,20 @@ public class ChangeLogTask extends AbstractCvsTask {
             inputDir = getProject().getBaseDir();
         }
         if (null == destFile) {
-            final String message = "Destfile must be set.";
-
-            throw new BuildException(message);
+            throw new BuildException("Destfile must be set.");
         }
         if (!inputDir.exists()) {
-            final String message = "Cannot find base dir "
-                 + inputDir.getAbsolutePath();
-
-            throw new BuildException(message);
+            throw new BuildException("Cannot find base dir %s",
+                inputDir.getAbsolutePath());
         }
         if (null != usersFile && !usersFile.exists()) {
-            final String message = "Cannot find user lookup list "
-                 + usersFile.getAbsolutePath();
-
-            throw new BuildException(message);
+            throw new BuildException("Cannot find user lookup list %s",
+                usersFile.getAbsolutePath());
         }
         if ((null != startTag || null != endTag)
             && (null != startDate || null != endDate)) {
-            final String message = "Specify either a tag or date range,"
-                + " not both";
-            throw new BuildException(message);
+            throw new BuildException(
+                "Specify either a tag or date range, not both");
         }
     }
 
@@ -400,10 +374,9 @@ public class ChangeLogTask extends AbstractCvsTask {
      * @return the filtered entry set
      */
     private CVSEntry[] filterEntrySet(final CVSEntry[] entrySet) {
-        final Vector results = new Vector();
+        final List<CVSEntry> results = new ArrayList<>();
 
-        for (int i = 0; i < entrySet.length; i++) {
-            final CVSEntry cvsEntry = entrySet[i];
+        for (CVSEntry cvsEntry : entrySet) {
             final Date date = cvsEntry.getDate();
 
             //bug#30471
@@ -431,13 +404,10 @@ public class ChangeLogTask extends AbstractCvsTask {
                 //Skip dates that are too late
                 continue;
             }
-            results.addElement(cvsEntry);
+            results.add(cvsEntry);
         }
 
-        final CVSEntry[] resultArray = new CVSEntry[results.size()];
-
-        results.copyInto(resultArray);
-        return resultArray;
+        return results.toArray(new CVSEntry[results.size()]);
     }
 
     /**
@@ -445,9 +415,7 @@ public class ChangeLogTask extends AbstractCvsTask {
      */
     private void replaceAuthorIdWithName(final Properties userList,
                                          final CVSEntry[] entrySet) {
-        for (int i = 0; i < entrySet.length; i++) {
-
-            final CVSEntry entry = entrySet[ i ];
+        for (final CVSEntry entry : entrySet) {
             if (userList.containsKey(entry.getAuthor())) {
                 entry.setAuthor(userList.getProperty(entry.getAuthor()));
             }
@@ -462,17 +430,11 @@ public class ChangeLogTask extends AbstractCvsTask {
      */
     private void writeChangeLog(final CVSEntry[] entrySet)
          throws BuildException {
-        OutputStream output = null;
 
-        try {
-            output = Files.newOutputStream(destFile.toPath());
-
-            final PrintWriter writer =
-                new PrintWriter(new OutputStreamWriter(output, "UTF-8"));
-
-            final ChangeLogWriter serializer = new ChangeLogWriter();
+        try (final PrintWriter writer = new PrintWriter(
+            new OutputStreamWriter(Files.newOutputStream(destFile.toPath()), "UTF-8"))) {
 
-            serializer.printChangeLog(writer, entrySet);
+            new ChangeLogWriter().printChangeLog(writer, entrySet);
 
             if (writer.checkError()) {
                 throw new IOException("Encountered an error writing changelog");
@@ -481,9 +443,6 @@ public class ChangeLogTask extends AbstractCvsTask {
             getProject().log(uee.toString(), Project.MSG_ERR);
         } catch (final IOException ioe) {
             throw new BuildException(ioe.toString(), ioe);
-        } finally {
-            FileUtils.close(output);
         }
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java
index ce92327..991c6fb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriter.java
@@ -20,9 +20,9 @@ package org.apache.tools.ant.taskdefs.cvslib;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.text.SimpleDateFormat;
-import java.util.Enumeration;
 import java.util.TimeZone;
 
+import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.util.DOMElementWriter;
 import org.apache.tools.ant.util.DOMUtils;
 import org.w3c.dom.Document;
@@ -36,9 +36,11 @@ public class ChangeLogWriter {
     /** output format for dates written to xml file */
     private final SimpleDateFormat outputDate
         = new SimpleDateFormat("yyyy-MM-dd");
+
     /** output format for times written to xml file */
     private SimpleDateFormat outputTime
         = new SimpleDateFormat("HH:mm");
+
     /** stateless helper for writing the XML document */
     private static final DOMElementWriter DOM_WRITER = new DOMElementWriter();
 
@@ -62,20 +64,17 @@ public class ChangeLogWriter {
             Element root = doc.createElement("changelog");
             DOM_WRITER.openElement(root, output, 0, "\t");
             output.println();
-            for (int i = 0; i < entries.length; i++) {
-                final CVSEntry entry = entries[i];
-
+            for (final CVSEntry entry : entries) {
                 printEntry(doc, output, entry);
             }
             DOM_WRITER.closeElement(root, output, 0, "\t", true);
             output.flush();
             output.close();
         } catch (IOException e) {
-            throw new org.apache.tools.ant.BuildException(e);
+            throw new BuildException(e);
         }
     }
 
-
     /**
      * Print out an individual entry in changelog.
      *
@@ -92,11 +91,7 @@ public class ChangeLogWriter {
                                    outputTime.format(entry.getDate()));
         DOMUtils.appendCDATAElement(ent, "author", entry.getAuthor());
 
-        final Enumeration enumeration = entry.getFiles().elements();
-
-        while (enumeration.hasMoreElements()) {
-            final RCSFile file = (RCSFile) enumeration.nextElement();
-
+        for (RCSFile file : entry.getFiles()) {
             Element f = DOMUtils.createChildElement(ent, "file");
             DOMUtils.appendCDATAElement(f, "name", file.getName());
             DOMUtils.appendTextElement(f, "revision", file.getRevision());
@@ -111,4 +106,3 @@ public class ChangeLogWriter {
         DOM_WRITER.write(ent, output, 1, "\t");
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
index 9fbc3fd..83ec607 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
@@ -21,17 +21,13 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.nio.file.Files;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
-import java.util.Vector;
-
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.AbstractCvsTask;
@@ -152,7 +148,7 @@ public class CvsTagDiff extends AbstractCvsTask {
     /**
      * temporary list of package names.
      */
-    private List packageNames = new ArrayList();
+    private List<String> packageNames = new ArrayList<>();
 
     /**
      * temporary list of "File:" + package name + "/" for all packages.
@@ -229,7 +225,6 @@ public class CvsTagDiff extends AbstractCvsTask {
         ignoreRemoved = b;
     }
 
-
     /**
      * Execute task.
      *
@@ -297,10 +292,9 @@ public class CvsTagDiff extends AbstractCvsTask {
      */
     private CvsTagEntry[] parseRDiff(File tmpFile) throws BuildException {
         // parse the output of the command
-        BufferedReader reader = null;
 
-        try {
-            reader = new BufferedReader(new FileReader(tmpFile)); //NOSONAR
+        try (BufferedReader reader =
+            new BufferedReader(new FileReader(tmpFile))) {
 
             // entries are of the form:
             //CVS 1.11
@@ -316,7 +310,7 @@ public class CvsTagDiff extends AbstractCvsTask {
             // File testantoine/antoine.bat is removed; TESTANTOINE_1 revision 1.1.1.1
             //
             // get rid of 'File module/"
-            Vector entries = new Vector();
+            List<CvsTagEntry> entries = new ArrayList<>();
 
             String line = reader.readLine();
 
@@ -325,6 +319,7 @@ public class CvsTagDiff extends AbstractCvsTask {
                                          packageNamePrefixLengths);
                 if (line != null) {
                     // use || in a perl like fashion
+                    @SuppressWarnings("unused")
                     boolean processed
                         =  doFileIsNew(entries, line)
                         || doFileHasChanged(entries, line)
@@ -333,24 +328,13 @@ public class CvsTagDiff extends AbstractCvsTask {
                 line = reader.readLine();
             }
 
-            CvsTagEntry[] array = new CvsTagEntry[entries.size()];
-            entries.copyInto(array);
-
-            return array;
+            return entries.toArray(new CvsTagEntry[entries.size()]);
         } catch (IOException e) {
             throw new BuildException("Error in parsing", e);
-        } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    log(e.toString(), Project.MSG_ERR);
-                }
-            }
         }
     }
 
-    private boolean doFileIsNew(Vector entries, String line) {
+    private boolean doFileIsNew(List<CvsTagEntry> entries, String line) {
         int index = line.indexOf(FILE_IS_NEW);
         if (index == -1) {
             return false;
@@ -364,12 +348,12 @@ public class CvsTagDiff extends AbstractCvsTask {
             rev = line.substring(indexrev + REVISION.length());
         }
         CvsTagEntry entry = new CvsTagEntry(filename, rev);
-        entries.addElement(entry);
+        entries.add(entry);
         log(entry.toString(), Project.MSG_VERBOSE);
         return true;
     }
 
-    private boolean doFileHasChanged(Vector entries, String line) {
+    private boolean doFileHasChanged(List<CvsTagEntry> entries, String line) {
         int index = line.indexOf(FILE_HAS_CHANGED);
         if (index == -1) {
             return false;
@@ -385,12 +369,12 @@ public class CvsTagDiff extends AbstractCvsTask {
         CvsTagEntry entry = new CvsTagEntry(filename,
                                             revision,
                                             prevRevision);
-        entries.addElement(entry);
+        entries.add(entry);
         log(entry.toString(), Project.MSG_VERBOSE);
         return true;
     }
 
-    private boolean doFileWasRemoved(Vector entries, String line) {
+    private boolean doFileWasRemoved(List<CvsTagEntry> entries, String line) {
         if (ignoreRemoved) {
             return false;
         }
@@ -406,7 +390,7 @@ public class CvsTagDiff extends AbstractCvsTask {
             rev = line.substring(indexrev + REVISION.length());
         }
         CvsTagEntry entry = new CvsTagEntry(filename, null, rev);
-        entries.addElement(entry);
+        entries.add(entry);
         log(entry.toString(), Project.MSG_VERBOSE);
         return true;
     }
@@ -418,11 +402,8 @@ public class CvsTagDiff extends AbstractCvsTask {
      * @exception BuildException if an error occurs
      */
     private void writeTagDiff(CvsTagEntry[] entries) throws BuildException {
-        OutputStream output = null;
-        try {
-            output = Files.newOutputStream(mydestfile.toPath());
-            PrintWriter writer = new PrintWriter(
-                                     new OutputStreamWriter(output, "UTF-8"));
+        try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(
+            Files.newOutputStream(mydestfile.toPath()), "UTF-8"))) {
             writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
             Document doc = DOMUtils.newDocument();
             Element root = doc.createElement("tagdiff");
@@ -455,14 +436,6 @@ public class CvsTagDiff extends AbstractCvsTask {
             log(uee.toString(), Project.MSG_ERR);
         } catch (IOException ioe) {
             throw new BuildException(ioe.toString(), ioe);
-        } finally {
-            if (null != output) {
-                try {
-                    output.close();
-                } catch (IOException ioe) {
-                    log(ioe.toString(), Project.MSG_ERR);
-                }
-            }
         }
     }
 
@@ -508,8 +481,8 @@ public class CvsTagDiff extends AbstractCvsTask {
         }
 
         if (null != mystartTag && null != mystartDate) {
-            throw new BuildException("Only one of start tag and start date "
-                                     + "must be set.");
+            throw new BuildException(
+                "Only one of start tag and start date must be set.");
         }
 
         if (null == myendTag && null == myendDate) {
@@ -517,8 +490,8 @@ public class CvsTagDiff extends AbstractCvsTask {
         }
 
         if (null != myendTag && null != myendDate) {
-            throw new BuildException("Only one of end tag and end date must "
-                                     + "be set.");
+            throw new BuildException(
+                "Only one of end tag and end date must be set.");
         }
     }
 
@@ -536,8 +509,7 @@ public class CvsTagDiff extends AbstractCvsTask {
                 addCommandArgument(pack);
             }
         }
-        for (Iterator iter = getModules().iterator(); iter.hasNext();) {
-            AbstractCvsTask.Module m = (AbstractCvsTask.Module) iter.next();
+        for (Module m : getModules()) {
             packageNames.add(m.getName());
             // will be added to command line in super.execute()
         }
@@ -549,7 +521,6 @@ public class CvsTagDiff extends AbstractCvsTask {
         }
     }
 
-
     /**
      * removes a "File: module/" prefix if present.
      *
@@ -561,17 +532,11 @@ public class CvsTagDiff extends AbstractCvsTask {
         if (line.length() < FILE_STRING_LENGTH) {
             return null;
         }
-        boolean matched = false;
         for (int i = 0; i < packagePrefixes.length; i++) {
             if (line.startsWith(packagePrefixes[i])) {
-                matched = true;
-                line = line.substring(prefixLengths[i]);
-                break;
+                return line.substring(prefixLengths[i]);
             }
         }
-        if (!matched) {
-            line = line.substring(FILE_STRING_LENGTH);
-        }
-        return line;
+        return line.substring(FILE_STRING_LENGTH);
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java
index 6e349c7..031d164 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java
@@ -89,8 +89,9 @@ public class CvsTagEntry {
      * Gets a String containing filename and difference from previous version
      * @return a string representation of this CVSTagEntry
      */
+    @Override
     public String toString() {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         buffer.append(filename);
         if (revision == null) {
             buffer.append(" was removed");