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 aae28aa5a..84b6fa261 100644 --- a/src/main/org/apache/tools/ant/types/resources/Resources.java +++ b/src/main/org/apache/tools/ant/types/resources/Resources.java @@ -45,23 +45,25 @@ public class Resources extends DataType implements ResourceCollection { return true; } public Iterator iterator() { - return new Iterator() { - public Object next() { - throw new NoSuchElementException(); - } - public boolean hasNext() { - return false; - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; + return EMPTY_ITERATOR; } public int size() { return 0; } }; + private static final Iterator EMPTY_ITERATOR = new Iterator() { + public Object next() { + throw new NoSuchElementException(); + } + public boolean hasNext() { + return false; + } + public void remove() { + throw new UnsupportedOperationException(); + } + }; + private class MyCollection extends AbstractCollection { private int size;