You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2018/05/16 17:13:22 UTC

[1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Repository: ant
Updated Branches:
  refs/heads/master ac35c0014 -> 070c3bc86


http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/ZipScanner.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java b/src/main/org/apache/tools/ant/types/ZipScanner.java
index a3df040..5667159 100644
--- a/src/main/org/apache/tools/ant/types/ZipScanner.java
+++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
@@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Map;
 import java.util.zip.ZipException;
 
@@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner {
                 "Only file provider resources are supported"));
 
         try (ZipFile zf = new ZipFile(srcFile, encoding)) {
-
-            Enumeration<ZipEntry> e = zf.getEntries();
-            while (e.hasMoreElements()) {
-                ZipEntry entry = e.nextElement();
+             for (ZipEntry entry : Collections.list(zf.getEntries())) {
                 Resource r = new ZipResource(srcFile, encoding, entry);
                 String name = entry.getName();
                 if (entry.isDirectory()) {

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java b/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java
index 4f2e1eb..413ae39 100644
--- a/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java
+++ b/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java
@@ -18,7 +18,7 @@
 package org.apache.tools.ant.types.optional.depend;
 
 import java.io.File;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Set;
 import java.util.Vector;
 import java.util.stream.Collectors;
@@ -126,12 +126,8 @@ public class DependScanner extends DirectoryScanner {
         Set<String> parentSet = Stream.of(parentScanner.getIncludedFiles())
             .collect(Collectors.toSet());
 
-        Enumeration<String> e = analyzer.getClassDependencies();
-
-        while (e.hasMoreElements()) {
-            String classname = e.nextElement();
-            String filename =
-                classname.replace('.', File.separatorChar) + ".class";
+        for (String classname : Collections.list(analyzer.getClassDependencies())) {
+            String filename = classname.replace('.', File.separatorChar) + ".class";
             File depFile = new File(basedir, filename);
             if (depFile.exists() && parentSet.contains(filename)) {
                 // This is included

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/resources/Resources.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/Resources.java b/src/main/org/apache/tools/ant/types/resources/Resources.java
index c11918c..afa92f8 100644
--- a/src/main/org/apache/tools/ant/types/resources/Resources.java
+++ b/src/main/org/apache/tools/ant/types/resources/Resources.java
@@ -34,7 +34,6 @@ import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.DataType;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
-import org.apache.tools.ant.util.CollectionUtils;
 
 /**
  * Generic ResourceCollection: Either stores nested ResourceCollections,
@@ -90,7 +89,8 @@ public class Resources extends DataType implements ResourceCollection {
         private synchronized Collection<Resource> getCache() {
             Collection<Resource> coll = cached;
             if (coll == null) {
-                coll = CollectionUtils.asCollection(new MyIterator());
+                coll = new ArrayList<>();
+                new MyIterator().forEachRemaining(coll::add);
                 if (cache) {
                     cached = coll;
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java b/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
index 444d1c1..c6f50ef 100644
--- a/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java
@@ -19,7 +19,7 @@
 package org.apache.tools.ant.types.selectors;
 
 import java.io.File;
-import java.util.Enumeration;
+import java.util.Collections;
 
 /**
  * This selector is here just to shake up your thinking a bit. Don't get
@@ -75,11 +75,9 @@ public class MajoritySelector extends BaseSelectorContainer {
         validate();
         int yesvotes = 0;
         int novotes = 0;
-        Enumeration<FileSelector> e = selectorElements();
 
-        while (e.hasMoreElements()) {
-            if (e.nextElement().isSelected(basedir,
-                    filename, file)) {
+        for (FileSelector fs : Collections.list(selectorElements())) {
+            if (fs.isSelected(basedir, filename, file)) {
                 yesvotes++;
             } else {
                 novotes++;

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java b/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java
index b5667f8..d091db0 100644
--- a/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java
@@ -221,11 +221,7 @@ public class SelectSelector extends BaseSelectorContainer {
         }
 
         Enumeration<FileSelector> e = selectorElements();
-        if (!e.hasMoreElements()) {
-            return true;
-        }
-        FileSelector f = e.nextElement();
-        return f.isSelected(basedir, filename, file);
+        return !e.hasMoreElements() || e.nextElement().isSelected(basedir, filename, file);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/util/CollectionUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/CollectionUtils.java b/src/main/org/apache/tools/ant/util/CollectionUtils.java
index 94fa928..c516fe3 100644
--- a/src/main/org/apache/tools/ant/util/CollectionUtils.java
+++ b/src/main/org/apache/tools/ant/util/CollectionUtils.java
@@ -36,6 +36,7 @@ import java.util.stream.Collectors;
  *
  * @since Ant 1.5
  */
+@Deprecated
 public class CollectionUtils {
 
     @SuppressWarnings("rawtypes")
@@ -80,20 +81,10 @@ public class CollectionUtils {
             return false;
         }
 
-        Enumeration<?> e1 = d1.keys();
-        while (e1.hasMoreElements()) {
-            Object key = e1.nextElement();
-            Object value1 = d1.get(key);
-            Object value2 = d2.get(key);
-            if (!value1.equals(value2)) {
-                return false;
-            }
-        }
-
         // don't need the opposite check as the Dictionaries have the
         // same size, so we've also covered all keys of d2 already.
-
-        return true;
+        return Collections.list(d1.keys()).stream()
+                .allMatch(key -> d1.get(key).equals(d2.get(key)));
     }
 
     /**
@@ -103,7 +94,9 @@ public class CollectionUtils {
      * @param c collection to transform
      * @return string representation of the collection
      * @since Ant 1.8.0
+     * @deprecated use stream().collect(Collectors.joining(","))
      */
+    @Deprecated
     public static String flattenToString(Collection<?> c) {
         return c.stream().map(String::valueOf).collect(Collectors.joining(","));
     }
@@ -120,10 +113,7 @@ public class CollectionUtils {
     @Deprecated
     public static <K, V> void putAll(Dictionary<? super K, ? super V> m1,
         Dictionary<? extends K, ? extends V> m2) {
-        for (Enumeration<? extends K> it = m2.keys(); it.hasMoreElements();) {
-            K key = it.nextElement();
-            m1.put(key, m2.get(key));
-        }
+        Collections.list(m2.keys()).forEach(key -> m1.put(key, m2.get(key)));
     }
 
     /**
@@ -159,7 +149,10 @@ public class CollectionUtils {
      * @param <E> element type
      * @return an enumeration representing e1 followed by e2.
      * @since Ant 1.6.3
+     * @deprecated use Stream.concat(Collections.list(e1).stream(), Collections.list(e2).stream())
+     *                 .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::enumeration))
      */
+    @Deprecated
     public static <E> Enumeration<E> append(Enumeration<E> e1, Enumeration<E> e2) {
         return new CompoundEnumeration<>(e1, e2);
     }
@@ -169,7 +162,9 @@ public class CollectionUtils {
      * @param iter the Iterator to adapt.
      * @param <E> element type
      * @return an Enumeration.
+     * @deprecated use Collections.enumeration()
      */
+    @Deprecated
     public static <E> Enumeration<E> asEnumeration(final Iterator<E> iter) {
         return new Enumeration<E>() {
             @Override
@@ -188,7 +183,9 @@ public class CollectionUtils {
      * @param e the Enumeration to adapt.
      * @param <E> element type
      * @return an Iterator.
+     * @deprecated use Collections.list(e).iterator()
      */
+    @Deprecated
     public static <E> Iterator<E> asIterator(final Enumeration<E> e) {
         return new Iterator<E>() {
             @Override
@@ -213,7 +210,9 @@ public class CollectionUtils {
      * @param <T> element type
      * @return the collection
      * @since Ant 1.8.0
+     * @deprecated instantiate a list an use forEachRemaining(list::add)
      */
+    @Deprecated
     public static <T> Collection<T> asCollection(final Iterator<? extends T> iter) {
         List<T> l = new ArrayList<>();
         iter.forEachRemaining(l::add);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/util/LinkedHashtable.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/LinkedHashtable.java b/src/main/org/apache/tools/ant/util/LinkedHashtable.java
index 4f73273..5224ff8 100644
--- a/src/main/org/apache/tools/ant/util/LinkedHashtable.java
+++ b/src/main/org/apache/tools/ant/util/LinkedHashtable.java
@@ -18,6 +18,7 @@
 package org.apache.tools.ant.util;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.LinkedHashMap;
@@ -79,7 +80,7 @@ public class LinkedHashtable<K, V> extends Hashtable<K, V> {
 
     @Override
     public Enumeration<V> elements() {
-        return CollectionUtils.asEnumeration(values().iterator());
+        return Collections.enumeration(values());
     }
 
     @Override
@@ -109,7 +110,7 @@ public class LinkedHashtable<K, V> extends Hashtable<K, V> {
 
     @Override
     public Enumeration<K> keys() {
-        return CollectionUtils.asEnumeration(keySet().iterator());
+        return Collections.enumeration(keySet());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java b/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
index fa2e9ee..8fc6d57 100644
--- a/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
+++ b/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
@@ -16,9 +16,10 @@
  *
  */
 package org.apache.tools.ant.util.depend.bcel;
+
 import java.io.File;
 import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Vector;
@@ -69,13 +70,9 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
         // classes upon which they depend
         Set<String> dependencies = new HashSet<>();
         Set<File> containers = new HashSet<>();
-        Set<String> toAnalyze = new HashSet<>();
+        Set<String> toAnalyze = new HashSet<>(Collections.list(getRootClasses()));
         Set<String> nextAnalyze = new HashSet<>();
 
-        for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) {
-            toAnalyze.add(e.nextElement());
-        }
-
         int count = 0;
         int maxCount = isClosureRequired() ? MAX_LOOPS : 2;
         while (!toAnalyze.isEmpty() && count++ < maxCount) {
@@ -115,9 +112,8 @@ public class AncestorAnalyzer extends AbstractAnalyzer {
                 }
             }
 
-            Set<String> temp = toAnalyze;
-            toAnalyze = nextAnalyze;
-            nextAnalyze = temp;
+            toAnalyze.clear();
+            toAnalyze.addAll(nextAnalyze);
         }
 
         files.clear();

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java b/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
index 0c6af25..8b6357d 100644
--- a/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
+++ b/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
@@ -19,7 +19,6 @@ package org.apache.tools.ant.util.depend.bcel;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Vector;
@@ -102,15 +101,10 @@ public class FullAnalyzer extends AbstractAnalyzer {
             }
 
             toAnalyze.clear();
-
             // now recover all the dependencies collected and add to the list.
-            Enumeration<String> depsEnum = dependencyVisitor.getDependencies();
-            while (depsEnum.hasMoreElements()) {
-                String className = depsEnum.nextElement();
-                if (!dependencies.contains(className)) {
-                    toAnalyze.add(className);
-                }
-            }
+            Collections.list(dependencyVisitor.getDependencies()).stream()
+                    .filter(className -> !dependencies.contains(className))
+                    .forEach(toAnalyze::add);
         }
 
         files.clear();

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/tests/junit/org/apache/tools/ant/util/LinkedHashtableTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/LinkedHashtableTest.java b/src/tests/junit/org/apache/tools/ant/util/LinkedHashtableTest.java
index 08ddbce..c2e16b9 100644
--- a/src/tests/junit/org/apache/tools/ant/util/LinkedHashtableTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/LinkedHashtableTest.java
@@ -18,6 +18,7 @@
 
 package org.apache.tools.ant.util;
 
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
@@ -112,7 +113,7 @@ public class LinkedHashtableTest {
     @Test
     public void testKeys() {
         multiSetup();
-        assertKeys(CollectionUtils.asIterator(h.keys()));
+        assertKeys(Collections.list(h.keys()).iterator());
     }
 
     @Test
@@ -124,7 +125,7 @@ public class LinkedHashtableTest {
     @Test
     public void testElements() {
         multiSetup();
-        assertValues(CollectionUtils.asIterator(h.elements()));
+        assertValues(Collections.list(h.elements()).iterator());
     }
 
     @Test


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Gintautas Grigelionis <g....@gmail.com>.
2018-05-20 16:08 GMT+02:00 Stefan Bodewig <bo...@apache.org>:

> I'm afraid you misunderstood my question. I didn't ask why streams may
> be preferable over Enumerations when you write new code or change
> existing code. I was asking how does this benefit the existing code
> right now when there is no other change at all.
>

Sorry if I was unclear but the point was that the stream is parallelizable.
So, potentially higher thoughput on multicore?

Gintas

Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Stefan Bodewig <bo...@apache.org>.
On 2018-05-20, Gintautas Grigelionis wrote:

> 2018-05-18 16:51 GMT+02:00 Stefan Bodewig <bo...@apache.org>:

>> On 2018-05-18, Gintautas Grigelionis wrote:

>>> I believe that Streams API can at least implement the logic run by an
>>> original Enumeration in a more concise way, or provide more powerful
>> idioms.
>>> That IMO makes it worth the while to investigate the Streams
>> alternatives.

>> I agree to do that as soon as we want to change the code to do something
>> that wants to use said idioms. I don't really see a reason to change the
>> code before that point in time.

>>> In the process I also found out that other iterators could be used in a
>>> more efficient way, or that there is a redundant object construction
>> going
>>> on.
>>> If you wish, I may spend some time to describe the changes I introduced,
>>> and maybe then we could discuss the their merits.

>> Let's use the concrete example that raised Maarten's email. In
>> ZipScanner we've gone from

>>             Enumeration<ZipEntry> e = zf.getEntries();
>>             while (e.hasMoreElements()) {
>>                 ZipEntry entry = e.nextElement();

>> to

>>             StreamUtils.enumerationAsStream(zf.getEntries()).forEach(entry
>> -> {

>> the Enumeration instance is created in both cases. What is the benfit
>> for the ZipScanner class right now?


> FWIW, the original java.util.ZipFile has a stream() that is based on an
> iterator since Java 8 [1].
> What is the reason for adding that method if Enumeration is so much better?
> ;-)
> I dare say, the benefit is that streams are parallelizable.

I'm afraid you misunderstood my question. I didn't ask why streams may
be preferable over Enumerations when you write new code or change
existing code. I was asking how does this benefit the existing code
right now when there is no other change at all.

Stefan

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


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Gintautas Grigelionis <g....@gmail.com>.
2018-05-18 16:51 GMT+02:00 Stefan Bodewig <bo...@apache.org>:

> On 2018-05-18, Gintautas Grigelionis wrote:
>
> > I believe that Streams API can at least implement the logic run by an
> > original Enumeration in a more concise way, or provide more powerful
> idioms.
> > That IMO makes it worth the while to investigate the Streams
> alternatives.
>
> I agree to do that as soon as we want to change the code to do something
> that wants to use said idioms. I don't really see a reason to change the
> code before that point in time.
>
> > In the process I also found out that other iterators could be used in a
> > more efficient way, or that there is a redundant object construction
> going
> > on.
> > If you wish, I may spend some time to describe the changes I introduced,
> > and maybe then we could discuss the their merits.
>
> Let's use the concrete example that raised Maarten's email. In
> ZipScanner we've gone from
>
>             Enumeration<ZipEntry> e = zf.getEntries();
>             while (e.hasMoreElements()) {
>                 ZipEntry entry = e.nextElement();
>
> to
>
>             StreamUtils.enumerationAsStream(zf.getEntries()).forEach(entry
> -> {
>
> the Enumeration instance is created in both cases. What is the benfit
> for the ZipScanner class right now?
>

FWIW, the original java.util.ZipFile has a stream() that is based on an
iterator since Java 8 [1].
What is the reason for adding that method if Enumeration is so much better?
;-)
I dare say, the benefit is that streams are parallelizable.

Gintas

[1]
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/util/zip/ZipFile.java#ZipFile.stream%28%29

Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Stefan Bodewig <bo...@apache.org>.
On 2018-05-18, Gintautas Grigelionis wrote:

> I believe that Streams API can at least implement the logic run by an
> original Enumeration in a more concise way, or provide more powerful idioms.
> That IMO makes it worth the while to investigate the Streams alternatives.

I agree to do that as soon as we want to change the code to do something
that wants to use said idioms. I don't really see a reason to change the
code before that point in time.

> In the process I also found out that other iterators could be used in a
> more efficient way, or that there is a redundant object construction going
> on.
> If you wish, I may spend some time to describe the changes I introduced,
> and maybe then we could discuss the their merits.

Let's use the concrete example that raised Maarten's email. In
ZipScanner we've gone from

            Enumeration<ZipEntry> e = zf.getEntries();
            while (e.hasMoreElements()) {
                ZipEntry entry = e.nextElement();

to

            StreamUtils.enumerationAsStream(zf.getEntries()).forEach(entry -> {

the Enumeration instance is created in both cases. What is the benfit
for the ZipScanner class right now?

Stefan

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


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Stefan Bodewig <bo...@apache.org>.
On 2018-05-20, Gintautas Grigelionis wrote:

> This time, I tried to start a discussion first, and I got no response.
> There were attempts to modernize the codebase about a year ago. AFAICS
> there was no discussion then.

True. I for one didn't expect you to try weeding out all deprecated APIs
and TBH didn't understand what you've been aking for.

> I hear that the consensus is "new stuff is for new code, or at least
> whenever one happens to change old code fixing the bugs".

Yes, please, this would be my preference.

What we have seen now are:

* changes that don't get proper review because they are too big

* mistakes (that everybody makes, I'm not complaining about them) slip
  through because of the point above

* willing contributors get frustrated and say they'll stop reviewing
  anthing or even drop out of the project

* merging from the 1.9 branch to master gets more difficult

For me these drawbacks outweigh all benefits of consistency.

Stefan

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


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Gintautas Grigelionis <g....@gmail.com>.
2018-05-20 21:05 GMT+02:00 Gintautas Grigelionis <g....@gmail.com>:

> 2018-05-18 16:11 GMT+02:00 Johan Corveleyn <jc...@gmail.com>:
>
>> 2) There is clearly no consensus here on the merits / desirability of
>> these bulk changes. Gintas, I understand your desire to move things
>> along, and you clearly have an opinion about it, but IMHO you really
>> need to stop doing any more bulk changes as long as there is no
>> consensus.
>>
>
> This time, I tried to start a discussion first, and I got no response.
> There were attempts to modernize the codebase about a year ago. AFAICS
> there was no discussion then.
> What was that saying: "don't vote, don't complain"? I'd like some
> discussion, that's all.
>
> I hear that the consensus is "new stuff is for new code, or at least
> whenever one happens to change old code fixing the bugs".
> I'm not quite sure whether that's a good idea, we should at least try to
> achieve some consistency
> -- and not necessarily sticking to the bottom line.
> Or maybe I'm too old school seeing major version changes as necessitating
> a porting effort ;-)
>

Just another .02€ -- if we agree on porting guidelines, there's no need to
squabble about "personal preferences".
At the moment, the only "global" issues I see are "informally deprecated"
JRE APIs (Vector, Hashtable, Stack,...) and the use of streams/lambdas.

Gintas

Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Gintautas Grigelionis <g....@gmail.com>.
2018-05-18 16:11 GMT+02:00 Johan Corveleyn <jc...@gmail.com>:

> 2) There is clearly no consensus here on the merits / desirability of
> these bulk changes. Gintas, I understand your desire to move things
> along, and you clearly have an opinion about it, but IMHO you really
> need to stop doing any more bulk changes as long as there is no
> consensus.
>

This time, I tried to start a discussion first, and I got no response.
There were attempts to modernize the codebase about a year ago. AFAICS
there was no discussion then.
What was that saying: "don't vote, don't complain"? I'd like some
discussion, that's all.

I hear that the consensus is "new stuff is for new code, or at least
whenever one happens to change old code fixing the bugs".
I'm not quite sure whether that's a good idea, we should at least try to
achieve some consistency
-- and not necessarily sticking to the bottom line.
Or maybe I'm too old school seeing major version changes as necessitating a
porting effort ;-)

Gintas

Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Johan Corveleyn <jc...@gmail.com>.
On Fri, May 18, 2018 at 10:07 AM, Gintautas Grigelionis
<g....@gmail.com> wrote:
> I accepted the original criticism that going Enumeration -> List -> Stream
> has an overhead and I tried to address that by using a decorator.
> I believe that Streams API can at least implement the logic run by an
> original Enumeration in a more concise way, or provide more powerful idioms.
> That IMO makes it worth the while to investigate the Streams alternatives.
>
> In the process I also found out that other iterators could be used in a
> more efficient way, or that there is a redundant object construction going
> on.
> If you wish, I may spend some time to describe the changes I introduced,
> and maybe then we could discuss the their merits.
>
> Gintas

As a lurker on this list, but also Java developer in $dayjob [1], I'd
like to add my 2 cents, FWIW.

I see two things going on that are causing a lot of irritation / frustration:

1) Large codebase-wide changes for adapting old (well working) code to
new API's, syntax, idioms, ... usually mostly cosmetic. From my
personal perspective (I know, I carry little weight here, I'm just an
innocent bystander) this is not a good idea. Except in specific cases
for example for security reasons, or where there is a clear benefit
also for users (for example it improves performance significantly in
certain scenarios -- Note that I say "significantly", because shaving
off 1 byte off an operation that's only run once by normal users is
not worth the code churn / review effort / risk (yes that means you
need to measure and show the significant improvement if you want to
use this as an argument)).

I remember years ago we had a similar discussion at $dayjob, when
someone proposed to standardize our rules for grouping import
statements. "Should we now bulk-change our entire codebase?" After
discussion the consensus was "no" (needless code churn, review burden,
possible future backport conflicts, ...), except when you're going to
edit the class anyway. So the simple rule was: "use the new style in
new code, and in code that you're going to change for 'external
reasons' anyway".


Which brings me to the more important problem:

2) There is clearly no consensus here on the merits / desirability of
these bulk changes. Gintas, I understand your desire to move things
along, and you clearly have an opinion about it, but IMHO you really
need to stop doing any more bulk changes as long as there is no
consensus.

Several people have voiced objections on this lists ([2], [3], [4],
...), so why are you continuing to do this? When people start raising
flags you really should pause for a moment, and start discussing
before making more commits. By making further disputable commits you
are making the discussion more difficult (it's much more difficult to
freely speak your mind if the code has already been changed ... the
work has already been done and it's even more work to revert it, ...).


[1] Full disclosure: I work at the same company as Maarten Coene. I'm
also an ASF member and PMC member of the Subversion project, but that
doesn't really matter here.

[2] https://mail-archives.apache.org/mod_mbox/ant-dev/201804.mbox/%3C5682399f-c52e-49bd-a48b-740feaf60653%40apache.org%3E
and its entire thread
[3] https://mail-archives.apache.org/mod_mbox/ant-dev/201804.mbox/%3C001301d3e070%246555ff10%243001fd30%24%40de%3E
and previous answers by other committers in that same thread.
[4] https://mail-archives.apache.org/mod_mbox/ant-dev/201805.mbox/%3C87efitnm5f.fsf_-_%40v45346.1blu.de%3E

-- 
Johan

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


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Gintautas Grigelionis <g....@gmail.com>.
I accepted the original criticism that going Enumeration -> List -> Stream
has an overhead and I tried to address that by using a decorator.
I believe that Streams API can at least implement the logic run by an
original Enumeration in a more concise way, or provide more powerful idioms.
That IMO makes it worth the while to investigate the Streams alternatives.

In the process I also found out that other iterators could be used in a
more efficient way, or that there is a redundant object construction going
on.
If you wish, I may spend some time to describe the changes I introduced,
and maybe then we could discuss the their merits.

Gintas

2018-05-18 8:30 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:

> If your objection is that I claimed that these qualify as "most of the
> cases" - I really don't know what else to say then. The original commit
> which did this change is this[1]. I haven't reviewed it fully, but the very
> first few changes that are done are these [2] [3] [4] [5][6].
>
> Of course, there's a subsequent commit which then uses a different new
> util, instead of just using the existing iterator/enumeration. Speaking of
> the subsequent commit, it still doesn't undo the (IMO unnecessary) change
> that was done to some of the code (take a look at
> ArgumentProcessorRegistry.java for example).
>
> Even if these don't fall under "most of the cases", why even change these
> places? I'm sure you would know this - the Enumeration or APIs that you
> refactored aren't even deprecated in Java version 10.
>
> Anyway, I'm really getting tired of these back and forth arguments on
> refactoring. The reason I get involved in certain open source projects is
> to get a chance to work with like minded developers and learn something out
> of it and not to go wage a war on which coding style is better or try and
> be critical of other committers' commits. Unfortunately, in the recent
> past, this has reached a state where I have ended up spending more time
> being critical of changes that have gone in, than actually adding much code
> of value. As much as I try to stay away from reviews or checking the commit
> logs, I just keep going back to them. I don't want to end up being a grumpy
> guy criticizing the commits. I'm just going to take a break from this for
> some days and be a regular user and come back and see if I still enjoy
> contributing.
>
> [1] https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624f
> e50ae82f0d11171b2
>
> [2] https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624f
> e50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL746
> [3] https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624f
> e50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL834
> [4] https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624f
> e50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL888
> [5] https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624f
> e50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL1359
>
> [6] https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624f
> e50ae82f0d11171b2#diff-b98a3d2097d6a9b5d7e0fc2eac033f24L348
>
>
> -Jaikiran
>
>
>
> On 18/05/18 11:15 AM, Gintautas Grigelionis wrote:
>
>> I'm not quite sure that what you say was true "in most of the cases".
>>
>> Gintas
>>
>> 2018-05-18 6:52 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:
>>
>> To be honest, I don't think this deprecation/conversion change is
>>> good(including this recent commit whichintroduces a
>>> StreamUtils.enumerationAsStream(...))
>>>
>>> To give you an example, the code that was previously present would (in
>>> most of the cases) get hold of an enumeration and would iterate over it
>>> and
>>> during that iteration would runcertain logic. With the changes that went
>>> in
>>> (which again is a bulk change!) the code now gets hold of an enumeration
>>> and instead of just getting on the business of iterating and running
>>> certain logic, instead now passes this enumeration aroundto convert it
>>> into
>>> some other form (thus additional code plus additional objects allocated
>>> in
>>> the process), all this to iterate over it and run some logic on it - all
>>> of
>>> which was already possible with the enumeration that was already
>>> available.
>>>
>>>
>>> -Jaikiran
>>>
>>>
>>>
>>> On 18/05/18 12:22 AM, Gintautas Grigelionis wrote:
>>>
>>> Thanks for reviewing, I hope Spliterators will do a better job.
>>>>
>>>> Gintas
>>>>
>>>> 2018-05-17 8:37 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:
>>>>
>>>> I agree. Especially when it's being done on something like for archive
>>>>
>>>>> entries which can betoo many depending on the archive that is being
>>>>> dealt
>>>>> with.
>>>>>
>>>>> -Jaikiran
>>>>>
>>>>>
>>>>>
>>>>> On 17/05/18 12:04 PM, Maarten Coene wrote:
>>>>>
>>>>> Converting an Enumeration to a List just for iterating it doesn't seem
>>>>>
>>>>>> performance and memory wise a good idea to me.
>>>>>> Maarten
>>>>>>
>>>>>>          Van: "gintas@apache.org" <gi...@apache.org>
>>>>>>     Aan: notifications@ant.apache.org
>>>>>>     Verzonden: woensdag 16 mei 19:13 2018
>>>>>>     Onderwerp: [1/2] ant git commit: Deprecate CollectionUtils and
>>>>>> Enumerations; reduce explicit use of Enumeration
>>>>>>       Repository: ant
>>>>>> Updated Branches:
>>>>>>      refs/heads/master ac35c0014 -> 070c3bc86
>>>>>>
>>>>>>
>>>>>> http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src
>>>>>> /main/org/apache/tools/ant/types/ZipScanner.java
>>>>>> ------------------------------------------------------------
>>>>>> ----------
>>>>>> diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>>> b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>>> index a3df040..5667159 100644
>>>>>> --- a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>>> +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>>> @@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
>>>>>>       import java.io.File;
>>>>>>     import java.io.IOException;
>>>>>> -import java.util.Enumeration;
>>>>>> +import java.util.Collections;
>>>>>>     import java.util.Map;
>>>>>>     import java.util.zip.ZipException;
>>>>>>     @@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner
>>>>>> {
>>>>>>                    "Only file provider resources are supported"));
>>>>>>              try (ZipFile zf = new ZipFile(srcFile, encoding)) {
>>>>>> -
>>>>>> -            Enumeration<ZipEntry> e = zf.getEntries();
>>>>>> -            while (e.hasMoreElements()) {
>>>>>> -                ZipEntry entry = e.nextElement();
>>>>>> +            for (ZipEntry entry : Collections.list(zf.getEntries()))
>>>>>> {
>>>>>>                    Resource r = new ZipResource(srcFile, encoding,
>>>>>> entry);
>>>>>>                    String name = entry.getName();
>>>>>>                    if (entry.isDirectory()) {
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Jaikiran Pai <ja...@gmail.com>.
If your objection is that I claimed that these qualify as "most of the 
cases" - I really don't know what else to say then. The original commit 
which did this change is this[1]. I haven't reviewed it fully, but the 
very first few changes that are done are these [2] [3] [4] [5][6].

Of course, there's a subsequent commit which then uses a different new 
util, instead of just using the existing iterator/enumeration. Speaking 
of the subsequent commit, it still doesn't undo the (IMO unnecessary) 
change that was done to some of the code (take a look at 
ArgumentProcessorRegistry.java for example).

Even if these don't fall under "most of the cases", why even change 
these places? I'm sure you would know this - the Enumeration or APIs 
that you refactored aren't even deprecated in Java version 10.

Anyway, I'm really getting tired of these back and forth arguments on 
refactoring. The reason I get involved in certain open source projects 
is to get a chance to work with like minded developers and learn 
something out of it and not to go wage a war on which coding style is 
better or try and be critical of other committers' commits. 
Unfortunately, in the recent past, this has reached a state where I have 
ended up spending more time being critical of changes that have gone in, 
than actually adding much code of value. As much as I try to stay away 
from reviews or checking the commit logs, I just keep going back to 
them. I don't want to end up being a grumpy guy criticizing the commits. 
I'm just going to take a break from this for some days and be a regular 
user and come back and see if I still enjoy contributing.

[1] 
https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624fe50ae82f0d11171b2

[2] 
https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624fe50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL746
[3] 
https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624fe50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL834
[4] 
https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624fe50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL888
[5] 
https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624fe50ae82f0d11171b2#diff-21eb59eaf9f2b5d0b487aeb5e5022ccdL1359

[6] 
https://github.com/apache/ant/commit/070c3bc86f85e8f01cb624fe50ae82f0d11171b2#diff-b98a3d2097d6a9b5d7e0fc2eac033f24L348


-Jaikiran


On 18/05/18 11:15 AM, Gintautas Grigelionis wrote:
> I'm not quite sure that what you say was true "in most of the cases".
>
> Gintas
>
> 2018-05-18 6:52 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:
>
>> To be honest, I don't think this deprecation/conversion change is
>> good(including this recent commit whichintroduces a
>> StreamUtils.enumerationAsStream(...))
>>
>> To give you an example, the code that was previously present would (in
>> most of the cases) get hold of an enumeration and would iterate over it and
>> during that iteration would runcertain logic. With the changes that went in
>> (which again is a bulk change!) the code now gets hold of an enumeration
>> and instead of just getting on the business of iterating and running
>> certain logic, instead now passes this enumeration aroundto convert it into
>> some other form (thus additional code plus additional objects allocated in
>> the process), all this to iterate over it and run some logic on it - all of
>> which was already possible with the enumeration that was already available.
>>
>>
>> -Jaikiran
>>
>>
>>
>> On 18/05/18 12:22 AM, Gintautas Grigelionis wrote:
>>
>>> Thanks for reviewing, I hope Spliterators will do a better job.
>>>
>>> Gintas
>>>
>>> 2018-05-17 8:37 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:
>>>
>>> I agree. Especially when it's being done on something like for archive
>>>> entries which can betoo many depending on the archive that is being dealt
>>>> with.
>>>>
>>>> -Jaikiran
>>>>
>>>>
>>>>
>>>> On 17/05/18 12:04 PM, Maarten Coene wrote:
>>>>
>>>> Converting an Enumeration to a List just for iterating it doesn't seem
>>>>> performance and memory wise a good idea to me.
>>>>> Maarten
>>>>>
>>>>>          Van: "gintas@apache.org" <gi...@apache.org>
>>>>>     Aan: notifications@ant.apache.org
>>>>>     Verzonden: woensdag 16 mei 19:13 2018
>>>>>     Onderwerp: [1/2] ant git commit: Deprecate CollectionUtils and
>>>>> Enumerations; reduce explicit use of Enumeration
>>>>>       Repository: ant
>>>>> Updated Branches:
>>>>>      refs/heads/master ac35c0014 -> 070c3bc86
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src
>>>>> /main/org/apache/tools/ant/types/ZipScanner.java
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>> b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>> index a3df040..5667159 100644
>>>>> --- a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>> +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>>> @@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
>>>>>       import java.io.File;
>>>>>     import java.io.IOException;
>>>>> -import java.util.Enumeration;
>>>>> +import java.util.Collections;
>>>>>     import java.util.Map;
>>>>>     import java.util.zip.ZipException;
>>>>>     @@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner {
>>>>>                    "Only file provider resources are supported"));
>>>>>              try (ZipFile zf = new ZipFile(srcFile, encoding)) {
>>>>> -
>>>>> -            Enumeration<ZipEntry> e = zf.getEntries();
>>>>> -            while (e.hasMoreElements()) {
>>>>> -                ZipEntry entry = e.nextElement();
>>>>> +            for (ZipEntry entry : Collections.list(zf.getEntries())) {
>>>>>                    Resource r = new ZipResource(srcFile, encoding,
>>>>> entry);
>>>>>                    String name = entry.getName();
>>>>>                    if (entry.isDirectory()) {
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>>


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


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Gintautas Grigelionis <g....@gmail.com>.
I'm not quite sure that what you say was true "in most of the cases".

Gintas

2018-05-18 6:52 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:

> To be honest, I don't think this deprecation/conversion change is
> good(including this recent commit whichintroduces a
> StreamUtils.enumerationAsStream(...))
>
> To give you an example, the code that was previously present would (in
> most of the cases) get hold of an enumeration and would iterate over it and
> during that iteration would runcertain logic. With the changes that went in
> (which again is a bulk change!) the code now gets hold of an enumeration
> and instead of just getting on the business of iterating and running
> certain logic, instead now passes this enumeration aroundto convert it into
> some other form (thus additional code plus additional objects allocated in
> the process), all this to iterate over it and run some logic on it - all of
> which was already possible with the enumeration that was already available.
>
>
> -Jaikiran
>
>
>
> On 18/05/18 12:22 AM, Gintautas Grigelionis wrote:
>
>> Thanks for reviewing, I hope Spliterators will do a better job.
>>
>> Gintas
>>
>> 2018-05-17 8:37 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:
>>
>> I agree. Especially when it's being done on something like for archive
>>> entries which can betoo many depending on the archive that is being dealt
>>> with.
>>>
>>> -Jaikiran
>>>
>>>
>>>
>>> On 17/05/18 12:04 PM, Maarten Coene wrote:
>>>
>>> Converting an Enumeration to a List just for iterating it doesn't seem
>>>> performance and memory wise a good idea to me.
>>>> Maarten
>>>>
>>>>         Van: "gintas@apache.org" <gi...@apache.org>
>>>>    Aan: notifications@ant.apache.org
>>>>    Verzonden: woensdag 16 mei 19:13 2018
>>>>    Onderwerp: [1/2] ant git commit: Deprecate CollectionUtils and
>>>> Enumerations; reduce explicit use of Enumeration
>>>>      Repository: ant
>>>> Updated Branches:
>>>>     refs/heads/master ac35c0014 -> 070c3bc86
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src
>>>> /main/org/apache/tools/ant/types/ZipScanner.java
>>>> ----------------------------------------------------------------------
>>>> diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>> b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>> index a3df040..5667159 100644
>>>> --- a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>> +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>>> @@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
>>>>      import java.io.File;
>>>>    import java.io.IOException;
>>>> -import java.util.Enumeration;
>>>> +import java.util.Collections;
>>>>    import java.util.Map;
>>>>    import java.util.zip.ZipException;
>>>>    @@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner {
>>>>                   "Only file provider resources are supported"));
>>>>             try (ZipFile zf = new ZipFile(srcFile, encoding)) {
>>>> -
>>>> -            Enumeration<ZipEntry> e = zf.getEntries();
>>>> -            while (e.hasMoreElements()) {
>>>> -                ZipEntry entry = e.nextElement();
>>>> +            for (ZipEntry entry : Collections.list(zf.getEntries())) {
>>>>                   Resource r = new ZipResource(srcFile, encoding,
>>>> entry);
>>>>                   String name = entry.getName();
>>>>                   if (entry.isDirectory()) {
>>>>
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Jaikiran Pai <ja...@gmail.com>.
To be honest, I don't think this deprecation/conversion change is 
good(including this recent commit whichintroduces a 
StreamUtils.enumerationAsStream(...))

To give you an example, the code that was previously present would (in 
most of the cases) get hold of an enumeration and would iterate over it 
and during that iteration would runcertain logic. With the changes that 
went in (which again is a bulk change!) the code now gets hold of an 
enumeration and instead of just getting on the business of iterating and 
running certain logic, instead now passes this enumeration aroundto 
convert it into some other form (thus additional code plus additional 
objects allocated in the process), all this to iterate over it and run 
some logic on it - all of which was already possible with the 
enumeration that was already available.


-Jaikiran


On 18/05/18 12:22 AM, Gintautas Grigelionis wrote:
> Thanks for reviewing, I hope Spliterators will do a better job.
>
> Gintas
>
> 2018-05-17 8:37 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:
>
>> I agree. Especially when it's being done on something like for archive
>> entries which can betoo many depending on the archive that is being dealt
>> with.
>>
>> -Jaikiran
>>
>>
>>
>> On 17/05/18 12:04 PM, Maarten Coene wrote:
>>
>>> Converting an Enumeration to a List just for iterating it doesn't seem
>>> performance and memory wise a good idea to me.
>>> Maarten
>>>
>>>         Van: "gintas@apache.org" <gi...@apache.org>
>>>    Aan: notifications@ant.apache.org
>>>    Verzonden: woensdag 16 mei 19:13 2018
>>>    Onderwerp: [1/2] ant git commit: Deprecate CollectionUtils and
>>> Enumerations; reduce explicit use of Enumeration
>>>      Repository: ant
>>> Updated Branches:
>>>     refs/heads/master ac35c0014 -> 070c3bc86
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src
>>> /main/org/apache/tools/ant/types/ZipScanner.java
>>> ----------------------------------------------------------------------
>>> diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>> b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>> index a3df040..5667159 100644
>>> --- a/src/main/org/apache/tools/ant/types/ZipScanner.java
>>> +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
>>> @@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
>>>      import java.io.File;
>>>    import java.io.IOException;
>>> -import java.util.Enumeration;
>>> +import java.util.Collections;
>>>    import java.util.Map;
>>>    import java.util.zip.ZipException;
>>>    @@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner {
>>>                   "Only file provider resources are supported"));
>>>             try (ZipFile zf = new ZipFile(srcFile, encoding)) {
>>> -
>>> -            Enumeration<ZipEntry> e = zf.getEntries();
>>> -            while (e.hasMoreElements()) {
>>> -                ZipEntry entry = e.nextElement();
>>> +            for (ZipEntry entry : Collections.list(zf.getEntries())) {
>>>                   Resource r = new ZipResource(srcFile, encoding, entry);
>>>                   String name = entry.getName();
>>>                   if (entry.isDirectory()) {
>>>
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>>


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


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Gintautas Grigelionis <g....@gmail.com>.
Thanks for reviewing, I hope Spliterators will do a better job.

Gintas

2018-05-17 8:37 GMT+02:00 Jaikiran Pai <ja...@gmail.com>:

> I agree. Especially when it's being done on something like for archive
> entries which can betoo many depending on the archive that is being dealt
> with.
>
> -Jaikiran
>
>
>
> On 17/05/18 12:04 PM, Maarten Coene wrote:
>
>> Converting an Enumeration to a List just for iterating it doesn't seem
>> performance and memory wise a good idea to me.
>> Maarten
>>
>>        Van: "gintas@apache.org" <gi...@apache.org>
>>   Aan: notifications@ant.apache.org
>>   Verzonden: woensdag 16 mei 19:13 2018
>>   Onderwerp: [1/2] ant git commit: Deprecate CollectionUtils and
>> Enumerations; reduce explicit use of Enumeration
>>     Repository: ant
>> Updated Branches:
>>    refs/heads/master ac35c0014 -> 070c3bc86
>>
>>
>> http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src
>> /main/org/apache/tools/ant/types/ZipScanner.java
>> ----------------------------------------------------------------------
>> diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java
>> b/src/main/org/apache/tools/ant/types/ZipScanner.java
>> index a3df040..5667159 100644
>> --- a/src/main/org/apache/tools/ant/types/ZipScanner.java
>> +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
>> @@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
>>     import java.io.File;
>>   import java.io.IOException;
>> -import java.util.Enumeration;
>> +import java.util.Collections;
>>   import java.util.Map;
>>   import java.util.zip.ZipException;
>>   @@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner {
>>                  "Only file provider resources are supported"));
>>            try (ZipFile zf = new ZipFile(srcFile, encoding)) {
>> -
>> -            Enumeration<ZipEntry> e = zf.getEntries();
>> -            while (e.hasMoreElements()) {
>> -                ZipEntry entry = e.nextElement();
>> +            for (ZipEntry entry : Collections.list(zf.getEntries())) {
>>                  Resource r = new ZipResource(srcFile, encoding, entry);
>>                  String name = entry.getName();
>>                  if (entry.isDirectory()) {
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Jaikiran Pai <ja...@gmail.com>.
I agree. Especially when it's being done on something like for archive 
entries which can betoo many depending on the archive that is being 
dealt with.

-Jaikiran


On 17/05/18 12:04 PM, Maarten Coene wrote:
> Converting an Enumeration to a List just for iterating it doesn't seem performance and memory wise a good idea to me.
> Maarten
>
>        Van: "gintas@apache.org" <gi...@apache.org>
>   Aan: notifications@ant.apache.org
>   Verzonden: woensdag 16 mei 19:13 2018
>   Onderwerp: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration
>     
> Repository: ant
> Updated Branches:
>    refs/heads/master ac35c0014 -> 070c3bc86
>
>
> http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/ZipScanner.java
> ----------------------------------------------------------------------
> diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java b/src/main/org/apache/tools/ant/types/ZipScanner.java
> index a3df040..5667159 100644
> --- a/src/main/org/apache/tools/ant/types/ZipScanner.java
> +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
> @@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
>   
>   import java.io.File;
>   import java.io.IOException;
> -import java.util.Enumeration;
> +import java.util.Collections;
>   import java.util.Map;
>   import java.util.zip.ZipException;
>   
> @@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner {
>                  "Only file provider resources are supported"));
>   
>          try (ZipFile zf = new ZipFile(srcFile, encoding)) {
> -
> -            Enumeration<ZipEntry> e = zf.getEntries();
> -            while (e.hasMoreElements()) {
> -                ZipEntry entry = e.nextElement();
> +            for (ZipEntry entry : Collections.list(zf.getEntries())) {
>                  Resource r = new ZipResource(srcFile, encoding, entry);
>                  String name = entry.getName();
>                  if (entry.isDirectory()) {
>
>
>     


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


Re: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by Maarten Coene <ma...@yahoo.com.INVALID>.
Converting an Enumeration to a List just for iterating it doesn't seem performance and memory wise a good idea to me.
Maarten

      Van: "gintas@apache.org" <gi...@apache.org>
 Aan: notifications@ant.apache.org 
 Verzonden: woensdag 16 mei 19:13 2018
 Onderwerp: [1/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration
   
Repository: ant
Updated Branches:
  refs/heads/master ac35c0014 -> 070c3bc86


http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/ZipScanner.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java b/src/main/org/apache/tools/ant/types/ZipScanner.java
index a3df040..5667159 100644
--- a/src/main/org/apache/tools/ant/types/ZipScanner.java
+++ b/src/main/org/apache/tools/ant/types/ZipScanner.java
@@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Map;
 import java.util.zip.ZipException;
 
@@ -62,10 +62,7 @@ public class ZipScanner extends ArchiveScanner {
                "Only file provider resources are supported"));
 
        try (ZipFile zf = new ZipFile(srcFile, encoding)) {
-
-            Enumeration<ZipEntry> e = zf.getEntries();
-            while (e.hasMoreElements()) {
-                ZipEntry entry = e.nextElement();
+            for (ZipEntry entry : Collections.list(zf.getEntries())) {
                Resource r = new ZipResource(srcFile, encoding, entry);
                String name = entry.getName();
                if (entry.isDirectory()) {


   

[2/2] ant git commit: Deprecate CollectionUtils and Enumerations; reduce explicit use of Enumeration

Posted by gi...@apache.org.
Deprecate CollectionUtils and Enumerations;
reduce explicit use of Enumeration

Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/070c3bc8
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/070c3bc8
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/070c3bc8

Branch: refs/heads/master
Commit: 070c3bc86f85e8f01cb624fe50ae82f0d11171b2
Parents: ac35c00
Author: Gintas Grigelionis <gi...@apache.org>
Authored: Wed May 16 18:32:03 2018 +0200
Committer: Gintas Grigelionis <gi...@apache.org>
Committed: Wed May 16 19:13:05 2018 +0200

----------------------------------------------------------------------
 .../org/apache/tools/ant/AntClassLoader.java    |  65 ++++------
 .../tools/ant/ArgumentProcessorRegistry.java    |   6 +-
 .../org/apache/tools/ant/ComponentHelper.java   |  11 +-
 src/main/org/apache/tools/ant/Diagnostics.java  |  12 +-
 src/main/org/apache/tools/ant/Main.java         |  67 +++--------
 src/main/org/apache/tools/ant/Project.java      |  14 +--
 .../tools/ant/ProjectHelperRepository.java      |   7 +-
 src/main/org/apache/tools/ant/Task.java         |   9 +-
 .../org/apache/tools/ant/UnknownElement.java    |   5 +-
 src/main/org/apache/tools/ant/XmlLogger.java    |  13 +-
 .../apache/tools/ant/filters/ReplaceTokens.java |   7 +-
 .../apache/tools/ant/listener/MailLogger.java   |   8 +-
 .../apache/tools/ant/taskdefs/AntStructure.java |  11 +-
 .../org/apache/tools/ant/taskdefs/Expand.java   |   6 +-
 .../org/apache/tools/ant/taskdefs/HostInfo.java |  12 +-
 src/main/org/apache/tools/ant/taskdefs/Jar.java |  22 +---
 .../tools/ant/taskdefs/MacroInstance.java       |   6 +-
 .../org/apache/tools/ant/taskdefs/Manifest.java |  69 +++--------
 .../apache/tools/ant/taskdefs/ManifestTask.java |  20 +---
 .../tools/ant/taskdefs/condition/And.java       |  10 +-
 .../tools/ant/taskdefs/condition/IsSigned.java  |  14 +--
 .../apache/tools/ant/taskdefs/condition/Or.java |  11 +-
 .../tools/ant/taskdefs/condition/Xor.java       |  10 +-
 .../tools/ant/taskdefs/cvslib/CvsTagDiff.java   |   5 +-
 .../ant/taskdefs/optional/TraXLiaison.java      |  20 +---
 .../taskdefs/optional/depend/AntAnalyzer.java   |  22 ++--
 .../ant/taskdefs/optional/depend/Depend.java    |  13 +-
 .../optional/ejb/GenericDeploymentTool.java     |  10 +-
 .../optional/ejb/WeblogicDeploymentTool.java    |   4 +-
 .../optional/ejb/WebsphereDeploymentTool.java   | 118 ++++++++-----------
 .../ant/taskdefs/optional/jlink/jlink.java      |   7 +-
 .../ant/taskdefs/optional/junit/BatchTest.java  |   6 +-
 .../taskdefs/optional/junit/Enumerations.java   |   7 ++
 .../ant/taskdefs/optional/junit/JUnitTask.java  |  33 ++----
 .../org/apache/tools/ant/types/FilterSet.java   |   8 +-
 .../org/apache/tools/ant/types/PropertySet.java |  13 +-
 .../org/apache/tools/ant/types/ZipScanner.java  |   7 +-
 .../types/optional/depend/DependScanner.java    |  10 +-
 .../tools/ant/types/resources/Resources.java    |   4 +-
 .../ant/types/selectors/MajoritySelector.java   |   8 +-
 .../ant/types/selectors/SelectSelector.java     |   6 +-
 .../apache/tools/ant/util/CollectionUtils.java  |  31 +++--
 .../apache/tools/ant/util/LinkedHashtable.java  |   5 +-
 .../ant/util/depend/bcel/AncestorAnalyzer.java  |  14 +--
 .../ant/util/depend/bcel/FullAnalyzer.java      |  12 +-
 .../tools/ant/util/LinkedHashtableTest.java     |   5 +-
 46 files changed, 265 insertions(+), 518 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/AntClassLoader.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java
index 482c0f2..41a0cde 100644
--- a/src/main/org/apache/tools/ant/AntClassLoader.java
+++ b/src/main/org/apache/tools/ant/AntClassLoader.java
@@ -35,6 +35,7 @@ import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Objects;
 import java.util.StringTokenizer;
 import java.util.Vector;
 import java.util.jar.Attributes;
@@ -42,10 +43,11 @@ import java.util.jar.Attributes.Name;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.launch.Locator;
 import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.CollectionUtils;
 import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.util.JavaEnvUtils;
 import org.apache.tools.ant.util.LoaderUtils;
@@ -740,14 +742,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
     private InputStream loadResource(final String name) {
         // we need to search the components of the path to see if we can
         // find the class we want.
-        InputStream stream = null;
-
-        final Enumeration<File> e = pathComponents.elements();
-        while (e.hasMoreElements() && stream == null) {
-            final File pathComponent = e.nextElement();
-            stream = getResourceStream(pathComponent, name);
-        }
-        return stream;
+        return Collections.list(pathComponents.elements()).stream()
+                .map(path -> getResourceStream(path, name))
+                .filter(Objects::nonNull).findFirst().orElse(null);
     }
 
     /**
@@ -829,23 +826,10 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
 
         // TODO - shouldn't this always return false in isolated mode?
 
-        boolean useParentFirst = parentFirst;
-
-        for (final Enumeration<String> e = systemPackages.elements(); e.hasMoreElements();) {
-            final String packageName = e.nextElement();
-            if (resourceName.startsWith(packageName)) {
-                useParentFirst = true;
-                break;
-            }
-        }
-        for (final Enumeration<String> e = loaderPackages.elements(); e.hasMoreElements();) {
-            final String packageName = e.nextElement();
-            if (resourceName.startsWith(packageName)) {
-                useParentFirst = false;
-                break;
-            }
-        }
-        return useParentFirst;
+        return Collections.list(loaderPackages.elements()).stream()
+                .noneMatch(resourceName::startsWith)
+                && (Collections.list(systemPackages.elements()).stream()
+                .anyMatch(resourceName::startsWith) || parentFirst);
     }
 
     /**
@@ -885,12 +869,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
         } else {
             // try and load from this loader if the parent either didn't find
             // it or wasn't consulted.
-            final Enumeration<File> e = pathComponents.elements();
-            while (e.hasMoreElements() && url == null) {
-                final File pathComponent = e.nextElement();
+            for (final File pathComponent : Collections.list(pathComponents.elements())) {
                 url = getResourceURL(pathComponent, name);
                 if (url != null) {
                     log("Resource " + name + " loaded from ant loader", Project.MSG_DEBUG);
+                    break;
                 }
             }
         }
@@ -974,14 +957,19 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
         }
         if (isParentFirst(name)) {
             // Normal case.
-            return CollectionUtils.append(base, mine);
+            return append(base, mine);
         }
         if (ignoreBase) {
-            return getRootLoader() == null ? mine : CollectionUtils.append(mine, getRootLoader()
-                    .getResources(name));
+            return getRootLoader() == null ? mine
+                    : append(mine, getRootLoader().getResources(name));
         }
         // parent last:
-        return CollectionUtils.append(mine, base);
+        return append(mine, base);
+    }
+
+    private static Enumeration<URL> append(Enumeration<URL> one, Enumeration<URL> two) {
+        return Stream.concat(Collections.list(one).stream(), Collections.list(two).stream())
+                .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::enumeration));
     }
 
     /**
@@ -1355,9 +1343,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
         // we need to search the components of the path to see if
         // we can find the class we want.
         final String classFilename = getClassFilename(name);
-        final Enumeration<File> e = pathComponents.elements();
-        while (e.hasMoreElements()) {
-            final File pathComponent = e.nextElement();
+        for (final File pathComponent : Collections.list(pathComponents.elements())) {
             InputStream stream = null;
             try {
                 stream = getResourceStream(pathComponent, classFilename);
@@ -1519,12 +1505,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
      * here
      */
     public void addJavaLibraries() {
-        final Vector<String> packages = JavaEnvUtils.getJrePackages();
-        final Enumeration<String> e = packages.elements();
-        while (e.hasMoreElements()) {
-            final String packageName = e.nextElement();
-            addSystemPackageRoot(packageName);
-        }
+        JavaEnvUtils.getJrePackages().forEach(this::addSystemPackageRoot);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java b/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
index 29f8edf..9119191 100644
--- a/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
+++ b/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
@@ -25,7 +25,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.tools.ant.util.FileUtils;
@@ -74,9 +74,7 @@ public class ArgumentProcessorRegistry {
         try {
             ClassLoader classLoader = LoaderUtils.getContextClassLoader();
             if (classLoader != null) {
-                Enumeration<URL> resources = classLoader.getResources(SERVICE_ID);
-                while (resources.hasMoreElements()) {
-                    URL resource = resources.nextElement();
+                for (URL resource : Collections.list(classLoader.getResources(SERVICE_ID))) {
                     URLConnection conn = resource.openConnection();
                     conn.setUseCaches(false);
                     ArgumentProcessor processor = getProcessorByService(conn.getInputStream());

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/ComponentHelper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java
index 04b048a..0011079 100644
--- a/src/main/org/apache/tools/ant/ComponentHelper.java
+++ b/src/main/org/apache/tools/ant/ComponentHelper.java
@@ -25,7 +25,6 @@ import java.io.StringWriter;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -756,10 +755,9 @@ public class ComponentHelper  {
         ClassLoader classLoader = getClassLoader(null);
         Properties props = getDefaultDefinitions(false);
         for (String name : props.stringPropertyNames()) {
-            String className = props.getProperty(name);
             AntTypeDefinition def = new AntTypeDefinition();
             def.setName(name);
-            def.setClassName(className);
+            def.setClassName(props.getProperty(name));
             def.setClassLoader(classLoader);
             def.setAdaptToClass(Task.class);
             def.setAdapterClass(TaskAdapter.class);
@@ -816,13 +814,10 @@ public class ComponentHelper  {
     private void initTypes() {
         ClassLoader classLoader = getClassLoader(null);
         Properties props = getDefaultDefinitions(true);
-        Enumeration<?> e = props.propertyNames();
-        while (e.hasMoreElements()) {
-            String name = (String) e.nextElement();
-            String className = props.getProperty(name);
+        for (String name : props.stringPropertyNames()) {
             AntTypeDefinition def = new AntTypeDefinition();
             def.setName(name);
-            def.setClassName(className);
+            def.setClassName(props.getProperty(name));
             def.setClassLoader(classLoader);
             antTypeTable.put(name, def);
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/Diagnostics.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/Diagnostics.java b/src/main/org/apache/tools/ant/Diagnostics.java
index bf6aca0..7434433 100644
--- a/src/main/org/apache/tools/ant/Diagnostics.java
+++ b/src/main/org/apache/tools/ant/Diagnostics.java
@@ -27,7 +27,6 @@ import java.lang.reflect.Method;
 import java.net.URL;
 import java.nio.file.Files;
 import java.util.Calendar;
-import java.util.Enumeration;
 import java.util.Properties;
 import java.util.TimeZone;
 
@@ -357,12 +356,8 @@ public final class Diagnostics {
             out.println("Access to System.getProperties() blocked " + "by a security manager");
             return;
         }
-        for (Enumeration<?> keys = sysprops.propertyNames();
-            keys.hasMoreElements();) {
-            String key = (String) keys.nextElement();
-            String value = getProperty(key);
-            out.println(key + " : " + value);
-        }
+        sysprops.stringPropertyNames().stream()
+                .map(key -> key + " : " + getProperty(key)).forEach(out::println);
     }
 
     /**
@@ -483,8 +478,7 @@ public final class Diagnostics {
             Properties props = new Properties();
             try {
                 props.load(is);
-                for (Enumeration<?> keys = props.keys(); keys.hasMoreElements();) {
-                    String key = (String) keys.nextElement();
+                for (String key : props.stringPropertyNames()) {
                     String classname = props.getProperty(key);
                     try {
                         Class.forName(classname);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/Main.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java
index 036ed26..1152906 100644
--- a/src/main/org/apache/tools/ant/Main.java
+++ b/src/main/org/apache/tools/ant/Main.java
@@ -33,10 +33,10 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 import java.util.Vector;
+import java.util.stream.Collectors;
 
 import org.apache.tools.ant.input.DefaultInputHandler;
 import org.apache.tools.ant.input.InputHandler;
@@ -45,7 +45,6 @@ import org.apache.tools.ant.listener.SilentLogger;
 import org.apache.tools.ant.property.GetProperty;
 import org.apache.tools.ant.property.ResolvePropertyMap;
 import org.apache.tools.ant.util.ClasspathUtils;
-import org.apache.tools.ant.util.CollectionUtils;
 import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.util.ProxySetup;
 
@@ -213,12 +212,8 @@ public class Main implements AntMain {
         }
 
         if (additionalUserProperties != null) {
-            for (final Enumeration<?> e = additionalUserProperties.keys();
-                    e.hasMoreElements();) {
-                final String key = (String) e.nextElement();
-                final String property = additionalUserProperties.getProperty(key);
-                definedProps.put(key, property);
-            }
+            additionalUserProperties.stringPropertyNames()
+                    .forEach(key -> definedProps.put(key, additionalUserProperties.getProperty(key)));
         }
 
         // expect the worst
@@ -407,9 +402,7 @@ public class Main implements AntMain {
                     final int newI = processor.readArguments(args, i);
                     if (newI != -1) {
                         List<String> extraArgs = extraArguments.computeIfAbsent(processor.getClass(), k -> new ArrayList<>());
-                        for (; i < newI && i < args.length; i++) {
-                            extraArgs.add(args[i]);
-                        }
+                        extraArgs.addAll(Arrays.asList(args).subList(newI, args.length));
                         processed = true;
                         break;
                     }
@@ -656,13 +649,9 @@ public class Main implements AntMain {
             }
 
             // ensure that -D properties take precedence
-            final Enumeration<?> propertyNames = props.propertyNames();
-            while (propertyNames.hasMoreElements()) {
-                final String name = (String) propertyNames.nextElement();
-                if (definedProps.getProperty(name) == null) {
-                    definedProps.put(name, props.getProperty(name));
-                }
-            }
+            props.stringPropertyNames().stream()
+                    .filter(name -> definedProps.getProperty(name) == null)
+                    .forEach(name -> definedProps.put(name, props.getProperty(name)));
         }
     }
 
@@ -896,11 +885,7 @@ public class Main implements AntMain {
         resolver.resolveAllProperties(props, null, false);
 
         // set user-define properties
-        for (final Entry<String, Object> ent : props.entrySet()) {
-            final String arg = ent.getKey();
-            final Object value = ent.getValue();
-            project.setUserProperty(arg, String.valueOf(value));
-        }
+        props.forEach((arg, value) -> project.setUserProperty(arg, String.valueOf(value)));
 
         project.setUserProperty(MagicNames.ANT_FILE,
                                 buildFile.getAbsolutePath());
@@ -915,7 +900,7 @@ public class Main implements AntMain {
         // Setting it here allows top-level tasks to access the
         // property.
         project.setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
-                                CollectionUtils.flattenToString(targets));
+                targets.stream().collect(Collectors.joining(",")));
     }
 
     /**
@@ -1136,25 +1121,18 @@ public class Main implements AntMain {
      */
     private static Map<String, Target> removeDuplicateTargets(final Map<String, Target> targets) {
         final Map<Location, Target> locationMap = new HashMap<>();
-        for (final Entry<String, Target> entry : targets.entrySet()) {
-            final String name = entry.getKey();
-            final Target target = entry.getValue();
+        targets.forEach((name, target) -> {
             final Target otherTarget = locationMap.get(target.getLocation());
             // Place this entry in the location map if
             //  a) location is not in the map
             //  b) location is in map, but its name is longer
             //     (an imported target will have a name. prefix)
-            if (otherTarget == null
-                || otherTarget.getName().length() > name.length()) {
-                locationMap.put(
-                    target.getLocation(), target); // Smallest name wins
+            if (otherTarget == null || otherTarget.getName().length() > name.length()) {
+                locationMap.put(target.getLocation(), target); // Smallest name wins
             }
-        }
-        final Map<String, Target> ret = new HashMap<>();
-        for (final Target target : locationMap.values()) {
-            ret.put(target.getName(), target);
-        }
-        return ret;
+        });
+        return locationMap.values().stream()
+                .collect(Collectors.toMap(Target::getName, target -> target, (a, b) -> b));
     }
 
     /**
@@ -1287,18 +1265,9 @@ public class Main implements AntMain {
                 msg.append(descriptions.elementAt(i));
             }
             msg.append(eol);
-            if (!dependencies.isEmpty()) {
-                final Enumeration<String> deps = dependencies.elementAt(i);
-                if (deps.hasMoreElements()) {
-                    msg.append("   depends on: ");
-                    while (deps.hasMoreElements()) {
-                        msg.append(deps.nextElement());
-                        if (deps.hasMoreElements()) {
-                            msg.append(", ");
-                        }
-                    }
-                    msg.append(eol);
-                }
+            if (!dependencies.isEmpty() && dependencies.elementAt(i).hasMoreElements()) {
+                msg.append(Collections.list(dependencies.elementAt(i)).stream()
+                        .collect(Collectors.joining(", ", "   depends on: ", eol)));
             }
         }
         project.log(msg.toString(), Project.MSG_WARN);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/Project.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java
index 844b7d4..4d8ab59 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -25,7 +25,6 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -48,7 +47,6 @@ import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceFactory;
 import org.apache.tools.ant.types.resources.FileResource;
-import org.apache.tools.ant.util.CollectionUtils;
 import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.util.JavaEnvUtils;
 import org.apache.tools.ant.util.VectorSet;
@@ -1249,7 +1247,7 @@ public class Project implements ResourceFactory {
      */
     public void executeTargets(final Vector<String> names) throws BuildException {
         setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
-                        CollectionUtils.flattenToString(names));
+                names.stream().collect(Collectors.joining(",")));
         getExecutor().executeTargets(this, names.toArray(new String[names.size()]));
     }
 
@@ -1374,9 +1372,7 @@ public class Project implements ResourceFactory {
         BuildException buildException = null; // first build exception
         for (final Target curtarget : sortedTargets) {
             boolean canExecute = true;
-            for (final Enumeration<String> depIter = curtarget.getDependencies();
-                 depIter.hasMoreElements();) {
-                final String dependencyName = depIter.nextElement();
+            for (final String dependencyName : Collections.list(curtarget.getDependencies())) {
                 if (!succeededTargets.contains(dependencyName)) {
                     canExecute = false;
                     log(curtarget,
@@ -1833,8 +1829,7 @@ public class Project implements ResourceFactory {
                 + " is " + ret, MSG_VERBOSE);
 
         final Vector<Target> complete = (returnAll) ? ret : new Vector<>(ret);
-        for (final Enumeration<String> en = targetTable.keys(); en.hasMoreElements();) {
-            final String curTarget = en.nextElement();
+        for (final String curTarget : targetTable.keySet()) {
             final String st = state.get(curTarget);
             if (st == null) {
                 tsort(curTarget, targetTable, state, visiting, complete);
@@ -1912,8 +1907,7 @@ public class Project implements ResourceFactory {
             }
             throw new BuildException(new String(sb));
         }
-        for (final Enumeration<String> en = target.getDependencies(); en.hasMoreElements();) {
-            final String cur = en.nextElement();
+        for (final String cur : Collections.list(target.getDependencies())) {
             final String m = state.get(cur);
             if (m == null) {
                 // Not been visited

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/ProjectHelperRepository.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/ProjectHelperRepository.java b/src/main/org/apache/tools/ant/ProjectHelperRepository.java
index 74a1bf7..8bb0cb2 100644
--- a/src/main/org/apache/tools/ant/ProjectHelperRepository.java
+++ b/src/main/org/apache/tools/ant/ProjectHelperRepository.java
@@ -24,7 +24,7 @@ import java.lang.reflect.Constructor;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.stream.Stream;
@@ -85,10 +85,7 @@ public class ProjectHelperRepository {
         try {
             ClassLoader classLoader = LoaderUtils.getContextClassLoader();
             if (classLoader != null) {
-                Enumeration<URL> resources =
-                    classLoader.getResources(ProjectHelper.SERVICE_ID);
-                while (resources.hasMoreElements()) {
-                    URL resource = resources.nextElement();
+                for (URL resource : Collections.list(classLoader.getResources(ProjectHelper.SERVICE_ID))) {
                     URLConnection conn = resource.openConnection();
                     conn.setUseCaches(false);
                     projectHelper =

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/Task.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/Task.java b/src/main/org/apache/tools/ant/Task.java
index 38d89e1..79e729d 100644
--- a/src/main/org/apache/tools/ant/Task.java
+++ b/src/main/org/apache/tools/ant/Task.java
@@ -19,7 +19,7 @@
 package org.apache.tools.ant;
 
 import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Collections;
 
 import org.apache.tools.ant.dispatch.DispatchUtils;
 
@@ -425,11 +425,8 @@ public abstract class Task extends ProjectComponent {
      */
     private void replaceChildren(RuntimeConfigurable wrapper,
                                  UnknownElement parentElement) {
-        Enumeration<RuntimeConfigurable> e = wrapper.getChildren();
-        while (e.hasMoreElements()) {
-            RuntimeConfigurable childWrapper = e.nextElement();
-            UnknownElement childElement =
-                new UnknownElement(childWrapper.getElementTag());
+        for (RuntimeConfigurable childWrapper : Collections.list(wrapper.getChildren())) {
+            UnknownElement childElement = new UnknownElement(childWrapper.getElementTag());
             parentElement.addChild(childElement);
             childElement.setProject(getProject());
             childElement.setRuntimeConfigurableWrapper(childWrapper);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/UnknownElement.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/UnknownElement.java b/src/main/org/apache/tools/ant/UnknownElement.java
index 32b7f11..4d1cc31 100644
--- a/src/main/org/apache/tools/ant/UnknownElement.java
+++ b/src/main/org/apache/tools/ant/UnknownElement.java
@@ -20,7 +20,7 @@ package org.apache.tools.ant;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -679,8 +679,7 @@ public class UnknownElement extends Task {
         }
         copyRC.addText(getWrapper().getText().toString());
 
-        for (Enumeration<RuntimeConfigurable> e = getWrapper().getChildren(); e.hasMoreElements();) {
-            RuntimeConfigurable r = e.nextElement();
+        for (RuntimeConfigurable r : Collections.list(getWrapper().getChildren())) {
             UnknownElement ueChild = (UnknownElement) r.getProxy();
             UnknownElement copyChild = ueChild.copy(newProject);
             copyRC.addChild(copyChild.getWrapper());

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/XmlLogger.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/XmlLogger.java b/src/main/org/apache/tools/ant/XmlLogger.java
index c4da280..789b9fd 100644
--- a/src/main/org/apache/tools/ant/XmlLogger.java
+++ b/src/main/org/apache/tools/ant/XmlLogger.java
@@ -24,7 +24,7 @@ import java.io.PrintStream;
 import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.Stack;
 
@@ -345,14 +345,9 @@ public class XmlLogger implements BuildLogger {
         if (element != null) {
             return element;
         }
-        for (Enumeration<Task> e = tasks.keys(); e.hasMoreElements();) {
-            Task key = e.nextElement();
-            if (key instanceof UnknownElement
-                && ((UnknownElement) key).getTask() == task) {
-                return tasks.get(key);
-            }
-        }
-        return null;
+        return Collections.list(tasks.keys()).stream().filter(UnknownElement.class::isInstance)
+                .filter(key -> ((UnknownElement) key).getTask() == task).findFirst()
+                .map(key -> tasks.get(key)).orElse(null);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
index 0a9c08b..416ffb2 100644
--- a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
+++ b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
@@ -21,7 +21,6 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
-import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
@@ -330,11 +329,7 @@ public final class ReplaceTokens
 
     private void makeTokensFromProperties(Resource r) {
         Properties props = getProperties(r);
-        for (Enumeration<?> e = props.keys(); e.hasMoreElements();) {
-            String key = (String) e.nextElement();
-            String value = props.getProperty(key);
-            hash.put(key, value);
-        }
+        props.stringPropertyNames().forEach(key -> hash.put(key, props.getProperty(key)));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/listener/MailLogger.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/listener/MailLogger.java b/src/main/org/apache/tools/ant/listener/MailLogger.java
index aed84f8..c2b9e25 100644
--- a/src/main/org/apache/tools/ant/listener/MailLogger.java
+++ b/src/main/org/apache/tools/ant/listener/MailLogger.java
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.io.PrintStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.Enumeration;
 import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
@@ -129,11 +128,8 @@ public class MailLogger extends DefaultLogger {
             }
         }
 
-        for (Enumeration<?> e = fileProperties.keys(); e.hasMoreElements();) {
-            String key = (String) e.nextElement();
-            String value = fileProperties.getProperty(key);
-            properties.put(key, project.replaceProperties(value));
-        }
+        fileProperties.stringPropertyNames()
+                .forEach(key -> properties.put(key, project.replaceProperties(fileProperties.getProperty(key))));
 
         boolean success = (event.getException() == null);
         String prefix = success ? "success" : "failure";

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
index 39fe89f..1770774 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
@@ -27,7 +27,7 @@ import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.nio.file.Files;
 import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Set;
@@ -309,10 +309,7 @@ public class AntStructure extends Task {
                 v.add(TASKS);
             }
 
-            Enumeration<String> e = ih.getNestedElements();
-            while (e.hasMoreElements()) {
-                v.add(e.nextElement());
-            }
+            v.addAll(Collections.list(ih.getNestedElements()));
 
             final Collector<CharSequence, ?, String> joinAlts =
                 Collectors.joining(" | ", "(", ")");
@@ -331,9 +328,7 @@ public class AntStructure extends Task {
             sb = new StringBuilder();
             sb.append(String.format("<!ATTLIST %s%n          id ID #IMPLIED", name));
 
-            e = ih.getAttributes();
-            while (e.hasMoreElements()) {
-                final String attrName = e.nextElement();
+            for (final String attrName : Collections.list(ih.getAttributes())) {
                 if ("id".equals(attrName)) {
                     continue;
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/Expand.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java
index de50311..82c80f4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Expand.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Expand.java
@@ -24,8 +24,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
+import java.util.Collections;
 import java.util.Date;
-import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -189,10 +189,8 @@ public class Expand extends Task {
         }
         try (ZipFile zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)) {
             boolean empty = true;
-            Enumeration<ZipEntry> e = zf.getEntries();
-            while (e.hasMoreElements()) {
+            for (ZipEntry ze : Collections.list(zf.getEntries())) {
                 empty = false;
-                ZipEntry ze = e.nextElement();
                 InputStream is = null;
                 log("extracting " + ze.getName(), Project.MSG_DEBUG);
                 try {

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/HostInfo.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/HostInfo.java b/src/main/org/apache/tools/ant/taskdefs/HostInfo.java
index 771ae7b..152d847 100644
--- a/src/main/org/apache/tools/ant/taskdefs/HostInfo.java
+++ b/src/main/org/apache/tools/ant/taskdefs/HostInfo.java
@@ -23,7 +23,7 @@ import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
 import java.util.Arrays;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -117,14 +117,8 @@ public class HostInfo extends Task {
     private void executeLocal() {
         try {
             inetAddrs = new LinkedList<>();
-            Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
-            while (interfaces.hasMoreElements()) {
-                NetworkInterface currentif = interfaces.nextElement();
-                Enumeration<InetAddress> addrs = currentif.getInetAddresses();
-                while (addrs.hasMoreElements()) {
-                    inetAddrs.add(addrs.nextElement());
-                }
-            }
+            Collections.list(NetworkInterface.getNetworkInterfaces())
+                    .forEach(netInterface -> inetAddrs.addAll(Collections.list(netInterface.getInetAddresses())));
             selectAddresses();
 
             if (nameAddr != null && hasHostName(nameAddr)) {

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/Jar.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
index 02fe9e7..64c658d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Jar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java
@@ -33,7 +33,6 @@ import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -325,10 +324,8 @@ public class Jar extends Zip {
 
             // must not use getEntry as "well behaving" applications
             // must accept the manifest in any capitalization
-            Enumeration<? extends ZipEntry> e = zf.entries();
-            while (e.hasMoreElements()) {
-                ZipEntry ze = e.nextElement();
-                if (MANIFEST_NAME.equalsIgnoreCase(ze.getName())) {
+            for (ZipEntry ze : Collections.list(zf.entries())) {
+                 if (MANIFEST_NAME.equalsIgnoreCase(ze.getName())) {
                     try (InputStreamReader isr =
                         new InputStreamReader(zf.getInputStream(ze), "UTF-8")) {
                         return getManifest(isr);
@@ -354,14 +351,8 @@ public class Jar extends Zip {
 
     private boolean jarHasIndex(File jarFile) throws IOException {
         try (ZipFile zf = new ZipFile(jarFile)) {
-            Enumeration<? extends ZipEntry> e = zf.entries();
-            while (e.hasMoreElements()) {
-                ZipEntry ze = e.nextElement();
-                if (INDEX_NAME.equalsIgnoreCase(ze.getName())) {
-                    return true;
-                }
-            }
-            return false;
+            return Collections.list(zf.entries()).stream()
+                    .anyMatch(ze -> INDEX_NAME.equalsIgnoreCase(ze.getName()));
         }
     }
 
@@ -1072,11 +1063,8 @@ public class Jar extends Zip {
                                                  List<String> files)
         throws IOException {
         try (org.apache.tools.zip.ZipFile zf = new org.apache.tools.zip.ZipFile(file, "utf-8")) {
-            Enumeration<org.apache.tools.zip.ZipEntry> entries = zf.getEntries();
             Set<String> dirSet = new HashSet<>();
-            while (entries.hasMoreElements()) {
-                org.apache.tools.zip.ZipEntry ze =
-                    entries.nextElement();
+            for (org.apache.tools.zip.ZipEntry ze : Collections.list(zf.getEntries())) {
                 String name = ze.getName();
                 if (ze.isDirectory()) {
                     dirSet.add(name);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java b/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
index 7190e39..f231866 100644
--- a/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
+++ b/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
@@ -19,7 +19,7 @@
 package org.apache.tools.ant.taskdefs;
 
 import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -277,9 +277,7 @@ public class MacroInstance extends Task implements DynamicAttribute, TaskContain
         rc.addText(macroSubs(ue.getWrapper().getText().toString(),
                              localAttributes));
 
-        Enumeration<RuntimeConfigurable> e = ue.getWrapper().getChildren();
-        while (e.hasMoreElements()) {
-            RuntimeConfigurable r = e.nextElement();
+        for (RuntimeConfigurable r : Collections.list(ue.getWrapper().getChildren())) {
             UnknownElement unknownElement = (UnknownElement) r.getProxy();
             String tag = unknownElement.getTaskType();
             if (tag != null) {

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/Manifest.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Manifest.java b/src/main/org/apache/tools/ant/taskdefs/Manifest.java
index 28634ef..70eb4fc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Manifest.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Manifest.java
@@ -26,6 +26,7 @@ import java.io.PrintWriter;
 import java.io.Reader;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.LinkedHashMap;
@@ -37,7 +38,6 @@ import java.util.Vector;
 import java.util.stream.Collectors;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.util.CollectionUtils;
 import org.apache.tools.ant.util.FileUtils;
 
 /**
@@ -490,21 +490,15 @@ public class Manifest {
                     "Unable to merge sections with different names");
             }
 
-            Enumeration<String> e = section.getAttributeKeys();
             Attribute classpathAttribute = null;
-            while (e.hasMoreElements()) {
-                String attributeName = e.nextElement();
+            for (String attributeName : Collections.list(section.getAttributeKeys())) {
                 Attribute attribute = section.getAttribute(attributeName);
                 if (ATTRIBUTE_CLASSPATH.equalsIgnoreCase(attributeName)) {
                     if (classpathAttribute == null) {
                         classpathAttribute = new Attribute();
                         classpathAttribute.setName(ATTRIBUTE_CLASSPATH);
                     }
-                    Enumeration<String> cpe = attribute.getValues();
-                    while (cpe.hasMoreElements()) {
-                        String value = cpe.nextElement();
-                        classpathAttribute.addValue(value);
-                    }
+                    Collections.list(attribute.getValues()).forEach(classpathAttribute::addValue);
                 } else {
                     // the merge file always wins
                     storeAttribute(attribute);
@@ -515,11 +509,7 @@ public class Manifest {
                 if (mergeClassPaths) {
                     Attribute currentCp = getAttribute(ATTRIBUTE_CLASSPATH);
                     if (currentCp != null) {
-                        for (Enumeration<String> attribEnum = currentCp.getValues();
-                             attribEnum.hasMoreElements();) {
-                            String value = attribEnum.nextElement();
-                            classpathAttribute.addValue(value);
-                        }
+                        Collections.list(currentCp.getValues()).forEach(classpathAttribute::addValue);
                     }
                 }
                 storeAttribute(classpathAttribute);
@@ -558,11 +548,8 @@ public class Manifest {
                 Attribute nameAttr = new Attribute(ATTRIBUTE_NAME, name);
                 nameAttr.write(writer);
             }
-            Enumeration<String> e = getAttributeKeys();
-            while (e.hasMoreElements()) {
-                String key = e.nextElement();
-                Attribute attribute = getAttribute(key);
-                attribute.write(writer, flatten);
+            for (String key : Collections.list(getAttributeKeys())) {
+                getAttribute(key).write(writer, flatten);
             }
             writer.print(EOL);
         }
@@ -586,7 +573,7 @@ public class Manifest {
          *         key of an attribute of the section.
          */
         public Enumeration<String> getAttributeKeys() {
-            return CollectionUtils.asEnumeration(attributes.keySet().iterator());
+            return Collections.enumeration(attributes.keySet());
         }
 
         /**
@@ -666,11 +653,7 @@ public class Manifest {
                     } else {
                         warnings.add(
                             "Multiple Class-Path attributes are supported but violate the Jar specification and may not be correctly processed in all environments");
-                        Enumeration<String> e = attribute.getValues();
-                        while (e.hasMoreElements()) {
-                            String value = e.nextElement();
-                            classpathAttribute.addValue(value);
-                        }
+                        Collections.list(attribute.getValues()).forEach(classpathAttribute::addValue);
                     }
                 } else if (attributes.containsKey(attributeKey)) {
                     throw new ManifestException("The attribute \""
@@ -693,13 +676,9 @@ public class Manifest {
         public Object clone() {
             Section cloned = new Section();
             cloned.setName(name);
-            Enumeration<String> e = getAttributeKeys();
-            while (e.hasMoreElements()) {
-                String key = e.nextElement();
-                Attribute attribute = getAttribute(key);
-                cloned.storeAttribute(new Attribute(attribute.getName(),
-                                                    attribute.getValue()));
-            }
+            Collections.list(getAttributeKeys()).stream()
+                    .map(key -> new Attribute(getAttribute(key).getName(),
+                    getAttribute(key).getValue())).forEach(cloned::storeAttribute);
             return cloned;
         }
 
@@ -951,9 +930,7 @@ public class Manifest {
                  manifestVersion = other.manifestVersion;
              }
 
-             Enumeration<String> e = other.getSectionNames();
-             while (e.hasMoreElements()) {
-                 String sectionName = e.nextElement();
+             for (String sectionName : Collections.list(other.getSectionNames())) {
                  Section ourSection = sections.get(sectionName);
                  Section otherSection
                     = other.sections.get(sectionName);
@@ -1042,22 +1019,14 @@ public class Manifest {
      * @return an enumeration of warning strings
      */
     public Enumeration<String> getWarnings() {
-        Vector<String> warnings = new Vector<>();
+        // create a vector and add in the warnings for the main section
+        List<String> warnings = new ArrayList<>(Collections.list(mainSection.getWarnings()));
 
-        Enumeration<String> warnEnum = mainSection.getWarnings();
-        while (warnEnum.hasMoreElements()) {
-            warnings.addElement(warnEnum.nextElement());
-        }
-
-        // create a vector and add in the warnings for all the sections
-        for (Section section : sections.values()) {
-            Enumeration<String> e2 = section.getWarnings();
-            while (e2.hasMoreElements()) {
-                warnings.addElement(e2.nextElement());
-            }
-        }
+        // add in the warnings for all the sections
+        sections.values().stream().map(section -> Collections.list(section.getWarnings()))
+                .forEach(warnings::addAll);
 
-        return warnings.elements();
+        return Collections.enumeration(warnings);
     }
 
     /**
@@ -1140,6 +1109,6 @@ public class Manifest {
      * @return an Enumeration of section names
      */
     public Enumeration<String> getSectionNames() {
-        return CollectionUtils.asEnumeration(sections.keySet().iterator());
+        return Collections.enumeration(sections.keySet());
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java b/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
index 151a3cf..69fa787 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
@@ -25,12 +25,11 @@ import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
-import java.util.Enumeration;
+import java.util.Collections;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Manifest.Attribute;
 import org.apache.tools.ant.types.EnumeratedAttribute;
 
 /**
@@ -113,12 +112,8 @@ public class ManifestTask extends Task {
      */
     public void addConfiguredSection(Manifest.Section section)
          throws ManifestException {
-        Enumeration<String> attributeKeys = section.getAttributeKeys();
-        while (attributeKeys.hasMoreElements()) {
-            Attribute attribute = section.getAttribute(
-                attributeKeys.nextElement());
-            checkAttribute(attribute);
-        }
+        Collections.list(section.getAttributeKeys()).stream()
+                .map(section::getAttribute).forEach(this::checkAttribute);
         nestedManifest.addConfiguredSection(section);
     }
 
@@ -245,12 +240,9 @@ public class ManifestTask extends Task {
             }
         }
 
-        //look for and print warnings
-        for (Enumeration<String> e = nestedManifest.getWarnings();
-                e.hasMoreElements();) {
-            log("Manifest warning: " + e.nextElement(),
-                    Project.MSG_WARN);
-        }
+        // look for and print warnings
+        Collections.list(nestedManifest.getWarnings())
+                .forEach(e -> log("Manifest warning: " + e, Project.MSG_WARN));
         try {
             if ("update".equals(mode.getValue()) && manifestFile.exists()) {
                 if (current != null) {

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/condition/And.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/And.java b/src/main/org/apache/tools/ant/taskdefs/condition/And.java
index 5ec6608..8fc5c6c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/And.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/And.java
@@ -18,7 +18,7 @@
 
 package org.apache.tools.ant.taskdefs.condition;
 
-import java.util.Enumeration;
+import java.util.Collections;
 
 import org.apache.tools.ant.BuildException;
 
@@ -38,13 +38,7 @@ public class And extends ConditionBase implements Condition {
      */
     @Override
     public boolean eval() throws BuildException {
-        Enumeration<Condition> e = getConditions();
-        while (e.hasMoreElements()) {
-            if (!e.nextElement().eval()) {
-                return false;
-            }
-        }
-        return true;
+        return Collections.list(getConditions()).stream().allMatch(Condition::eval);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
index 851bf12..199abe1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
@@ -19,13 +19,12 @@ package org.apache.tools.ant.taskdefs.condition;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Collections;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.ManifestTask;
 import org.apache.tools.ant.types.DataType;
-import org.apache.tools.zip.ZipEntry;
 import org.apache.tools.zip.ZipFile;
 
 /**
@@ -73,15 +72,8 @@ public class IsSigned extends DataType implements Condition {
         throws IOException {
         try (ZipFile jarFile = new ZipFile(zipFile)) {
             if (null == name) {
-                Enumeration<ZipEntry> entries = jarFile.getEntries();
-                while (entries.hasMoreElements()) {
-                    String eName = entries.nextElement().getName();
-                    if (eName.startsWith(SIG_START)
-                        && eName.endsWith(SIG_END)) {
-                        return true;
-                    }
-                }
-                return false;
+                return Collections.list(jarFile.getEntries()).stream()
+                        .anyMatch(e -> e.getName().startsWith(SIG_START) && e.getName().endsWith(SIG_END));
             }
             name = replaceInvalidChars(name);
             boolean shortSig = jarFile.getEntry(SIG_START

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
index c16f89f..32caaa8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
@@ -18,7 +18,7 @@
 
 package org.apache.tools.ant.taskdefs.condition;
 
-import java.util.Enumeration;
+import java.util.Collections;
 
 import org.apache.tools.ant.BuildException;
 
@@ -38,14 +38,7 @@ public class Or extends ConditionBase implements Condition {
      */
     @Override
     public boolean eval() throws BuildException {
-        Enumeration<Condition> e = getConditions();
-        while (e.hasMoreElements()) {
-            Condition c = e.nextElement();
-            if (c.eval()) {
-                return true;
-            }
-        }
-        return false;
+        return Collections.list(getConditions()).stream().anyMatch(Condition::eval);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java b/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
index 5a0ac81..a771e95 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Xor.java
@@ -17,7 +17,7 @@
  */
 package org.apache.tools.ant.taskdefs.condition;
 
-import java.util.Enumeration;
+import java.util.Collections;
 
 import org.apache.tools.ant.BuildException;
 
@@ -36,12 +36,10 @@ public class Xor extends ConditionBase implements Condition {
      */
     @Override
     public boolean eval() throws BuildException {
-        Enumeration<Condition> e = getConditions();
-        //initial state is false.
+        // initial state is false.
         boolean state = false;
-        while (e.hasMoreElements()) {
-            Condition c = e.nextElement();
-            //every condition is xored against the previous one
+        for (Condition c : Collections.list(getConditions())) {
+            // every condition is xored against the previous one
             state ^= c.eval();
         }
         return state;

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
index 95cd6c1..3dc3a6f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
+++ b/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
@@ -28,10 +28,11 @@ import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
+import java.util.stream.Collectors;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.AbstractCvsTask;
-import org.apache.tools.ant.util.CollectionUtils;
 import org.apache.tools.ant.util.DOMElementWriter;
 import org.apache.tools.ant.util.DOMUtils;
 import org.apache.tools.ant.util.FileUtils;
@@ -420,7 +421,7 @@ public class CvsTagDiff extends AbstractCvsTask {
 
             root.setAttribute("cvsroot", getCvsRoot());
             root.setAttribute("package",
-                              CollectionUtils.flattenToString(packageNames));
+                    packageNames.stream().collect(Collectors.joining(",")));
             DOM_WRITER.openElement(root, writer, 0, "\t");
             writer.println();
             for (CvsTagEntry entry : entries) {

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
index ed1a927..01fe812 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
@@ -618,16 +618,11 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
         final XSLTProcess.Factory factory = xsltTask.getFactory();
         if (factory != null) {
             setFactory(factory.getName());
-
             // configure factory attributes
-            for (final XSLTProcess.Factory.Attribute attr
-                    : Collections.list(factory.getAttributes())) {
-                setAttribute(attr.getName(), attr.getValue());
-            }
-            for (final XSLTProcess.Factory.Feature feature
-                     : factory.getFeatures()) {
-                setFeature(feature.getName(), feature.getValue());
-            }
+            Collections.list(factory.getAttributes())
+                    .forEach(attr -> setAttribute(attr.getName(), attr.getValue()));
+            factory.getFeatures()
+                    .forEach(feature -> setFeature(feature.getName(), feature.getValue()));
         }
 
         final XMLCatalog xmlCatalog = xsltTask.getXMLCatalog();
@@ -637,12 +632,9 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
             setURIResolver(xmlCatalog);
         }
 
-
         // configure output properties
-        for (final XSLTProcess.OutputProperty prop
-                : Collections.list(xsltTask.getOutputProperties())) {
-            setOutputProperty(prop.getName(), prop.getValue());
-        }
+        Collections.list(xsltTask.getOutputProperties())
+                .forEach(prop -> setOutputProperty(prop.getName(), prop.getValue()));
 
         suppressWarnings = xsltTask.getSuppressWarnings();
 

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java
index 95ec973..6ddcd0b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java
@@ -51,15 +51,15 @@ public class AntAnalyzer extends AbstractAnalyzer {
     protected void determineDependencies(Vector<File> files, Vector<String> classes) {
         // we get the root classes and build up a set of
         // classes upon which they depend
+        Set<String> dependencies = new HashSet<>();
+        Set<File> containers = new HashSet<>();
         Set<String> toAnalyze = new HashSet<>(Collections.list(getRootClasses()));
+        Set<String> analyzedDeps = new HashSet<>();
 
         int count = 0;
         int maxCount = isClosureRequired() ? MAX_LOOPS : 1;
-        Set<String> dependencies = new HashSet<>();
-        Set<File> containers = new HashSet<>();
-        Set<String> analyzedDeps = null;
         while (!toAnalyze.isEmpty() && count++ < maxCount) {
-            analyzedDeps = new HashSet<>();
+            analyzedDeps.clear();
             for (String classname : toAnalyze) {
                 dependencies.add(classname);
                 try {
@@ -76,11 +76,9 @@ public class AntAnalyzer extends AbstractAnalyzer {
                             inStream = Files.newInputStream(Paths.get(container.getPath()));
                         } else {
                             zipFile = new ZipFile(container.getPath());
-                            String entryName
-                                = classname.replace('.', '/') + ".class";
+                            String entryName = classname.replace('.', '/') + ".class";
                             ZipEntry entry = new ZipEntry(entryName);
-                            inStream
-                                = zipFile.getInputStream(entry);
+                            inStream = zipFile.getInputStream(entry);
                         }
                         ClassFile classFile = new ClassFile();
                         classFile.read(inStream);
@@ -95,13 +93,9 @@ public class AntAnalyzer extends AbstractAnalyzer {
             }
 
             toAnalyze.clear();
-
             // now recover all the dependencies collected and add to the list.
-            for (String className : analyzedDeps) {
-                if (!dependencies.contains(className)) {
-                    toAnalyze.add(className);
-                }
-            }
+            analyzedDeps.stream().filter(className -> !dependencies.contains(className))
+                    .forEach(toAnalyze::add);
         }
 
         // pick up the last round of dependencies that were determined

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
index 4827aef..4be59b5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
@@ -25,7 +25,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -322,14 +322,9 @@ public class Depend extends MatchingTask {
                 analyzer.addRootClass(info.className);
                 analyzer.addClassPath(destPath);
                 analyzer.setClosure(false);
-                dependencyList = new ArrayList<>();
-                Enumeration<String> depEnum = analyzer.getClassDependencies();
-                while (depEnum.hasMoreElements()) {
-                    String o = depEnum.nextElement();
-                    dependencyList.add(o);
-                    log("Class " + info.className + " depends on " + o,
-                        Project.MSG_DEBUG);
-                }
+                dependencyList = new ArrayList<>(Collections.list(analyzer.getClassDependencies()));
+                dependencyList.forEach(o -> log("Class " + info.className + " depends on " + o,
+                        Project.MSG_DEBUG));
                 cacheDirty = true;
                 dependencyMap.put(info.className, dependencyList);
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
index 02566a6..7a34876 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
@@ -21,7 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
@@ -838,12 +838,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
             }
         }
 
-        Enumeration<String> e = dependencyAnalyzer.getClassDependencies();
-
-        while (e.hasMoreElements()) {
-            String classname = e.nextElement();
-            String location
-                = classname.replace('.', File.separatorChar) + ".class";
+        for (String classname : Collections.list(dependencyAnalyzer.getClassDependencies())) {
+            String location = classname.replace('.', File.separatorChar) + ".class";
             File classFile = new File(config.srcDir, location);
             if (classFile.exists()) {
                 checkEntries.put(location, classFile);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
index 6698bd6..c44aea4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
@@ -766,9 +766,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
                     newJarStream.setLevel(0);
 
                     // Copy files from old WebLogic jar
-                    for (Enumeration<JarEntry> e = wlEntries.elements(); e.hasMoreElements();) {
-                        JarEntry je = e.nextElement();
-
+                    for (JarEntry je : wlEntries.values()) {
                         if (je.getCompressedSize() == -1
                             || je.getCompressedSize() == je.getSize()) {
                             newJarStream.setLevel(0);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
index 3caea06..45bb25e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
@@ -21,17 +21,18 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
 
 import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Java;
-import org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.DTDLocation;
 import org.apache.tools.ant.types.Environment;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.util.FileUtils;
@@ -353,9 +354,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
         // any supplied by the user
         handler.registerDTD(PUBLICID_EJB11, ejb11DTD);
 
-        for (DTDLocation dtdLocation : getConfig().dtdLocations) {
-            handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation());
-        }
+        getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation()));
         return handler;
     }
 
@@ -372,9 +371,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
                 }
             };
 
-        for (DTDLocation dtdLocation : getConfig().dtdLocations) {
-            handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation());
-        }
+        getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation()));
         return handler;
     }
 
@@ -669,73 +666,64 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
                 genericJar = new JarFile(genericJarFile);
                 wasJar = new JarFile(websphereJarFile);
 
-                Hashtable<String, JarEntry> genericEntries = new Hashtable<>();
-                Hashtable<String, JarEntry> wasEntries = new Hashtable<>();
-                Hashtable<String, JarEntry> replaceEntries = new Hashtable<>();
-
                 //get the list of generic jar entries
-                for (Enumeration<JarEntry> e = genericJar.entries(); e.hasMoreElements();) {
-                    JarEntry je = e.nextElement();
-                    genericEntries.put(je.getName().replace('\\', '/'), je);
-                }
+                Hashtable<String, JarEntry> genericEntries = Collections.list(genericJar.entries()).stream()
+                        .collect(Collectors.toMap(je -> je.getName().replace('\\', '/'),
+                                je -> je, (a, b) -> b, Hashtable::new));
+
                 // get the list of WebSphere jar entries
-                for (Enumeration<JarEntry> e = wasJar.entries(); e.hasMoreElements();) {
-                    JarEntry je = e.nextElement();
-                    wasEntries.put(je.getName(), je);
-                }
+                Hashtable<String, JarEntry> wasEntries = Collections.list(wasJar.entries()).stream()
+                        .collect(Collectors.toMap(ZipEntry::getName, je -> je, (a, b) -> b, Hashtable::new));
 
                 // Cycle through generic and make sure its in WebSphere
                 genericLoader = getClassLoaderFromJar(genericJarFile);
 
-                for (Enumeration<String> e = genericEntries.keys(); e.hasMoreElements();) {
-                    String filepath = e.nextElement();
-
-                    if (wasEntries.containsKey(filepath)) {
-                        // File name/path match
-                        // Check files see if same
-                        JarEntry genericEntry = genericEntries.get(filepath);
-                        JarEntry wasEntry = wasEntries.get(filepath);
-
-                        if (genericEntry.getCrc() != wasEntry.getCrc()
-                            || genericEntry.getSize() != wasEntry.getSize()) {
-
-                            if (genericEntry.getName().endsWith(".class")) {
-                                //File are different see if its an object or an interface
-                                String classname
-                                    = genericEntry.getName().replace(File.separatorChar, '.');
-
-                                classname = classname.substring(0, classname.lastIndexOf(".class"));
-
-                                Class<?> genclass = genericLoader.loadClass(classname);
-
-                                if (genclass.isInterface()) {
-                                    //Interface changed   rebuild jar.
-                                    log("Interface " + genclass.getName()
-                                        + " has changed", Project.MSG_VERBOSE);
-                                    rebuild = true;
-                                    break;
-                                }
-                                //Object class Changed   update it.
-                                replaceEntries.put(filepath, genericEntry);
-                            } else {
-                                // is it the manifest. If so ignore it
-                                if (!genericEntry.getName().equals("META-INF/MANIFEST.MF")) {
-                                    //File other then class changed  rebuild
-                                    log("Non class file " + genericEntry.getName()
-                                        + " has changed", Project.MSG_VERBOSE);
-                                    rebuild = true;
-                                }
-                                break;
-                            }
-                        }
-                    } else {
+                Hashtable<String, JarEntry> replaceEntries = new Hashtable<>();
+                for (String filepath : genericEntries.keySet()) {
+                    if (!wasEntries.containsKey(filepath)) {
                         // a file doesn't exist rebuild
-
                         log("File " + filepath + " not present in websphere jar",
                             Project.MSG_VERBOSE);
                         rebuild = true;
                         break;
                     }
+                    // File name/path match
+                    // Check files see if same
+                    JarEntry genericEntry = genericEntries.get(filepath);
+                    JarEntry wasEntry = wasEntries.get(filepath);
+
+                    if (genericEntry.getCrc() != wasEntry.getCrc()
+                        || genericEntry.getSize() != wasEntry.getSize()) {
+
+                        if (genericEntry.getName().endsWith(".class")) {
+                            //File are different see if its an object or an interface
+                            String classname
+                                = genericEntry.getName().replace(File.separatorChar, '.');
+
+                            classname = classname.substring(0, classname.lastIndexOf(".class"));
+
+                            Class<?> genclass = genericLoader.loadClass(classname);
+
+                            if (genclass.isInterface()) {
+                                //Interface changed   rebuild jar.
+                                log("Interface " + genclass.getName()
+                                    + " has changed", Project.MSG_VERBOSE);
+                                rebuild = true;
+                                break;
+                            }
+                            //Object class Changed   update it.
+                            replaceEntries.put(filepath, genericEntry);
+                        } else {
+                            // is it the manifest. If so ignore it
+                            if (!genericEntry.getName().equals("META-INF/MANIFEST.MF")) {
+                                //File other then class changed  rebuild
+                                log("Non class file " + genericEntry.getName()
+                                    + " has changed", Project.MSG_VERBOSE);
+                                rebuild = true;
+                            }
+                            break;
+                        }
+                    }
                 }
 
                 if (!rebuild) {
@@ -749,9 +737,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
                     newJarStream.setLevel(0);
 
                     // Copy files from old WebSphere jar
-                    for (Enumeration<JarEntry> e = wasEntries.elements(); e.hasMoreElements();) {
-                        JarEntry je = e.nextElement();
-
+                    for (JarEntry je : Collections.list(wasEntries.elements())) {
                         if (je.getCompressedSize() == -1
                             || je.getCompressedSize() == je.getSize()) {
                             newJarStream.setLevel(0);

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
index 7531e98..234b8c4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
@@ -28,7 +28,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.List;
 import java.util.Vector;
 import java.util.zip.CRC32;
@@ -207,10 +207,7 @@ public class jlink {
             return;
         }
         try (ZipFile zipf = new ZipFile(f)) {
-            Enumeration<? extends ZipEntry> entries = zipf.entries();
-
-            while (entries.hasMoreElements()) {
-                ZipEntry inputEntry = entries.nextElement();
+            for (ZipEntry inputEntry : Collections.list(zipf.entries())) {
                 //Ignore manifest entries.  They're bound to cause conflicts between
                 //files that are being merged.  User should supply their own
                 //manifest file when doing the merge.

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
index 29cd238..51ad7d1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
@@ -18,8 +18,9 @@
 
 package org.apache.tools.ant.taskdefs.optional.junit;
 
-
 import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Vector;
 import java.util.stream.Stream;
@@ -99,8 +100,7 @@ public final class BatchTest extends BaseTest {
      * a <tt>JUnitTest</tt> instance.
      */
     public Enumeration<JUnitTest> elements() {
-        JUnitTest[] tests = createAllJUnitTest();
-        return Enumerations.fromArray(tests);
+        return Collections.enumeration(Arrays.asList(createAllJUnitTest()));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java
index dfe2b1f..da76dc8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Enumerations.java
@@ -28,6 +28,7 @@ import java.util.NoSuchElementException;
  * instead of 1.1.
  *
  */
+@Deprecated
 public final class Enumerations {
 
     private Enumerations() {
@@ -38,7 +39,9 @@ public final class Enumerations {
      * @param <T> object type
      * @param array the array of object to enumerate.
      * @return the enumeration over the array of objects.
+     * @deprecated use Collections.enumeration(Arrays.asList(array))
      */
+    @Deprecated
     @SafeVarargs
     public static <T> Enumeration<T> fromArray(T... array) {
         return Collections.enumeration(Arrays.asList(array));
@@ -51,7 +54,10 @@ public final class Enumerations {
      * @param <T> object type
      * @param enums the array of enumerations.
      * @return the enumeration over the array of enumerations.
+     * @deprecated Stream.concat(Collections.list ( one).stream(), Collections.list(two).stream())
+     *             .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::enumeration))
      */
+    @Deprecated
     @SafeVarargs
     public static <T> Enumeration<T> fromCompound(Enumeration<? extends T>... enums) {
         return new CompoundEnumeration<>(enums);
@@ -89,6 +95,7 @@ public final class Enumerations {
  * }
  * </pre>
  */
+@Deprecated
 class CompoundEnumeration<T> implements Enumeration<T> {
 
     /** enumeration array */

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
index 09bba29..53f36b8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
@@ -43,6 +43,8 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Vector;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.BuildException;
@@ -1376,9 +1378,7 @@ public class JUnitTask extends Task {
                 LoaderUtils.classNameToResource(Project.class.getName());
             URL previous = null;
             try {
-                for (final Enumeration<URL> e = loader.getResources(projectResourceName);
-                     e.hasMoreElements();) {
-                    final URL current = e.nextElement();
+                for (final URL current : Collections.list(loader.getResources(projectResourceName))) {
                     if (previous != null && !urlEquals(current, previous)) {
                         log(String.format(
                                 "WARNING: multiple versions of ant detected in path for junit%n"
@@ -1660,16 +1660,9 @@ public class JUnitTask extends Task {
      * @since Ant 1.3
      */
     protected Enumeration<JUnitTest> getIndividualTests() {
-        final int count = batchTests.size();
-        @SuppressWarnings("unchecked")
-        final Enumeration<JUnitTest>[] enums = new Enumeration[ count + 1];
-
-        for (int i = 0; i < count; i++) {
-            final BatchTest batchtest = batchTests.get(i);
-            enums[i] = batchtest.elements();
-        }
-        enums[enums.length - 1] = Collections.enumeration(tests);
-        return Enumerations.fromCompound(enums);
+        return Collections.enumeration(Stream.concat(batchTests.stream()
+                .flatMap(b -> Collections.list(b.elements()).stream()), tests.stream())
+                .collect(Collectors.toList()));
     }
 
     /**
@@ -1685,11 +1678,8 @@ public class JUnitTask extends Task {
         if (tests.isEmpty()) {
             return;
         }
-        for (JUnitTest test : tests) {
-            if (test.hasMethodsSpecified() && test.shouldRun(getProject())) {
-                test.resolveMethods();
-            }
-        }
+        tests.stream().filter(test -> test.hasMethodsSpecified() && test.shouldRun(getProject()))
+                .forEach(JUnitTest::resolveMethods);
     }
 
     /**
@@ -1763,8 +1753,8 @@ public class JUnitTask extends Task {
      * @since Ant 1.3
      */
     protected Enumeration<BaseTest> allTests() {
-        return Enumerations.fromCompound(Collections.enumeration(tests),
-            Collections.enumeration(batchTests));
+        return Collections.enumeration(Stream.concat(tests.stream(), batchTests.stream())
+                .collect(Collectors.toList()));
     }
 
     /**
@@ -2164,8 +2154,7 @@ public class JUnitTask extends Task {
         final Enumeration<JUnitTest> testList, final boolean runIndividual) {
         final Map<ForkedTestConfiguration, List<JUnitTest>> testConfigurations =
             new HashMap<>();
-        while (testList.hasMoreElements()) {
-            final JUnitTest test = testList.nextElement();
+        for (final JUnitTest test : Collections.list(testList)) {
             if (test.shouldRun(getProject())) {
                 /* with multi-threaded runs need to defer execution of even */
                 /* individual tests so the threads can pick tests off the queue. */

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/FilterSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java
index 41db058..a3fefce 100644
--- a/src/main/org/apache/tools/ant/types/FilterSet.java
+++ b/src/main/org/apache/tools/ant/types/FilterSet.java
@@ -20,7 +20,7 @@ package org.apache.tools.ant.types;
 import java.io.File;
 import java.io.InputStream;
 import java.nio.file.Files;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
@@ -252,10 +252,8 @@ public class FilterSet extends DataType implements Cloneable {
         dieOnCircularReference();
         if (filterHash == null) {
             filterHash = new Hashtable<>(getFilters().size());
-            for (Enumeration<Filter> e = getFilters().elements(); e.hasMoreElements();) {
-               Filter filter = e.nextElement();
-               filterHash.put(filter.getToken(), filter.getValue());
-            }
+            Collections.list(getFilters().elements())
+                    .forEach(filter -> filterHash.put(filter.getToken(), filter.getValue()));
         }
         return filterHash;
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/070c3bc8/src/main/org/apache/tools/ant/types/PropertySet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/PropertySet.java b/src/main/org/apache/tools/ant/types/PropertySet.java
index ee25e44..a423946 100644
--- a/src/main/org/apache/tools/ant/types/PropertySet.java
+++ b/src/main/org/apache/tools/ant/types/PropertySet.java
@@ -19,7 +19,6 @@
 package org.apache.tools.ant.types;
 
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -31,6 +30,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.Stack;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import org.apache.tools.ant.BuildException;
@@ -276,17 +276,12 @@ public class PropertySet extends DataType implements ResourceCollection {
 
     /**
      * Convert the system properties to a Map.
-     * Use propertynames to get the list of properties (including
+     * Use stringPropertyNames to get the list of properties (including
      * default ones).
      */
     private Map<String, Object> getAllSystemProperties() {
-        Map<String, Object>  ret = new HashMap<>();
-        for (Enumeration<?> e = System.getProperties().propertyNames();
-             e.hasMoreElements();) {
-            String name = (String) e.nextElement();
-            ret.put(name, System.getProperties().getProperty(name));
-        }
-        return ret;
+        return System.getProperties().stringPropertyNames().stream()
+                .collect(Collectors.toMap(name -> name, name -> System.getProperties().getProperty(name), (a, b) -> b));
     }
 
     /**