You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Matt Benson <mb...@apache.org> on 2017/04/13 15:21:15 UTC

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

Sorry for the giant pile of changes. Tests pass for me; does anyone object
to my merging these to master?

Matt

On Thu, Apr 13, 2017 at 10:16 AM, <mb...@apache.org> wrote:

> http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/
> src/main/org/apache/tools/ant/taskdefs/Java.java
> ----------------------------------------------------------------------
> diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java
> b/src/main/org/apache/tools/ant/taskdefs/Java.java
> index ed9f906..b4b5a7e 100644
> --- a/src/main/org/apache/tools/ant/taskdefs/Java.java
> +++ b/src/main/org/apache/tools/ant/taskdefs/Java.java
> @@ -20,8 +20,6 @@ package org.apache.tools.ant.taskdefs;
>
>  import java.io.File;
>  import java.io.IOException;
> -import java.io.PrintWriter;
> -import java.io.StringWriter;
>  import java.util.Vector;
>
>  import org.apache.tools.ant.BuildException;
> @@ -52,6 +50,8 @@ import org.apache.tools.ant.util.StringUtils;
>   * @ant.task category="java"
>   */
>  public class Java extends Task {
> +    private static final String TIMEOUT_MESSAGE =
> +            "Timeout: killed the sub-process";
>
>      private CommandlineJava cmdl = new CommandlineJava();
>      private Environment env = new Environment();
> @@ -78,9 +78,6 @@ public class Java extends Task {
>      private boolean spawn = false;
>      private boolean incompatibleWithSpawn = false;
>
> -    private static final String TIMEOUT_MESSAGE =
> -        "Timeout: killed the sub-process";
> -
>      /**
>       * Normal constructor
>       */
> @@ -100,6 +97,7 @@ public class Java extends Task {
>       * @throws BuildException if failOnError is set to true and the
> application
>       * returns a nonzero result code.
>       */
> +    @Override
>      public void execute() throws BuildException {
>          File savedDir = dir;
>          Permissions savedPermissions = perm;
> @@ -148,30 +146,32 @@ public class Java extends Task {
>              throw new BuildException("Classname must not be null.");
>          }
>          if (!fork && getCommandLine().getJar() != null) {
> -            throw new BuildException("Cannot execute a jar in non-forked
> mode."
> -                                     + " Please set fork='true'. ");
> +            throw new BuildException(
> +                "Cannot execute a jar in non-forked mode. Please set
> fork='true'. ");
>          }
>          if (!fork && getCommandLine().getModule() != null) {
> -            throw new BuildException("Cannot execute a module in
> non-forked mode."
> -                                     + " Please set fork='true'. ");
> +            throw new BuildException(
> +                "Cannot execute a module in non-forked mode. Please set
> fork='true'. ");
>          }
>          if (spawn && !fork) {
> -            throw new BuildException("Cannot spawn a java process in
> non-forked mode."
> -                                     + " Please set fork='true'. ");
> +            throw new BuildException(
> +                "Cannot spawn a java process in non-forked mode. Please
> set fork='true'. ");
>          }
>          if (getCommandLine().getClasspath() != null
>              && getCommandLine().getJar() != null) {
> -            log("When using 'jar' attribute classpath-settings are
> ignored. "
> -                + "See the manual for more information.",
> Project.MSG_VERBOSE);
> +            log("When using 'jar' attribute classpath-settings are
> ignored. See the manual for more information.",
> +                Project.MSG_VERBOSE);
>          }
>          if (spawn && incompatibleWithSpawn) {
> -            getProject().log("spawn does not allow attributes related to
> input, "
> -            + "output, error, result", Project.MSG_ERR);
> +            getProject().log(
> +                "spawn does not allow attributes related to input,
> output, error, result",
> +                Project.MSG_ERR);
>              getProject().log("spawn also does not allow timeout",
> Project.MSG_ERR);
> -            getProject().log("finally, spawn is not compatible "
> -                + "with a nested I/O <redirector>", Project.MSG_ERR);
> -            throw new BuildException("You have used an attribute "
> -                + "or nested element which is not compatible with spawn");
> +            getProject().log(
> +                "finally, spawn is not compatible with a nested I/O
> <redirector>",
> +                Project.MSG_ERR);
> +            throw new BuildException(
> +                "You have used an attribute or nested element which is
> not compatible with spawn");
>          }
>          if (getCommandLine().getAssertions() != null && !fork) {
>              log("Assertion statements are currently ignored in non-forked
> mode");
> @@ -191,8 +191,8 @@ public class Java extends Task {
>                      Project.MSG_WARN);
>              }
>              if (newEnvironment || null != env.getVariables()) {
> -                log("Changes to environment variables are ignored when
> same "
> -                    + "JVM is used.", Project.MSG_WARN);
> +                log("Changes to environment variables are ignored when
> same JVM is used.",
> +                    Project.MSG_WARN);
>              }
>              if (getCommandLine().getBootclasspath() != null) {
>                  log("bootclasspath ignored when same JVM is used.",
> @@ -217,19 +217,17 @@ public class Java extends Task {
>      protected int executeJava(CommandlineJava commandLine) {
>          try {
>              if (fork) {
> -                if (!spawn) {
> -                    return fork(commandLine.getCommandline());
> -                } else {
> +                if (spawn) {
>                      spawn(commandLine.getCommandline());
>                      return 0;
>                  }
> -            } else {
> -                try {
> -                    run(commandLine);
> -                    return 0;
> -                } catch (ExitException ex) {
> -                    return ex.getStatus();
> -                }
> +                return fork(commandLine.getCommandline());
> +            }
> +            try {
> +                run(commandLine);
> +                return 0;
> +            } catch (ExitException ex) {
> +                return ex.getStatus();
>              }
>          } catch (BuildException e) {
>              if (e.getLocation() == null && getLocation() != null) {
> @@ -237,23 +235,21 @@ public class Java extends Task {
>              }
>              if (failOnError) {
>                  throw e;
> +            }
> +            if (TIMEOUT_MESSAGE.equals(e.getMessage())) {
> +                log(TIMEOUT_MESSAGE);
>              } else {
> -                if (TIMEOUT_MESSAGE.equals(e.getMessage())) {
> -                    log(TIMEOUT_MESSAGE);
> -                } else {
> -                    log(e);
> -                }
> -                return -1;
> +                log(e);
>              }
> +            return -1;
>          } catch (ThreadDeath t) {
>              throw t; // cf. NB #47191
>          } catch (Throwable t) {
>              if (failOnError) {
>                  throw new BuildException(t, getLocation());
> -            } else {
> -                log(t);
> -                return -1;
>              }
> +            log(t);
> +            return -1;
>          }
>      }
>
> @@ -363,8 +359,8 @@ public class Java extends Task {
>       */
>      public void setJar(File jarfile) throws BuildException {
>          if (getCommandLine().getClassname() != null ||
> getCommandLine().getModule() != null) {
> -            throw new BuildException("Cannot use 'jar' with 'classname'
> or 'module' "
> -                                     + "attributes in same command.");
> +            throw new BuildException(
> +                "Cannot use 'jar' with 'classname' or 'module' attributes
> in same command.");
>          }
>          getCommandLine().setJar(jarfile.getAbsolutePath());
>      }
> @@ -378,8 +374,8 @@ public class Java extends Task {
>       */
>      public void setClassname(String s) throws BuildException {
>          if (getCommandLine().getJar() != null) {
> -            throw new BuildException("Cannot use 'jar' and 'classname' "
> -                                     + "attributes in same command");
> +            throw new BuildException(
> +                "Cannot use 'jar' and 'classname' attributes in same
> command");
>          }
>          getCommandLine().setClassname(s);
>      }
> @@ -394,8 +390,8 @@ public class Java extends Task {
>       */
>      public void setModule(String module) throws BuildException {
>          if (getCommandLine().getJar() != null) {
> -            throw new BuildException("Cannot use 'jar' and 'module' "
> -                                     + "attributes in same command");
> +            throw new BuildException(
> +                "Cannot use 'jar' and 'module' attributes in same
> command");
>          }
>          getCommandLine().setModule(module);
>      }
> @@ -409,8 +405,8 @@ public class Java extends Task {
>       * @ant.attribute ignore="true"
>       */
>      public void setArgs(String s) {
> -        log("The args attribute is deprecated. "
> -            + "Please use nested arg elements.", Project.MSG_WARN);
> +        log("The args attribute is deprecated. Please use nested arg
> elements.",
> +            Project.MSG_WARN);
>          getCommandLine().createArgument().setLine(s);
>      }
>
> @@ -477,8 +473,8 @@ public class Java extends Task {
>       * @param s jvmargs.
>       */
>      public void setJvmargs(String s) {
> -        log("The jvmargs attribute is deprecated. "
> -            + "Please use nested jvmarg elements.", Project.MSG_WARN);
> +        log("The jvmargs attribute is deprecated. Please use nested
> jvmarg elements.",
> +            Project.MSG_WARN);
>          getCommandLine().createVmArgument().setLine(s);
>      }
>
> @@ -559,8 +555,8 @@ public class Java extends Task {
>       */
>      public void setInput(File input) {
>          if (inputString != null) {
> -            throw new BuildException("The \"input\" and \"inputstring\" "
> -                + "attributes cannot both be specified");
> +            throw new BuildException(
> +                "The \"input\" and \"inputstring\" attributes cannot both
> be specified");
>          }
>          this.input = input;
>          incompatibleWithSpawn = true;
> @@ -573,8 +569,8 @@ public class Java extends Task {
>       */
>      public void setInputString(String inputString) {
>          if (input != null) {
> -            throw new BuildException("The \"input\" and \"inputstring\" "
> -                + "attributes cannot both be specified");
> +            throw new BuildException(
> +                "The \"input\" and \"inputstring\" attributes cannot both
> be specified");
>          }
>          this.inputString = inputString;
>          incompatibleWithSpawn = true;
> @@ -728,6 +724,7 @@ public class Java extends Task {
>       *
>       * @since Ant 1.5
>       */
> +    @Override
>      protected void handleOutput(String output) {
>          if (redirector.getOutputStream() != null) {
>              redirector.handleOutput(output);
> @@ -748,6 +745,7 @@ public class Java extends Task {
>       * @exception IOException if the data cannot be read.
>       * @since Ant 1.6
>       */
> +    @Override
>      public int handleInput(byte[] buffer, int offset, int length)
>          throws IOException {
>          // Should work whether or not redirector.inputStream == null:
> @@ -761,6 +759,7 @@ public class Java extends Task {
>       *
>       * @since Ant 1.5.2
>       */
> +    @Override
>      protected void handleFlush(String output) {
>          if (redirector.getOutputStream() != null) {
>              redirector.handleFlush(output);
> @@ -776,6 +775,7 @@ public class Java extends Task {
>       *
>       * @since Ant 1.5
>       */
> +    @Override
>      protected void handleErrorOutput(String output) {
>          if (redirector.getErrorStream() != null) {
>              redirector.handleErrorOutput(output);
> @@ -791,6 +791,7 @@ public class Java extends Task {
>       *
>       * @since Ant 1.5.2
>       */
> +    @Override
>      protected void handleErrorFlush(String output) {
>          if (redirector.getErrorStream() != null) {
>              redirector.handleErrorFlush(output);
> @@ -897,8 +898,8 @@ public class Java extends Task {
>      private void setupEnvironment(Execute exe) {
>          String[] environment = env.getVariables();
>          if (environment != null) {
> -            for (int i = 0; i < environment.length; i++) {
> -                log("Setting environment variable: " + environment[i],
> +            for (String element : environment) {
> +                log("Setting environment variable: " + element,
>                      Project.MSG_VERBOSE);
>              }
>          }
> @@ -914,7 +915,7 @@ public class Java extends Task {
>      private void setupWorkingDir(Execute exe) {
>          if (dir == null) {
>              dir = getProject().getBaseDir();
> -        } else if (!dir.exists() || !dir.isDirectory()) {
> +        } else if (!dir.isDirectory()) {
>              throw new BuildException(dir.getAbsolutePath()
>                                       + " is not a valid directory",
>                                       getLocation());
> @@ -962,10 +963,7 @@ public class Java extends Task {
>      protected void run(String classname, Vector<String> args) throws
> BuildException {
>          CommandlineJava cmdj = new CommandlineJava();
>          cmdj.setClassname(classname);
> -        final int size = args.size();
> -        for (int i = 0; i < size; i++) {
> -            cmdj.createArgument().setValue(args.elementAt(i));
> -        }
> +        args.forEach(arg -> cmdj.createArgument().setValue(arg));
>          run(cmdj);
>      }
>
>
> http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/
> src/main/org/apache/tools/ant/taskdefs/Javac.java
> ----------------------------------------------------------------------
> diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java
> b/src/main/org/apache/tools/ant/taskdefs/Javac.java
> index 6e7cee3..0e97f0a 100644
> --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
> +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
> @@ -19,7 +19,6 @@
>  package org.apache.tools.ant.taskdefs;
>
>  import java.io.File;
> -import java.io.FileFilter;
>  import java.io.IOException;
>  import java.io.OutputStream;
>  import java.nio.file.Files;
> @@ -28,7 +27,6 @@ import java.util.Collection;
>  import java.util.HashMap;
>  import java.util.List;
>  import java.util.Map;
> -import java.util.Map.Entry;
>  import java.util.TreeMap;
>
>  import org.apache.tools.ant.BuildException;
> @@ -138,7 +136,7 @@ public class Javac extends MatchingTask {
>      protected boolean failOnError = true;
>      protected boolean listFiles = false;
>      protected File[] compileList = new File[0];
> -    private Map<String, Long> packageInfos = new HashMap<String, Long>();
> +    private Map<String, Long> packageInfos = new HashMap<>();
>      // CheckStyle:VisibilityModifier ON
>
>      private String source;
> @@ -162,19 +160,23 @@ public class Javac extends MatchingTask {
>      private String assumedJavaVersion() {
>          if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) {
>              return JAVAC14;
> -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
> +        }
> +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
>              return JAVAC15;
> -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) {
> +        }
> +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) {
>              return JAVAC16;
> -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) {
> +        }
> +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) {
>              return JAVAC17;
> -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
> +        }
> +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
>              return JAVAC18;
> -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)) {
> +        }
> +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)) {
>              return JAVAC9;
> -        } else {
> -            return CLASSIC;
>          }
> +        return CLASSIC;
>      }
>
>      /**
> @@ -1083,8 +1085,8 @@ public class Javac extends MatchingTask {
>       */
>      public void add(final CompilerAdapter adapter) {
>          if (nestedAdapter != null) {
> -            throw new BuildException("Can't have more than one compiler"
> -                                     + " adapter");
> +            throw new BuildException(
> +                "Can't have more than one compiler adapter");
>          }
>          nestedAdapter = adapter;
>      }
> @@ -1131,7 +1133,7 @@ public class Javac extends MatchingTask {
>       */
>      protected void resetFileLists() {
>          compileList = new File[0];
> -        packageInfos = new HashMap<String, Long>();
> +        packageInfos = new HashMap<>();
>      }
>
>      /**
> @@ -1146,8 +1148,8 @@ public class Javac extends MatchingTask {
>          final GlobPatternMapper m = new GlobPatternMapper();
>          final String[] extensions = findSupportedFileExtensions();
>
> -        for (int i = 0; i < extensions.length; i++) {
> -            m.setFrom(extensions[i]);
> +        for (String extension : extensions) {
> +            m.setFrom(extension);
>              m.setTo("*.class");
>              final SourceFileScanner sfs = new SourceFileScanner(this);
>              final File[] newFiles = sfs.restrictAsFiles(files, srcDir,
> destDir, m);
> @@ -1186,7 +1188,8 @@ public class Javac extends MatchingTask {
>          final FileUtils fu = FileUtils.getFileUtils();
>          for (String pathElement : moduleSourcepath.list()) {
>              boolean valid = false;
> -            for (Map.Entry<String,Collection<File>> modules :
> resolveModuleSourcePathElement(getProject().getBaseDir(),
> pathElement).entrySet()) {
> +            for (Map.Entry<String, Collection<File>> modules :
> resolveModuleSourcePathElement(
> +                getProject().getBaseDir(), pathElement).entrySet()) {
>                  final String moduleName = modules.getKey();
>                  for (File srcDir : modules.getValue()) {
>                      if (srcDir.exists()) {
> @@ -1218,7 +1221,7 @@ public class Javac extends MatchingTask {
>          }
>
>          if (extensions == null) {
> -            extensions = new String[] {"java"};
> +            extensions = new String[] { "java" };
>          }
>
>          // now process the extensions to ensure that they are the
> @@ -1297,8 +1300,8 @@ public class Javac extends MatchingTask {
>              if (isJdkCompiler(compilerImpl)) {
>                  compilerImpl = EXTJAVAC;
>              } else {
> -                log("Since compiler setting isn't classic or modern, "
> -                    + "ignoring fork setting.", Project.MSG_WARN);
> +                log("Since compiler setting isn't classic or modern,
> ignoring fork setting.",
> +                    Project.MSG_WARN);
>              }
>          }
>          return compilerImpl;
> @@ -1353,13 +1356,12 @@ public class Javac extends MatchingTask {
>          if (destDir != null && !destDir.isDirectory()) {
>              throw new BuildException("destination directory \""
>                                       + destDir
> -                                     + "\" does not exist "
> -                                     + "or is not a directory",
> getLocation());
> +                                     + "\" does not exist or is not a
> directory", getLocation());
>          }
>          if (includeAntRuntime == null && getProject().getProperty("build.sysclasspath")
> == null) {
> -            log(getLocation() + "warning: 'includeantruntime' was not
> set, " +
> -                    "defaulting to build.sysclasspath=last; set to false
> for repeatable builds",
> -                    Project.MSG_WARN);
> +            log(getLocation()
> +                + "warning: 'includeantruntime' was not set, defaulting
> to build.sysclasspath=last; set to false for repeatable builds",
> +                Project.MSG_WARN);
>          }
>      }
>
> @@ -1377,9 +1379,8 @@ public class Javac extends MatchingTask {
>                  + (destDir != null ? " to " + destDir : ""));
>
>              if (listFiles) {
> -                for (int i = 0; i < compileList.length; i++) {
> -                  final String filename = compileList[i].
> getAbsolutePath();
> -                  log(filename);
> +                for (File element : compileList) {
> +                  log(element.getAbsolutePath());
>                  }
>              }
>
> @@ -1414,9 +1415,8 @@ public class Javac extends MatchingTask {
>                  }
>                  if (failOnError) {
>                      throw new BuildException(FAIL_MSG, getLocation());
> -                } else {
> -                    log(FAIL_MSG, Project.MSG_ERR);
>                  }
> +                log(FAIL_MSG, Project.MSG_ERR);
>              }
>          }
>      }
> @@ -1438,9 +1438,8 @@ public class Javac extends MatchingTask {
>      }
>
>      private void lookForPackageInfos(final File srcDir, final File[]
> newFiles) {
> -        for (int i = 0; i < newFiles.length; i++) {
> -            final File f = newFiles[i];
> -            if (!f.getName().equals("package-info.java")) {
> +        for (File f : newFiles) {
> +            if (!"package-info.java".equals(f.getName())) {
>                  continue;
>              }
>              final String path = FILE_UTILS.removeLeadingPath(srcDir, f).
> @@ -1451,7 +1450,7 @@ public class Javac extends MatchingTask {
>                  continue;
>              }
>              final String pkg = path.substring(0, path.length() -
> suffix.length());
> -            packageInfos.put(pkg, new Long(f.lastModified()));
> +            packageInfos.put(pkg, Long.valueOf(f.lastModified()));
>          }
>      }
>
> @@ -1461,7 +1460,7 @@ public class Javac extends MatchingTask {
>       * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=
> 43114">Bug #43114</a>
>       */
>      private void generateMissingPackageInfoClasses(final File dest)
> throws IOException {
> -        for (final Entry<String, Long> entry : packageInfos.entrySet()) {
> +        for (final Map.Entry<String, Long> entry :
> packageInfos.entrySet()) {
>              final String pkg = entry.getKey();
>              final Long sourceLastMod = entry.getValue();
>              final File pkgBinDir = new File(dest, pkg.replace('/',
> File.separatorChar));
> @@ -1490,7 +1489,7 @@ public class Javac extends MatchingTask {
>       * @since 1.9.7
>       */
>      private static boolean hasPath(final Path path) {
> -        return path != null && path.size() > 0;
> +        return path != null && !path.isEmpty();
>      }
>
>      /**
> @@ -1524,7 +1523,7 @@ public class Javac extends MatchingTask {
>       */
>      private static Collection<? extends CharSequence> expandGroups(
>              final CharSequence element) {
> -        List<StringBuilder> result = new ArrayList<StringBuilder>();
> +        List<StringBuilder> result = new ArrayList<>();
>          result.add(new StringBuilder());
>          StringBuilder resolved = new StringBuilder();
>          for (int i = 0; i < element.length(); i++) {
> @@ -1547,7 +1546,7 @@ public class Javac extends MatchingTask {
>                              break;
>                          default:
>                              final List<StringBuilder> oldRes = result;
> -                            result = new ArrayList<StringBuilder>(oldRes.size()
> * parts.size());
> +                            result = new ArrayList<>(oldRes.size() *
> parts.size());
>                              for (CharSequence part : parts) {
>                                  for (CharSequence prefix : oldRes) {
>                                      result.add(new
> StringBuilder(prefix).append(resolved).append(part));
> @@ -1574,7 +1573,7 @@ public class Javac extends MatchingTask {
>       * @since 1.9.7
>       */
>      private static Collection<? extends CharSequence> resolveGroup(final
> CharSequence group) {
> -        final Collection<CharSequence> result = new
> ArrayList<CharSequence>();
> +        final Collection<CharSequence> result = new ArrayList<>();
>          int start = 0;
>          int depth = 0;
>          for (int i = 0; i < group.length(); i++) {
> @@ -1643,26 +1642,26 @@ public class Javac extends MatchingTask {
>          final int startIndex = pattern.indexOf(MODULE_MARKER);
>          if (startIndex == -1) {
>              findModules(root, pattern, null, collector);
> -        } else {
> -            if (startIndex == 0) {
> -                throw new BuildException("The modulesourcepath entry must
> be a folder.");
> -            }
> -            final int endIndex = startIndex + MODULE_MARKER.length();
> -            if (pattern.charAt(startIndex - 1) != File.separatorChar) {
> -                    throw new BuildException("The module mark must be
> preceded by separator");
> -            }
> -            if (endIndex < pattern.length() && pattern.charAt(endIndex)
> != File.separatorChar) {
> -                throw new BuildException("The module mark must be
> followed by separator");
> -            }
> -            if (pattern.indexOf(MODULE_MARKER, endIndex) != -1) {
> -                throw new BuildException("The modulesourcepath entry must
> contain at most one module mark");
> -            }
> -            final String pathToModule = pattern.substring(0, startIndex);
> -            final String pathInModule = endIndex == pattern.length() ?
> -                    null :
> -                    pattern.substring(endIndex + 1);  //+1 the separator
> -            findModules(root, pathToModule, pathInModule, collector);
> +            return;
>          }
> +        if (startIndex == 0) {
> +            throw new BuildException("The modulesourcepath entry must be
> a folder.");
> +        }
> +        final int endIndex = startIndex + MODULE_MARKER.length();
> +        if (pattern.charAt(startIndex - 1) != File.separatorChar) {
> +                throw new BuildException("The module mark must be
> preceded by separator");
> +        }
> +        if (endIndex < pattern.length() && pattern.charAt(endIndex) !=
> File.separatorChar) {
> +            throw new BuildException("The module mark must be followed by
> separator");
> +        }
> +        if (pattern.indexOf(MODULE_MARKER, endIndex) != -1) {
> +            throw new BuildException("The modulesourcepath entry must
> contain at most one module mark");
> +        }
> +        final String pathToModule = pattern.substring(0, startIndex);
> +        final String pathInModule = endIndex == pattern.length() ?
> +                null :
> +                pattern.substring(endIndex + 1);  //+1 the separator
> +        findModules(root, pathToModule, pathInModule, collector);
>      }
>
>      /**
> @@ -1683,19 +1682,14 @@ public class Javac extends MatchingTask {
>          if (!f.isDirectory()) {
>              return;
>          }
> -        final File[] modules = f.listFiles(new FileFilter() {
> -            public boolean accept(File pathname) {
> -                return pathname.isDirectory();
> -            }
> -        });
> -        for (File module : modules) {
> +        for (File module : f.listFiles(File::isDirectory)) {
>              final String moduleName = module.getName();
>              final File moduleSourceRoot = pathInModule == null ?
>                      module :
>                      new File(module, pathInModule);
>              Collection<File> moduleRoots = collector.get(moduleName);
>              if (moduleRoots == null) {
> -                moduleRoots = new ArrayList<File>();
> +                moduleRoots = new ArrayList<>();
>                  collector.put(moduleName, moduleRoots);
>              }
>              moduleRoots.add(moduleSourceRoot);
>
> http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/
> src/main/org/apache/tools/ant/taskdefs/Javadoc.java
> ----------------------------------------------------------------------
> diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
> b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
> index ccf1548..62366ad 100644
> --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
> +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
> @@ -23,22 +23,24 @@ import java.io.File;
>  import java.io.FileNotFoundException;
>  import java.io.FileReader;
>  import java.io.FileWriter;
> -import java.io.FilenameFilter;
>  import java.io.IOException;
>  import java.io.InputStream;
>  import java.io.InputStreamReader;
> -import java.io.OutputStream;
>  import java.io.OutputStreamWriter;
>  import java.net.MalformedURLException;
>  import java.net.URL;
>  import java.nio.file.Files;
>  import java.util.ArrayList;
> +import java.util.Collections;
>  import java.util.Enumeration;
>  import java.util.HashSet;
>  import java.util.Iterator;
> +import java.util.List;
>  import java.util.Locale;
> +import java.util.Set;
>  import java.util.StringTokenizer;
>  import java.util.Vector;
> +import java.util.stream.Collectors;
>
>  import org.apache.tools.ant.BuildException;
>  import org.apache.tools.ant.DirectoryScanner;
> @@ -225,7 +227,7 @@ public class Javadoc extends Task {
>      public class DocletInfo extends ExtensionInfo {
>
>          /** Collection of doclet parameters. */
> -        private final Vector<DocletParam> params = new
> Vector<DocletParam>();
> +        private final List<DocletParam> params = new Vector<>();
>
>          /**
>           * Create a doclet parameter to be configured by Ant.
> @@ -234,8 +236,7 @@ public class Javadoc extends Task {
>           */
>          public DocletParam createParam() {
>              final DocletParam param = new DocletParam();
> -            params.addElement(param);
> -
> +            params.add(param);
>              return param;
>          }
>
> @@ -245,7 +246,7 @@ public class Javadoc extends Task {
>           * @return an Enumeration of DocletParam instances.
>           */
>          public Enumeration<DocletParam> getParams() {
> -            return params.elements();
> +            return Collections.enumeration(params);
>          }
>      }
>
> @@ -367,7 +368,7 @@ public class Javadoc extends Task {
>          public String[] getValues() {
>              // Protected first so if any GUI tool offers a default
>              // based on enum #0, it will be right.
> -            return new String[] {"protected", "public", "package",
> "private"};
> +            return new String[] { "protected", "public", "package",
> "private" };
>          }
>      }
>
> @@ -378,8 +379,11 @@ public class Javadoc extends Task {
>       * contains special handling for FileSets that has to occur at
>       * task runtime.</p>
>       */
> -    public class ResourceCollectionContainer {
> -        private final ArrayList<ResourceCollection> rcs = new
> ArrayList<ResourceCollection>();
> +    public class ResourceCollectionContainer
> +        implements Iterable<ResourceCollection> {
> +
> +        private final List<ResourceCollection> rcs = new ArrayList<>();
> +
>          /**
>           * Add a resource collection to the container.
>           * @param rc the collection to add.
> @@ -392,7 +396,8 @@ public class Javadoc extends Task {
>           * Get an iterator on the collection.
>           * @return an iterator.
>           */
> -        private Iterator<ResourceCollection> iterator() {
> +        @Override
> +        public Iterator<ResourceCollection> iterator() {
>              return rcs.iterator();
>          }
>      }
> @@ -422,12 +427,12 @@ public class Javadoc extends Task {
>       * @param value the argument value.
>       */
>      private void addArgIfNotEmpty(final String key, final String value) {
> -        if (value != null && value.length() != 0) {
> -            cmd.createArgument().setValue(key);
> -            cmd.createArgument().setValue(value);
> -        } else {
> +        if (value == null || value.isEmpty()) {
>              log("Warning: Leaving out empty argument '" + key + "'",
>                  Project.MSG_WARN);
> +        } else {
> +            cmd.createArgument().setValue(key);
> +            cmd.createArgument().setValue(value);
>          }
>      }
>
> @@ -443,9 +448,9 @@ public class Javadoc extends Task {
>      private boolean failOnWarning = false;
>      private Path sourcePath = null;
>      private File destDir = null;
> -    private final Vector<SourceFile> sourceFiles = new
> Vector<SourceFile>();
> -    private final Vector<PackageName> packageNames = new
> Vector<PackageName>();
> -    private final Vector<PackageName> excludePackageNames = new
> Vector<PackageName>(1);
> +    private final List<SourceFile> sourceFiles = new Vector<>();
> +    private final List<PackageName> packageNames = new Vector<>();
> +    private final List<PackageName> excludePackageNames = new Vector<>(1);
>      private boolean author = true;
>      private boolean version = true;
>      private DocletInfo doclet = null;
> @@ -453,9 +458,9 @@ public class Javadoc extends Task {
>      private Path bootclasspath = null;
>      private String group = null;
>      private String packageList = null;
> -    private final Vector<LinkArgument> links = new Vector<LinkArgument>();
> -    private final Vector<GroupArgument> groups = new
> Vector<GroupArgument>();
> -    private final Vector<Object> tags = new Vector<Object>();
> +    private final List<LinkArgument> links = new Vector<>();
> +    private final List<GroupArgument> groups = new Vector<>();
> +    private final List<Object> tags = new Vector<>();
>      private boolean useDefaultExcludes = true;
>      private Html doctitle = null;
>      private Html header = null;
> @@ -475,7 +480,7 @@ public class Javadoc extends Task {
>
>      private final ResourceCollectionContainer nestedSourceFiles
>          = new ResourceCollectionContainer();
> -    private final Vector<DirSet> packageSets = new Vector<DirSet>();
> +    private final List<DirSet> packageSets = new Vector<>();
>
>      /**
>       * Work around command line length limit by using an external file
> @@ -593,7 +598,7 @@ public class Javadoc extends Task {
>       * @param sf the source file to be processed.
>       */
>      public void addSource(final SourceFile sf) {
> -        sourceFiles.addElement(sf);
> +        sourceFiles.add(sf);
>      }
>
>      /**
> @@ -623,7 +628,7 @@ public class Javadoc extends Task {
>       * @param pn the package name, possibly wildcarded.
>       */
>      public void addPackage(final PackageName pn) {
> -        packageNames.addElement(pn);
> +        packageNames.add(pn);
>      }
>
>      /**
> @@ -648,7 +653,7 @@ public class Javadoc extends Task {
>       * @param pn the name of the package (wildcards are not permitted).
>       */
>      public void addExcludePackage(final PackageName pn) {
> -        excludePackageNames.addElement(pn);
> +        excludePackageNames.add(pn);
>      }
>
>      /**
> @@ -772,7 +777,7 @@ public class Javadoc extends Task {
>       * @param tagletInfo information about the taglet.
>       */
>      public void addTaglet(final ExtensionInfo tagletInfo) {
> -        tags.addElement(tagletInfo);
> +        tags.add(tagletInfo);
>      }
>
>      /**
> @@ -1191,7 +1196,7 @@ public class Javadoc extends Task {
>       */
>      public LinkArgument createLink() {
>          final LinkArgument la = new LinkArgument();
> -        links.addElement(la);
> +        links.add(la);
>          return la;
>      }
>
> @@ -1304,7 +1309,7 @@ public class Javadoc extends Task {
>       */
>      public TagArgument createTag() {
>          final TagArgument ta = new TagArgument();
> -        tags.addElement (ta);
> +        tags.add(ta);
>          return ta;
>      }
>
> @@ -1377,48 +1382,47 @@ public class Javadoc extends Task {
>              final StringTokenizer tok = new StringTokenizer
> (verboseScope, ",");
>              while (tok.hasMoreTokens()) {
>                  final String next = tok.nextToken().trim();
> -                if (next.equals("all")) {
> +                if ("all".equals(next)) {
>                      if (gotAll) {
> -                        getProject().log ("Repeated tag scope element:
> all",
> +                        getProject().log("Repeated tag scope element:
> all",
>                                            Project.MSG_VERBOSE);
>                      }
>                      gotAll = true;
>                  } else {
>                      int i;
>                      for (i = 0; i < SCOPE_ELEMENTS.length; i++) {
> -                        if (next.equals (SCOPE_ELEMENTS[i])) {
> +                        if (SCOPE_ELEMENTS[i].equals(next)) {
>                              break;
>                          }
>                      }
>                      if (i == SCOPE_ELEMENTS.length) {
> -                        throw new BuildException ("Unrecognised scope
> element: "
> -                                                  + next);
> -                    } else {
> -                        if (elements[i]) {
> -                            getProject().log ("Repeated tag scope
> element: "
> -                                              + next,
> Project.MSG_VERBOSE);
> -                        }
> -                        elements[i] = true;
> -                        gotNotAll = true;
> +                        throw new BuildException(
> +                            "Unrecognised scope element: %s", next);
> +                    }
> +                    if (elements[i]) {
> +                        getProject().log("Repeated tag scope element: " +
> next,
> +                            Project.MSG_VERBOSE);
>                      }
> +                    elements[i] = true;
> +                    gotNotAll = true;
>                  }
>              }
>
>              if (gotNotAll && gotAll) {
> -                throw new BuildException ("Mixture of \"all\" and other
> scope "
> -                                          + "elements in tag parameter.");
> +                throw new BuildException(
> +                    "Mixture of \"all\" and other scope elements in tag
> parameter.");
>              }
>              if (!gotNotAll && !gotAll) {
> -                throw new BuildException ("No scope elements specified in
> tag "
> -                                          + "parameter.");
> +                throw new BuildException(
> +                    "No scope elements specified in tag parameter.");
>              }
>              if (gotAll) {
>                  this.scope = "a";
>              } else {
> -                final StringBuffer buff = new StringBuffer
> (elements.length);
> +                final StringBuilder buff = new
> StringBuilder(elements.length);
>                  for (int i = 0; i < elements.length; i++) {
>                      if (elements[i]) {
> -                        buff.append (SCOPE_ELEMENTS[i].charAt(0));
> +                        buff.append(SCOPE_ELEMENTS[i].charAt(0));
>                      }
>                  }
>                  this.scope = buff.toString();
> @@ -1441,17 +1445,17 @@ public class Javadoc extends Task {
>           *                           is <code>null</code> or empty.
>           */
>          public String getParameter() throws BuildException {
> -            if (name == null || name.equals("")) {
> -                throw new BuildException ("No name specified for custom
> tag.");
> +            if (name == null || name.isEmpty()) {
> +                throw new BuildException("No name specified for custom
> tag.");
>              }
>              if (getDescription() != null) {
>                  return name + ":" + (enabled ? "" : "X")
>                      + scope + ":" + getDescription();
> -            } else if (!enabled || !"a".equals(scope)) {
> +            }
> +            if (!enabled || !"a".equals(scope)) {
>                  return name + ":" + (enabled ? "" : "X") + scope;
> -            } else {
> -                return name;
>              }
> +            return name;
>          }
>      }
>
> @@ -1462,22 +1466,16 @@ public class Javadoc extends Task {
>       */
>      public GroupArgument createGroup() {
>          final GroupArgument ga = new GroupArgument();
> -        groups.addElement(ga);
> +        groups.add(ga);
>          return ga;
>      }
>
> -
>      /**
>       * A class corresponding to the group nested element.
>       */
>      public class GroupArgument {
>          private Html title;
> -        private final Vector<PackageName> packages = new
> Vector<PackageName>();
> -
> -        /** Constructor for GroupArgument */
> -        public GroupArgument() {
> -            //empty
> -        }
> +        private final List<PackageName> packages = new Vector<>();
>
>          /**
>           * Set the title attribute using a string.
> @@ -1488,6 +1486,7 @@ public class Javadoc extends Task {
>              h.addText(src);
>              addTitle(h);
>          }
> +
>          /**
>           * Set the title attribute using a nested Html value.
>           * @param text a <code>Html</code> value
> @@ -1517,12 +1516,13 @@ public class Javadoc extends Task {
>                  addPackage(pn);
>              }
>          }
> +
>          /**
>           * Add a package nested element.
>           * @param pn a nested element specifying the package.
>           */
>          public void addPackage(final PackageName pn) {
> -            packages.addElement(pn);
> +            packages.add(pn);
>          }
>
>          /**
> @@ -1530,15 +1530,8 @@ public class Javadoc extends Task {
>           * @return the packages as a string
>           */
>          public String getPackages() {
> -            final StringBuffer p = new StringBuffer();
> -            final int size = packages.size();
> -            for (int i = 0; i < size; i++) {
> -                if (i > 0) {
> -                    p.append(":");
> -                }
> -                p.append(packages.elementAt(i).toString());
> -            }
> -            return p.toString();
> +            return packages.stream().map(Object::toString)
> +                .collect(Collectors.joining(":"));
>          }
>      }
>
> @@ -1602,7 +1595,7 @@ public class Javadoc extends Task {
>       * @since 1.5
>       */
>      public void addPackageset(final DirSet packageSet) {
> -        packageSets.addElement(packageSet);
> +        packageSets.add(packageSet);
>      }
>
>      /**
> @@ -1705,7 +1698,7 @@ public class Javadoc extends Task {
>      public void execute() throws BuildException {
>          checkTaskName();
>
> -        final Vector<String> packagesToDoc = new Vector<String>();
> +        final List<String> packagesToDoc = new Vector<>();
>          final Path sourceDirs = new Path(getProject());
>
>          checkPackageAndSourcePath();
> @@ -1717,15 +1710,14 @@ public class Javadoc extends Task {
>          parsePackages(packagesToDoc, sourceDirs);
>          checkPackages(packagesToDoc, sourceDirs);
>
> -        @SuppressWarnings("unchecked")
> -        final Vector<SourceFile> sourceFilesToDoc = (Vector<SourceFile>)
> sourceFiles.clone();
> +        final List<SourceFile> sourceFilesToDoc = new
> ArrayList<>(sourceFiles);
>          addSourceFiles(sourceFilesToDoc);
>
>          checkPackagesToDoc(packagesToDoc, sourceFilesToDoc);
>
>          log("Generating Javadoc", Project.MSG_INFO);
>
> -        final Commandline toExecute = (Commandline) cmd.clone();
> +        final Commandline toExecute = cmd.clone();
>          if (executable != null) {
>              toExecute.setExecutable(executable);
>          } else {
> @@ -1846,25 +1838,24 @@ public class Javadoc extends Task {
>          }
>      }
>
> -    private void checkPackages(final Vector<String> packagesToDoc, final
> Path sourceDirs) {
> -        if (packagesToDoc.size() != 0 && sourceDirs.size() == 0) {
> -            final String msg = "sourcePath attribute must be set when "
> -                + "specifying package names.";
> -            throw new BuildException(msg);
> +    private void checkPackages(final List<String> packagesToDoc, final
> Path sourceDirs) {
> +        if (!packagesToDoc.isEmpty() && sourceDirs.isEmpty()) {
> +            throw new BuildException(
> +                "sourcePath attribute must be set when specifying package
> names.");
>          }
>      }
>
>      private void checkPackagesToDoc(
> -        final Vector<String> packagesToDoc, final Vector<SourceFile>
> sourceFilesToDoc) {
> -        if (packageList == null && packagesToDoc.size() == 0
> -            && sourceFilesToDoc.size() == 0) {
> -            throw new BuildException("No source files and no packages
> have "
> -                                     + "been specified.");
> +        final List<String> packagesToDoc, final List<SourceFile>
> sourceFilesToDoc) {
> +        if (packageList == null && packagesToDoc.isEmpty()
> +            && sourceFilesToDoc.isEmpty()) {
> +            throw new BuildException(
> +                "No source files and no packages have been specified.");
>          }
>      }
>
>      private void doSourcePath(final Commandline toExecute, final Path
> sourceDirs) {
> -        if (sourceDirs.size() > 0) {
> +        if (!sourceDirs.isEmpty()) {
>              toExecute.createArgument().setValue("-sourcepath");
>              toExecute.createArgument().setPath(sourceDirs);
>          }
> @@ -1889,7 +1880,7 @@ public class Javadoc extends Task {
>          }
>
>          if (classpath == null) {
> -            classpath = (new Path(getProject())).
> concatSystemClasspath("last");
> +            classpath = new Path(getProject()).
> concatSystemClasspath("last");
>          } else {
>              classpath = classpath.concatSystemClasspath("ignore");
>          }
> @@ -1914,32 +1905,31 @@ public class Javadoc extends Task {
>      private void doDoclet(final Commandline toExecute) {
>          if (doclet != null) {
>              if (doclet.getName() == null) {
> -                throw new BuildException("The doclet name must be "
> -                                         + "specified.", getLocation());
> -            } else {
> -                toExecute.createArgument().setValue("-doclet");
> -                toExecute.createArgument().setValue(doclet.getName());
> -                if (doclet.getPath() != null) {
> -                    final Path docletPath
> -                        = doclet.getPath().concatSystemClasspath("ignore"
> );
> -                    if (docletPath.size() != 0) {
> -                        toExecute.createArgument().
> setValue("-docletpath");
> -                        toExecute.createArgument().setPath(docletPath);
> -                    }
> +                throw new BuildException("The doclet name must be
> specified.",
> +                    getLocation());
> +            }
> +            toExecute.createArgument().setValue("-doclet");
> +            toExecute.createArgument().setValue(doclet.getName());
> +            if (doclet.getPath() != null) {
> +                final Path docletPath
> +                    = doclet.getPath().concatSystemClasspath("ignore");
> +                if (docletPath.size() != 0) {
> +                    toExecute.createArgument().setValue("-docletpath");
> +                    toExecute.createArgument().setPath(docletPath);
> +                }
> +            }
> +            for (final Enumeration<DocletParam> e = doclet.getParams();
> +                 e.hasMoreElements();) {
> +                final DocletParam param = e.nextElement();
> +                if (param.getName() == null) {
> +                    throw new BuildException(
> +                        "Doclet parameters must have a name");
>                  }
> -                for (final Enumeration<DocletParam> e =
> doclet.getParams();
> -                     e.hasMoreElements();) {
> -                    final DocletParam param = e.nextElement();
> -                    if (param.getName() == null) {
> -                        throw new BuildException("Doclet parameters must "
> -                                                 + "have a name");
> -                    }
>
> -                    toExecute.createArgument().setValue(param.getName());
> -                    if (param.getValue() != null) {
> -                        toExecute.createArgument()
> -                            .setValue(param.getValue());
> -                    }
> +                toExecute.createArgument().setValue(param.getName());
> +                if (param.getValue() != null) {
> +                    toExecute.createArgument()
> +                        .setValue(param.getValue());
>                  }
>              }
>          }
> @@ -1948,7 +1938,6 @@ public class Javadoc extends Task {
>      private void writeExternalArgs(final Commandline toExecute) {
>          // If using an external file, write the command line options to it
>          File optionsTmpFile = null;
> -        BufferedWriter optionsListWriter = null;
>          try {
>              optionsTmpFile = FILE_UTILS.createTempFile(
>                  "javadocOptions", "", null, true, true);
> @@ -1956,23 +1945,20 @@ public class Javadoc extends Task {
>              toExecute.clearArgs();
>              toExecute.createArgument().setValue(
>                  "@" + optionsTmpFile.getAbsolutePath());
> -            optionsListWriter = new BufferedWriter(
> -                new FileWriter(optionsTmpFile.getAbsolutePath(), true));
> -            for (int i = 0; i < listOpt.length; i++) {
> -                final String string = listOpt[i];
> -                if (string.startsWith("-J-")) {
> -                    toExecute.createArgument().setValue(string);
> -                } else  {
> -                    if (string.startsWith("-")) {
> -                        optionsListWriter.write(string);
> +            try (BufferedWriter optionsListWriter = new BufferedWriter(
> +                new FileWriter(optionsTmpFile.getAbsolutePath(), true)))
> {
> +                for (final String opt : listOpt) {
> +                    if (opt.startsWith("-J-")) {
> +                        toExecute.createArgument().setValue(opt);
> +                    } else if (opt.startsWith("-")) {
> +                        optionsListWriter.write(opt);
>                          optionsListWriter.write(" ");
>                      } else {
> -                        optionsListWriter.write(quoteString(string));
> +                        optionsListWriter.write(quoteString(opt));
>                          optionsListWriter.newLine();
>                      }
>                  }
>              }
> -            optionsListWriter.close();
>          } catch (final IOException ex) {
>              if (optionsTmpFile != null) {
>                  optionsTmpFile.delete();
> @@ -1980,8 +1966,6 @@ public class Javadoc extends Task {
>              throw new BuildException(
>                  "Error creating or writing temporary file for javadoc
> options",
>                  ex, getLocation());
> -        } finally {
> -            FileUtils.close(optionsListWriter);
>          }
>      }
>
> @@ -1998,85 +1982,78 @@ public class Javadoc extends Task {
>      }
>
>      private void doLinks(final Commandline toExecute) {
> -        if (links.size() != 0) {
> -            for (final Enumeration<LinkArgument> e = links.elements();
> e.hasMoreElements();) {
> -                final LinkArgument la = e.nextElement();
> -
> -                if (la.getHref() == null || la.getHref().length() == 0) {
> -                    log("No href was given for the link - skipping",
> -                        Project.MSG_VERBOSE);
> +        for (final LinkArgument la : links) {
> +            if (la.getHref() == null || la.getHref().isEmpty()) {
> +                log("No href was given for the link - skipping",
> +                    Project.MSG_VERBOSE);
> +                continue;
> +            }
> +            String link = null;
> +            if (la.shouldResolveLink()) {
> +                final File hrefAsFile =
> +                    getProject().resolveFile(la.getHref());
> +                if (hrefAsFile.exists()) {
> +                    try {
> +                        link = FILE_UTILS.getFileURL(hrefAsFile)
> +                            .toExternalForm();
> +                    } catch (final MalformedURLException ex) {
> +                        // should be impossible
> +                        log("Warning: link location was invalid "
> +                            + hrefAsFile, Project.MSG_WARN);
> +                    }
> +                }
> +            }
> +            if (link == null) {
> +                // is the href a valid URL
> +                try {
> +                    final URL base = new URL("file://.");
> +                    // created for the side effect of throwing a
> MalformedURLException
> +                    new URL(base, la.getHref()); //NOSONAR
> +                    link = la.getHref();
> +                } catch (final MalformedURLException mue) {
> +                    // ok - just skip
> +                    log("Link href \"" + la.getHref()
> +                        + "\" is not a valid url - skipping link",
> +                        Project.MSG_WARN);
>                      continue;
>                  }
> -                String link = null;
> -                if (la.shouldResolveLink()) {
> -                    final File hrefAsFile =
> -                        getProject().resolveFile(la.getHref());
> -                    if (hrefAsFile.exists()) {
> +            }
> +
> +            if (la.isLinkOffline()) {
> +                final File packageListLocation = la.getPackagelistLoc();
> +                URL packageListURL = la.getPackagelistURL();
> +                if (packageListLocation == null
> +                    && packageListURL == null) {
> +                    throw new BuildException(
> +                        "The package list location for link " +
> la.getHref()
> +                            + " must be provided because the link is
> offline");
> +                }
> +                if (packageListLocation != null) {
> +                    final File packageListFile =
> +                        new File(packageListLocation, "package-list");
> +                    if (packageListFile.exists()) {
>                          try {
> -                            link = FILE_UTILS.getFileURL(hrefAsFile)
> -                                .toExternalForm();
> +                            packageListURL =
> +                                FILE_UTILS.getFileURL(
> packageListLocation);
>                          } catch (final MalformedURLException ex) {
> -                            // should be impossible
> -                            log("Warning: link location was invalid "
> -                                + hrefAsFile, Project.MSG_WARN);
> +                            log("Warning: Package list location was "
> +                                + "invalid " + packageListLocation,
> +                                Project.MSG_WARN);
>                          }
> +                    } else {
> +                        log("Warning: No package list was found at "
> +                            + packageListLocation, Project.MSG_VERBOSE);
>                      }
>                  }
> -                if (link == null) {
> -                    // is the href a valid URL
> -                    try {
> -                        final URL base = new URL("file://.");
> -                        // created for the side effect of throwing a
> MalformedURLException
> -                        new URL(base, la.getHref()); //NOSONAR
> -                        link = la.getHref();
> -                    } catch (final MalformedURLException mue) {
> -                        // ok - just skip
> -                        log("Link href \"" + la.getHref()
> -                            + "\" is not a valid url - skipping link",
> -                            Project.MSG_WARN);
> -                        continue;
> -                    }
> -                }
> -
> -                if (la.isLinkOffline()) {
> -                    final File packageListLocation =
> la.getPackagelistLoc();
> -                    URL packageListURL = la.getPackagelistURL();
> -                    if (packageListLocation == null
> -                        && packageListURL == null) {
> -                        throw new BuildException("The package list"
> -                                                 + " location for link "
> -                                                 + la.getHref()
> -                                                 + " must be provided "
> -                                                 + "because the link is "
> -                                                 + "offline");
> -                    }
> -                    if (packageListLocation != null) {
> -                        final File packageListFile =
> -                            new File(packageListLocation, "package-list");
> -                        if (packageListFile.exists()) {
> -                            try {
> -                                packageListURL =
> -                                    FILE_UTILS.getFileURL(
> packageListLocation);
> -                            } catch (final MalformedURLException ex) {
> -                                log("Warning: Package list location was "
> -                                    + "invalid " + packageListLocation,
> -                                    Project.MSG_WARN);
> -                            }
> -                        } else {
> -                            log("Warning: No package list was found at "
> -                                + packageListLocation,
> Project.MSG_VERBOSE);
> -                        }
> -                    }
> -                    if (packageListURL != null) {
> -                        toExecute.createArgument().
> setValue("-linkoffline");
> -                        toExecute.createArgument().setValue(link);
> -                        toExecute.createArgument()
> -                            .setValue(packageListURL.toExternalForm());
> -                    }
> -                } else {
> -                    toExecute.createArgument().setValue("-link");
> +                if (packageListURL != null) {
> +                    toExecute.createArgument().setValue("-linkoffline");
>                      toExecute.createArgument().setValue(link);
> +                    toExecute.createArgument()
> +                        .setValue(packageListURL.toExternalForm());
>                  }
> +            } else {
> +                toExecute.createArgument().setValue("-link");
> +                toExecute.createArgument().setValue(link);
>              }
>          }
>      }
> @@ -2098,7 +2075,7 @@ public class Javadoc extends Task {
>              final StringTokenizer tok = new StringTokenizer(group, ",",
> false);
>              while (tok.hasMoreTokens()) {
>                  final String grp = tok.nextToken().trim();
> -                final int space = grp.indexOf(" ");
> +                final int space = grp.indexOf(' ');
>                  if (space > 0) {
>                      final String name = grp.substring(0, space);
>                      final String pkgList = grp.substring(space + 1);
> @@ -2112,36 +2089,30 @@ public class Javadoc extends Task {
>
>      // add the group arguments
>      private void doGroups(final Commandline toExecute) {
> -        if (groups.size() != 0) {
> -            for (final Enumeration<GroupArgument> e = groups.elements();
> e.hasMoreElements();) {
> -                final GroupArgument ga = e.nextElement();
> -                final String title = ga.getTitle();
> -                final String packages = ga.getPackages();
> -                if (title == null || packages == null) {
> -                    throw new BuildException("The title and packages must
> "
> -                                             + "be specified for group "
> -                                             + "elements.");
> -                }
> -                toExecute.createArgument().setValue("-group");
> -                toExecute.createArgument().setValue(expand(title));
> -                toExecute.createArgument().setValue(packages);
> +        for (final GroupArgument ga : groups) {
> +            final String title = ga.getTitle();
> +            final String packages = ga.getPackages();
> +            if (title == null || packages == null) {
> +                throw new BuildException(
> +                    "The title and packages must be specified for group
> elements.");
>              }
> +            toExecute.createArgument().setValue("-group");
> +            toExecute.createArgument().setValue(expand(title));
> +            toExecute.createArgument().setValue(packages);
>          }
>      }
>
>      // Do java1.4 arguments
>      private void doJava14(final Commandline toExecute) {
> -        for (final Enumeration<Object> e = tags.elements();
> e.hasMoreElements();) {
> -            final Object element = e.nextElement();
> +        for (final Object element : tags) {
>              if (element instanceof TagArgument) {
>                  final TagArgument ta = (TagArgument) element;
>                  final File tagDir = ta.getDir(getProject());
>                  if (tagDir == null) {
>                      // The tag element is not used as a fileset,
>                      // but specifies the tag directly.
> -                    toExecute.createArgument().setValue ("-tag");
> -                    toExecute.createArgument()
> -                        .setValue (ta.getParameter());
> +                    toExecute.createArgument().setValue("-tag");
> +                    toExecute.createArgument().
> setValue(ta.getParameter());
>                  } else {
>                      // The tag element is used as a
>                      // fileset. Parse all the files and create
> @@ -2149,26 +2120,22 @@ public class Javadoc extends Task {
>                      final DirectoryScanner tagDefScanner =
>                          ta.getDirectoryScanner(getProject());
>                      final String[] files = tagDefScanner.
> getIncludedFiles();
> -                    for (int i = 0; i < files.length; i++) {
> -                        final File tagDefFile = new File(tagDir,
> files[i]);
> -                        try {
> -                            final BufferedReader in
> -                                = new BufferedReader(
> -                                    new FileReader(tagDefFile)
> -                                                     );
> -                            String line = null;
> +                    for (String file : files) {
> +                        final File tagDefFile = new File(tagDir, file);
> +                        try (final BufferedReader in =
> +                            new BufferedReader(new
> FileReader(tagDefFile))) {
> +                            String line;
>                              while ((line = in.readLine()) != null) {
>                                  toExecute.createArgument()
>                                      .setValue("-tag");
>                                  toExecute.createArgument()
>                                      .setValue(line);
>                              }
> -                            in.close();
>                          } catch (final IOException ioe) {
>                              throw new BuildException(
> -                                "Couldn't read "
> -                                + " tag file from "
> -                                + tagDefFile.getAbsolutePath(), ioe);
> +                                "Couldn't read tag file from "
> +                                    + tagDefFile.getAbsolutePath(),
> +                                ioe);
>                          }
>                      }
>                  }
> @@ -2180,7 +2147,7 @@ public class Javadoc extends Task {
>                  if (tagletInfo.getPath() != null) {
>                      final Path tagletPath = tagletInfo.getPath()
>                          .concatSystemClasspath("ignore");
> -                    if (tagletPath.size() != 0) {
> +                    if (!tagletPath.isEmpty()) {
>                          toExecute.createArgument()
>                              .setValue("-tagletpath");
>                          toExecute.createArgument().setPath(tagletPath);
> @@ -2208,8 +2175,8 @@ public class Javadoc extends Task {
>      private void doDocFilesSubDirs(final Commandline toExecute) {
>          if (docFilesSubDirs) {
>              toExecute.createArgument().setValue("-docfilessubdirs");
> -            if (excludeDocFilesSubDir != null
> -                && excludeDocFilesSubDir.trim().length() > 0) {
> +            if (!(excludeDocFilesSubDir == null
> +                || excludeDocFilesSubDir.trim().isEmpty())) {
>                  toExecute.createArgument().setValue("-
> excludedocfilessubdir");
>                  toExecute.createArgument().setValue(
> excludeDocFilesSubDir);
>              }
> @@ -2218,10 +2185,10 @@ public class Javadoc extends Task {
>
>      private void doSourceAndPackageNames(
>          final Commandline toExecute,
> -        final Vector<String> packagesToDoc,
> -        final Vector<SourceFile> sourceFilesToDoc,
> +        final List<String> packagesToDoc,
> +        final List<SourceFile> sourceFilesToDoc,
>          final boolean useExternalFile,
> -        final File    tmpList,
> +        final File tmpList,
>          final BufferedWriter srcListWriter)
>          throws IOException {
>          for (final String packageName : packagesToDoc) {
> @@ -2238,7 +2205,7 @@ public class Javadoc extends Task {
>              if (useExternalFile) {
>                  // TODO what is the following doing?
>                  //     should it run if !javadoc4 && executable != null?
> -                if (sourceFileName.indexOf(" ") > -1) {
> +                if (sourceFileName.indexOf(' ') > -1) {
>                      String name = sourceFileName;
>                      if (File.separatorChar == '\\') {
>                          name = sourceFileName.replace(File.separatorChar,
> '/');
> @@ -2268,9 +2235,8 @@ public class Javadoc extends Task {
>          }
>          if (str.indexOf('\'') == -1) {
>              return quoteString(str, '\'');
> -        } else {
> -            return quoteString(str, '"');
>          }
> +        return quoteString(str, '"');
>      }
>
>      private boolean containsWhitespace(final String s) {
> @@ -2284,7 +2250,7 @@ public class Javadoc extends Task {
>      }
>
>      private String quoteString(final String str, final char delim) {
> -        final StringBuffer buf = new StringBuffer(str.length() * 2);
> +        final StringBuilder buf = new StringBuilder(str.length() * 2);
>          buf.append(delim);
>          final int len = str.length();
>          boolean lastCharWasCR = false;
> @@ -2332,18 +2298,16 @@ public class Javadoc extends Task {
>       *
>       * @since 1.7
>       */
> -    private void addSourceFiles(final Vector<SourceFile> sf) {
> -        final Iterator<ResourceCollection> e =
> nestedSourceFiles.iterator();
> -        while (e.hasNext()) {
> -            ResourceCollection rc = e.next();
> +    private void addSourceFiles(final List<SourceFile> sf) {
> +        for (ResourceCollection rc : nestedSourceFiles) {
>              if (!rc.isFilesystemOnly()) {
> -                throw new BuildException("only file system based
> resources are"
> -                                         + " supported by javadoc");
> +                throw new BuildException(
> +                    "only file system based resources are supported by
> javadoc");
>              }
>              if (rc instanceof FileSet) {
>                  final FileSet fs = (FileSet) rc;
>                  if (!fs.hasPatterns() && !fs.hasSelectors()) {
> -                    final FileSet fs2 = (FileSet) fs.clone();
> +                    final FileSet fs2 = fs.clone();
>                      fs2.createInclude().setName("**/*.java");
>                      if (includeNoSourcePackages) {
>                          fs2.createInclude().setName("**/package.html");
> @@ -2352,7 +2316,7 @@ public class Javadoc extends Task {
>                  }
>              }
>              for (final Resource r : rc) {
> -                sf.addElement(new SourceFile(r.as(FileProvider.
> class).getFile()));
> +                sf.add(new SourceFile(r.as(FileProvider.
> class).getFile()));
>              }
>          }
>      }
> @@ -2365,10 +2329,9 @@ public class Javadoc extends Task {
>       *
>       * @since 1.5
>       */
> -    private void parsePackages(final Vector<String> pn, final Path sp) {
> -        final HashSet<String> addedPackages = new HashSet<String>();
> -        @SuppressWarnings("unchecked")
> -        final Vector<DirSet> dirSets = (Vector<DirSet>)
> packageSets.clone();
> +    private void parsePackages(final List<String> pn, final Path sp) {
> +        final Set<String> addedPackages = new HashSet<>();
> +        final List<DirSet> dirSets = new ArrayList<>(packageSets);
>
>          // for each sourcePath entry, add a directoryset with includes
>          // taken from packagenames attribute and nested package
> @@ -2377,51 +2340,35 @@ public class Javadoc extends Task {
>          if (sourcePath != null) {
>              final PatternSet ps = new PatternSet();
>              ps.setProject(getProject());
> -            if (packageNames.size() > 0) {
> -                final Enumeration<PackageName> e =
> packageNames.elements();
> -                while (e.hasMoreElements()) {
> -                    final PackageName p = e.nextElement();
> -                    String pkg = p.getName().replace('.', '/');
> -                    if (pkg.endsWith("*")) {
> -                        pkg += "*";
> -                    }
> -                    ps.createInclude().setName(pkg);
> -                }
> -            } else {
> +            if (packageNames.isEmpty()) {
>                  ps.createInclude().setName("**");
> +            } else {
> +                packageNames.stream().map(PackageName::getName)
> +                    .map(s -> s.replace('.', '/').replaceFirst("\\*$",
> "**"))
> +                    .forEach(pkg -> ps.createInclude().setName(pkg));
>              }
>
> -            final Enumeration<PackageName> e =
> excludePackageNames.elements();
> -            while (e.hasMoreElements()) {
> -                final PackageName p = e.nextElement();
> -                String pkg = p.getName().replace('.', '/');
> -                if (pkg.endsWith("*")) {
> -                    pkg += "*";
> -                }
> -                ps.createExclude().setName(pkg);
> -            }
> -
> +            excludePackageNames.stream().map(PackageName::getName)
> +                .map(s -> s.replace('.', '/').replaceFirst("\\*$", "**"))
> +                .forEach(pkg -> ps.createExclude().setName(pkg));
>
> -            final String[] pathElements = sourcePath.list();
> -            for (int i = 0; i < pathElements.length; i++) {
> -                final File dir = new File(pathElements[i]);
> +            for (String pathElement : sourcePath.list()) {
> +                final File dir = new File(pathElement);
>                  if (dir.isDirectory()) {
>                      final DirSet ds = new DirSet();
>                      ds.setProject(getProject());
>                      ds.setDefaultexcludes(useDefaultExcludes);
>                      ds.setDir(dir);
>                      ds.createPatternSet().addConfiguredPatternset(ps);
> -                    dirSets.addElement(ds);
> +                    dirSets.add(ds);
>                  } else {
> -                    log("Skipping " + pathElements[i]
> +                    log("Skipping " + pathElement
>                          + " since it is no directory.", Project.MSG_WARN);
>                  }
>              }
>          }
>
> -        final Enumeration<DirSet> e = dirSets.elements();
> -        while (e.hasMoreElements()) {
> -            final DirSet ds = e.nextElement();
> +        for (DirSet ds : dirSets) {
>              final File baseDir = ds.getDir(getProject());
>              log("scanning " + baseDir + " for packages.",
> Project.MSG_DEBUG);
>              final DirectoryScanner dsc = ds.getDirectoryScanner(
> getProject());
> @@ -2430,20 +2377,14 @@ public class Javadoc extends Task {
>              for (int i = 0; i < dirs.length; i++) {
>                  // are there any java files in this directory?
>                  final File pd = new File(baseDir, dirs[i]);
> -                final String[] files = pd.list(new FilenameFilter () {
> -                        public boolean accept(final File dir1, final
> String name) {
> -                            return name.endsWith(".java")
> -                                || (includeNoSourcePackages
> -                                    && name.equals("package.html"));
> -                        }
> -                    });
> +                final String[] files = pd.list((dir1,
> +                    name) -> name.endsWith(".java") ||
> (includeNoSourcePackages
> +                        && name.equals("package.html")));
>
>                  if (files.length > 0) {
>                      if ("".equals(dirs[i])) {
>                          log(baseDir
> -                            + " contains source files in the default
> package,"
> -                            + " you must specify them as source files"
> -                            + " not packages.",
> +                            + " contains source files in the default
> package, you must specify them as source files not packages.",
>                              Project.MSG_WARN);
>                      } else {
>                          containsPackages = true;
> @@ -2451,7 +2392,7 @@ public class Javadoc extends Task {
>                              dirs[i].replace(File.separatorChar, '.');
>                          if (!addedPackages.contains(packageName)) {
>                              addedPackages.add(packageName);
> -                            pn.addElement(packageName);
> +                            pn.add(packageName);
>                          }
>                      }
>                  }
> @@ -2476,14 +2417,13 @@ public class Javadoc extends Task {
>                  Project.MSG_VERBOSE);
>              return;
>          }
> -        final String fixData;
>          final InputStream in = Javadoc.class
>              .getResourceAsStream("javadoc-frame-injections-fix.txt");
>          if (in == null) {
> -            throw new FileNotFoundException("Missing resource "
> -                                            + "'javadoc-frame-injections-fix.txt'
> in "
> -                                            + "classpath.");
> +            throw new FileNotFoundException(
> +                "Missing resource 'javadoc-frame-injections-fix.txt' in
> classpath.");
>          }
> +        final String fixData;
>          try {
>              fixData =
>                  fixLineFeeds(FileUtils
> @@ -2516,14 +2456,10 @@ public class Javadoc extends Task {
>              : FILE_UTILS.getDefaultEncoding();
>          // we load the whole file as one String (toc/index files are
>          // generally small, because they only contain frameset
> declaration):
> -        final InputStream fin = Files.newInputStream(file.toPath());
>          String fileContents;
> -        try {
> -            fileContents =
> -                fixLineFeeds(FileUtils
> -                             .safeReadFully(new InputStreamReader(fin,
> enc)));
> -        } finally {
> -            FileUtils.close(fin);
> +        try (InputStreamReader reader =
> +            new InputStreamReader(Files.newInputStream(file.toPath()),
> enc)) {
> +            fileContents = fixLineFeeds(FileUtils.safeReadFully(reader));
>          }
>
>          // check if file may be vulnerable because it was not
> @@ -2532,14 +2468,11 @@ public class Javadoc extends Task {
>              // we need to patch the file!
>              final String patchedFileContents = patchContent(fileContents,
> fixData);
>              if (!patchedFileContents.equals(fileContents)) {
> -                final OutputStream fos = Files.newOutputStream(file.
> toPath());
> -                try {
> -                    final OutputStreamWriter w = new
> OutputStreamWriter(fos, enc);
> +                try (final OutputStreamWriter w =
> +                    new OutputStreamWriter(Files.
> newOutputStream(file.toPath()), enc)) {
>                      w.write(patchedFileContents);
>                      w.close();
>                      return 1;
> -                } finally {
> -                    FileUtils.close(fos);
>                  }
>              }
>          }
> @@ -2598,7 +2531,6 @@ public class Javadoc extends Task {
>              }
>          }
>
> -
>          protected void logFlush() {
>              if (queuedLine != null) {
>                  super.processLine(queuedLine, Project.MSG_VERBOSE);
>
> http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/
> src/main/org/apache/tools/ant/taskdefs/Length.java
> ----------------------------------------------------------------------
> diff --git a/src/main/org/apache/tools/ant/taskdefs/Length.java
> b/src/main/org/apache/tools/ant/taskdefs/Length.java
> index 68fb20a..e776b59 100644
> --- a/src/main/org/apache/tools/ant/taskdefs/Length.java
> +++ b/src/main/org/apache/tools/ant/taskdefs/Length.java
> @@ -108,7 +108,7 @@ public class Length extends Task implements Condition {
>       * @param ell the long length to compare with.
>       */
>      public synchronized void setLength(long ell) {
> -        length = new Long(ell);
> +        length = Long.valueOf(ell);
>      }
>
>      /**
> @@ -152,7 +152,7 @@ public class Length extends Task implements Condition {
>       * @param trim <code>boolean</code>.
>       */
>      public synchronized void setTrim(boolean trim) {
> -        this.trim = trim ? Boolean.TRUE : Boolean.FALSE;
> +        this.trim = Boolean.valueOf(trim);
>      }
>
>      /**
> @@ -160,25 +160,31 @@ public class Length extends Task implements
> Condition {
>       * @return boolean trim setting.
>       */
>      public boolean getTrim() {
> -        return trim != null && trim.booleanValue();
> +        return Boolean.TRUE.equals(trim);
>      }
>
>      /**
>       * Execute the length task.
>       */
> +    @Override
>      public void execute() {
>          validate();
> -        PrintStream ps = new PrintStream((property != null)
> -            ? (OutputStream) new PropertyOutputStream(getProject(),
> property)
> -            : (OutputStream) new LogOutputStream(this, Project.MSG_INFO));
> +        OutputStream out =
> +            property == null ? new LogOutputStream(this, Project.MSG_INFO)
> +                : new PropertyOutputStream(getProject(), property);
> +        PrintStream ps = new PrintStream(out);
>
> -        if (STRING.equals(mode)) {
> +        switch (mode) {
> +        case STRING:
>              ps.print(getLength(string, getTrim()));
>              ps.close();
> -        } else if (EACH.equals(mode)) {
> +            break;
> +        case EACH:
>              handleResources(new EachHandler(ps));
> -        } else if (ALL.equals(mode)) {
> +            break;
> +        case ALL:
>              handleResources(new AllHandler(ps));
> +            break;
>          }
>      }
>
> @@ -187,6 +193,7 @@ public class Length extends Task implements Condition {
>       * @return true if the condition is true.
>       * @throws BuildException if an error occurs.
>       */
> +    @Override
>      public boolean eval() {
>          validate();
>          if (length == null) {
> @@ -194,11 +201,11 @@ public class Length extends Task implements
> Condition {
>          }
>          Long ell;
>          if (STRING.equals(mode)) {
> -            ell = new Long(getLength(string, getTrim()));
> +            ell = Long.valueOf(getLength(string, getTrim()));
>          } else {
>              AccumHandler h = new AccumHandler();
>              handleResources(h);
> -            ell = new Long(h.getAccum());
> +            ell = Long.valueOf(h.getAccum());
>          }
>          return when.evaluate(ell.compareTo(length));
>      }
> @@ -206,25 +213,26 @@ public class Length extends Task implements
> Condition {
>      private void validate() {
>          if (string != null) {
>              if (resources != null) {
> -                throw new BuildException("the string length function"
> -                    + " is incompatible with the file/resource length
> function");
> +                throw new BuildException(
> +                    "the string length function is incompatible with the
> file/resource length function");
>              }
>              if (!(STRING.equals(mode))) {
> -                throw new BuildException("the mode attribute is for use"
> -                    + " with the file/resource length function");
> +                throw new BuildException(
> +                    "the mode attribute is for use with the file/resource
> length function");
>              }
>          } else if (resources != null) {
>              if (!(EACH.equals(mode) || ALL.equals(mode))) {
> -                throw new BuildException("invalid mode setting for"
> -                    + " file/resource length function: \"" + mode + "\"");
> -            } else if (trim != null) {
> -                throw new BuildException("the trim attribute is"
> -                    + " for use with the string length function only");
> +                throw new BuildException(
> +                    "invalid mode setting for file/resource length
> function: \""
> +                        + mode + "\"");
> +            }
> +            if (trim != null) {
> +                throw new BuildException(
> +                    "the trim attribute is for use with the string length
> function only");
>              }
>          } else {
> -            throw new BuildException("you must set either the string
> attribute"
> -                + " or specify one or more files using the file attribute
> or"
> -                + " nested resource collections");
> +            throw new BuildException(
> +                "you must set either the string attribute or specify one
> or more files using the file attribute or nested resource collections");
>          }
>      }
>
> @@ -247,12 +255,13 @@ public class Length extends Task implements
> Condition {
>
>      /** EnumeratedAttribute operation mode */
>      public static class FileMode extends EnumeratedAttribute {
> -        static final String[] MODES = new String[] {EACH, ALL}; //NOSONAR
> +        static final String[] MODES = new String[] { EACH, ALL };
> //NOSONAR
>
>          /**
>           * Return the possible values for FileMode.
>           * @return <code>String[]</code>.
>           */
> +        @Override
>          public String[] getValues() {
>              return MODES;
>          }
> @@ -268,6 +277,7 @@ public class Length extends Task implements Condition {
>
>      private abstract class Handler {
>          private PrintStream ps;
> +
>          Handler(PrintStream ps) {
>              this.ps = ps;
>          }
> @@ -287,6 +297,8 @@ public class Length extends Task implements Condition {
>          EachHandler(PrintStream ps) {
>              super(ps);
>          }
> +
> +        @Override
>          protected void handle(Resource r) {
>              getPs().print(r.toString());
>              getPs().print(" : ");
> @@ -306,12 +318,16 @@ public class Length extends Task implements
> Condition {
>          AccumHandler() {
>              super(null);
>          }
> +
>          protected AccumHandler(PrintStream ps) {
>              super(ps);
>          }
> +
>          protected long getAccum() {
>              return accum;
>          }
> +
> +        @Override
>          protected synchronized void handle(Resource r) {
>              long size = r.getSize();
>              if (size == Resource.UNKNOWN_SIZE) {
> @@ -326,6 +342,8 @@ public class Length extends Task implements Condition {
>          AllHandler(PrintStream ps) {
>              super(ps);
>          }
> +
> +        @Override
>          void complete() {
>              getPs().print(getAccum());
>              super.complete();
>
> http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/
> src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
> ----------------------------------------------------------------------
> diff --git a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
> b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
> index 4c20c7c..9ff4e6e 100644
> --- a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
> +++ b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
> @@ -17,12 +17,12 @@
>   */
>  package org.apache.tools.ant.taskdefs;
>
> -import java.io.BufferedInputStream;
>  import java.io.ByteArrayInputStream;
>  import java.io.File;
>  import java.io.IOException;
>  import java.io.InputStreamReader;
> -import java.io.Reader;
> +import java.nio.charset.Charset;
> +import java.util.List;
>  import java.util.Properties;
>  import java.util.Vector;
>
> @@ -30,6 +30,7 @@ import org.apache.tools.ant.BuildException;
>  import org.apache.tools.ant.Project;
>  import org.apache.tools.ant.Task;
>  import org.apache.tools.ant.filters.util.ChainReaderHelper;
> +import org.apache.tools.ant.filters.util.ChainReaderHelper.ChainReader;
>  import org.apache.tools.ant.types.FilterChain;
>  import org.apache.tools.ant.types.Path;
>  import org.apache.tools.ant.types.Reference;
> @@ -37,7 +38,6 @@ import org.apache.tools.ant.types.Resource;
>  import org.apache.tools.ant.types.ResourceCollection;
>  import org.apache.tools.ant.types.resources.FileResource;
>  import org.apache.tools.ant.types.resources.JavaResource;
> -import org.apache.tools.ant.util.FileUtils;
>  import org.apache.tools.ant.util.ResourceUtils;
>
>  /**
> @@ -56,7 +56,7 @@ public class LoadProperties extends Task {
>      /**
>       * Holds filterchains
>       */
> -    private final Vector<FilterChain> filterChains = new
> Vector<FilterChain>();
> +    private final List<FilterChain> filterChains = new Vector<>();
>
>      /**
>       * Encoding to use for input; defaults to the platform's default
> encoding.
> @@ -158,6 +158,7 @@ public class LoadProperties extends Task {
>       *
>       * @exception BuildException if something goes wrong with the build
>       */
> +    @Override
>      public final void execute() throws BuildException {
>          //validation
>          if (src == null) {
> @@ -171,30 +172,21 @@ public class LoadProperties extends Task {
>              }
>              throw new BuildException("Source resource does not exist: " +
> src);
>          }
> -        BufferedInputStream bis = null;
> -        Reader instream = null;
> -        ByteArrayInputStream tis = null;
> -
> -        try {
> -            bis = new BufferedInputStream(src.getInputStream());
> -            if (encoding == null) {
> -                instream = new InputStreamReader(bis);
> -            } else {
> -                instream = new InputStreamReader(bis, encoding);
> -            }
> -            ChainReaderHelper crh = new ChainReaderHelper();
> -            crh.setPrimaryReader(instream);
> -            crh.setFilterChains(filterChains);
> -            crh.setProject(getProject());
> -            instream = crh.getAssembledReader();
>
> -            String text = crh.readFully(instream);
> +        Charset charset = encoding == null ? Charset.defaultCharset() :
> Charset.forName(encoding);
> +
> +        try (ChainReader instream = new ChainReaderHelper(getProject(),
> +            new InputStreamReader(src.getInputStream(), charset),
> filterChains)
> +                .getAssembledReader()) {
> +
> +            String text = instream.readFully();
>
> -            if (text != null && text.length() != 0) {
> +            if (!(text == null || text.isEmpty())) {
>                  if (!text.endsWith("\n")) {
>                      text = text + "\n";
>                  }
> -                tis = new ByteArrayInputStream(text.
> getBytes(ResourceUtils.ISO_8859_1));
> +                ByteArrayInputStream tis = new ByteArrayInputStream(
> +                    text.getBytes(ResourceUtils.ISO_8859_1));
>                  final Properties props = new Properties();
>                  props.load(tis);
>
> @@ -206,9 +198,6 @@ public class LoadProperties extends Task {
>              }
>          } catch (final IOException ioe) {
>              throw new BuildException("Unable to load file: " + ioe, ioe,
> getLocation());
> -        } finally {
> -            FileUtils.close(bis);
> -            FileUtils.close(tis);
>          }
>      }
>
> @@ -217,7 +206,7 @@ public class LoadProperties extends Task {
>       * @param filter the filter to add
>       */
>      public final void addFilterChain(FilterChain filter) {
> -        filterChains.addElement(filter);
> +        filterChains.add(filter);
>      }
>
>      /**
>
>

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

Posted by Matt Benson <gu...@gmail.com>.
Thanks for taking the time to look them over!

Matt

On Apr 18, 2017 2:25 AM, "Stefan Bodewig" <bo...@apache.org> wrote:

> On 2017-04-14, Stefan Bodewig wrote:
>
> > On 2017-04-13, Matt Benson wrote:
>
> >> Sorry for the giant pile of changes. Tests pass for me; does anyone
> object
> >> to my merging these to master?
>
> > Most likely I won't have any reason to object, but please allow me some
> > time to digest it :-)
>
> +1 for merging
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

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

Posted by Stefan Bodewig <bo...@apache.org>.
On 2017-04-14, Stefan Bodewig wrote:

> On 2017-04-13, Matt Benson wrote:

>> Sorry for the giant pile of changes. Tests pass for me; does anyone object
>> to my merging these to master?

> Most likely I won't have any reason to object, but please allow me some
> time to digest it :-)

+1 for merging

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


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

Posted by Stefan Bodewig <bo...@apache.org>.
On 2017-04-13, Matt Benson wrote:

> Sorry for the giant pile of changes. Tests pass for me; does anyone object
> to my merging these to master?

Most likely I won't have any reason to object, but please allow me some
time to digest it :-)

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org