Browse Source

Use foreach loops

master
Gintas Grigelionis 7 years ago
parent
commit
1c80d507f4
100 changed files with 569 additions and 724 deletions
  1. +2
    -4
      src/main/org/apache/tools/ant/AntClassLoader.java
  2. +4
    -6
      src/main/org/apache/tools/ant/Diagnostics.java
  3. +13
    -14
      src/main/org/apache/tools/ant/DirectoryScanner.java
  4. +4
    -10
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  5. +30
    -41
      src/main/org/apache/tools/ant/Project.java
  6. +3
    -3
      src/main/org/apache/tools/ant/ProjectHelper.java
  7. +4
    -4
      src/main/org/apache/tools/ant/PropertyHelper.java
  8. +1
    -4
      src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java
  9. +5
    -5
      src/main/org/apache/tools/ant/filters/ConcatFilter.java
  10. +5
    -5
      src/main/org/apache/tools/ant/filters/HeadFilter.java
  11. +5
    -5
      src/main/org/apache/tools/ant/filters/LineContains.java
  12. +7
    -7
      src/main/org/apache/tools/ant/filters/LineContainsRegExp.java
  13. +3
    -3
      src/main/org/apache/tools/ant/filters/PrefixLines.java
  14. +6
    -7
      src/main/org/apache/tools/ant/filters/SortFilter.java
  15. +3
    -3
      src/main/org/apache/tools/ant/filters/StripLineBreaks.java
  16. +3
    -3
      src/main/org/apache/tools/ant/filters/StripLineComments.java
  17. +3
    -3
      src/main/org/apache/tools/ant/filters/SuffixLines.java
  18. +4
    -4
      src/main/org/apache/tools/ant/filters/TabsToSpaces.java
  19. +5
    -5
      src/main/org/apache/tools/ant/filters/TailFilter.java
  20. +1
    -2
      src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java
  21. +2
    -2
      src/main/org/apache/tools/ant/helper/DefaultExecutor.java
  22. +3
    -3
      src/main/org/apache/tools/ant/helper/IgnoreDependenciesExecutor.java
  23. +7
    -6
      src/main/org/apache/tools/ant/launch/Launcher.java
  24. +3
    -6
      src/main/org/apache/tools/ant/launch/Locator.java
  25. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java
  26. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/AntStructure.java
  27. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Checksum.java
  28. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/Classloader.java
  29. +15
    -17
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  30. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/CopyPath.java
  31. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/Copydir.java
  32. +6
    -8
      src/main/org/apache/tools/ant/taskdefs/Delete.java
  33. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/Deltree.java
  34. +8
    -9
      src/main/org/apache/tools/ant/taskdefs/ExecTask.java
  35. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  36. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  37. +6
    -8
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  38. +8
    -11
      src/main/org/apache/tools/ant/taskdefs/Expand.java
  39. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  40. +7
    -10
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  41. +3
    -5
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  42. +12
    -21
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  43. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Jikes.java
  44. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  45. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/Move.java
  46. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Parallel.java
  47. +9
    -12
      src/main/org/apache/tools/ant/taskdefs/Recorder.java
  48. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  49. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/SubAnt.java
  50. +12
    -11
      src/main/org/apache/tools/ant/taskdefs/Sync.java
  51. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Touch.java
  52. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Untar.java
  53. +6
    -9
      src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
  54. +6
    -7
      src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
  55. +2
    -6
      src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java
  56. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
  57. +11
    -12
      src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java
  58. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java
  59. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
  60. +10
    -20
      src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
  61. +8
    -17
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  62. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java
  63. +4
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
  64. +2
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java
  65. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java
  66. +6
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
  67. +1
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
  68. +1
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
  69. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
  70. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  71. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
  72. +6
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter.java
  73. +11
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  74. +43
    -53
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  75. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  76. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java
  77. +32
    -35
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  78. +32
    -36
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  79. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java
  80. +6
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
  81. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  82. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
  83. +4
    -4
      src/main/org/apache/tools/ant/types/AbstractFileSet.java
  84. +5
    -7
      src/main/org/apache/tools/ant/types/Commandline.java
  85. +2
    -2
      src/main/org/apache/tools/ant/types/CommandlineJava.java
  86. +1
    -3
      src/main/org/apache/tools/ant/types/FilterChain.java
  87. +2
    -3
      src/main/org/apache/tools/ant/types/FilterSet.java
  88. +18
    -22
      src/main/org/apache/tools/ant/types/Path.java
  89. +8
    -8
      src/main/org/apache/tools/ant/types/PatternSet.java
  90. +2
    -2
      src/main/org/apache/tools/ant/types/Quantifier.java
  91. +7
    -8
      src/main/org/apache/tools/ant/types/RedirectorElement.java
  92. +3
    -4
      src/main/org/apache/tools/ant/types/XMLCatalog.java
  93. +3
    -4
      src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
  94. +4
    -4
      src/main/org/apache/tools/ant/types/resources/BZip2Resource.java
  95. +4
    -4
      src/main/org/apache/tools/ant/types/resources/Files.java
  96. +6
    -7
      src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
  97. +5
    -5
      src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
  98. +10
    -10
      src/main/org/apache/tools/ant/types/selectors/DateSelector.java
  99. +6
    -6
      src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
  100. +6
    -6
      src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java

