Author: mbenson Date: Wed Jul 25 15:40:12 2007 New Revision: 559638 URL: http://svn.apache.org/viewvc?view=rev&rev=559638 Log: fix interface detection; I knew this. :(
Modified: ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java?view=diff&rev=559638&r1=559637&r2=559638 ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java Wed Jul 25 15:40:12 2007 @@ -19,11 +19,12 @@ import java.text.ParsePosition; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.Vector; import java.util.Enumeration; @@ -902,8 +903,7 @@ * @since Ant 1.8 */ public synchronized void add(Delegate delegate) { - List d = getDelegateInterfaces(delegate); - for (Iterator iter = d.iterator(); iter.hasNext();) { + for (Iterator iter = getDelegateInterfaces(delegate).iterator(); iter.hasNext();) { Object key = iter.next(); List list = (List) delegates.get(key); if (list == null) { @@ -925,23 +925,28 @@ */ protected synchronized List getDelegates(Class type) { return delegates.containsKey(type) - ? (List) new ArrayList((Collection) delegates.get(type)) : Collections.EMPTY_LIST; + ? (List) new ArrayList((List) delegates.get(type)) : Collections.EMPTY_LIST; } /** * Get all Delegate interfaces (excluding Delegate itself) from the specified Delegate. * @param d the Delegate to inspect. - * @return List<Class> + * @return Set<Class> * @since Ant 1.8 */ - protected List getDelegateInterfaces(Delegate d) { - Class[] c = d.getClass().getInterfaces(); - ArrayList result = new ArrayList(); - for (int i = 0; i < c.length; i++) { - if (Delegate.class.isAssignableFrom(c[i]) && !Delegate.class.equals(c[i])) { - result.add(c[i]); + protected Set getDelegateInterfaces(Delegate d) { + HashSet result = new HashSet(); + Class c = d.getClass(); + while (c != null) { + Class[] ifs = c.getInterfaces(); + for (int i = 0; i < ifs.length; i++) { + if (Delegate.class.isAssignableFrom(ifs[i])) { + result.add(ifs[i]); + } } + c = c.getSuperclass(); } + result.remove(Delegate.class); return result; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]