Hi,

I really like the new attributes code. At first, I was not happy about it - it seemed more complicated. Yet, it looks prettier and is much more full-featured than the old code. I especially like the parameter attributes - nice touch! The one downside of the new code is the requirement that each attribute have an associated class, which can be a pain for marker attributes.

I found a bug in AttributeUtil in the method "getObjectsWithAttributeType". Looks like a cut and paste error. Basically, it isn't filtering out the objects correctly, but it is instead returning classes... It is the exact same code as "getClassesWithAttributeType" - which doesn't seem right. Patch is attached.

Cheers,

Dan
Index: AttributeUtil.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons-sandbox/attributes/api/src/java/org/apache/commons/attributes/AttributeUtil.java,v
retrieving revision 1.1
diff -u -r1.1 AttributeUtil.java
--- AttributeUtil.java  24 Aug 2003 17:47:59 -0000      1.1
+++ AttributeUtil.java  23 Sep 2003 23:28:50 -0000
@@ -56,18 +56,9 @@
  */
 package org.apache.commons.attributes;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
+import java.util.Collection;
 import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
 
 /**
  * Commonly used convenience functions.
@@ -99,9 +90,10 @@
         ArrayList result = new ArrayList ();
         Iterator iter = objects.iterator ();
         while (iter.hasNext ()) {
-            Class clazz = (Class) iter.next ().getClass ();
-            if (Attributes.hasAttributeType (clazz, attributeClass)) {
-                result.add (clazz);
+            Object attribute = iter.next();
+            if ( attribute.getClass().equals( attributeClass ) )
+            {
+                result.add(attribute);
             }
         }
         

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to