+ 2
- 4
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -361,11 +361,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
public void setClassPath(final Path classpath) { public void setClassPath(final Path classpath) {
pathComponents.removeAllElements(); pathComponents.removeAllElements();
if (classpath != null) { if (classpath != null) {
final Path actualClasspath = classpath.concatSystemClasspath("ignore");
final String[] pathElements = actualClasspath.list();
for (int i = 0; i < pathElements.length; ++i) {
for (String pathElement : classpath.concatSystemClasspath("ignore").list()) {
try { try {
addPathElement(pathElements[i]);
addPathElement(pathElement);
} catch (final BuildException e) { } catch (final BuildException e) {
// ignore path elements which are invalid // ignore path elements which are invalid
// relative to the project // relative to the project


+ 4
- 6
src/main/org/apache/tools/ant/Diagnostics.java View File

@@ -410,8 +410,7 @@ public final class Diagnostics {
*/ */
private static void doReportAntHomeLibraries(PrintStream out) { private static void doReportAntHomeLibraries(PrintStream out) {
out.println(MagicNames.ANT_HOME + ": " + System.getProperty(MagicNames.ANT_HOME)); out.println(MagicNames.ANT_HOME + ": " + System.getProperty(MagicNames.ANT_HOME));
File[] libs = listLibraries();
printLibraries(libs, out);
printLibraries(listLibraries(), out);
} }


/** /**
@@ -423,8 +422,7 @@ public final class Diagnostics {
String home = System.getProperty(Launcher.USER_HOMEDIR); String home = System.getProperty(Launcher.USER_HOMEDIR);
out.println("user.home: " + home); out.println("user.home: " + home);
File libDir = new File(home, Launcher.USER_LIBDIR); File libDir = new File(home, Launcher.USER_LIBDIR);
File[] libs = listJarFiles(libDir);
printLibraries(libs, out);
printLibraries(listJarFiles(libDir), out);
} }


/** /**
@@ -437,8 +435,8 @@ public final class Diagnostics {
out.println("No such directory."); out.println("No such directory.");
return; return;
} }
for (int i = 0; i < libs.length; i++) {
out.println(libs[i].getName() + " (" + libs[i].length() + " bytes)");
for (File lib : libs) {
out.println(lib.getName() + " (" + lib.length() + " bytes)");
} }
} }




+ 13
- 14
src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -1204,7 +1204,7 @@ public class DirectoryScanner
} }


private void scandir(final File dir, final TokenizedPath path, final boolean fast, private void scandir(final File dir, final TokenizedPath path, final boolean fast,
String[] newfiles, final Deque<String> directoryNamesFollowed) {
String[] newFiles, final Deque<String> directoryNamesFollowed) {
String vpath = path.toString(); String vpath = path.toString();
if (vpath.length() > 0 && !vpath.endsWith(File.separator)) { if (vpath.length() > 0 && !vpath.endsWith(File.separator)) {
vpath += File.separator; vpath += File.separator;
@@ -1216,16 +1216,16 @@ public class DirectoryScanner
} }
if (!followSymlinks) { if (!followSymlinks) {
final ArrayList<String> noLinks = new ArrayList<>(); final ArrayList<String> noLinks = new ArrayList<>();
for (final String newfile : newfiles) {
for (final String newFile : newFiles) {
final Path filePath; final Path filePath;
if (dir == null) { if (dir == null) {
filePath = Paths.get(newfile);
filePath = Paths.get(newFile);
} else { } else {
filePath = Paths.get(dir.toPath().toString(), newfile);
filePath = Paths.get(dir.toPath().toString(), newFile);
} }
if (Files.isSymbolicLink(filePath)) { if (Files.isSymbolicLink(filePath)) {
final String name = vpath + newfile;
final File file = new File(dir, newfile);
final String name = vpath + newFile;
final File file = new File(dir, newFile);
if (file.isDirectory()) { if (file.isDirectory()) {
dirsExcluded.addElement(name); dirsExcluded.addElement(name);
} else if (file.isFile()) { } else if (file.isFile()) {
@@ -1233,18 +1233,18 @@ public class DirectoryScanner
} }
accountForNotFollowedSymlink(name, file); accountForNotFollowedSymlink(name, file);
} else { } else {
noLinks.add(newfile);
noLinks.add(newFile);
} }
} }
newfiles = noLinks.toArray(new String[noLinks.size()]);
newFiles = noLinks.toArray(new String[noLinks.size()]);
} else { } else {
directoryNamesFollowed.addFirst(dir.getName()); directoryNamesFollowed.addFirst(dir.getName());
} }


for (int i = 0; i < newfiles.length; i++) {
final String name = vpath + newfiles[i];
final TokenizedPath newPath = new TokenizedPath(path, newfiles[i]);
final File file = new File(dir, newfiles[i]);
for (String newFile : newFiles) {
final String name = vpath + newFile;
final TokenizedPath newPath = new TokenizedPath(path, newFile);
final File file = new File(dir, newFile);
final String[] children = file.list(); final String[] children = file.list();
if (children == null || (children.length == 0 && file.isFile())) { if (children == null || (children.length == 0 && file.isFile())) {
if (isIncluded(newPath)) { if (isIncluded(newPath)) {
@@ -1256,8 +1256,7 @@ public class DirectoryScanner
} else if (file.isDirectory()) { // dir } else if (file.isDirectory()) { // dir


if (followSymlinks if (followSymlinks
&& causesIllegalSymlinkLoop(newfiles[i], dir,
directoryNamesFollowed)) {
&& causesIllegalSymlinkLoop(newFile, dir, directoryNamesFollowed)) {
// will be caught and redirected to Ant's logging system // will be caught and redirected to Ant's logging system
System.err.println("skipping symbolic link " System.err.println("skipping symbolic link "
+ file.getAbsolutePath() + file.getAbsolutePath()


+ 4
- 10
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -179,10 +179,8 @@ public final class IntrospectionHelper {
*/ */
private IntrospectionHelper(final Class<?> bean) { private IntrospectionHelper(final Class<?> bean) {
this.bean = bean; this.bean = bean;
final Method[] methods = bean.getMethods();
Method addTextMethod = null; Method addTextMethod = null;
for (int i = 0; i < methods.length; i++) {
final Method m = methods[i];
for (final Method m : bean.getMethods()) {
final String name = m.getName(); final String name = m.getName();
final Class<?> returnType = m.getReturnType(); final Class<?> returnType = m.getReturnType();
final Class<?>[] args = m.getParameterTypes(); final Class<?>[] args = m.getParameterTypes();
@@ -205,7 +203,7 @@ public final class IntrospectionHelper {
} }
if ("addText".equals(name) && Void.TYPE.equals(returnType) if ("addText".equals(name) && Void.TYPE.equals(returnType)
&& args.length == 1 && String.class.equals(args[0])) { && args.length == 1 && String.class.equals(args[0])) {
addTextMethod = methods[i];
addTextMethod = m;
} else if (name.startsWith("set") && Void.TYPE.equals(returnType) } else if (name.startsWith("set") && Void.TYPE.equals(returnType)
&& args.length == 1 && !args[0].isArray()) { && args.length == 1 && !args[0].isArray()) {
final String propName = getPropertyName(name, "set"); final String propName = getPropertyName(name, "set");
@@ -1641,9 +1639,7 @@ public final class IntrospectionHelper {
Class<?> matchedClass = null; Class<?> matchedClass = null;
Method matchedMethod = null; Method matchedMethod = null;


final int size = methods.size();
for (int i = 0; i < size; ++i) {
final Method method = methods.get(i);
for (final Method method : methods) {
final Class<?> methodClass = method.getParameterTypes()[0]; final Class<?> methodClass = method.getParameterTypes()[0];
if (methodClass.isAssignableFrom(paramClass)) { if (methodClass.isAssignableFrom(paramClass)) {
if (matchedClass == null) { if (matchedClass == null) {
@@ -1689,9 +1685,7 @@ public final class IntrospectionHelper {
return null; return null;
} }
synchronized (definitions) { synchronized (definitions) {
final int size = definitions.size();
for (int i = 0; i < size; ++i) {
final AntTypeDefinition d = definitions.get(i);
for (final AntTypeDefinition d : definitions) {
final Class<?> exposedClass = d.getExposedClass(helper.getProject()); final Class<?> exposedClass = d.getExposedClass(helper.getProject());
if (exposedClass == null) { if (exposedClass == null) {
continue; continue;


+ 30
- 41
src/main/org/apache/tools/ant/Project.java View File

@@ -393,8 +393,8 @@ public class Project implements ResourceFactory {
public void addBuildListener(final BuildListener listener) { public void addBuildListener(final BuildListener listener) {
synchronized (listenersLock) { synchronized (listenersLock) {
// If the listeners already has this listener, do nothing // If the listeners already has this listener, do nothing
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
for (BuildListener buildListener : listeners) {
if (buildListener == listener) {
return; return;
} }
} }
@@ -439,8 +439,8 @@ public class Project implements ResourceFactory {
public Vector<BuildListener> getBuildListeners() { public Vector<BuildListener> getBuildListeners() {
synchronized (listenersLock) { synchronized (listenersLock) {
final Vector<BuildListener> r = new Vector<>(listeners.length); final Vector<BuildListener> r = new Vector<>(listeners.length);
for (int i = 0; i < listeners.length; i++) {
r.add(listeners[i]);
for (BuildListener listener : listeners) {
r.add(listener);
} }
return r; return r;
} }
@@ -1826,13 +1826,13 @@ public class Project implements ResourceFactory {
// dependency tree, not just on the Targets that depend on the // dependency tree, not just on the Targets that depend on the
// build Target. // build Target.


for (int i = 0; i < roots.length; i++) {
final String st = state.get(roots[i]);
for (String root : roots) {
final String st = state.get(root);
if (st == null) { if (st == null) {
tsort(roots[i], targetTable, state, visiting, ret);
tsort(root, targetTable, state, visiting, ret);
} else if (st == VISITING) { } else if (st == VISITING) {
throw new BuildException("Unexpected node in visiting state: " throw new BuildException("Unexpected node in visiting state: "
+ roots[i]);
+ root);
} }
} }
final StringBuilder buf = new StringBuilder("Build sequence for target(s)"); final StringBuilder buf = new StringBuilder("Build sequence for target(s)");
@@ -2087,9 +2087,8 @@ public class Project implements ResourceFactory {
*/ */
public void fireBuildStarted() { public void fireBuildStarted() {
final BuildEvent event = new BuildEvent(this); final BuildEvent event = new BuildEvent(this);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].buildStarted(event);
for (BuildListener currListener : listeners) {
currListener.buildStarted(event);
} }
} }


@@ -2103,9 +2102,8 @@ public class Project implements ResourceFactory {
public void fireBuildFinished(final Throwable exception) { public void fireBuildFinished(final Throwable exception) {
final BuildEvent event = new BuildEvent(this); final BuildEvent event = new BuildEvent(this);
event.setException(exception); event.setException(exception);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].buildFinished(event);
for (BuildListener currListener : listeners) {
currListener.buildFinished(event);
} }
// Inform IH to clear the cache // Inform IH to clear the cache
IntrospectionHelper.clearCache(); IntrospectionHelper.clearCache();
@@ -2119,10 +2117,9 @@ public class Project implements ResourceFactory {
*/ */
public void fireSubBuildStarted() { public void fireSubBuildStarted() {
final BuildEvent event = new BuildEvent(this); final BuildEvent event = new BuildEvent(this);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
if (currListeners[i] instanceof SubBuildListener) {
((SubBuildListener) currListeners[i]).subBuildStarted(event);
for (BuildListener currListener : listeners) {
if (currListener instanceof SubBuildListener) {
((SubBuildListener) currListener).subBuildStarted(event);
} }
} }
} }
@@ -2139,10 +2136,9 @@ public class Project implements ResourceFactory {
public void fireSubBuildFinished(final Throwable exception) { public void fireSubBuildFinished(final Throwable exception) {
final BuildEvent event = new BuildEvent(this); final BuildEvent event = new BuildEvent(this);
event.setException(exception); event.setException(exception);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
if (currListeners[i] instanceof SubBuildListener) {
((SubBuildListener) currListeners[i]).subBuildFinished(event);
for (BuildListener currListener : listeners) {
if (currListener instanceof SubBuildListener) {
((SubBuildListener) currListener).subBuildFinished(event);
} }
} }
} }
@@ -2156,9 +2152,8 @@ public class Project implements ResourceFactory {
*/ */
protected void fireTargetStarted(final Target target) { protected void fireTargetStarted(final Target target) {
final BuildEvent event = new BuildEvent(target); final BuildEvent event = new BuildEvent(target);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].targetStarted(event);
for (BuildListener currListener : listeners) {
currListener.targetStarted(event);
} }


} }
@@ -2176,9 +2171,8 @@ public class Project implements ResourceFactory {
protected void fireTargetFinished(final Target target, final Throwable exception) { protected void fireTargetFinished(final Target target, final Throwable exception) {
final BuildEvent event = new BuildEvent(target); final BuildEvent event = new BuildEvent(target);
event.setException(exception); event.setException(exception);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].targetFinished(event);
for (BuildListener currListener : listeners) {
currListener.targetFinished(event);
} }


} }
@@ -2194,9 +2188,8 @@ public class Project implements ResourceFactory {
// register this as the current task on the current thread. // register this as the current task on the current thread.
registerThreadTask(Thread.currentThread(), task); registerThreadTask(Thread.currentThread(), task);
final BuildEvent event = new BuildEvent(task); final BuildEvent event = new BuildEvent(task);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].taskStarted(event);
for (BuildListener currListener : listeners) {
currListener.taskStarted(event);
} }
} }


@@ -2216,9 +2209,8 @@ public class Project implements ResourceFactory {
System.err.flush(); System.err.flush();
final BuildEvent event = new BuildEvent(task); final BuildEvent event = new BuildEvent(task);
event.setException(exception); event.setException(exception);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].taskFinished(event);
for (BuildListener currListener : listeners) {
currListener.taskFinished(event);
} }


} }
@@ -2264,9 +2256,8 @@ public class Project implements ResourceFactory {
} }
try { try {
isLoggingMessage.set(Boolean.TRUE); isLoggingMessage.set(Boolean.TRUE);
final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].messageLogged(event);
for (BuildListener currListener : listeners) {
currListener.messageLogged(event);
} }
} finally { } finally {
isLoggingMessage.set(Boolean.FALSE); isLoggingMessage.set(Boolean.FALSE);
@@ -2466,11 +2457,9 @@ public class Project implements ResourceFactory {
return; return;
} }
try { try {
final Method method =
obj.getClass().getMethod(
"setProject", new Class[] {Project.class});
final Method method = obj.getClass().getMethod("setProject", Project.class);
if (method != null) { if (method != null) {
method.invoke(obj, new Object[] {this});
method.invoke(obj, this);
} }
} catch (final Throwable e) { } catch (final Throwable e) {
// ignore this if the object does not have // ignore this if the object does not have


+ 3
- 3
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -136,9 +136,9 @@ public class ProjectHelper {
if (name == null) { if (name == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
for (int i = 0; i < values.length; i++) {
if (name.equals(values[i].name())) {
return values[i];
for (OnMissingExtensionPoint value : values) {
if (name.equals(value.name())) {
return value;
} }
} }
throw new IllegalArgumentException( throw new IllegalArgumentException(


+ 4
- 4
src/main/org/apache/tools/ant/PropertyHelper.java View File

@@ -1131,11 +1131,11 @@ public class PropertyHelper implements GetProperty {
final HashSet<Class<? extends Delegate>> result = new HashSet<>(); final HashSet<Class<? extends Delegate>> result = new HashSet<>();
Class<?> c = d.getClass(); Class<?> c = d.getClass();
while (c != null) { while (c != null) {
Class<?>[] ifs = c.getInterfaces();
for (int i = 0; i < ifs.length; i++) {
if (Delegate.class.isAssignableFrom(ifs[i])) {
for (Class<?> ifc : c.getInterfaces()) {
if (Delegate.class.isAssignableFrom(ifc)) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final Class<? extends Delegate> delegateInterface = (Class<? extends Delegate>) ifs[i];
final Class<? extends Delegate> delegateInterface =
(Class<? extends Delegate>) ifc;
result.add(delegateInterface); result.add(delegateInterface);
} }
} }


+ 1
- 4
src/main/org/apache/tools/ant/attribute/BaseIfAttribute.java View File

@@ -20,7 +20,6 @@ package org.apache.tools.ant.attribute;


import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map; import java.util.Map;


import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.ProjectComponent;
@@ -72,9 +71,7 @@ public abstract class BaseIfAttribute
Map<String, String> ret = new HashMap<>(); Map<String, String> ret = new HashMap<>();
RuntimeConfigurable rc = el.getWrapper(); RuntimeConfigurable rc = el.getWrapper();
Hashtable<String, Object> attributes = rc.getAttributeMap(); // This does a copy! Hashtable<String, Object> attributes = rc.getAttributeMap(); // This does a copy!
for (Iterator<Map.Entry<String, Object>> i =
attributes.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, Object> entry = i.next();
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String value = (String) entry.getValue(); String value = (String) entry.getValue();
if (key.startsWith("ant-attribute:param")) { if (key.startsWith("ant-attribute:param")) {


+ 5
- 5
src/main/org/apache/tools/ant/filters/ConcatFilter.java View File

@@ -191,13 +191,13 @@ public final class ConcatFilter extends BaseParamFilterReader
// get parameters // get parameters
final Parameter[] params = getParameters(); final Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if ("prepend".equals(params[i].getName())) {
setPrepend(new File(params[i].getValue()));
for (Parameter param : params) {
if ("prepend".equals(param.getName())) {
setPrepend(new File(param.getValue()));
continue; continue;
} }
if ("append".equals(params[i].getName())) {
setAppend(new File(params[i].getValue()));
if ("append".equals(param.getName())) {
setAppend(new File(param.getValue()));
continue; continue;
} }
} }


+ 5
- 5
src/main/org/apache/tools/ant/filters/HeadFilter.java View File

@@ -187,13 +187,13 @@ public final class HeadFilter extends BaseParamFilterReader
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (LINES_KEY.equals(params[i].getName())) {
lines = Long.parseLong(params[i].getValue());
for (Parameter param : params) {
if (LINES_KEY.equals(param.getName())) {
lines = Long.parseLong(param.getValue());
continue; continue;
} }
if (SKIP_KEY.equals(params[i].getName())) {
skip = Long.parseLong(params[i].getValue());
if (SKIP_KEY.equals(param.getName())) {
skip = Long.parseLong(param.getValue());
continue; continue;
} }
} }


+ 5
- 5
src/main/org/apache/tools/ant/filters/LineContains.java View File

@@ -204,11 +204,11 @@ public final class LineContains
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (CONTAINS_KEY.equals(params[i].getType())) {
contains.addElement(params[i].getValue());
} else if (NEGATE_KEY.equals(params[i].getType())) {
setNegate(Project.toBoolean(params[i].getValue()));
for (Parameter param : params) {
if (CONTAINS_KEY.equals(param.getType())) {
contains.addElement(param.getValue());
} else if (NEGATE_KEY.equals(param.getType())) {
setNegate(Project.toBoolean(param.getValue()));
} }
} }
} }


+ 7
- 7
src/main/org/apache/tools/ant/filters/LineContainsRegExp.java View File

@@ -237,13 +237,13 @@ public final class LineContainsRegExp
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (REGEXP_KEY.equals(params[i].getType())) {
setRegexp(params[i].getValue());
} else if (NEGATE_KEY.equals(params[i].getType())) {
setNegate(Project.toBoolean(params[i].getValue()));
} else if (CS_KEY.equals(params[i].getType())) {
setCaseSensitive(Project.toBoolean(params[i].getValue()));
for (Parameter param : params) {
if (REGEXP_KEY.equals(param.getType())) {
setRegexp(param.getValue());
} else if (NEGATE_KEY.equals(param.getType())) {
setNegate(Project.toBoolean(param.getValue()));
} else if (CS_KEY.equals(param.getType())) {
setCaseSensitive(Project.toBoolean(param.getValue()));
} }
} }
} }


+ 3
- 3
src/main/org/apache/tools/ant/filters/PrefixLines.java View File

@@ -153,9 +153,9 @@ public final class PrefixLines
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (PREFIX_KEY.equals(params[i].getName())) {
prefix = params[i].getValue();
for (Parameter param : params) {
if (PREFIX_KEY.equals(param.getName())) {
prefix = param.getValue();
break; break;
} }
} }


+ 6
- 7
src/main/org/apache/tools/ant/filters/SortFilter.java View File

@@ -314,19 +314,18 @@ public final class SortFilter extends BaseParamFilterReader
// get parameters // get parameters
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
final String paramName = params[i].getName();
for (Parameter param : params) {
final String paramName = param.getName();
if (REVERSE_KEY.equals(paramName)) { if (REVERSE_KEY.equals(paramName)) {
setReverse(Boolean.valueOf(params[i].getValue())
.booleanValue());
setReverse(Boolean.valueOf(param.getValue()).booleanValue());
continue; continue;
} }
if (COMPARATOR_KEY.equals(paramName)) { if (COMPARATOR_KEY.equals(paramName)) {
try { try {
String className = (String) params[i].getValue();
String className = (String) param.getValue();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final Comparator<? super String> comparatorInstance = (Comparator<? super String>) (Class
.forName(className).newInstance());
final Comparator<? super String> comparatorInstance
= (Comparator<? super String>) (Class.forName(className).newInstance());
setComparator(comparatorInstance); setComparator(comparatorInstance);
continue; continue;
} catch (InstantiationException e) { } catch (InstantiationException e) {


+ 3
- 3
src/main/org/apache/tools/ant/filters/StripLineBreaks.java View File

@@ -140,9 +140,9 @@ public final class StripLineBreaks
String userDefinedLineBreaks = null; String userDefinedLineBreaks = null;
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (LINE_BREAKS_KEY.equals(params[i].getName())) {
userDefinedLineBreaks = params[i].getValue();
for (Parameter param : params) {
if (LINE_BREAKS_KEY.equals(param.getName())) {
userDefinedLineBreaks = param.getValue();
break; break;
} }
} }


+ 3
- 3
src/main/org/apache/tools/ant/filters/StripLineComments.java View File

@@ -186,9 +186,9 @@ public final class StripLineComments
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (COMMENTS_KEY.equals(params[i].getType())) {
comments.addElement(params[i].getValue());
for (Parameter param : params) {
if (COMMENTS_KEY.equals(param.getType())) {
comments.addElement(param.getValue());
} }
} }
} }


+ 3
- 3
src/main/org/apache/tools/ant/filters/SuffixLines.java View File

@@ -163,9 +163,9 @@ public final class SuffixLines
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (SUFFIX_KEY.equals(params[i].getName())) {
suffix = params[i].getValue();
for (Parameter param : params) {
if (SUFFIX_KEY.equals(param.getName())) {
suffix = param.getValue();
break; break;
} }
} }


+ 4
- 4
src/main/org/apache/tools/ant/filters/TabsToSpaces.java View File

@@ -142,10 +142,10 @@ public final class TabsToSpaces
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (params[i] != null) {
if (TAB_LENGTH_KEY.equals(params[i].getName())) {
tabLength = Integer.parseInt(params[i].getValue());
for (Parameter param : params) {
if (param != null) {
if (TAB_LENGTH_KEY.equals(param.getName())) {
tabLength = Integer.parseInt(param.getValue());
break; break;
} }
} }


+ 5
- 5
src/main/org/apache/tools/ant/filters/TailFilter.java View File

@@ -187,13 +187,13 @@ public final class TailFilter extends BaseParamFilterReader
private void initialize() { private void initialize() {
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (int i = 0; i < params.length; i++) {
if (LINES_KEY.equals(params[i].getName())) {
setLines(Long.parseLong(params[i].getValue()));
for (Parameter param : params) {
if (LINES_KEY.equals(param.getName())) {
setLines(Long.parseLong(param.getValue()));
continue; continue;
} }
if (SKIP_KEY.equals(params[i].getName())) {
skip = Long.parseLong(params[i].getValue());
if (SKIP_KEY.equals(param.getName())) {
skip = Long.parseLong(param.getValue());
continue; continue;
} }
} }


+ 1
- 2
src/main/org/apache/tools/ant/filters/util/JavaClassHelper.java View File

@@ -48,8 +48,7 @@ public final class JavaClassHelper {
final ClassParser parser = new ClassParser(bis, ""); final ClassParser parser = new ClassParser(bis, "");
final JavaClass javaClass = parser.parse(); final JavaClass javaClass = parser.parse();
final Field[] fields = javaClass.getFields(); final Field[] fields = javaClass.getFields();
for (int i = 0; i < fields.length; i++) {
final Field field = fields[i];
for (final Field field : fields) {
if (field != null) { if (field != null) {
final ConstantValue cv = field.getConstantValue(); final ConstantValue cv = field.getConstantValue();
if (cv != null) { if (cv != null) {


+ 2
- 2
src/main/org/apache/tools/ant/helper/DefaultExecutor.java View File

@@ -36,9 +36,9 @@ public class DefaultExecutor implements Executor {
public void executeTargets(Project project, String[] targetNames) public void executeTargets(Project project, String[] targetNames)
throws BuildException { throws BuildException {
BuildException thrownException = null; BuildException thrownException = null;
for (int i = 0; i < targetNames.length; i++) {
for (String targetName : targetNames) {
try { try {
project.executeTarget(targetNames[i]);
project.executeTarget(targetName);
} catch (BuildException ex) { } catch (BuildException ex) {
if (project.isKeepGoingMode()) { if (project.isKeepGoingMode()) {
thrownException = ex; thrownException = ex;


+ 3
- 3
src/main/org/apache/tools/ant/helper/IgnoreDependenciesExecutor.java View File

@@ -42,11 +42,11 @@ public class IgnoreDependenciesExecutor implements Executor {
throws BuildException { throws BuildException {
Hashtable<String, Target> targets = project.getTargets(); Hashtable<String, Target> targets = project.getTargets();
BuildException thrownException = null; BuildException thrownException = null;
for (int i = 0; i < targetNames.length; i++) {
for (String targetName : targetNames) {
try { try {
Target t = targets.get(targetNames[i]);
Target t = targets.get(targetName);
if (t == null) { if (t == null) {
throw new BuildException("Unknown target " + targetNames[i]);
throw new BuildException("Unknown target " + targetName);
} }
t.performTasks(); t.performTasks();
} catch (BuildException ex) { } catch (BuildException ex) {


+ 7
- 6
src/main/org/apache/tools/ant/launch/Launcher.java View File

@@ -144,10 +144,11 @@ public class Launcher {
} }
if (getJars && element.isDirectory()) { if (getJars && element.isDirectory()) {
// add any jars in the directory // add any jars in the directory
final URL[] dirURLs = Locator.getLocationURLs(element);
for (int j = 0; j < dirURLs.length; ++j) {
if (launchDiag) { System.out.println("adding library JAR: " + dirURLs[j]);}
libPathURLs.add(dirURLs[j]);
for (URL dirURL : Locator.getLocationURLs(element)) {
if (launchDiag) {
System.out.println("adding library JAR: " + dirURL);
}
libPathURLs.add(dirURL);
} }
} }


@@ -265,9 +266,9 @@ public class Launcher {
baseClassPath.setLength(baseClassPath.length() - 1); baseClassPath.setLength(baseClassPath.length() - 1);
} }


for (int i = 0; i < jars.length; ++i) {
for (URL jar : jars) {
baseClassPath.append(File.pathSeparatorChar); baseClassPath.append(File.pathSeparatorChar);
baseClassPath.append(Locator.fromURI(jars[i].toString()));
baseClassPath.append(Locator.fromURI(jar.toString()));
} }


setProperty(JAVA_CLASS_PATH, baseClassPath.toString()); setProperty(JAVA_CLASS_PATH, baseClassPath.toString());


+ 3
- 6
src/main/org/apache/tools/ant/launch/Locator.java View File

@@ -86,10 +86,7 @@ public final class Locator {
gAfterEscaping2[DEL] = 'F'; gAfterEscaping2[DEL] = 'F';
char[] escChs = {' ', '<', '>', '#', '%', '"', '{', '}', char[] escChs = {' ', '<', '>', '#', '%', '"', '{', '}',
'|', '\\', '^', '~', '[', ']', '`'}; '|', '\\', '^', '~', '[', ']', '`'};
int len = escChs.length;
char ch;
for (int i = 0; i < len; i++) {
ch = escChs[i];
for (char ch : escChs) {
gNeedEscaping[ch] = true; gNeedEscaping[ch] = true;
gAfterEscaping1[ch] = gHexChs[ch >> NIBBLE]; gAfterEscaping1[ch] = gHexChs[ch >> NIBBLE];
gAfterEscaping2[ch] = gHexChs[ch & NIBBLE_MASK]; gAfterEscaping2[ch] = gHexChs[ch & NIBBLE_MASK];
@@ -485,8 +482,8 @@ public final class Locator {
urls = new URL[1]; urls = new URL[1];
String path = location.getPath(); String path = location.getPath();
String littlePath = path.toLowerCase(Locale.ENGLISH); String littlePath = path.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < extensions.length; ++i) {
if (littlePath.endsWith(extensions[i])) {
for (String extension : extensions) {
if (littlePath.endsWith(extension)) {
urls[0] = fileToURL(location); urls[0] = fileToURL(location);
break; break;
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java View File

@@ -430,10 +430,10 @@ public abstract class AbstractCvsTask extends Task {
buf.append(newLine); buf.append(newLine);
buf.append("environment:"); buf.append("environment:");
buf.append(newLine); buf.append(newLine);
for (int z = 0; z < variableArray.length; z++) {
for (String variable : variableArray) {
buf.append(newLine); buf.append(newLine);
buf.append("\t"); buf.append("\t");
buf.append(variableArray[z]);
buf.append(variable);
} }
} }




+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/AntStructure.java View File

@@ -428,8 +428,8 @@ public class AntStructure extends Task {
* @return true if all the strings in the array math XML-NMTOKEN * @return true if all the strings in the array math XML-NMTOKEN
*/ */
public static final boolean areNmtokens(final String[] s) { public static final boolean areNmtokens(final String[] s) {
for (int i = 0; i < s.length; i++) {
if (!isNmtoken(s[i])) {
for (String value : s) {
if (!isNmtoken(value)) {
return false; return false;
} }
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Checksum.java View File

@@ -579,8 +579,8 @@ public class Checksum extends MatchingTask implements Condition {


private String createDigestString(byte[] fileDigest) { private String createDigestString(byte[] fileDigest) {
StringBuilder checksumSb = new StringBuilder(); StringBuilder checksumSb = new StringBuilder();
for (int i = 0; i < fileDigest.length; i++) {
String hexStr = Integer.toHexString(BYTE_MASK & fileDigest[i]);
for (byte digestByte : fileDigest) {
String hexStr = Integer.toHexString(BYTE_MASK & digestByte);
if (hexStr.length() < 2) { if (hexStr.length() < 2) {
checksumSb.append('0'); checksumSb.append('0');
} }


+ 2
- 3
src/main/org/apache/tools/ant/taskdefs/Classloader.java View File

@@ -221,9 +221,8 @@ public class Classloader extends Task {
} }


if (existingLoader && classpath != null) { if (existingLoader && classpath != null) {
String[] list = classpath.list();
for (int i = 0; i < list.length; i++) {
File f = new File(list[i]);
for (String path : classpath.list()) {
File f = new File(path);
if (f.exists()) { if (f.exists()) {
log("Adding to class loader " + acl + " " + f.getAbsolutePath(), log("Adding to class loader " + acl + " " + f.getAbsolutePath(),
Project.MSG_DEBUG); Project.MSG_DEBUG);


+ 15
- 17
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -774,9 +774,9 @@ public class Copy extends Task {
String[] toCopy = null; String[] toCopy = null;
if (forceOverwrite) { if (forceOverwrite) {
final Vector<String> v = new Vector<String>(); final Vector<String> v = new Vector<String>();
for (int i = 0; i < names.length; i++) {
if (mapper.mapFileName(names[i]) != null) {
v.addElement(names[i]);
for (String name : names) {
if (mapper.mapFileName(name) != null) {
v.addElement(name);
} }
} }
toCopy = new String[v.size()]; toCopy = new String[v.size()];
@@ -785,16 +785,16 @@ public class Copy extends Task {
final SourceFileScanner ds = new SourceFileScanner(this); final SourceFileScanner ds = new SourceFileScanner(this);
toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity); toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity);
} }
for (int i = 0; i < toCopy.length; i++) {
final File src = new File(fromDir, toCopy[i]);
final String[] mappedFiles = mapper.mapFileName(toCopy[i]);
for (String name : toCopy) {
final File src = new File(fromDir, name);
final String[] mappedFiles = mapper.mapFileName(name);
if (mappedFiles == null || mappedFiles.length == 0) { if (mappedFiles == null || mappedFiles.length == 0) {
continue; continue;
} }


if (!enableMultipleMappings) { if (!enableMultipleMappings) {
map.put(src.getAbsolutePath(), map.put(src.getAbsolutePath(),
new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()});
new String[]{new File(toDir, mappedFiles[0]).getAbsolutePath()});
} else { } else {
// reuse the array created by the mapper // reuse the array created by the mapper
for (int k = 0; k < mappedFiles.length; k++) { for (int k = 0; k < mappedFiles.length; k++) {
@@ -820,9 +820,9 @@ public class Copy extends Task {
Resource[] toCopy; Resource[] toCopy;
if (forceOverwrite) { if (forceOverwrite) {
final List<Resource> v = new ArrayList<>(); final List<Resource> v = new ArrayList<>();
for (int i = 0; i < fromResources.length; i++) {
if (mapper.mapFileName(fromResources[i].getName()) != null) {
v.add(fromResources[i]);
for (Resource rc : fromResources) {
if (mapper.mapFileName(rc.getName()) != null) {
v.add(rc);
} }
} }
toCopy = v.toArray(new Resource[v.size()]); toCopy = v.toArray(new Resource[v.size()]);
@@ -832,22 +832,21 @@ public class Copy extends Task {
(ResourceFactory) name -> new FileResource(toDir, name), (ResourceFactory) name -> new FileResource(toDir, name),
granularity); granularity);
} }
for (int i = 0; i < toCopy.length; i++) {
final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName());
for (Resource rc : toCopy) {
final String[] mappedFiles = mapper.mapFileName(rc.getName());
if (mappedFiles == null || mappedFiles.length == 0) { if (mappedFiles == null || mappedFiles.length == 0) {
throw new BuildException("Can't copy a resource without a" throw new BuildException("Can't copy a resource without a"
+ " name if the mapper doesn't" + " name if the mapper doesn't"
+ " provide one."); + " provide one.");
} }
if (!enableMultipleMappings) { if (!enableMultipleMappings) {
map.put(toCopy[i],
new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()});
map.put(rc, new String[]{new File(toDir, mappedFiles[0]).getAbsolutePath()});
} else { } else {
// reuse the array created by the mapper // reuse the array created by the mapper
for (int k = 0; k < mappedFiles.length; k++) { for (int k = 0; k < mappedFiles.length; k++) {
mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath(); mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath();
} }
map.put(toCopy[i], mappedFiles);
map.put(rc, mappedFiles);
} }
} }
return map; return map;
@@ -865,9 +864,8 @@ public class Copy extends Task {


for (final Map.Entry<String, String[]> e : fileCopyMap.entrySet()) { for (final Map.Entry<String, String[]> e : fileCopyMap.entrySet()) {
final String fromFile = e.getKey(); final String fromFile = e.getKey();
final String[] toFiles = e.getValue();


for (final String toFile : toFiles) {
for (final String toFile : e.getValue()) {
if (fromFile.equals(toFile)) { if (fromFile.equals(toFile)) {
log("Skipping self-copy of " + fromFile, verbosity); log("Skipping self-copy of " + fromFile, verbosity);
continue; continue;


+ 2
- 4
src/main/org/apache/tools/ant/taskdefs/CopyPath.java View File

@@ -177,17 +177,15 @@ public class CopyPath extends Task {
return; return;
} }


for (int sources = 0; sources < sourceFiles.length; sources++) {
for (String sourceFileName : sourceFiles) {


String sourceFileName = sourceFiles[sources];
File sourceFile = new File(sourceFileName); File sourceFile = new File(sourceFileName);
String[] toFiles = (String[]) mapper.mapFileName(sourceFileName); String[] toFiles = (String[]) mapper.mapFileName(sourceFileName);
if (toFiles == null) { if (toFiles == null) {
continue; continue;
} }


for (int i = 0; i < toFiles.length; i++) {
String destFileName = toFiles[i];
for (String destFileName : toFiles) {
File destFile = new File(destDir, destFileName); File destFile = new File(destDir, destFileName);


if (sourceFile.equals(destFile)) { if (sourceFile.equals(destFile)) {


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/Copydir.java View File

@@ -146,8 +146,7 @@ public class Copydir extends MatchingTask {
} }


private void scanDir(File from, File to, String[] files) { private void scanDir(File from, File to, String[] files) {
for (int i = 0; i < files.length; i++) {
String filename = files[i];
for (String filename : files) {
File srcFile = new File(from, filename); File srcFile = new File(from, filename);
File destFile; File destFile;
if (flatten) { if (flatten) {


+ 6
- 8
src/main/org/apache/tools/ant/taskdefs/Delete.java View File

@@ -663,8 +663,7 @@ public class Delete extends MatchingTask {
} }


final int size = filesets.size(); final int size = filesets.size();
for (int i = 0; i < size; i++) {
FileSet fs = filesets.get(i);
for (FileSet fs : filesets) {
if (fs.getProject() == null) { if (fs.getProject() == null) {
log("Deleting fileset with no project specified; assuming executing project", log("Deleting fileset with no project specified; assuming executing project",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
@@ -713,8 +712,8 @@ public class Delete extends MatchingTask {
String[] links = new String[n.length]; String[] links = new String[n.length];
System.arraycopy(n, 0, links, 0, n.length); System.arraycopy(n, 0, links, 0, n.length);
Arrays.sort(links, Comparator.reverseOrder()); Arrays.sort(links, Comparator.reverseOrder());
for (int l = 0; l < links.length; l++) {
final Path filePath = Paths.get(links[l]);
for (String link : links) {
final Path filePath = Paths.get(link);
if (!Files.isSymbolicLink(filePath)) { if (!Files.isSymbolicLink(filePath)) {
// it's not a symbolic link, so move on // it's not a symbolic link, so move on
continue; continue;
@@ -814,8 +813,7 @@ public class Delete extends MatchingTask {
if (list == null) { if (list == null) {
list = new String[0]; list = new String[0];
} }
for (int i = 0; i < list.length; i++) {
String s = list[i];
for (String s : list) {
File f = new File(d, s); File f = new File(d, s);
if (f.isDirectory()) { if (f.isDirectory()) {
removeDir(f); removeDir(f);
@@ -843,8 +841,8 @@ public class Delete extends MatchingTask {
if (files.length > 0) { if (files.length > 0) {
log("Deleting " + files.length + " files from " log("Deleting " + files.length + " files from "
+ d.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity); + d.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity);
for (int j = 0; j < files.length; j++) {
File f = new File(d, files[j]);
for (String filename : files) {
File f = new File(d, filename);
log("Deleting " + f.getAbsolutePath(), log("Deleting " + f.getAbsolutePath(),
quiet ? Project.MSG_VERBOSE : verbosity); quiet ? Project.MSG_VERBOSE : verbosity);
if (!delete(f)) { if (!delete(f)) {


+ 1
- 3
src/main/org/apache/tools/ant/taskdefs/Deltree.java View File

@@ -90,9 +90,7 @@ public class Deltree extends Task {
// if (dir.getCanonicalPath().equals(dir.getAbsolutePath())) { // if (dir.getCanonicalPath().equals(dir.getAbsolutePath())) {
// (costin) It will not work if /home/costin is symlink to // (costin) It will not work if /home/costin is symlink to
// /da0/home/costin ( taz for example ) // /da0/home/costin ( taz for example )
String[] list = dir.list();
for (int i = 0; i < list.length; i++) {
String s = list[i];
for (String s : dir.list()) {
File f = new File(dir, s); File f = new File(dir, s);
if (f.isDirectory()) { if (f.isDirectory()) {
removeDir(f); removeDir(f);


+ 8
- 9
src/main/org/apache/tools/ant/taskdefs/ExecTask.java View File

@@ -446,9 +446,9 @@ public class ExecTask extends Task {
Path p = null; Path p = null;
String[] environment = env.getVariables(); String[] environment = env.getVariables();
if (environment != null) { if (environment != null) {
for (int i = 0; i < environment.length; i++) {
if (isPath(environment[i])) {
p = new Path(getProject(), getPath(environment[i]));
for (String variable : environment) {
if (isPath(variable)) {
p = new Path(getProject(), getPath(variable));
break; break;
} }
} }
@@ -460,10 +460,9 @@ public class ExecTask extends Task {
} }
} }
if (p != null) { if (p != null) {
String[] dirs = p.list();
for (int i = 0; i < dirs.length; i++) {
for (String pathname : p.list()) {
executableFile executableFile
= FILE_UTILS.resolveFile(new File(dirs[i]), exec);
= FILE_UTILS.resolveFile(new File(pathname), exec);
if (executableFile.exists()) { if (executableFile.exists()) {
return executableFile.getAbsolutePath(); return executableFile.getAbsolutePath();
} }
@@ -605,9 +604,9 @@ public class ExecTask extends Task {
exe.setVMLauncher(vmLauncher); exe.setVMLauncher(vmLauncher);
String[] environment = env.getVariables(); String[] environment = env.getVariables();
if (environment != null) { if (environment != null) {
for (int i = 0; i < environment.length; i++) {
log("Setting environment variable: " + environment[i],
Project.MSG_VERBOSE);
for (String variable : environment) {
log("Setting environment variable: " + variable,
Project.MSG_VERBOSE);
} }
} }
exe.setNewenvironment(newEnvironment); exe.setNewenvironment(newEnvironment);


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -614,8 +614,7 @@ public class Execute {
} }
Map<String, String> osEnv = Map<String, String> osEnv =
new LinkedHashMap<>(getEnvironmentVariables()); new LinkedHashMap<>(getEnvironmentVariables());
for (int i = 0; i < env.length; i++) {
String keyValue = env[i];
for (String keyValue : env) {
String key = keyValue.substring(0, keyValue.indexOf('=')); String key = keyValue.substring(0, keyValue.indexOf('='));
// Find the key in the current environment copy // Find the key in the current environment copy
// and remove it. // and remove it.


+ 2
- 3
src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java View File

@@ -275,9 +275,8 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
public int fork(ProjectComponent pc) throws BuildException { public int fork(ProjectComponent pc) throws BuildException {
CommandlineJava cmdl = new CommandlineJava(); CommandlineJava cmdl = new CommandlineJava();
cmdl.setClassname(javaCommand.getExecutable()); cmdl.setClassname(javaCommand.getExecutable());
String[] args = javaCommand.getArguments();
for (int i = 0; i < args.length; i++) {
cmdl.createArgument().setValue(args[i]);
for (String arg : javaCommand.getArguments()) {
cmdl.createArgument().setValue(arg);
} }
if (classpath != null) { if (classpath != null) {
cmdl.createClasspath(pc.getProject()).append(classpath); cmdl.createClasspath(pc.getProject()).append(classpath);


+ 6
- 8
src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java View File

@@ -374,18 +374,16 @@ public class ExecuteOn extends ExecTask {
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject());


if (!FileDirBoth.DIR.equals(currentType)) { if (!FileDirBoth.DIR.equals(currentType)) {
String[] s = getFiles(base, ds);
for (int j = 0; j < s.length; j++) {
for (String value : getFiles(base, ds)) {
totalFiles++; totalFiles++;
fileNames.add(s[j]);
fileNames.add(value);
baseDirs.add(base); baseDirs.add(base);
} }
} }
if (!FileDirBoth.FILE.equals(currentType)) { if (!FileDirBoth.FILE.equals(currentType)) {
String[] s = getDirs(base, ds);
for (int j = 0; j < s.length; j++) {
for (String value : getDirs(base, ds)) {
totalDirs++; totalDirs++;
fileNames.add(s[j]);
fileNames.add(value);
baseDirs.add(base); baseDirs.add(base);
} }
} }
@@ -520,8 +518,8 @@ public class ExecuteOn extends ExecTask {
List<String> targets = new ArrayList<>(); List<String> targets = new ArrayList<>();
if (targetFilePos != null) { if (targetFilePos != null) {
Set<String> addedFiles = new HashSet<>(); Set<String> addedFiles = new HashSet<>();
for (int i = 0; i < srcFiles.length; i++) {
String[] subTargets = mapper.mapFileName(srcFiles[i]);
for (String srcFile : srcFiles) {
String[] subTargets = mapper.mapFileName(srcFile);
if (subTargets != null) { if (subTargets != null) {
for (String subTarget : subTargets) { for (String subTarget : subTargets) {
String name; String name;


+ 8
- 11
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -275,18 +275,16 @@ public class Expand extends Task {
boolean included = false; boolean included = false;
Set<String> includePatterns = new HashSet<>(); Set<String> includePatterns = new HashSet<>();
Set<String> excludePatterns = new HashSet<>(); Set<String> excludePatterns = new HashSet<>();
final int size = patternsets.size();
for (int v = 0; v < size; v++) {
PatternSet p = patternsets.get(v);
for (PatternSet p : patternsets) {
String[] incls = p.getIncludePatterns(getProject()); String[] incls = p.getIncludePatterns(getProject());
if (incls == null || incls.length == 0) { if (incls == null || incls.length == 0) {
// no include pattern implicitly means includes="**" // no include pattern implicitly means includes="**"
incls = new String[] {"**"};
incls = new String[]{"**"};
} }


for (int w = 0; w < incls.length; w++) {
String pattern = incls[w].replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
for (String incl : incls) {
String pattern = incl.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
if (pattern.endsWith(File.separator)) { if (pattern.endsWith(File.separator)) {
pattern += "**"; pattern += "**";
} }
@@ -295,10 +293,9 @@ public class Expand extends Task {


String[] excls = p.getExcludePatterns(getProject()); String[] excls = p.getExcludePatterns(getProject());
if (excls != null) { if (excls != null) {
for (int w = 0; w < excls.length; w++) {
String pattern = excls[w]
.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
for (String excl : excls) {
String pattern = excl.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
if (pattern.endsWith(File.separator)) { if (pattern.endsWith(File.separator)) {
pattern += "**"; pattern += "**";
} }


+ 2
- 3
src/main/org/apache/tools/ant/taskdefs/FixCRLF.java View File

@@ -302,10 +302,9 @@ public class FixCRLF extends MatchingTask implements ChainableReader {
Project.MSG_VERBOSE); Project.MSG_VERBOSE);


DirectoryScanner ds = super.getDirectoryScanner(srcDir); DirectoryScanner ds = super.getDirectoryScanner(srcDir);
String[] files = ds.getIncludedFiles();


for (int i = 0; i < files.length; i++) {
processFile(files[i]);
for (String filename : ds.getIncludedFiles()) {
processFile(filename);
} }
} }




+ 7
- 10
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -533,10 +533,8 @@ public class Jar extends Zip {


private void writeManifest(ZipOutputStream zOut, Manifest manifest) private void writeManifest(ZipOutputStream zOut, Manifest manifest)
throws IOException { throws IOException {
for (Enumeration<String> e = manifest.getWarnings();
e.hasMoreElements();) {
log("Manifest warning: " + e.nextElement(),
Project.MSG_WARN);
for (String warning : Collections.list(manifest.getWarnings())) {
log("Manifest warning: " + warning, Project.MSG_WARN);
} }


zipDir((Resource) null, zOut, "META-INF/", ZipFileSet.DEFAULT_DIR_MODE, zipDir((Resource) null, zOut, "META-INF/", ZipFileSet.DEFAULT_DIR_MODE,
@@ -621,13 +619,12 @@ public class Jar extends Zip {
cpEntries[c++] = tok.nextToken(); cpEntries[c++] = tok.nextToken();
} }
} }
String[] indexJarEntries = indexJars.list();
for (int i = 0; i < indexJarEntries.length; i++) {
String name = findJarName(indexJarEntries[i], cpEntries);
for (String indexJarEntry : indexJars.list()) {
String name = findJarName(indexJarEntry, cpEntries);
if (name != null) { if (name != null) {
ArrayList<String> dirs = new ArrayList<String>(); ArrayList<String> dirs = new ArrayList<String>();
ArrayList<String> files = new ArrayList<String>(); ArrayList<String> files = new ArrayList<String>();
grabFilesAndDirs(indexJarEntries[i], dirs, files);
grabFilesAndDirs(indexJarEntry, dirs, files);
if (dirs.size() + files.size() > 0) { if (dirs.size() + files.size() > 0) {
writer.println(name); writer.println(name);
writeIndexLikeList(dirs, files, writer); writeIndexLikeList(dirs, files, writer);
@@ -777,8 +774,8 @@ public class Jar extends Zip {
// checks here deferring them for the second run // checks here deferring them for the second run
Resource[][] manifests = grabManifests(rcs); Resource[][] manifests = grabManifests(rcs);
int count = 0; int count = 0;
for (int i = 0; i < manifests.length; i++) {
count += manifests[i].length;
for (Resource[] mf : manifests) {
count += mf.length;
} }
log("found a total of " + count + " manifests in " log("found a total of " + count + " manifests in "
+ manifests.length + " resource collections", + manifests.length + " resource collections",


+ 3
- 5
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -1156,9 +1156,8 @@ public class Javac extends MatchingTask {
*/ */
protected void scanDir(final File srcDir, final File destDir, final String[] files) { protected void scanDir(final File srcDir, final File destDir, final String[] files) {
final GlobPatternMapper m = new GlobPatternMapper(); final GlobPatternMapper m = new GlobPatternMapper();
final String[] extensions = findSupportedFileExtensions();


for (String extension : extensions) {
for (String extension : findSupportedFileExtensions()) {
m.setFrom(extension); m.setFrom(extension);
m.setTo("*.class"); m.setTo("*.class");
final SourceFileScanner sfs = new SourceFileScanner(this); final SourceFileScanner sfs = new SourceFileScanner(this);
@@ -1178,9 +1177,8 @@ public class Javac extends MatchingTask {
} }


private void collectFileListFromSourcePath() { private void collectFileListFromSourcePath() {
final String[] list = src.list();
for (int i = 0; i < list.length; i++) {
final File srcDir = getProject().resolveFile(list[i]);
for (String filename : src.list()) {
final File srcDir = getProject().resolveFile(filename);
if (!srcDir.exists()) { if (!srcDir.exists()) {
throw new BuildException("srcdir \"" throw new BuildException("srcdir \""
+ srcDir.getPath() + srcDir.getPath()


+ 12
- 21
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -1922,18 +1922,14 @@ public class Javadoc extends Task {
toExecute.createArgument().setPath(docletPath); toExecute.createArgument().setPath(docletPath);
} }
} }
for (final Enumeration<DocletParam> e = doclet.getParams();
e.hasMoreElements();) {
final DocletParam param = e.nextElement();
for (final DocletParam param : Collections.list(doclet.getParams())) {
if (param.getName() == null) { if (param.getName() == null) {
throw new BuildException(
"Doclet parameters must have a name");
throw new BuildException("Doclet parameters must have a name");
} }


toExecute.createArgument().setValue(param.getName()); toExecute.createArgument().setValue(param.getName());
if (param.getValue() != null) { if (param.getValue() != null) {
toExecute.createArgument()
.setValue(param.getValue());
toExecute.createArgument().setValue(param.getValue());
} }
} }
} }
@@ -2123,8 +2119,7 @@ public class Javadoc extends Task {
// -tag arguments. // -tag arguments.
final DirectoryScanner tagDefScanner = final DirectoryScanner tagDefScanner =
ta.getDirectoryScanner(getProject()); ta.getDirectoryScanner(getProject());
final String[] files = tagDefScanner.getIncludedFiles();
for (String file : files) {
for (String file : tagDefScanner.getIncludedFiles()) {
final File tagDefFile = new File(tagDir, file); final File tagDefFile = new File(tagDir, file);
try (final BufferedReader in = try (final BufferedReader in =
new BufferedReader(new FileReader(tagDefFile))) { new BufferedReader(new FileReader(tagDefFile))) {
@@ -2244,9 +2239,8 @@ public class Javadoc extends Task {
} }


private boolean containsWhitespace(final String s) { private boolean containsWhitespace(final String s) {
final int len = s.length();
for (int i = 0; i < len; i++) {
if (Character.isWhitespace(s.charAt(i))) {
for (char c : s.toCharArray()) {
if (Character.isWhitespace(c)) {
return true; return true;
} }
} }
@@ -2256,10 +2250,8 @@ public class Javadoc extends Task {
private String quoteString(final String str, final char delim) { private String quoteString(final String str, final char delim) {
final StringBuilder buf = new StringBuilder(str.length() * 2); final StringBuilder buf = new StringBuilder(str.length() * 2);
buf.append(delim); buf.append(delim);
final int len = str.length();
boolean lastCharWasCR = false; boolean lastCharWasCR = false;
for (int i = 0; i < len; i++) {
final char c = str.charAt(i);
for (final char c : str.toCharArray()) {
if (c == delim) { // can't put the non-constant delim into a case if (c == delim) { // can't put the non-constant delim into a case
buf.append('\\').append(c); buf.append('\\').append(c);
lastCharWasCR = false; lastCharWasCR = false;
@@ -2376,24 +2368,23 @@ public class Javadoc extends Task {
final File baseDir = ds.getDir(getProject()); final File baseDir = ds.getDir(getProject());
log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG); log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG);
final DirectoryScanner dsc = ds.getDirectoryScanner(getProject()); final DirectoryScanner dsc = ds.getDirectoryScanner(getProject());
final String[] dirs = dsc.getIncludedDirectories();
boolean containsPackages = false; boolean containsPackages = false;
for (int i = 0; i < dirs.length; i++) {
for (String dir : dsc.getIncludedDirectories()) {
// are there any java files in this directory? // are there any java files in this directory?
final File pd = new File(baseDir, dirs[i]);
final String[] files = pd.list((dir1,
final File pd = new File(baseDir, dir);
final String[] files = pd.list((directory,
name) -> name.endsWith(".java") || (includeNoSourcePackages name) -> name.endsWith(".java") || (includeNoSourcePackages
&& name.equals("package.html"))); && name.equals("package.html")));


if (files.length > 0) { if (files.length > 0) {
if ("".equals(dirs[i])) {
if ("".equals(dir)) {
log(baseDir 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); Project.MSG_WARN);
} else { } else {
containsPackages = true; containsPackages = true;
final String packageName = final String packageName =
dirs[i].replace(File.separatorChar, '.');
dir.replace(File.separatorChar, '.');
if (!addedPackages.contains(packageName)) { if (!addedPackages.contains(packageName)) {
addedPackages.add(packageName); addedPackages.add(packageName);
pn.add(packageName); pn.add(packageName);


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Jikes.java View File

@@ -90,8 +90,8 @@ public class Jikes {
tmpFile = FileUtils.getFileUtils().createTempFile("jikes", tmpFile = FileUtils.getFileUtils().createTempFile("jikes",
"tmp", null, false, true); "tmp", null, false, true);
out = new BufferedWriter(new FileWriter(tmpFile)); out = new BufferedWriter(new FileWriter(tmpFile));
for (int i = 0; i < args.length; i++) {
out.write(args[i]);
for (String arg : args) {
out.write(arg);
out.newLine(); out.newLine();
} }
out.flush(); out.flush();


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -264,8 +264,7 @@ public class MacroDef extends AntlibDefinition {
attribute.getName()); attribute.getName());
} }
final int size = attributes.size(); final int size = attributes.size();
for (int i = 0; i < size; ++i) {
Attribute att = attributes.get(i);
for (Attribute att : attributes) {
if (att.getName().equals(attribute.getName())) { if (att.getName().equals(attribute.getName())) {
throw new BuildException( throw new BuildException(
"the name \"%s\" has already been used in another attribute element", "the name \"%s\" has already been used in another attribute element",


+ 3
- 4
src/main/org/apache/tools/ant/taskdefs/Move.java View File

@@ -170,15 +170,14 @@ public class Move extends Copy {
int createCount = 0; int createCount = 0;
for (Map.Entry<String, String[]> entry : dirCopyMap.entrySet()) { for (Map.Entry<String, String[]> entry : dirCopyMap.entrySet()) {
String fromDirName = entry.getKey(); String fromDirName = entry.getKey();
String[] toDirNames = entry.getValue();
boolean selfMove = false; boolean selfMove = false;
for (int i = 0; i < toDirNames.length; i++) {
if (fromDirName.equals(toDirNames[i])) {
for (String toDirName : entry.getValue()) {
if (fromDirName.equals(toDirName)) {
log("Skipping self-move of " + fromDirName, verbosity); log("Skipping self-move of " + fromDirName, verbosity);
selfMove = true; selfMove = true;
continue; continue;
} }
File d = new File(toDirNames[i]);
File d = new File(toDirName);
if (!d.exists()) { if (!d.exists()) {
if (!(d.mkdirs() || d.exists())) { if (!(d.mkdirs() || d.exists())) {
log("Unable to create directory " log("Unable to create directory "


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Parallel.java View File

@@ -411,9 +411,9 @@ public class Parallel extends Task
int tries = 0; int tries = 0;
do { do {
oneAlive = false; oneAlive = false;
for (int i = 0; i < running.length; i++) {
if (running[i] != null && !running[i].isFinished()) {
running[i].interrupt();
for (TaskRunnable runnable : running) {
if (runnable != null && !runnable.isFinished()) {
runnable.interrupt();
Thread.yield(); Thread.yield();
oneAlive = true; oneAlive = true;
} }


+ 9
- 12
src/main/org/apache/tools/ant/taskdefs/Recorder.java View File

@@ -18,7 +18,6 @@
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map; import java.util.Map;


import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildEvent;
@@ -68,7 +67,7 @@ public class Recorder extends Task implements SubBuildListener {
/** Strip task banners if true. */ /** Strip task banners if true. */
private boolean emacsMode = false; private boolean emacsMode = false;
/** The list of recorder entries. */ /** The list of recorder entries. */
private static Hashtable recorderEntries = new Hashtable();
private static Hashtable<String, RecorderEntry> recorderEntries = new Hashtable<>();


////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// CONSTRUCTORS / INITIALIZERS // CONSTRUCTORS / INITIALIZERS
@@ -206,10 +205,9 @@ public class Recorder extends Task implements SubBuildListener {
*/ */
protected RecorderEntry getRecorder(String name, Project proj) protected RecorderEntry getRecorder(String name, Project proj)
throws BuildException { throws BuildException {
Object o = recorderEntries.get(name);
RecorderEntry entry;
RecorderEntry entry = recorderEntries.get(name);


if (o == null) {
if (entry == null) {
// create a recorder entry // create a recorder entry
entry = new RecorderEntry(name); entry = new RecorderEntry(name);


@@ -220,9 +218,8 @@ public class Recorder extends Task implements SubBuildListener {
} }
entry.setProject(proj); entry.setProject(proj);
recorderEntries.put(name, entry); recorderEntries.put(name, entry);
} else {
entry = (RecorderEntry) o;
} }

return entry; return entry;
} }


@@ -308,12 +305,12 @@ public class Recorder extends Task implements SubBuildListener {
* *
* @since Ant 1.7 * @since Ant 1.7
*/ */
@SuppressWarnings("unchecked")
private void cleanup() { private void cleanup() {
Hashtable entries = (Hashtable) recorderEntries.clone();
Iterator itEntries = entries.entrySet().iterator();
while (itEntries.hasNext()) {
Map.Entry entry = (Map.Entry) itEntries.next();
RecorderEntry re = (RecorderEntry) entry.getValue();
Hashtable<String, RecorderEntry> entries
= (Hashtable<String, RecorderEntry>) recorderEntries.clone();
for (Map.Entry<String, RecorderEntry> entry : entries.entrySet()) {
RecorderEntry re = entry.getValue();
if (re.getProject() == getProject()) { if (re.getProject() == getProject()) {
recorderEntries.remove(entry.getKey()); recorderEntries.remove(entry.getKey());
} }


+ 1
- 3
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -716,9 +716,7 @@ public class Replace extends MatchingTask {
*/ */
private StringBuffer buildFilterChain(StringBuffer inputBuffer) { private StringBuffer buildFilterChain(StringBuffer inputBuffer) {
StringBuffer buf = inputBuffer; StringBuffer buf = inputBuffer;
final int size = replacefilters.size();
for (int i = 0; i < size; i++) {
Replacefilter filter = replacefilters.get(i);
for (Replacefilter filter : replacefilters) {
filter.setInputBuffer(buf); filter.setInputBuffer(buf);
buf = filter.getOutputBuffer(); buf = filter.getOutputBuffer();
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/SubAnt.java View File

@@ -203,13 +203,13 @@ public class SubAnt extends Task {
} }
*/ */
BuildException buildException = null; BuildException buildException = null;
for (int i = 0; i < count; ++i) {
for (String filename : filenames) {
File file = null; File file = null;
String subdirPath = null; String subdirPath = null;
Throwable thrownException = null; Throwable thrownException = null;
try { try {
File directory = null; File directory = null;
file = new File(filenames[i]);
file = new File(filename);
if (file.isDirectory()) { if (file.isDirectory()) {
if (verbose) { if (verbose) {
subdirPath = file.getPath(); subdirPath = file.getPath();


+ 12
- 11
src/main/org/apache/tools/ant/taskdefs/Sync.java View File

@@ -19,7 +19,9 @@
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
@@ -226,8 +228,7 @@ public class Sync extends Task {
ds.addExcludes(excls); ds.addExcludes(excls);


ds.scan(); ds.scan();
String[] files = ds.getIncludedFiles();
for (String file : files) {
for (String file : ds.getIncludedFiles()) {
File f = new File(toDir, file); File f = new File(toDir, file);
log("Removing orphan file: " + f, Project.MSG_DEBUG); log("Removing orphan file: " + f, Project.MSG_DEBUG);
f.delete(); f.delete();
@@ -239,8 +240,9 @@ public class Sync extends Task {
// leaves before their parent nodes - thus making sure (well, // leaves before their parent nodes - thus making sure (well,
// more likely) that the directories are empty when we try to // more likely) that the directories are empty when we try to
// delete them. // delete them.
for (int i = dirs.length - 1; i >= 0; --i) {
File f = new File(toDir, dirs[i]);
Arrays.sort(dirs, Comparator.reverseOrder());
for (String dir : dirs) {
File f = new File(toDir, dir);
String[] children = f.list(); String[] children = f.list();
if (children == null || children.length < 1) { if (children == null || children.length < 1) {
log("Removing orphan directory: " + f, Project.MSG_DEBUG); log("Removing orphan directory: " + f, Project.MSG_DEBUG);
@@ -255,8 +257,9 @@ public class Sync extends Task {
fs.setDir(toDir); fs.setDir(toDir);
String[] preservedDirs = String[] preservedDirs =
fs.getDirectoryScanner(getProject()).getIncludedDirectories(); fs.getDirectoryScanner(getProject()).getIncludedDirectories();
for (int i = preservedDirs.length - 1; i >= 0; --i) {
preservedDirectories.add(new File(toDir, preservedDirs[i]));
Arrays.sort(preservedDirs, Comparator.reverseOrder());
for (String dir : preservedDirs) {
preservedDirectories.add(new File(toDir, dir));
} }
} }


@@ -286,13 +289,11 @@ public class Sync extends Task {
int removedCount = 0; int removedCount = 0;
if (dir.isDirectory()) { if (dir.isDirectory()) {
File[] children = dir.listFiles(); File[] children = dir.listFiles();
for (int i = 0; i < children.length; ++i) {
File file = children[i];
for (File file : children) {
// Test here again to avoid method call for non-directories! // Test here again to avoid method call for non-directories!
if (file.isDirectory()) { if (file.isDirectory()) {
removedCount +=
removeEmptyDirectories(file, true,
preservedEmptyDirectories);
removedCount += removeEmptyDirectories(file, true,
preservedEmptyDirectories);
} }
} }
if (children.length > 0) { if (children.length > 0) {


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Touch.java View File

@@ -342,8 +342,8 @@ public class Touch extends Task {
if (millis < 0 && r.isExists()) { if (millis < 0 && r.isExists()) {
modTime = r.getLastModified(); modTime = r.getLastModified();
} }
for (int i = 0; i < mapped.length; i++) {
touch(getProject().resolveFile(mapped[i]), modTime);
for (String fileName : mapped) {
touch(getProject().resolveFile(fileName), modTime);
} }
} }
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Untar.java View File

@@ -230,8 +230,8 @@ public class Untar extends Expand {
} }
if (BZIP2.equals(v)) { if (BZIP2.equals(v)) {
final char[] magic = new char[] { 'B', 'Z' }; final char[] magic = new char[] { 'B', 'Z' };
for (int i = 0; i < magic.length; i++) {
if (istream.read() != magic[i]) {
for (char c : magic) {
if (istream.read() != c) {
throw new BuildException("Invalid bz2 file." + name); throw new BuildException("Invalid bz2 file." + name);
} }
} }


+ 6
- 9
src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java View File

@@ -54,19 +54,16 @@ public class Javac12 extends DefaultCompilerAdapter {
try { try {
// Create an instance of the compiler, redirecting output to // Create an instance of the compiler, redirecting output to
// the project log // the project log
Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME);
Class<?> c = Class.forName(CLASSIC_COMPILER_CLASSNAME);
Constructor cons = Constructor cons =
c.getConstructor(new Class[] {OutputStream.class,
String.class});
c.getConstructor(OutputStream.class, String.class);
Object compiler Object compiler
= cons.newInstance(new Object[] {logstr, "javac"});
= cons.newInstance(logstr, "javac");


// Call the compile() method // Call the compile() method
Method compile = c.getMethod("compile",
new Class [] {String[].class});
Boolean ok =
(Boolean) compile.invoke(compiler,
new Object[] {cmd.getArguments()});
Method compile = c.getMethod("compile", String[].class);
Boolean ok = (Boolean) compile.invoke(compiler,
new Object[] {cmd.getArguments()});
return ok.booleanValue(); return ok.booleanValue();
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new BuildException("Cannot use classic compiler, as it is " throw new BuildException("Cannot use classic compiler, as it is "


+ 6
- 7
src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java View File

@@ -102,18 +102,17 @@ public class AntVersion extends Task implements Condition {
private DeweyDecimal getVersion() { private DeweyDecimal getVersion() {
Project p = new Project(); Project p = new Project();
p.init(); p.init();
char[] versionString = p.getProperty("ant.version").toCharArray();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
boolean foundFirstDigit = false; boolean foundFirstDigit = false;
for (int i = 0; i < versionString.length; i++) {
if (Character.isDigit(versionString[i])) {
sb.append(versionString[i]);
for (char versionChar : p.getProperty("ant.version").toCharArray()) {
if (Character.isDigit(versionChar)) {
sb.append(versionChar);
foundFirstDigit = true; foundFirstDigit = true;
} }
if (versionString[i] == '.' && foundFirstDigit) {
sb.append(versionString[i]);
if (versionChar == '.' && foundFirstDigit) {
sb.append(versionChar);
} }
if (Character.isLetter(versionString[i]) && foundFirstDigit) {
if (Character.isLetter(versionChar) && foundFirstDigit) {
break; break;
} }
} }


+ 2
- 6
src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java View File

@@ -165,9 +165,7 @@ public class HasMethod extends ProjectComponent implements Condition {
} }


private boolean isFieldFound(Class<?> clazz) { private boolean isFieldFound(Class<?> clazz) {
Field[] fields = clazz.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field fieldEntry = fields[i];
for (Field fieldEntry : clazz.getDeclaredFields()) {
if (fieldEntry.getName().equals(field)) { if (fieldEntry.getName().equals(field)) {
return true; return true;
} }
@@ -176,9 +174,7 @@ public class HasMethod extends ProjectComponent implements Condition {
} }


private boolean isMethodFound(Class<?> clazz) { private boolean isMethodFound(Class<?> clazz) {
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
Method methodEntry = methods[i];
for (Method methodEntry : clazz.getDeclaredMethods()) {
if (methodEntry.getName().equals(method)) { if (methodEntry.getName().equals(method)) {
return true; return true;
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java View File

@@ -423,8 +423,8 @@ public class CvsTagDiff extends AbstractCvsTask {
CollectionUtils.flattenToString(packageNames)); CollectionUtils.flattenToString(packageNames));
DOM_WRITER.openElement(root, writer, 0, "\t"); DOM_WRITER.openElement(root, writer, 0, "\t");
writer.println(); writer.println();
for (int i = 0, c = entries.length; i < c; i++) {
writeTagEntry(doc, writer, entries[i]);
for (CvsTagEntry entry : entries) {
writeTagEntry(doc, writer, entry);
} }
DOM_WRITER.closeElement(root, writer, 0, "\t", true); DOM_WRITER.closeElement(root, writer, 0, "\t", true);
writer.flush(); writer.flush();


+ 11
- 12
src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java View File

@@ -27,6 +27,8 @@ import java.io.PrintStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.security.Provider; import java.security.Provider;
import java.security.Security; import java.security.Security;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@@ -265,15 +267,15 @@ public class MimeMailer extends Mailer {
if (invalid == null) { if (invalid == null) {
invalid = new Address[0]; invalid = new Address[0];
} }
for (int i = 0; i < invalid.length; i++) {
didntReach(invalid[i], "invalid", sfe);
for (Address address : invalid) {
didntReach(address, "invalid", sfe);
} }
Address[] validUnsent = sfe.getValidUnsentAddresses(); Address[] validUnsent = sfe.getValidUnsentAddresses();
if (validUnsent == null) { if (validUnsent == null) {
validUnsent = new Address[0]; validUnsent = new Address[0];
} }
for (int i = 0; i < validUnsent.length; i++) {
didntReach(validUnsent[i], "valid", sfe);
for (Address address : validUnsent) {
didntReach(address, "valid", sfe);
} }
} }
} catch (MessagingException | IOException e) { } catch (MessagingException | IOException e) {
@@ -284,18 +286,15 @@ public class MimeMailer extends Mailer {
private static InternetAddress[] internetAddresses(final Vector<EmailAddress> list) private static InternetAddress[] internetAddresses(final Vector<EmailAddress> list)
throws AddressException, UnsupportedEncodingException { throws AddressException, UnsupportedEncodingException {


final int size = list.size();
final InternetAddress[] addrs = new InternetAddress[size];

for (int i = 0; i < size; ++i) {
final EmailAddress addr = list.get(i);
final List<InternetAddress> addrs = new ArrayList<>();


for (final EmailAddress addr : list) {
final String name = addr.getName(); final String name = addr.getName();
addrs[i] = (name == null)
addrs.add((name == null)
? new InternetAddress(addr.getAddress()) ? new InternetAddress(addr.getAddress())
: new InternetAddress(addr.getAddress(), name);
: new InternetAddress(addr.getAddress(), name));
} }
return addrs;
return addrs.toArray(new InternetAddress[addrs.size()]);
} }


private String parseCharSetFromMimeType(final String type) { private String parseCharSetFromMimeType(final String type) {


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java View File

@@ -99,13 +99,13 @@ public class VmsCommandLauncher extends Java13CommandLauncher {
// add the environment as logicals to the DCL script // add the environment as logicals to the DCL script
if (env != null) { if (env != null) {
int eqIndex; int eqIndex;
for (int i = 0; i < env.length; i++) {
eqIndex = env[i].indexOf('=');
for (String variable : env) {
eqIndex = variable.indexOf('=');
if (eqIndex != -1) { if (eqIndex != -1) {
out.write("$ DEFINE/NOLOG "); out.write("$ DEFINE/NOLOG ");
out.write(env[i].substring(0, eqIndex));
out.write(variable.substring(0, eqIndex));
out.write(" \""); out.write(" \"");
out.write(env[i].substring(eqIndex + 1));
out.write(variable.substring(eqIndex + 1));
out.write('\"'); out.write('\"');
out.newLine(); out.newLine();
} }


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java View File

@@ -255,10 +255,10 @@ public class Native2Ascii extends MatchingTask {
String message = "Converting " + count + " file" String message = "Converting " + count + " file"
+ (count != 1 ? "s" : "") + " from "; + (count != 1 ? "s" : "") + " from ";
log(message + srcDir + " to " + destDir); log(message + srcDir + " to " + destDir);
for (int i = 0; i < files.length; i++) {
String[] dest = m.mapFileName(files[i]);
for (String file : files) {
String[] dest = m.mapFileName(file);
if (dest != null && dest.length > 0) { if (dest != null && dest.length > 0) {
convert(files[i], dest[0]);
convert(file, dest[0]);
} }
} }
} }


+ 10
- 20
src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java View File

@@ -28,7 +28,7 @@ import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
@@ -121,7 +121,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
private URIResolver uriResolver; private URIResolver uriResolver;


/** transformer output properties */ /** transformer output properties */
private final Vector outputProperties = new Vector();
private final Vector<String[]> outputProperties = new Vector<>();


/** stylesheet parameters */ /** stylesheet parameters */
private final Hashtable<String, Object> params = new Hashtable<String, Object>(); private final Hashtable<String, Object> params = new Hashtable<String, Object>();
@@ -327,9 +327,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
if (uriResolver != null) { if (uriResolver != null) {
transformer.setURIResolver(uriResolver); transformer.setURIResolver(uriResolver);
} }
final int size = outputProperties.size();
for (int i = 0; i < size; i++) {
final String[] pair = (String[]) outputProperties.elementAt(i);
for (String[] pair : outputProperties) {
transformer.setOutputProperty(pair[0], pair[1]); transformer.setOutputProperty(pair[0], pair[1]);
} }


@@ -369,11 +367,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
* Sets the parameters for the transformer. * Sets the parameters for the transformer.
*/ */
private void setTransformationParameters() { private void setTransformationParameters() {
for (final Enumeration enumeration = params.keys();
enumeration.hasMoreElements();) {
final String name = (String) enumeration.nextElement();
final Object value = params.get(name);
transformer.setParameter(name, value);
for (Map.Entry<String, Object> entry : params.entrySet()) {
transformer.setParameter(entry.getKey(), entry.getValue());
} }
} }


@@ -428,8 +423,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware


// specific attributes for the transformer // specific attributes for the transformer
final int size = attributes.size(); final int size = attributes.size();
for (int i = 0; i < size; i++) {
final Object[] pair = attributes.get(i);
for (final Object[] pair : attributes) {
tfactory.setAttribute((String) pair[0], pair[1]); tfactory.setAttribute((String) pair[0], pair[1]);
} }


@@ -629,10 +623,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
setFactory(factory.getName()); setFactory(factory.getName());


// configure factory attributes // configure factory attributes
for (final Enumeration attrs = factory.getAttributes();
attrs.hasMoreElements();) {
final XSLTProcess.Factory.Attribute attr =
(XSLTProcess.Factory.Attribute) attrs.nextElement();
for (final XSLTProcess.Factory.Attribute attr
: Collections.list(factory.getAttributes())) {
setAttribute(attr.getName(), attr.getValue()); setAttribute(attr.getName(), attr.getValue());
} }
for (final XSLTProcess.Factory.Feature feature for (final XSLTProcess.Factory.Feature feature
@@ -650,10 +642,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware




// configure output properties // configure output properties
for (final Enumeration props = xsltTask.getOutputProperties();
props.hasMoreElements();) {
final XSLTProcess.OutputProperty prop
= (XSLTProcess.OutputProperty) props.nextElement();
for (final XSLTProcess.OutputProperty prop
: Collections.list(xsltTask.getOutputProperties())) {
setOutputProperty(prop.getName(), prop.getValue()); setOutputProperty(prop.getName(), prop.getValue());
} }




+ 8
- 17
src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java View File

@@ -74,7 +74,7 @@ public class XMLValidateTask extends Task {
/** file to be validated */ /** file to be validated */
protected File file = null; protected File file = null;
/** sets of file to be validated */ /** sets of file to be validated */
protected Vector filesets = new Vector();
protected Vector<FileSet> filesets = new Vector<>();
protected Path classpath; protected Path classpath;


/** /**
@@ -90,12 +90,12 @@ public class XMLValidateTask extends Task {
// CheckStyle:VisibilityModifier ON // CheckStyle:VisibilityModifier ON


/** The vector to store all attributes (features) to be set on the parser. **/ /** The vector to store all attributes (features) to be set on the parser. **/
private Vector attributeList = new Vector();
private Vector<Attribute> attributeList = new Vector<>();


/** /**
* List of properties. * List of properties.
*/ */
private final Vector propertyList = new Vector();
private final Vector<Property> propertyList = new Vector<>();


private XMLCatalog xmlCatalog = new XMLCatalog(); private XMLCatalog xmlCatalog = new XMLCatalog();
/** Message for successful validation */ /** Message for successful validation */
@@ -307,15 +307,10 @@ public class XMLValidateTask extends Task {
} }
} }


final int size = filesets.size();
for (int i = 0; i < size; i++) {

FileSet fs = (FileSet) filesets.elementAt(i);
for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();

for (int j = 0; j < files.length; j++) {
File srcFile = new File(fs.getDir(getProject()), files[j]);
for (String fileName : ds.getIncludedFiles()) {
File srcFile = new File(fs.getDir(getProject()), fileName);
doValidate(srcFile); doValidate(srcFile);
fileProcessed++; fileProcessed++;
} }
@@ -353,16 +348,12 @@ public class XMLValidateTask extends Task {
setFeature(XmlConstants.FEATURE_VALIDATION, true); setFeature(XmlConstants.FEATURE_VALIDATION, true);
} }
// set the feature from the attribute list // set the feature from the attribute list
final int attSize = attributeList.size();
for (int i = 0; i < attSize; i++) {
Attribute feature = (Attribute) attributeList.elementAt(i);
for (Attribute feature : attributeList) {
setFeature(feature.getName(), feature.getValue()); setFeature(feature.getName(), feature.getValue());


} }
// Sets properties // Sets properties
final int propSize = propertyList.size();
for (int i = 0; i < propSize; i++) {
final Property prop = (Property) propertyList.elementAt(i);
for (Property prop : propertyList) {
setProperty(prop.getName(), prop.getValue()); setProperty(prop.getName(), prop.getValue());
} }
} }


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java View File

@@ -284,16 +284,16 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool {
int endOfPath = descriptorFileName.lastIndexOf(File.separator); int endOfPath = descriptorFileName.lastIndexOf(File.separator);
String relativePath = descriptorFileName.substring(0, endOfPath + 1); String relativePath = descriptorFileName.substring(0, endOfPath + 1);


for (int i = 0; i < cmpDescriptors.length; i++) {
int endOfCmp = cmpDescriptors[i].lastIndexOf('/');
String cmpDescriptor = cmpDescriptors[i].substring(endOfCmp + 1);
for (String descriptor : cmpDescriptors) {
int endOfCmp = descriptor.lastIndexOf('/');
String cmpDescriptor = descriptor.substring(endOfCmp + 1);


File cmpFile = new File(baseDir, relativePath + cmpDescriptor); File cmpFile = new File(baseDir, relativePath + cmpDescriptor);
if (!cmpFile.exists()) { if (!cmpFile.exists()) {
throw new BuildException("The CMP descriptor file (" throw new BuildException("The CMP descriptor file ("
+ cmpFile + ") could not be found.", getLocation()); + cmpFile + ") could not be found.", getLocation());
} }
files.put(cmpDescriptors[i], cmpFile);
files.put(descriptor, cmpFile);
} }
} }
return files; return files;


+ 4
- 6
src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java View File

@@ -31,7 +31,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@@ -1209,9 +1208,9 @@ public class IPlanetEjbc {
* Loop through each stub/skeleton class that must be generated, and * Loop through each stub/skeleton class that must be generated, and
* determine (if all exist) which file has the most recent timestamp * determine (if all exist) which file has the most recent timestamp
*/ */
for (int i = 0; i < classnames.length; i++) {
for (String classname : classnames) {
String pathToClass = String pathToClass =
classnames[i].replace('.', File.separatorChar) + ".class";
classname.replace('.', File.separatorChar) + ".class";
File classFile = new File(destDir, pathToClass); File classFile = new File(destDir, pathToClass);


/* /*
@@ -1306,9 +1305,8 @@ public class IPlanetEjbc {
+ "\n\r iiop: " + iiop + "\n\r iiop: " + iiop
+ "\n\r hasession: " + hasession; + "\n\r hasession: " + hasession;


Iterator<String> i = cmpDescriptors.iterator();
while (i.hasNext()) {
s += "\n\r CMP Descriptor: " + i.next();
for (String cmpDescriptor : cmpDescriptors) {
s += "\n\r CMP Descriptor: " + cmpDescriptor;
} }


return s; return s;


+ 2
- 3
src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java View File

@@ -96,9 +96,8 @@ public final class ExtensionUtil {


final DirectoryScanner scanner = fileSet.getDirectoryScanner(project); final DirectoryScanner scanner = fileSet.getDirectoryScanner(project);
final File basedir = scanner.getBasedir(); final File basedir = scanner.getBasedir();
final String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
final File file = new File(basedir, files[ i ]);
for (String fileName : scanner.getIncludedFiles()) {
final File file = new File(basedir, fileName);
loadExtensions(file, extensions, includeImpl, includeURL); loadExtensions(file, extensions, includeImpl, includeURL);
} }
} }


+ 8
- 8
src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java View File

@@ -73,29 +73,29 @@ class LibraryDisplayer {
printLine(size); printLine(size);
if (0 != available.length) { if (0 != available.length) {
System.out.println("Extensions Supported By Library:"); System.out.println("Extensions Supported By Library:");
for (int i = 0; i < available.length; i++) {
System.out.println(available[i]);
for (Extension extension : available) {
System.out.println(extension);
} }
} }


if (0 != required.length) { if (0 != required.length) {
System.out.println("Extensions Required By Library:"); System.out.println("Extensions Required By Library:");
for (int i = 0; i < required.length; i++) {
System.out.println(required[i]);
for (Extension extension : required) {
System.out.println(extension);
} }
} }


if (0 != options.length) { if (0 != options.length) {
System.out.println("Extensions that will be used by Library if present:"); System.out.println("Extensions that will be used by Library if present:");
for (int i = 0; i < options.length; i++) {
System.out.println(options[i]);
for (Extension option : options) {
System.out.println(option);
} }
} }


if (0 != specifications.length) { if (0 != specifications.length) {
System.out.println("Specifications Supported By Library:"); System.out.println("Specifications Supported By Library:");
for (int i = 0; i < specifications.length; i++) {
displaySpecification(specifications[i]);
for (Specification specification : specifications) {
displaySpecification(specification);
} }
} }
} }


+ 6
- 9
src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java View File

@@ -486,10 +486,9 @@ public class Translate extends MatchingTask {
int filesProcessed = 0; int filesProcessed = 0;
for (FileSet fs : filesets) { for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] srcFiles = ds.getIncludedFiles();
for (int j = 0; j < srcFiles.length; j++) {
for (String srcFile : ds.getIncludedFiles()) {
try { try {
File dest = FILE_UTILS.resolveFile(toDir, srcFiles[j]);
File dest = FILE_UTILS.resolveFile(toDir, srcFile);
//Make sure parent dirs exist, else, create them. //Make sure parent dirs exist, else, create them.
try { try {
File destDir = new File(dest.getParent()); File destDir = new File(dest.getParent());
@@ -502,7 +501,7 @@ public class Translate extends MatchingTask {
Project.MSG_DEBUG); Project.MSG_DEBUG);
} }
destLastModified = dest.lastModified(); destLastModified = dest.lastModified();
File src = FILE_UTILS.resolveFile(ds.getBasedir(), srcFiles[j]);
File src = FILE_UTILS.resolveFile(ds.getBasedir(), srcFile);
srcLastModified = src.lastModified(); srcLastModified = src.lastModified();
//Check to see if dest file has to be recreated //Check to see if dest file has to be recreated
boolean needsWork = forceOverwrite boolean needsWork = forceOverwrite
@@ -516,14 +515,12 @@ public class Translate extends MatchingTask {
} }
} }
if (needsWork) { if (needsWork) {
log("Processing " + srcFiles[j],
Project.MSG_DEBUG);
log("Processing " + srcFile, Project.MSG_DEBUG);
translateOneFile(src, dest); translateOneFile(src, dest);
++filesProcessed; ++filesProcessed;
} else { } else {
log("Skipping " + srcFiles[j]
+ " as destination file is up to date",
Project.MSG_VERBOSE);
log("Skipping " + srcFile + " as destination file is up to date",
Project.MSG_VERBOSE);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
throw new BuildException(ioe.getMessage(), getLocation()); throw new BuildException(ioe.getMessage(), getLocation());


+ 1
- 2
src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java View File

@@ -225,8 +225,7 @@ public class Image extends MatchingTask {
final File dstDir, final FileNameMapper mapper) { final File dstDir, final FileNameMapper mapper) {
int writeCount = 0; int writeCount = 0;


for (int i = 0; i < srcNames.length; ++i) {
final String srcName = srcNames[i];
for (final String srcName : srcNames) {
final File srcFile = new File(srcDir, srcName).getAbsoluteFile(); final File srcFile = new File(srcDir, srcName).getAbsoluteFile();


final String[] dstNames = mapper.mapFileName(srcName); final String[] dstNames = mapper.mapFileName(srcName);


+ 1
- 4
src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java View File

@@ -256,10 +256,7 @@ public class jlink {
*/ */
private void addDirContents(ZipOutputStream output, File dir, String prefix, private void addDirContents(ZipOutputStream output, File dir, String prefix,
boolean compress) throws IOException { boolean compress) throws IOException {
String[] contents = dir.list();

for (int i = 0; i < contents.length; ++i) {
String name = contents[i];
for (String name : dir.list()) {
File file = new File(dir, name); File file = new File(dir, name);


if (file.isDirectory()) { if (file.isDirectory()) {


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java View File

@@ -478,8 +478,8 @@ public class JspC extends MatchingTask {
// lists and compile lists // lists and compile lists
resetFileLists(); resetFileLists();
int filecount = 0; int filecount = 0;
for (int i = 0; i < list.length; i++) {
File srcDir = getProject().resolveFile(list[i]);
for (String fileName : list) {
File srcDir = getProject().resolveFile(fileName);
if (!srcDir.exists()) { if (!srcDir.exists()) {
throw new BuildException("srcdir \"" + srcDir.getPath() throw new BuildException("srcdir \"" + srcDir.getPath()
+ "\" does not exist!", + "\" does not exist!",


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java View File

@@ -112,8 +112,8 @@ public final class BatchTest extends BaseTest {
void addTestsTo(Vector<? super JUnitTest> v) { void addTestsTo(Vector<? super JUnitTest> v) {
JUnitTest[] tests = createAllJUnitTest(); JUnitTest[] tests = createAllJUnitTest();
v.ensureCapacity(v.size() + tests.length); v.ensureCapacity(v.size() + tests.length);
for (int i = 0; i < tests.length; i++) {
v.addElement(tests[i]);
for (JUnitTest test : tests) {
v.addElement(test);
} }
} }




+ 1
- 3
src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java View File

@@ -25,7 +25,6 @@ import java.io.OutputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.Iterator;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
@@ -300,8 +299,7 @@ public class FailureRecorder extends ProjectComponent implements JUnitResultForm
writer.newLine(); writer.newLine();
writer.write(" TestSuite suite = new TestSuite();"); writer.write(" TestSuite suite = new TestSuite();");
writer.newLine(); writer.newLine();
for (Iterator<TestInfos> iter = failedTests.iterator(); iter.hasNext();) {
TestInfos testInfos = iter.next();
for (TestInfos testInfos : failedTests) {
writer.write(" suite.addTest("); writer.write(" suite.addTest(");
writer.write(String.valueOf(testInfos)); writer.write(String.valueOf(testInfos));
writer.write(");"); writer.write(");");


+ 6
- 7
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter.java View File

@@ -139,9 +139,9 @@ public class JUnit4TestMethodAdapter implements Test {
throw new IllegalArgumentException("methodNames is <null>"); throw new IllegalArgumentException("methodNames is <null>");
} }
methodsListDescription = Description.createSuiteDescription(testClass); methodsListDescription = Description.createSuiteDescription(testClass);
for (int i = 0; i < methodNames.length; i++) {
for (String methodName : methodNames) {
methodsListDescription.addChild( methodsListDescription.addChild(
Description.createTestDescription(testClass, methodNames[i]));
Description.createTestDescription(testClass, methodName));
} }
this.testClass = testClass; this.testClass = testClass;
this.methodNames = methodNames; this.methodNames = methodNames;
@@ -165,12 +165,11 @@ public class JUnit4TestMethodAdapter implements Test {
if (methodNames.length == 0) { if (methodNames.length == 0) {
buf.append("No methods"); buf.append("No methods");
} else { } else {
buf.append(methodNames.length == 1 ? "Method" : "Methods");
buf.append(' ');
buf.append(methodNames[0]);
for (int i = 1; i < methodNames.length; i++) {
buf.append(',').append(methodNames[i]);
buf.append(methodNames.length == 1 ? "Method " : "Methods ");
for (String methodName : methodNames) {
buf.append(methodName).append(',');
} }
buf.setLength(buf.length() - 1);
} }
buf.append('(').append(testClass.getName()).append(')'); buf.append('(').append(testClass.getName()).append(')');
return buf.toString(); return buf.toString();


+ 11
- 21
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -963,18 +963,12 @@ public class JUnitTask extends Task {
/* I assume we don't want to do this with "per batch" forking. */ /* I assume we don't want to do this with "per batch" forking. */
List<List<JUnitTest>> newlist = new ArrayList<>(); List<List<JUnitTest>> newlist = new ArrayList<>();
if (forkMode.getValue().equals(ForkMode.PER_TEST)) { if (forkMode.getValue().equals(ForkMode.PER_TEST)) {
final Iterator<List<JUnitTest>> i1 = testList.iterator();
while (i1.hasNext()) {
final List<JUnitTest> l = i1.next();
if (l.size() == 1) {
newlist.add(l);
for (List<JUnitTest> list : testList) {
if (list.size() == 1) {
newlist.add(list);
} else { } else {
final Iterator<JUnitTest> i2 = l.iterator();
while (i2.hasNext()) {
final List<JUnitTest> tmpSingleton =
new ArrayList<>();
tmpSingleton.add(i2.next());
newlist.add(tmpSingleton);
for (JUnitTest test : list) {
newlist.add(Collections.singletonList(test));
} }
} }
} }
@@ -1203,8 +1197,7 @@ public class JUnitTask extends Task {


StringBuilder formatterArg = new StringBuilder(STRING_BUFFER_SIZE); StringBuilder formatterArg = new StringBuilder(STRING_BUFFER_SIZE);
final FormatterElement[] feArray = mergeFormatters(test); final FormatterElement[] feArray = mergeFormatters(test);
for (int i = 0; i < feArray.length; i++) {
final FormatterElement fe = feArray[i];
for (final FormatterElement fe : feArray) {
if (fe.shouldUse(this)) { if (fe.shouldUse(this)) {
formatterArg.append(Constants.FORMATTER); formatterArg.append(Constants.FORMATTER);
formatterArg.append(fe.getClassname()); formatterArg.append(fe.getClassname());
@@ -1251,9 +1244,9 @@ public class JUnitTask extends Task {


final String[] environment = env.getVariables(); final String[] environment = env.getVariables();
if (environment != null) { if (environment != null) {
for (int i = 0; i < environment.length; i++) {
log("Setting environment variable: " + environment[i],
Project.MSG_VERBOSE);
for (String variable : environment) {
log("Setting environment variable: " + variable,
Project.MSG_VERBOSE);
} }
} }
execute.setNewenvironment(newEnvironment); execute.setNewenvironment(newEnvironment);
@@ -1613,9 +1606,7 @@ public class JUnitTask extends Task {


runner.setPermissions(perm); runner.setPermissions(perm);


final FormatterElement[] feArray = mergeFormatters(test);
for (int i = 0; i < feArray.length; i++) {
final FormatterElement fe = feArray[i];
for (final FormatterElement fe : mergeFormatters(test)) {
if (fe.shouldUse(this)) { if (fe.shouldUse(this)) {
final File outFile = getOutput(fe, test); final File outFile = getOutput(fe, test);
if (outFile != null) { if (outFile != null) {
@@ -1922,8 +1913,7 @@ public class JUnitTask extends Task {


test.setCounts(1, 0, 1, 0); test.setCounts(1, 0, 1, 0);
test.setProperties(getProject().getProperties()); test.setProperties(getProject().getProperties());
for (int i = 0; i < feArray.length; i++) {
final FormatterElement fe = feArray[i];
for (final FormatterElement fe : feArray) {
if (fe.shouldUse(this)) { if (fe.shouldUse(this)) {
final JUnitTaskMirror.JUnitResultFormatterMirror formatter = final JUnitTaskMirror.JUnitResultFormatterMirror formatter =
fe.createFormatter(classLoader); fe.createFormatter(classLoader);


+ 43
- 53
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java View File

@@ -365,9 +365,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
public void run() { public void run() {
res = new IgnoredTestResult(); res = new IgnoredTestResult();
res.addListener(wrapListener(this)); res.addListener(wrapListener(this));
final int size = formatters.size();
for (int i = 0; i < size; i++) {
res.addListener(wrapListener((TestListener) formatters.elementAt(i)));
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) {
res.addListener(wrapListener((TestListener) f));
} }


final ByteArrayOutputStream errStrm = new ByteArrayOutputStream(); final ByteArrayOutputStream errStrm = new ByteArrayOutputStream();
@@ -506,9 +505,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
suite = TestSuite.createTest(testClass, methods[0]); suite = TestSuite.createTest(testClass, methods[0]);
} else { } else {
final TestSuite testSuite = new TestSuite(testClass.getName()); final TestSuite testSuite = new TestSuite(testClass.getName());
for (int i = 0; i < methods.length; i++) {
testSuite.addTest(
TestSuite.createTest(testClass, methods[i]));
for (String method : methods) {
testSuite.addTest(TestSuite.createTest(testClass, method));
} }
suite = testSuite; suite = testSuite;
} }
@@ -524,9 +522,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
fireStartTestSuite(); fireStartTestSuite();
startTestSuiteSuccess = true; startTestSuiteSuccess = true;
if (exception != null) { // had an exception constructing suite if (exception != null) { // had an exception constructing suite
final int formatterSize = formatters.size();
for (int i = 0; i < formatterSize; i++) {
((TestListener) formatters.elementAt(i)).addError(null, exception);
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) {
((TestListener) f).addError(null, exception);
} }
junitTest.setCounts(1, 0, 1, 0); junitTest.setCounts(1, 0, 1, 0);
junitTest.setRunTime(0); junitTest.setRunTime(0);
@@ -837,27 +834,22 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
} }


private void sendOutAndErr(final String out, final String err) { private void sendOutAndErr(final String out, final String err) {
final int size = formatters.size();
for (int i = 0; i < size; i++) {
final JUnitResultFormatter formatter =
(JUnitResultFormatter) formatters.get(i);

for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) {
final JUnitResultFormatter formatter = (JUnitResultFormatter) f;
formatter.setSystemOutput(out); formatter.setSystemOutput(out);
formatter.setSystemError(err); formatter.setSystemError(err);
} }
} }


private void fireStartTestSuite() { private void fireStartTestSuite() {
final int size = formatters.size();
for (int i = 0; i < size; i++) {
((JUnitResultFormatter) formatters.elementAt(i)).startTestSuite(junitTest);
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) {
((JUnitResultFormatter) f).startTestSuite(junitTest);
} }
} }


private void fireEndTestSuite() { private void fireEndTestSuite() {
final int size = formatters.size();
for (int i = 0; i < size; i++) {
((JUnitResultFormatter) formatters.elementAt(i)).endTestSuite(junitTest);
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) {
((JUnitResultFormatter) f).endTestSuite(junitTest);
} }
} }


@@ -937,52 +929,52 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
args[0] = args[0].substring(Constants.TESTSFILE.length()); args[0] = args[0].substring(Constants.TESTSFILE.length());
} }


for (int i = 1; i < args.length; i++) {
if (args[i].startsWith(Constants.METHOD_NAMES)) {
for (String arg : args) {
if (arg.startsWith(Constants.METHOD_NAMES)) {
try { try {
final String methodsList = args[i].substring(Constants.METHOD_NAMES.length());
final String methodsList = arg.substring(Constants.METHOD_NAMES.length());
methods = JUnitTest.parseTestMethodNamesList(methodsList); methods = JUnitTest.parseTestMethodNamesList(methodsList);
} catch (final IllegalArgumentException ex) { } catch (final IllegalArgumentException ex) {
System.err.println("Invalid specification of test method names: " + args[i]);
System.err.println("Invalid specification of test method names: " + arg);
System.exit(ERRORS); System.exit(ERRORS);
} }
} else if (args[i].startsWith(Constants.HALT_ON_ERROR)) {
haltError = Project.toBoolean(args[i].substring(Constants.HALT_ON_ERROR.length()));
} else if (args[i].startsWith(Constants.HALT_ON_FAILURE)) {
haltFail = Project.toBoolean(args[i].substring(Constants.HALT_ON_FAILURE.length()));
} else if (args[i].startsWith(Constants.FILTERTRACE)) {
stackfilter = Project.toBoolean(args[i].substring(Constants.FILTERTRACE.length()));
} else if (args[i].startsWith(Constants.CRASHFILE)) {
crashFile = args[i].substring(Constants.CRASHFILE.length());
} else if (arg.startsWith(Constants.HALT_ON_ERROR)) {
haltError = Project.toBoolean(arg.substring(Constants.HALT_ON_ERROR.length()));
} else if (arg.startsWith(Constants.HALT_ON_FAILURE)) {
haltFail = Project.toBoolean(arg.substring(Constants.HALT_ON_FAILURE.length()));
} else if (arg.startsWith(Constants.FILTERTRACE)) {
stackfilter = Project.toBoolean(arg.substring(Constants.FILTERTRACE.length()));
} else if (arg.startsWith(Constants.CRASHFILE)) {
crashFile = arg.substring(Constants.CRASHFILE.length());
registerTestCase(Constants.BEFORE_FIRST_TEST); registerTestCase(Constants.BEFORE_FIRST_TEST);
} else if (args[i].startsWith(Constants.FORMATTER)) {
} else if (arg.startsWith(Constants.FORMATTER)) {
try { try {
createAndStoreFormatter(args[i].substring(Constants.FORMATTER.length()));
createAndStoreFormatter(arg.substring(Constants.FORMATTER.length()));
} catch (final BuildException be) { } catch (final BuildException be) {
System.err.println(be.getMessage()); System.err.println(be.getMessage());
System.exit(ERRORS); System.exit(ERRORS);
} }
} else if (args[i].startsWith(Constants.PROPSFILE)) {
final InputStream in = Files.newInputStream(Paths.get(args[i]
} else if (arg.startsWith(Constants.PROPSFILE)) {
final InputStream in = Files.newInputStream(Paths.get(arg
.substring(Constants.PROPSFILE.length()))); .substring(Constants.PROPSFILE.length())));
props.load(in); props.load(in);
in.close(); in.close();
} else if (args[i].startsWith(Constants.SHOWOUTPUT)) {
showOut = Project.toBoolean(args[i].substring(Constants.SHOWOUTPUT.length()));
} else if (args[i].startsWith(Constants.LOGTESTLISTENEREVENTS)) {
} else if (arg.startsWith(Constants.SHOWOUTPUT)) {
showOut = Project.toBoolean(arg.substring(Constants.SHOWOUTPUT.length()));
} else if (arg.startsWith(Constants.LOGTESTLISTENEREVENTS)) {
logTestListenerEvents = Project.toBoolean( logTestListenerEvents = Project.toBoolean(
args[i].substring(Constants.LOGTESTLISTENEREVENTS.length()));
} else if (args[i].startsWith(Constants.OUTPUT_TO_FORMATTERS)) {
arg.substring(Constants.LOGTESTLISTENEREVENTS.length()));
} else if (arg.startsWith(Constants.OUTPUT_TO_FORMATTERS)) {
outputToFormat = Project.toBoolean( outputToFormat = Project.toBoolean(
args[i].substring(Constants.OUTPUT_TO_FORMATTERS.length()));
} else if (args[i].startsWith(Constants.LOG_FAILED_TESTS)) {
arg.substring(Constants.OUTPUT_TO_FORMATTERS.length()));
} else if (arg.startsWith(Constants.LOG_FAILED_TESTS)) {
logFailedTests = Project.toBoolean( logFailedTests = Project.toBoolean(
args[i].substring(Constants.LOG_FAILED_TESTS.length()));
} else if (args[i].startsWith(Constants.SKIP_NON_TESTS)) {
arg.substring(Constants.LOG_FAILED_TESTS.length()));
} else if (arg.startsWith(Constants.SKIP_NON_TESTS)) {
skipNonTests = Project.toBoolean( skipNonTests = Project.toBoolean(
args[i].substring(Constants.SKIP_NON_TESTS.length()));
} else if (args[i].startsWith(Constants.THREADID)) {
antThreadID = Integer.parseInt(args[i].substring(Constants.THREADID.length()));
arg.substring(Constants.SKIP_NON_TESTS.length()));
} else if (arg.startsWith(Constants.THREADID)) {
antThreadID = Integer.parseInt(arg.substring(Constants.THREADID.length()));
} }
} }


@@ -1096,9 +1088,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
registerTestCase(JUnitVersionHelper.getTestCaseName(arg0)); registerTestCase(JUnitVersionHelper.getTestCaseName(arg0));
} }
}); });
final int size = fromCmdLine.size();
for (int i = 0; i < size; i++) {
final FormatterElement fe = fromCmdLine.elementAt(i);
for (FormatterElement fe : fromCmdLine) {
if (multipleTests && fe.getUseFile()) { if (multipleTests && fe.getUseFile()) {
final File destFile = new File(test.getTodir(), final File destFile = new File(test.getTodir(),
test.getOutfile() + fe.getExtension()); test.getOutfile() + fe.getExtension());
@@ -1180,8 +1170,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR
} }


private static boolean filterLine(final String line) { private static boolean filterLine(final String line) {
for (int i = 0; i < DEFAULT_TRACE_FILTERS.length; i++) {
if (line.indexOf(DEFAULT_TRACE_FILTERS[i]) != -1) {
for (String filter : DEFAULT_TRACE_FILTERS) {
if (line.indexOf(filter) != -1) {
return true; return true;
} }
} }


+ 2
- 4
src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java View File

@@ -230,14 +230,12 @@ public class XMLResultAggregator extends Task implements XMLConstants {
generatedId = 0; generatedId = 0;


// get all files and add them to the document // get all files and add them to the document
File[] files = getFiles();
for (int i = 0; i < files.length; i++) {
File file = files[i];
for (File file : getFiles()) {
try { try {
log("Parsing file: '" + file + "'", Project.MSG_VERBOSE); log("Parsing file: '" + file + "'", Project.MSG_VERBOSE);
if (file.length() > 0) { if (file.length() > 0) {
Document testsuiteDoc = builder.parse(FileUtils Document testsuiteDoc = builder.parse(FileUtils
.getFileUtils().toURI(files[i].getAbsolutePath()));
.getFileUtils().toURI(file.getAbsolutePath()));
Element elem = testsuiteDoc.getDocumentElement(); Element elem = testsuiteDoc.getDocumentElement();
// make sure that this is REALLY a testsuite. // make sure that this is REALLY a testsuite.
if (TESTSUITE.equals(elem.getNodeName())) { if (TESTSUITE.equals(elem.getNodeName())) {


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java View File

@@ -77,9 +77,9 @@ public final class KaffeNative2Ascii extends DefaultNative2Ascii {
* @return null if neither class can get loaded. * @return null if neither class can get loaded.
*/ */
private static Class<?> getN2aClass() { private static Class<?> getN2aClass() {
for (int i = 0; i < N2A_CLASSNAMES.length; i++) {
for (String className : N2A_CLASSNAMES) {
try { try {
return Class.forName(N2A_CLASSNAMES[i]);
return Class.forName(className);
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
// Ignore // Ignore
} }


+ 32
- 35
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -27,7 +27,9 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -245,7 +247,7 @@ public class FTP extends Task implements FTPTaskConfig {
@Override @Override
public String getParent() { public String getParent() {
String result = ""; String result = "";
for(int i = 0; i < parts.length - 1; i++){
for (int i = 0; i < parts.length - 1; i++){
result += File.separatorChar + parts[i]; result += File.separatorChar + parts[i];
} }
return result; return result;
@@ -403,10 +405,10 @@ public class FTP extends Task implements FTPTaskConfig {
Map<String, String> newroots = new HashMap<>(); Map<String, String> newroots = new HashMap<>();
// put in the newroots vector the include patterns without // put in the newroots vector the include patterns without
// wildcard tokens // wildcard tokens
for (int icounter = 0; icounter < includes.length; icounter++) {
String newpattern =
SelectorUtils.rtrimWildcardTokens(includes[icounter]);
newroots.put(newpattern, includes[icounter]);
for (String include : includes) {
String newpattern
= SelectorUtils.rtrimWildcardTokens(include);
newroots.put(newpattern, include);
} }
if (remotedir == null) { if (remotedir == null) {
try { try {
@@ -519,11 +521,10 @@ public class FTP extends Task implements FTPTaskConfig {
ftp.changeToParentDirectory(); ftp.changeToParentDirectory();
return; return;
} }
for (int i = 0; i < newfiles.length; i++) {
FTPFile file = newfiles[i];
for (FTPFile file : newfiles) {
if (file != null if (file != null
&& !".".equals(file.getName())
&& !"..".equals(file.getName())) {
&& !".".equals(file.getName())
&& !"..".equals(file.getName())) {
String name = vpath + file.getName(); String name = vpath + file.getName();
scannedDirs.put(name, new FTPFileProxy(file)); scannedDirs.put(name, new FTPFileProxy(file));
if (isFunctioningAsDirectory(ftp, dir, file)) { if (isFunctioningAsDirectory(ftp, dir, file)) {
@@ -533,7 +534,7 @@ public class FTP extends Task implements FTPTaskConfig {
slowScanAllowed = false; slowScanAllowed = false;
} else if (isIncluded(name)) { } else if (isIncluded(name)) {
accountForIncludedDir(name, accountForIncludedDir(name,
new AntFTPFile(ftp, file, completePath) , fast);
new AntFTPFile(ftp, file, completePath), fast);
} else { } else {
dirsNotIncluded.addElement(name); dirsNotIncluded.addElement(name);
if (fast && couldHoldIncluded(name)) { if (fast && couldHoldIncluded(name)) {
@@ -765,13 +766,13 @@ public class FTP extends Task implements FTPTaskConfig {


private String fiddleName(String origin) { private String fiddleName(String origin) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (int icounter = 0; icounter < origin.length(); icounter++) {
if (Character.isLowerCase(origin.charAt(icounter))) {
result.append(Character.toUpperCase(origin.charAt(icounter)));
} else if (Character.isUpperCase(origin.charAt(icounter))) {
result.append(Character.toLowerCase(origin.charAt(icounter)));
for (char ch : origin.toCharArray()) {
if (Character.isLowerCase(ch)) {
result.append(Character.toUpperCase(ch));
} else if (Character.isUpperCase(ch)) {
result.append(Character.toLowerCase(ch));
} else { } else {
result.append(origin.charAt(icounter));
result.append(ch);
} }
} }
return result.toString(); return result.toString();
@@ -831,9 +832,7 @@ public class FTP extends Task implements FTPTaskConfig {
throw new BuildException( throw new BuildException(
"could not change working dir to %s", parent.curpwd); "could not change working dir to %s", parent.curpwd);
} }
final int size = pathElements.size();
for (int fcount = 0; fcount < size - 1; fcount++) {
String currentPathElement = pathElements.get(fcount);
for (String currentPathElement : pathElements) {
try { try {
if (!this.client if (!this.client
.changeWorkingDirectory(currentPathElement)) { .changeWorkingDirectory(currentPathElement)) {
@@ -871,14 +870,14 @@ public class FTP extends Task implements FTPTaskConfig {
String soughtPathElement) { String soughtPathElement) {
// we are already in the right path, so the second parameter // we are already in the right path, so the second parameter
// is false // is false
FTPFile[] theFiles = listFiles(parentPath, false);
if (theFiles == null) {
FTPFile[] files = listFiles(parentPath, false);
if (files == null) {
return null; return null;
} }
for (FTPFile f : theFiles) {
if (f != null
&& f.getName().equalsIgnoreCase(soughtPathElement)) {
return f.getName();
for (FTPFile file : files) {
if (file != null
&& file.getName().equalsIgnoreCase(soughtPathElement)) {
return file.getName();
} }
} }
return null; return null;
@@ -1815,8 +1814,8 @@ public class FTP extends Task implements FTPTaskConfig {
if (action == RM_DIR) { if (action == RM_DIR) {
// to remove directories, start by the end of the list // to remove directories, start by the end of the list
// the trunk does not let itself be removed before the leaves // the trunk does not let itself be removed before the leaves
for (int i = dsfiles.length - 1; i >= 0; i--) {
final String dsfile = dsfiles[i];
Arrays.sort(dsfiles, Comparator.reverseOrder());
for (final String dsfile : dsfiles) {
executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile); executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile);
} }
} else { } else {
@@ -1826,8 +1825,7 @@ public class FTP extends Task implements FTPTaskConfig {
this.granularityMillis = this.granularityMillis =
this.timestampGranularity.getMilliseconds(action); this.timestampGranularity.getMilliseconds(action);
} }
for (int i = 0; i < dsfiles.length; i++) {
final String dsfile = dsfiles[i];
for (final String dsfile : dsfiles) {
executeRetryable(h, () -> { executeRetryable(h, () -> {
switch (action) { switch (action) {
case SEND_FILES: case SEND_FILES:
@@ -2013,7 +2011,7 @@ public class FTP extends Task implements FTPTaskConfig {
* find a suitable name for local and remote temporary file * find a suitable name for local and remote temporary file
*/ */
private File findFileName(FTPClient ftp) { private File findFileName(FTPClient ftp) {
FTPFile[] theFiles = null;
FTPFile[] files = null;
final int maxIterations = 1000; final int maxIterations = 1000;
for (int counter = 1; counter < maxIterations; counter++) { for (int counter = 1; counter < maxIterations; counter++) {
File localFile = FILE_UTILS.createTempFile( File localFile = FILE_UTILS.createTempFile(
@@ -2022,12 +2020,11 @@ public class FTP extends Task implements FTPTaskConfig {
String fileName = localFile.getName(); String fileName = localFile.getName();
boolean found = false; boolean found = false;
try { try {
if (theFiles == null) {
theFiles = ftp.listFiles();
if (files == null) {
files = ftp.listFiles();
} }
for (int counter2 = 0; counter2 < theFiles.length; counter2++) {
if (theFiles[counter2] != null
&& theFiles[counter2].getName().equals(fileName)) {
for (FTPFile file : files) {
if (file != null && file.getName().equals(fileName)) {
found = true; found = true;
break; break;
} }


+ 32
- 36
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -27,6 +27,8 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -293,10 +295,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
Map<String, String> newroots = new Hashtable<>(); Map<String, String> newroots = new Hashtable<>();
// put in the newroots vector the include patterns without // put in the newroots vector the include patterns without
// wildcard tokens // wildcard tokens
for (int icounter = 0; icounter < includes.length; icounter++) {
for (String include : includes) {
String newpattern = String newpattern =
SelectorUtils.rtrimWildcardTokens(includes[icounter]);
newroots.put(newpattern, includes[icounter]);
SelectorUtils.rtrimWildcardTokens(include);
newroots.put(newpattern, include);
} }
if (task.getRemotedir() == null) { if (task.getRemotedir() == null) {
try { try {
@@ -412,11 +414,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
ftp.changeToParentDirectory(); ftp.changeToParentDirectory();
return; return;
} }
for (int i = 0; i < newfiles.length; i++) {
FTPFile file = newfiles[i];
for (FTPFile file : newfiles) {
if (file != null if (file != null
&& !".".equals(file.getName())
&& !"..".equals(file.getName())) {
&& !".".equals(file.getName())
&& !"..".equals(file.getName())) {
String name = vpath + file.getName(); String name = vpath + file.getName();
scannedDirs.put(name, new FTPFileProxy(file)); scannedDirs.put(name, new FTPFileProxy(file));
if (isFunctioningAsDirectory(ftp, dir, file)) { if (isFunctioningAsDirectory(ftp, dir, file)) {
@@ -426,7 +427,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
slowScanAllowed = false; slowScanAllowed = false;
} else if (isIncluded(name)) { } else if (isIncluded(name)) {
accountForIncludedDir(name, accountForIncludedDir(name,
new AntFTPFile(ftp, file, completePath) , fast);
new AntFTPFile(ftp, file, completePath), fast);
} else { } else {
dirsNotIncluded.addElement(name); dirsNotIncluded.addElement(name);
if (fast && couldHoldIncluded(name)) { if (fast && couldHoldIncluded(name)) {
@@ -664,13 +665,13 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {


private String fiddleName(String origin) { private String fiddleName(String origin) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (int icounter = 0; icounter < origin.length(); icounter++) {
if (Character.isLowerCase(origin.charAt(icounter))) {
result.append(Character.toUpperCase(origin.charAt(icounter)));
} else if (Character.isUpperCase(origin.charAt(icounter))) {
result.append(Character.toLowerCase(origin.charAt(icounter)));
for (char ch : origin.toCharArray()) {
if (Character.isLowerCase(ch)) {
result.append(Character.toUpperCase(ch));
} else if (Character.isUpperCase(ch)) {
result.append(Character.toLowerCase(ch));
} else { } else {
result.append(origin.charAt(icounter));
result.append(ch);
} }
} }
return result.toString(); return result.toString();
@@ -733,9 +734,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
throw new BuildException( throw new BuildException(
"could not change working dir to %s", parent.curpwd); "could not change working dir to %s", parent.curpwd);
} }
final int size = pathElements.size();
for (int fcount = 0; fcount < size - 1; fcount++) {
String currentPathElement = pathElements.get(fcount);
for (String currentPathElement : pathElements) {
try { try {
if (!this.client.changeWorkingDirectory(currentPathElement)) { if (!this.client.changeWorkingDirectory(currentPathElement)) {
if (!isCaseSensitive() && (remoteSystemCaseSensitive if (!isCaseSensitive() && (remoteSystemCaseSensitive
@@ -757,9 +756,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
currentPathElement, this.curpwd); currentPathElement, this.curpwd);
} }
} }
String lastpathelement = pathElements.get(size - 1);
FTPFile[] theFiles = listFiles(this.curpwd);
this.ftpFile = getFile(theFiles, lastpathelement);
String lastpathelement = pathElements.get(pathElements.size() - 1);
this.ftpFile = getFile(listFiles(this.curpwd), lastpathelement);
} }
/** /**
* find a file in a directory in case insensitive way * find a file in a directory in case insensitive way
@@ -771,14 +769,14 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
String soughtPathElement) { String soughtPathElement) {
// we are already in the right path, so the second parameter // we are already in the right path, so the second parameter
// is false // is false
FTPFile[] theFiles = listFiles(parentPath, false);
if (theFiles == null) {
FTPFile[] files = listFiles(parentPath, false);
if (files == null) {
return null; return null;
} }
for (FTPFile f : theFiles) {
if (f != null
&& f.getName().equalsIgnoreCase(soughtPathElement)) {
return f.getName();
for (FTPFile file : files) {
if (file != null
&& file.getName().equalsIgnoreCase(soughtPathElement)) {
return file.getName();
} }
} }
return null; return null;
@@ -1188,8 +1186,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
if (task.getAction() == FTPTask.RM_DIR) { if (task.getAction() == FTPTask.RM_DIR) {
// to remove directories, start by the end of the list // to remove directories, start by the end of the list
// the trunk does not let itself be removed before the leaves // the trunk does not let itself be removed before the leaves
for (int i = dsfiles.length - 1; i >= 0; i--) {
final String dsfile = dsfiles[i];
Arrays.sort(dsfiles, Comparator.reverseOrder());
for (final String dsfile : dsfiles) {
executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile); executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile);
} }
} else { } else {
@@ -1199,8 +1197,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
task.setGranularityMillis(task.getTimestampGranularity() task.setGranularityMillis(task.getTimestampGranularity()
.getMilliseconds(task.getAction())); .getMilliseconds(task.getAction()));
} }
for (int i = 0; i < dsfiles.length; i++) {
final String dsfile = dsfiles[i];
for (final String dsfile : dsfiles) {
executeRetryable(h, () -> { executeRetryable(h, () -> {
switch (task.getAction()) { switch (task.getAction()) {
case FTPTask.SEND_FILES: case FTPTask.SEND_FILES:
@@ -1395,7 +1392,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
* find a suitable name for local and remote temporary file * find a suitable name for local and remote temporary file
*/ */
private File findFileName(FTPClient ftp) { private File findFileName(FTPClient ftp) {
FTPFile[] theFiles = null;
FTPFile[] files = null;
final int maxIterations = 1000; final int maxIterations = 1000;
for (int counter = 1; counter < maxIterations; counter++) { for (int counter = 1; counter < maxIterations; counter++) {
File localFile = FILE_UTILS.createTempFile( File localFile = FILE_UTILS.createTempFile(
@@ -1404,12 +1401,11 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
String fileName = localFile.getName(); String fileName = localFile.getName();
boolean found = false; boolean found = false;
try { try {
if (theFiles == null) {
theFiles = ftp.listFiles();
if (files == null) {
files = ftp.listFiles();
} }
for (int counter2 = 0; counter2 < theFiles.length; counter2++) {
if (theFiles[counter2] != null
&& theFiles[counter2].getName().equals(fileName)) {
for (FTPFile file : files) {
if (file != null && file.getName().equals(fileName)) {
found = true; found = true;
break; break;
} }


+ 3
- 4
src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java View File

@@ -147,10 +147,9 @@ public class SoundTask extends Task {
if (source.exists()) { if (source.exists()) {
if (source.isDirectory()) { if (source.isDirectory()) {
// get the list of files in the dir // get the list of files in the dir
String[] entries = source.list();
Vector files = new Vector();
for (int i = 0; i < entries.length; i++) {
File f = new File(source, entries[i]);
Vector<File> files = new Vector<>();
for (String file : source.list()) {
File f = new File(source, file);
if (f.isFile()) { if (f.isFile()) {
files.addElement(f); files.addElement(f);
} }


+ 6
- 8
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java View File

@@ -84,10 +84,9 @@ public class SSHSession extends SSHBase {
* tunnel specifications * tunnel specifications
*/ */
public void setLocaltunnels(final String tunnels) { public void setLocaltunnels(final String tunnels) {
final String[] specs = tunnels.split(", ");
for (int i = 0; i < specs.length; i++) {
if (specs[i].length() > 0) {
final String[] spec = specs[i].split(":", 3);
for (String tunnelSpec : tunnels.split(", ")) {
if (tunnelSpec.length() > 0) {
final String[] spec = tunnelSpec.split(":", 3);
final int lport = Integer.parseInt(spec[0]); final int lport = Integer.parseInt(spec[0]);
final String rhost = spec[1]; final String rhost = spec[1];
final int rport = Integer.parseInt(spec[2]); final int rport = Integer.parseInt(spec[2]);
@@ -107,10 +106,9 @@ public class SSHSession extends SSHBase {
* tunnel specifications * tunnel specifications
*/ */
public void setRemotetunnels(final String tunnels) { public void setRemotetunnels(final String tunnels) {
final String[] specs = tunnels.split(", ");
for (int i = 0; i < specs.length; i++) {
if (specs[i].length() > 0) {
final String[] spec = specs[i].split(":", 3);
for (String tunnelSpec : tunnels.split(", ")) {
if (tunnelSpec.length() > 0) {
final String[] spec = tunnelSpec.split(":", 3);
final int rport = Integer.parseInt(spec[0]); final int rport = Integer.parseInt(spec[0]);
final String lhost = spec[1]; final String lhost = spec[1];
final int lport = Integer.parseInt(spec[2]); final int lport = Integer.parseInt(spec[2]);


+ 3
- 4
src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -205,8 +205,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
Commandline cmd = new Commandline(); Commandline cmd = new Commandline();


if (options != null) { if (options != null) {
for (int i = 0; i < options.length; i++) {
cmd.createArgument().setValue(options[i]);
for (String option : options) {
cmd.createArgument().setValue(option);
} }
} }


@@ -329,8 +329,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
protected String[] filterJvmCompilerArgs(String[] compilerArgs) { protected String[] filterJvmCompilerArgs(String[] compilerArgs) {
int len = compilerArgs.length; int len = compilerArgs.length;
List<String> args = new ArrayList<>(len); List<String> args = new ArrayList<>(len);
for (int i = 0; i < len; i++) {
String arg = compilerArgs[i];
for (String arg : compilerArgs) {
if (arg.startsWith("-J")) { if (arg.startsWith("-J")) {
attributes.log("Dropping " + arg + " from compiler arguments"); attributes.log("Dropping " + arg + " from compiler arguments");
} else { } else {


+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java View File

@@ -63,12 +63,12 @@ public class KaffeRmic extends DefaultRmicAdapter {
if (c == null) { if (c == null) {
StringBuilder buf = new StringBuilder( StringBuilder buf = new StringBuilder(
"Cannot use Kaffe rmic, as it is not available. None of "); "Cannot use Kaffe rmic, as it is not available. None of ");
for (int i = 0; i < RMIC_CLASSNAMES.length; i++) {
if (i != 0) {
for (String className : RMIC_CLASSNAMES) {
if (buf.length() > 0) {
buf.append(", "); buf.append(", ");
} }


buf.append(RMIC_CLASSNAMES[i]);
buf.append(className);
} }
buf.append( buf.append(
" have been found. A common solution is to set the environment variable JAVA_HOME or CLASSPATH."); " have been found. A common solution is to set the environment variable JAVA_HOME or CLASSPATH.");
@@ -102,9 +102,9 @@ public class KaffeRmic extends DefaultRmicAdapter {
* @return null if neither class can get loaded. * @return null if neither class can get loaded.
*/ */
private static Class<?> getRmicClass() { private static Class<?> getRmicClass() {
for (int i = 0; i < RMIC_CLASSNAMES.length; i++) {
for (String className : RMIC_CLASSNAMES) {
try { try {
return Class.forName(RMIC_CLASSNAMES[i]);
return Class.forName(className);
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
// Ignore // Ignore
} }


+ 4
- 4
src/main/org/apache/tools/ant/types/AbstractFileSet.java View File

@@ -283,8 +283,8 @@ public abstract class AbstractFileSet extends DataType
throw tooManyAttributes(); throw tooManyAttributes();
} }
if (includes != null) { if (includes != null) {
for (int i = 0; i < includes.length; i++) {
defaultPatterns.createInclude().setName(includes[i]);
for (String include : includes) {
defaultPatterns.createInclude().setName(include);
} }
directoryScanner = null; directoryScanner = null;
} }
@@ -318,8 +318,8 @@ public abstract class AbstractFileSet extends DataType
throw tooManyAttributes(); throw tooManyAttributes();
} }
if (excludes != null) { if (excludes != null) {
for (int i = 0; i < excludes.length; i++) {
defaultPatterns.createExclude().setName(excludes[i]);
for (String exclude : excludes) {
defaultPatterns.createExclude().setName(exclude);
} }
directoryScanner = null; directoryScanner = null;
} }


+ 5
- 7
src/main/org/apache/tools/ant/types/Commandline.java View File

@@ -353,8 +353,8 @@ public class Commandline implements Cloneable {
* @param line an array of arguments to append. * @param line an array of arguments to append.
*/ */
public void addArguments(String[] line) { public void addArguments(String[] line) {
for (int i = 0; i < line.length; i++) {
createArgument().setValue(line[i]);
for (String l : line) {
createArgument().setValue(l);
} }
} }


@@ -397,13 +397,11 @@ public class Commandline implements Cloneable {
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void addArgumentsToList(ListIterator<String> list) { public void addArgumentsToList(ListIterator<String> list) {
final int size = arguments.size();
for (int i = 0; i < size; i++) {
Argument arg = arguments.get(i);
for (Argument arg : arguments) {
String[] s = arg.getParts(); String[] s = arg.getParts();
if (s != null) { if (s != null) {
for (int j = 0; j < s.length; j++) {
list.add(s[j]);
for (String value : s) {
list.add(value);
} }
} }
} }


+ 2
- 2
src/main/org/apache/tools/ant/types/CommandlineJava.java View File

@@ -108,8 +108,8 @@ public class CommandlineJava implements Cloneable {
public void addDefinitionsToList(ListIterator<String> listIt) { public void addDefinitionsToList(ListIterator<String> listIt) {
String[] props = super.getVariables(); String[] props = super.getVariables();
if (props != null) { if (props != null) {
for (int i = 0; i < props.length; i++) {
listIt.add("-D" + props[i]);
for (String prop : props) {
listIt.add("-D" + prop);
} }
} }
Properties propertySetProperties = mergePropertySets(); Properties propertySetProperties = mergePropertySets();


+ 1
- 3
src/main/org/apache/tools/ant/types/FilterChain.java View File

@@ -17,7 +17,6 @@
*/ */
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import java.util.Iterator;
import java.util.Stack; import java.util.Stack;
import java.util.Vector; import java.util.Vector;


@@ -405,8 +404,7 @@ public class FilterChain extends DataType {
if (isReference()) { if (isReference()) {
super.dieOnCircularReference(stk, p); super.dieOnCircularReference(stk, p);
} else { } else {
for (Iterator<Object> i = filterReaders.iterator(); i.hasNext();) {
Object o = i.next();
for (Object o : filterReaders) {
if (o instanceof DataType) { if (o instanceof DataType) {
pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); pushAndInvokeCircularReferenceCheck((DataType) o, stk, p);
} }


+ 2
- 3
src/main/org/apache/tools/ant/types/FilterSet.java View File

@@ -222,9 +222,8 @@ public class FilterSet extends DataType implements Cloneable {
// silly hack to avoid stack overflow... // silly hack to avoid stack overflow...
if (!readingFiles) { if (!readingFiles) {
readingFiles = true; readingFiles = true;
final int size = filtersFiles.size();
for (int i = 0; i < size; i++) {
readFiltersFromFile(filtersFiles.get(i));
for (File filtersFile : filtersFiles) {
readFiltersFromFile(filtersFile);
} }
filtersFiles.clear(); filtersFiles.clear();
readingFiles = false; readingFiles = false;


+ 18
- 22
src/main/org/apache/tools/ant/types/Path.java View File

@@ -21,6 +21,7 @@ package org.apache.tools.ant.types;
import java.io.File; import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -330,17 +331,16 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
* @param tryUserDir if true try the user directory if the file is not present * @param tryUserDir if true try the user directory if the file is not present
*/ */
public void addExisting(Path source, boolean tryUserDir) { public void addExisting(Path source, boolean tryUserDir) {
String[] list = source.list();
File userDir = (tryUserDir) ? new File(System.getProperty("user.dir")) File userDir = (tryUserDir) ? new File(System.getProperty("user.dir"))
: null; : null;


for (int i = 0; i < list.length; i++) {
File f = resolveFile(getProject(), list[i]);
for (String name : source.list()) {
File f = resolveFile(getProject(), name);


// probably not the best choice, but it solves the problem of // probably not the best choice, but it solves the problem of
// relative paths in CLASSPATH // relative paths in CLASSPATH
if (tryUserDir && !f.exists()) { if (tryUserDir && !f.exists()) {
f = new File(userDir, list[i]);
f = new File(userDir, name);
} }
if (f.exists()) { if (f.exists()) {
setLocation(f); setLocation(f);
@@ -631,28 +631,25 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
+ File.separator + "rt.jar")); + File.separator + "rt.jar"));


// Sun's and Apple's 1.4 have JCE and JSSE in separate jars. // Sun's and Apple's 1.4 have JCE and JSSE in separate jars.
String[] secJars = {"jce", "jsse"};
for (int i = 0; i < secJars.length; i++) {
for (String secJar : Arrays.asList("jce", "jsse")) {
addExisting(new Path(null, addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + secJars[i] + ".jar"));
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + secJar + ".jar"));
addExisting(new Path(null, addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + ".."
+ File.separator + "Classes"
+ File.separator + secJars[i] + ".jar"));
System.getProperty("java.home")
+ File.separator + ".."
+ File.separator + "Classes"
+ File.separator + secJar + ".jar"));
} }


// IBM's 1.4 has rt.jar split into 4 smaller jars and a combined // IBM's 1.4 has rt.jar split into 4 smaller jars and a combined
// JCE/JSSE in security.jar. // JCE/JSSE in security.jar.
String[] ibmJars
= {"core", "graphics", "security", "server", "xml"};
for (int i = 0; i < ibmJars.length; i++) {
for (String ibmJar : Arrays.asList("core", "graphics", "security", "server", "xml")) {
addExisting(new Path(null, addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + ibmJars[i] + ".jar"));
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + ibmJar + ".jar"));
} }


// Added for MacOS X // Added for MacOS X
@@ -686,9 +683,8 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
} }
} }


String[] dirs = extdirs.list();
for (int i = 0; i < dirs.length; i++) {
File dir = resolveFile(getProject(), dirs[i]);
for (String d : extdirs.list()) {
File dir = resolveFile(getProject(), d);
if (dir.exists() && dir.isDirectory()) { if (dir.exists() && dir.isDirectory()) {
FileSet fs = new FileSet(); FileSet fs = new FileSet();
fs.setDir(dir); fs.setDir(dir);


+ 8
- 8
src/main/org/apache/tools/ant/types/PatternSet.java View File

@@ -230,13 +230,13 @@ public class PatternSet extends DataType implements Cloneable {
String[] nestedExcludes = p.getExcludePatterns(getProject()); String[] nestedExcludes = p.getExcludePatterns(getProject());


if (nestedIncludes != null) { if (nestedIncludes != null) {
for (int i = 0; i < nestedIncludes.length; i++) {
createInclude().setName(nestedIncludes[i]);
for (String nestedInclude : nestedIncludes) {
createInclude().setName(nestedInclude);
} }
} }
if (nestedExcludes != null) { if (nestedExcludes != null) {
for (int i = 0; i < nestedExcludes.length; i++) {
createExclude().setName(nestedExcludes[i]);
for (String nestedExclude : nestedExcludes) {
createExclude().setName(nestedExclude);
} }
} }
} }
@@ -391,14 +391,14 @@ public class PatternSet extends DataType implements Cloneable {
dieOnCircularReference(p); dieOnCircularReference(p);
String[] incl = other.getIncludePatterns(p); String[] incl = other.getIncludePatterns(p);
if (incl != null) { if (incl != null) {
for (int i = 0; i < incl.length; i++) {
createInclude().setName(incl[i]);
for (String include : incl) {
createInclude().setName(include);
} }
} }
String[] excl = other.getExcludePatterns(p); String[] excl = other.getExcludePatterns(p);
if (excl != null) { if (excl != null) {
for (int i = 0; i < excl.length; i++) {
createExclude().setName(excl[i]);
for (String exclude : excl) {
createExclude().setName(exclude);
} }
} }
} }


+ 2
- 2
src/main/org/apache/tools/ant/types/Quantifier.java View File

@@ -154,8 +154,8 @@ public class Quantifier extends EnumeratedAttribute {
*/ */
public boolean evaluate(boolean[] b) { public boolean evaluate(boolean[] b) {
int t = 0; int t = 0;
for (int i = 0; i < b.length; i++) {
if (b[i]) {
for (boolean bn : b) {
if (bn) {
t++; t++;
} }
} }


+ 7
- 8
src/main/org/apache/tools/ant/types/RedirectorElement.java View File

@@ -573,9 +573,9 @@ public class RedirectorElement extends DataType {
} }
//remove any null elements //remove any null elements
ArrayList<File> list = new ArrayList<>(name.length); ArrayList<File> list = new ArrayList<>(name.length);
for (int i = 0; i < name.length; i++) {
if (name[i] != null) {
list.add(getProject().resolveFile(name[i]));
for (String n : name) {
if (n != null) {
list.add(getProject().resolveFile(n));
} }
} }
return (File[]) (list.toArray(new File[list.size()])); return (File[]) (list.toArray(new File[list.size()]));
@@ -597,11 +597,10 @@ public class RedirectorElement extends DataType {
if (isReference()) { if (isReference()) {
super.dieOnCircularReference(stk, p); super.dieOnCircularReference(stk, p);
} else { } else {
Mapper[] m = new Mapper[] {inputMapper, outputMapper, errorMapper};
for (int i = 0; i < m.length; i++) {
if (m[i] != null) {
stk.push(m[i]);
m[i].dieOnCircularReference(stk, p);
for (Mapper m : Arrays.asList(inputMapper, outputMapper, errorMapper)) {
if (m != null) {
stk.push(m);
m.dieOnCircularReference(stk, p);
stk.pop(); stk.pop();
} }
} }


+ 3
- 4
src/main/org/apache/tools/ant/types/XMLCatalog.java View File

@@ -1107,14 +1107,13 @@ public class XMLCatalog extends DataType
if (catPath != null) { if (catPath != null) {
log("Using catalogpath '" + getCatalogPath() + "'", log("Using catalogpath '" + getCatalogPath() + "'",
Project.MSG_DEBUG); Project.MSG_DEBUG);
String[] catPathList = getCatalogPath().list();


for (int i = 0; i < catPathList.length; i++) {
File catFile = new File(catPathList[i]);
for (String catFileName : getCatalogPath().list()) {
File catFile = new File(catFileName);
log("Parsing " + catFile, Project.MSG_DEBUG); log("Parsing " + catFile, Project.MSG_DEBUG);
try { try {
parseCatalog.invoke(resolverImpl, parseCatalog.invoke(resolverImpl,
new Object[] {catFile.getPath()});
new Object[]{catFile.getPath()});
} catch (Exception ex) { } catch (Exception ex) {
throw new BuildException(ex); throw new BuildException(ex);
} }


+ 3
- 4
src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java View File

@@ -130,10 +130,9 @@ public class ClassfileSet extends FileSet {
for (FileSet additionalRootSet : rootFileSets) { for (FileSet additionalRootSet : rootFileSets) {
DirectoryScanner additionalScanner DirectoryScanner additionalScanner
= additionalRootSet.getDirectoryScanner(p); = additionalRootSet.getDirectoryScanner(p);
String[] files = additionalScanner.getIncludedFiles();
for (int i = 0; i < files.length; ++i) {
if (files[i].endsWith(".class")) {
String classFilePath = StringUtils.removeSuffix(files[i], ".class");
for (String file : additionalScanner.getIncludedFiles()) {
if (file.endsWith(".class")) {
String classFilePath = StringUtils.removeSuffix(file, ".class");
String className String className
= classFilePath.replace('/', '.').replace('\\', '.'); = classFilePath.replace('/', '.').replace('\\', '.');
allRootClasses.addElement(className); allRootClasses.addElement(className);


+ 4
- 4
src/main/org/apache/tools/ant/types/resources/BZip2Resource.java View File

@@ -55,8 +55,8 @@ public class BZip2Resource extends CompressedResource {
*/ */
@Override @Override
protected InputStream wrapStream(InputStream in) throws IOException { protected InputStream wrapStream(InputStream in) throws IOException {
for (int i = 0; i < MAGIC.length; i++) {
if (in.read() != MAGIC[i]) {
for (char ch : MAGIC) {
if (in.read() != ch) {
throw new IOException("Invalid bz2 stream."); throw new IOException("Invalid bz2 stream.");
} }
} }
@@ -71,8 +71,8 @@ public class BZip2Resource extends CompressedResource {
*/ */
@Override @Override
protected OutputStream wrapStream(OutputStream out) throws IOException { protected OutputStream wrapStream(OutputStream out) throws IOException {
for (int i = 0; i < MAGIC.length; i++) {
out.write(MAGIC[i]);
for (char ch : MAGIC) {
out.write(ch);
} }
return new CBZip2OutputStream(out); return new CBZip2OutputStream(out);
} }


+ 4
- 4
src/main/org/apache/tools/ant/types/resources/Files.java View File

@@ -180,8 +180,8 @@ public class Files extends AbstractSelectorContainer
public synchronized void appendIncludes(String[] includes) { public synchronized void appendIncludes(String[] includes) {
checkAttributesAllowed(); checkAttributesAllowed();
if (includes != null) { if (includes != null) {
for (int i = 0; i < includes.length; i++) {
defaultPatterns.createInclude().setName(includes[i]);
for (String include : includes) {
defaultPatterns.createInclude().setName(include);
} }
ds = null; ds = null;
} }
@@ -210,8 +210,8 @@ public class Files extends AbstractSelectorContainer
public synchronized void appendExcludes(String[] excludes) { public synchronized void appendExcludes(String[] excludes) {
checkAttributesAllowed(); checkAttributesAllowed();
if (excludes != null) { if (excludes != null) {
for (int i = 0; i < excludes.length; i++) {
defaultPatterns.createExclude().setName(excludes[i]);
for (String exclude : excludes) {
defaultPatterns.createExclude().setName(exclude);
} }
ds = null; ds = null;
} }


+ 6
- 7
src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java View File

@@ -111,17 +111,16 @@ public class ContainsRegexpSelector extends BaseExtendSelector
public void setParameters(Parameter... parameters) { public void setParameters(Parameter... parameters) {
super.setParameters(parameters); super.setParameters(parameters);
if (parameters != null) { if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
String paramname = parameters[i].getName();
for (Parameter parameter : parameters) {
String paramname = parameter.getName();
if (EXPRESSION_KEY.equalsIgnoreCase(paramname)) { if (EXPRESSION_KEY.equalsIgnoreCase(paramname)) {
setExpression(parameters[i].getValue());
setExpression(parameter.getValue());
} else if (CS_KEY.equalsIgnoreCase(paramname)) { } else if (CS_KEY.equalsIgnoreCase(paramname)) {
setCaseSensitive(Project
.toBoolean(parameters[i].getValue()));
setCaseSensitive(Project.toBoolean(parameter.getValue()));
} else if (ML_KEY.equalsIgnoreCase(paramname)) { } else if (ML_KEY.equalsIgnoreCase(paramname)) {
setMultiLine(Project.toBoolean(parameters[i].getValue()));
setMultiLine(Project.toBoolean(parameter.getValue()));
} else if (SL_KEY.equalsIgnoreCase(paramname)) { } else if (SL_KEY.equalsIgnoreCase(paramname)) {
setSingleLine(Project.toBoolean(parameters[i].getValue()));
setSingleLine(Project.toBoolean(parameter.getValue()));
} else { } else {
setError("Invalid parameter " + paramname); setError("Invalid parameter " + paramname);
} }


+ 5
- 5
src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java View File

@@ -111,16 +111,16 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele
public void setParameters(Parameter... parameters) { public void setParameters(Parameter... parameters) {
super.setParameters(parameters); super.setParameters(parameters);
if (parameters != null) { if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
String paramname = parameters[i].getName();
for (Parameter parameter : parameters) {
String paramname = parameter.getName();
if (CONTAINS_KEY.equalsIgnoreCase(paramname)) { if (CONTAINS_KEY.equalsIgnoreCase(paramname)) {
setText(parameters[i].getValue());
setText(parameter.getValue());
} else if (CASE_KEY.equalsIgnoreCase(paramname)) { } else if (CASE_KEY.equalsIgnoreCase(paramname)) {
setCasesensitive(Project.toBoolean( setCasesensitive(Project.toBoolean(
parameters[i].getValue()));
parameter.getValue()));
} else if (WHITESPACE_KEY.equalsIgnoreCase(paramname)) { } else if (WHITESPACE_KEY.equalsIgnoreCase(paramname)) {
setIgnorewhitespace(Project.toBoolean( setIgnorewhitespace(Project.toBoolean(
parameters[i].getValue()));
parameter.getValue()));
} else { } else {
setError("Invalid parameter " + paramname); setError("Invalid parameter " + paramname);
} }


+ 10
- 10
src/main/org/apache/tools/ant/types/selectors/DateSelector.java View File

@@ -160,30 +160,30 @@ public class DateSelector extends BaseExtendSelector {
public void setParameters(Parameter... parameters) { public void setParameters(Parameter... parameters) {
super.setParameters(parameters); super.setParameters(parameters);
if (parameters != null) { if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
String paramname = parameters[i].getName();
for (Parameter parameter : parameters) {
String paramname = parameter.getName();
if (MILLIS_KEY.equalsIgnoreCase(paramname)) { if (MILLIS_KEY.equalsIgnoreCase(paramname)) {
try { try {
setMillis(Long.parseLong(parameters[i].getValue()));
setMillis(Long.parseLong(parameter.getValue()));
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
setError("Invalid millisecond setting " setError("Invalid millisecond setting "
+ parameters[i].getValue());
+ parameter.getValue());
} }
} else if (DATETIME_KEY.equalsIgnoreCase(paramname)) { } else if (DATETIME_KEY.equalsIgnoreCase(paramname)) {
setDatetime(parameters[i].getValue());
setDatetime(parameter.getValue());
} else if (CHECKDIRS_KEY.equalsIgnoreCase(paramname)) { } else if (CHECKDIRS_KEY.equalsIgnoreCase(paramname)) {
setCheckdirs(Project.toBoolean(parameters[i].getValue()));
setCheckdirs(Project.toBoolean(parameter.getValue()));
} else if (GRANULARITY_KEY.equalsIgnoreCase(paramname)) { } else if (GRANULARITY_KEY.equalsIgnoreCase(paramname)) {
try { try {
setGranularity(Integer.parseInt(parameters[i].getValue()));
setGranularity(Integer.parseInt(parameter.getValue()));
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
setError("Invalid granularity setting " setError("Invalid granularity setting "
+ parameters[i].getValue());
+ parameter.getValue());
} }
} else if (WHEN_KEY.equalsIgnoreCase(paramname)) { } else if (WHEN_KEY.equalsIgnoreCase(paramname)) {
setWhen(new TimeComparison(parameters[i].getValue()));
setWhen(new TimeComparison(parameter.getValue()));
} else if (PATTERN_KEY.equalsIgnoreCase(paramname)) { } else if (PATTERN_KEY.equalsIgnoreCase(paramname)) {
setPattern(parameters[i].getValue());
setPattern(parameter.getValue());
} else { } else {
setError("Invalid parameter " + paramname); setError("Invalid parameter " + paramname);
} }


+ 6
- 6
src/main/org/apache/tools/ant/types/selectors/DepthSelector.java View File

@@ -84,21 +84,21 @@ public class DepthSelector extends BaseExtendSelector {
public void setParameters(Parameter... parameters) { public void setParameters(Parameter... parameters) {
super.setParameters(parameters); super.setParameters(parameters);
if (parameters != null) { if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
String paramname = parameters[i].getName();
for (Parameter parameter : parameters) {
String paramname = parameter.getName();
if (MIN_KEY.equalsIgnoreCase(paramname)) { if (MIN_KEY.equalsIgnoreCase(paramname)) {
try { try {
setMin(Integer.parseInt(parameters[i].getValue()));
setMin(Integer.parseInt(parameter.getValue()));
} catch (NumberFormatException nfe1) { } catch (NumberFormatException nfe1) {
setError("Invalid minimum value " setError("Invalid minimum value "
+ parameters[i].getValue());
+ parameter.getValue());
} }
} else if (MAX_KEY.equalsIgnoreCase(paramname)) { } else if (MAX_KEY.equalsIgnoreCase(paramname)) {
try { try {
setMax(Integer.parseInt(parameters[i].getValue()));
setMax(Integer.parseInt(parameter.getValue()));
} catch (NumberFormatException nfe1) { } catch (NumberFormatException nfe1) {
setError("Invalid maximum value " setError("Invalid maximum value "
+ parameters[i].getValue());
+ parameter.getValue());
} }
} else { } else {
setError("Invalid parameter " + paramname); setError("Invalid parameter " + paramname);


+ 6
- 6
src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java View File

@@ -125,17 +125,17 @@ public class FilenameSelector extends BaseExtendSelector {
public void setParameters(Parameter... parameters) { public void setParameters(Parameter... parameters) {
super.setParameters(parameters); super.setParameters(parameters);
if (parameters != null) { if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
String paramname = parameters[i].getName();
for (Parameter parameter : parameters) {
String paramname = parameter.getName();
if (NAME_KEY.equalsIgnoreCase(paramname)) { if (NAME_KEY.equalsIgnoreCase(paramname)) {
setName(parameters[i].getValue());
setName(parameter.getValue());
} else if (CASE_KEY.equalsIgnoreCase(paramname)) { } else if (CASE_KEY.equalsIgnoreCase(paramname)) {
setCasesensitive(Project.toBoolean( setCasesensitive(Project.toBoolean(
parameters[i].getValue()));
parameter.getValue()));
} else if (NEGATE_KEY.equalsIgnoreCase(paramname)) { } else if (NEGATE_KEY.equalsIgnoreCase(paramname)) {
setNegate(Project.toBoolean(parameters[i].getValue()));
setNegate(Project.toBoolean(parameter.getValue()));
} else if (REGEX_KEY.equalsIgnoreCase(paramname)) { } else if (REGEX_KEY.equalsIgnoreCase(paramname)) {
setRegex(parameters[i].getValue());
setRegex(parameter.getValue());
} else { } else {
setError("Invalid parameter " + paramname); setError("Invalid parameter " + paramname);
} }


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save