On Sun, 20 May 2001, Johan Compagner wrote:

> Suddenly problems when importing the code into VAJ!!
> 
> This is because for the FastTreeMap does this in hashCode and Equals:
> 
> Iterator i = map.entrySet().iterator();
> 
> Then VAJ Complains about Iterator not being visible. (despite of the import)
> This is because a super class TreeMap already defines a innerclass Iterator
> that one is private (so not visible)
> So VAJ seems to look first up the class  tree and then to the imports
> maybe javac does it the other way around i don't know.
> But if the inner Iterator class was suddenly made protected or private by sun
> then FastTreeMap wouldn't compile anymore so i would vote for deleting
> the import and using full qualified names in those 2 methods.
> 
> Johan Compagner
> 

I just checked in an update to use the fully qualified class name
(java.util.Iterator) for these cases.  Could you give it a try?

Craig


> 
> 
> 
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, May 20, 2001 3:15 AM
> Subject: cvs commit: jakarta-struts/src/share/org/apache/struts/util 
>FastArrayList.java FastHashMap.java FastTreeMap.java
> 
> 
> > craigmcc    01/05/19 18:15:18
> >
> >   Modified:    src/share/org/apache/struts/util FastArrayList.java
> >                         FastHashMap.java FastTreeMap.java
> >   Log:
> >   Update to current versions from the Commons Collections project.  After
> >   1.0 final, Struts will be modified to use the Commons classes directly.
> >
> >   Revision  Changes    Path
> >   1.4       +101 -6    
>jakarta-struts/src/share/org/apache/struts/util/FastArrayList.java
> >
> >   Index: FastArrayList.java
> >   ===================================================================
> >   RCS file: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastArrayList.java,v
> >   retrieving revision 1.3
> >   retrieving revision 1.4
> >   diff -u -r1.3 -r1.4
> >   --- FastArrayList.java 2001/02/12 00:32:13 1.3
> >   +++ FastArrayList.java 2001/05/20 01:15:17 1.4
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastArrayList.java,v 1.3 
>2001/02/12 00:32:13 craigmcc Exp
> $
> >   - * $Revision: 1.3 $
> >   - * $Date: 2001/02/12 00:32:13 $
> >   + * $Header: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastArrayList.java,v 1.4 
>2001/05/20 01:15:17 craigmcc Exp
> $
> >   + * $Revision: 1.4 $
> >   + * $Date: 2001/05/20 01:15:17 $
> >     *
> >     * ====================================================================
> >     *
> >   @@ -93,14 +93,14 @@
> >     * <code>java.util.ArrayList</code> directly (with no synchronization), for
> >     * maximum performance.</p>
> >     *
> >   - * <p><strong>NOTE</strong>: The following methods are <strong>NOT</strong>
> >   - * overridden:  clone(), equals(Object), hashCode().</p>
> >   + * @deprecated At some point after Struts 1.0 final, will be replaced by
> >   + *  an equivalent class in the Jakarta Commons Collections package.
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.3 $ $Date: 2001/02/12 00:32:13 $
> >   + * @version $Revision: 1.4 $ $Date: 2001/05/20 01:15:17 $
> >     */
> >
> >   -public class FastArrayList implements List, Cloneable, Serializable {
> >   +public class FastArrayList extends ArrayList {
> >
> >
> >        // ----------------------------------------------------------- Constructors
> >   @@ -301,6 +301,26 @@
> >
> >
> >        /**
> >   +     * Return a shallow copy of this <code>FastArrayList</code> instance.
> >   +     * The elements themselves are not copied.
> >   +     */
> >   +    public Object clone() {
> >   +
> >   +        FastArrayList results = null;
> >   +        if (fast) {
> >   +            results = new FastArrayList(list);
> >   +        } else {
> >   +            synchronized (list) {
> >   +                results = new FastArrayList(list);
> >   +            }
> >   +        }
> >   +        results.setFast(getFast());
> >   +        return (results);
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >         * Return <code>true</code> if this list contains the specified element.
> >         *
> >         * @param element The element to test for
> >   @@ -362,6 +382,51 @@
> >
> >
> >        /**
> >   +     * Compare the specified object with this list for equality.  This
> >   +     * implementation uses exactly the code that is used to define the
> >   +     * list equals function in the documentation for the
> >   +     * <code>List.equals</code> method.
> >   +     *
> >   +     * @param o Object to be compared to this list
> >   +     */
> >   +    public boolean equals(Object o) {
> >   +
> >   +        // Simple tests that require no synchronization
> >   +        if (o == this)
> >   +            return (true);
> >   +        else if (!(o instanceof List))
> >   +            return (false);
> >   +        List lo = (List) o;
> >   +
> >   +        // Compare the sets of elements for equality
> >   +        if (fast) {
> >   +            ListIterator li1 = list.listIterator();
> >   +            ListIterator li2 = lo.listIterator();
> >   +            while (li1.hasNext() && li2.hasNext()) {
> >   +                Object o1 = li1.next();
> >   +                Object o2 = li2.next();
> >   +                if (!(o1 == null ? o2 == null : o1.equals(o2)))
> >   +                    return (false);
> >   +            }
> >   +            return (!(li1.hasNext() || li2.hasNext()));
> >   +        } else {
> >   +            synchronized (list) {
> >   +                ListIterator li1 = list.listIterator();
> >   +                ListIterator li2 = lo.listIterator();
> >   +                while (li1.hasNext() && li2.hasNext()) {
> >   +                    Object o1 = li1.next();
> >   +                    Object o2 = li2.next();
> >   +                    if (!(o1 == null ? o2 == null : o1.equals(o2)))
> >   +                        return (false);
> >   +                }
> >   +                return (!(li1.hasNext() || li2.hasNext()));
> >   +            }
> >   +        }
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >         * Return the element at the specified position in the list.
> >         *
> >         * @param index The index of the element to return
> >   @@ -375,6 +440,36 @@
> >            } else {
> >                synchronized (list) {
> >                    return (list.get(index));
> >   +            }
> >   +        }
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >   +     * Return the hash code value for this list.  This implementation uses
> >   +     * exactly the code that is used to define the list hash function in the
> >   +     * documentation for the <code>List.hashCode</code> method.
> >   +     */
> >   +    public int hashCode() {
> >   +
> >   +        if (fast) {
> >   +            int hashCode = 1;
> >   +            Iterator i = list.iterator();
> >   +            while (i.hasNext()) {
> >   +                Object o = i.next();
> >   +                hashCode = 31 * hashCode + (o == null ? 0 : o.hashCode());
> >   +            }
> >   +            return (hashCode);
> >   +        } else {
> >   +            synchronized (list) {
> >   +                int hashCode = 1;
> >   +                Iterator i = list.iterator();
> >   +                while (i.hasNext()) {
> >   +                    Object o = i.next();
> >   +                    hashCode = 31 * hashCode + (o == null ? 0 : o.hashCode());
> >   +                }
> >   +                return (hashCode);
> >                }
> >            }
> >
> >
> >
> >
> >   1.4       +113 -7    
>jakarta-struts/src/share/org/apache/struts/util/FastHashMap.java
> >
> >   Index: FastHashMap.java
> >   ===================================================================
> >   RCS file: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastHashMap.java,v
> >   retrieving revision 1.3
> >   retrieving revision 1.4
> >   diff -u -r1.3 -r1.4
> >   --- FastHashMap.java 2001/02/12 00:32:13 1.3
> >   +++ FastHashMap.java 2001/05/20 01:15:17 1.4
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastHashMap.java,v 1.3 
>2001/02/12 00:32:13 craigmcc Exp $
> >   - * $Revision: 1.3 $
> >   - * $Date: 2001/02/12 00:32:13 $
> >   + * $Header: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastHashMap.java,v 1.4 
>2001/05/20 01:15:17 craigmcc Exp $
> >   + * $Revision: 1.4 $
> >   + * $Date: 2001/05/20 01:15:17 $
> >     *
> >     * ====================================================================
> >     *
> >   @@ -68,6 +68,7 @@
> >    import java.util.HashMap;
> >    import java.util.Iterator;
> >    import java.util.Map;
> >   +import java.util.Map.Entry;
> >    import java.util.Set;
> >
> >
> >   @@ -93,14 +94,14 @@
> >     * <code>java.util.HashMap</code> directly (with no synchronization), for
> >     * maximum performance.</p>
> >     *
> >   - * <p><strong>NOTE</strong>: The following methods are <strong>NOT</strong>
> >   - * overridden:  clone(), equals(Object), hashCode().</p>
> >   + * @deprecated At some point after Struts 1.0 final, will be replaced by
> >   + *  an equivalent class in the Jakarta Commons Collections package.
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.3 $ $Date: 2001/02/12 00:32:13 $
> >   + * @version $Revision: 1.4 $ $Date: 2001/05/20 01:15:17 $
> >     */
> >
> >   -public class FastHashMap implements Map, Cloneable, Serializable {
> >   +public class FastHashMap extends HashMap {
> >
> >
> >        // ----------------------------------------------------------- Constructors
> >   @@ -207,6 +208,26 @@
> >
> >
> >        /**
> >   +     * Return a shallow copy of this <code>FastHashMap</code> instance.
> >   +     * The keys and values themselves are not copied.
> >   +     */
> >   +    public Object clone() {
> >   +
> >   +        FastHashMap results = null;
> >   +        if (fast) {
> >   +            results = new FastHashMap(map);
> >   +        } else {
> >   +            synchronized (map) {
> >   +                results = new FastHashMap(map);
> >   +            }
> >   +        }
> >   +        results.setFast(getFast());
> >   +        return (results);
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >         * Return <code>true</code> if this map contains a mapping for the
> >         * specified key.
> >         *
> >   @@ -262,6 +283,65 @@
> >
> >
> >        /**
> >   +     * Compare the specified object with this list for equality.  This
> >   +     * implementation uses exactly the code that is used to define the
> >   +     * list equals function in the documentation for the
> >   +     * <code>Map.equals</code> method.
> >   +     *
> >   +     * @param o Object to be compared to this list
> >   +     */
> >   +    public boolean equals(Object o) {
> >   +
> >   +        // Simple tests that require no synchronization
> >   +        if (o == this)
> >   +            return (true);
> >   +        else if (!(o instanceof Map))
> >   +            return (false);
> >   +        Map mo = (Map) o;
> >   +
> >   +        // Compare the two maps for equality
> >   +        if (fast) {
> >   +            if (mo.size() != map.size())
> >   +                return (false);
> >   +            Iterator i = map.entrySet().iterator();
> >   +            while (i.hasNext()) {
> >   +                Map.Entry e = (Map.Entry) i.next();
> >   +                Object key = e.getKey();
> >   +                Object value = e.getValue();
> >   +                if (value == null) {
> >   +                    if (!(mo.get(key) == null && mo.containsKey(key)))
> >   +                        return (false);
> >   +                } else {
> >   +                    if (!value.equals(mo.get(key)))
> >   +                        return (false);
> >   +                }
> >   +            }
> >   +            return (true);
> >   +        } else {
> >   +            synchronized (map) {
> >   +                if (mo.size() != map.size())
> >   +                    return (false);
> >   +                Iterator i = map.entrySet().iterator();
> >   +                while (i.hasNext()) {
> >   +                    Map.Entry e = (Map.Entry) i.next();
> >   +                    Object key = e.getKey();
> >   +                    Object value = e.getValue();
> >   +                    if (value == null) {
> >   +                        if (!(mo.get(key) == null && mo.containsKey(key)))
> >   +                            return (false);
> >   +                    } else {
> >   +                        if (!value.equals(mo.get(key)))
> >   +                            return (false);
> >   +                    }
> >   +                }
> >   +                return (true);
> >   +            }
> >   +        }
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >         * Return the value to which this map maps the specified key.  Returns
> >         * <code>null</code> if the map contains no mapping for this key, or if
> >         * there is a mapping with a value of <code>null</code>.  Use the
> >   @@ -276,6 +356,32 @@
> >            } else {
> >                synchronized (map) {
> >                    return (map.get(key));
> >   +            }
> >   +        }
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >   +     * Return the hash code value for this map.  This implementation uses
> >   +     * exactly the code that is used to define the list hash function in the
> >   +     * documentation for the <code>Map.hashCode</code> method.
> >   +     */
> >   +    public int hashCode() {
> >   +
> >   +        if (fast) {
> >   +            int h = 0;
> >   +            Iterator i = map.entrySet().iterator();
> >   +            while (i.hasNext())
> >   +                h += i.next().hashCode();
> >   +            return (h);
> >   +        } else {
> >   +            synchronized (map) {
> >   +                int h = 0;
> >   +                Iterator i = map.entrySet().iterator();
> >   +                while (i.hasNext())
> >   +                    h += i.next().hashCode();
> >   +                return (h);
> >                }
> >            }
> >
> >
> >
> >
> >   1.3       +113 -7    
>jakarta-struts/src/share/org/apache/struts/util/FastTreeMap.java
> >
> >   Index: FastTreeMap.java
> >   ===================================================================
> >   RCS file: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastTreeMap.java,v
> >   retrieving revision 1.2
> >   retrieving revision 1.3
> >   diff -u -r1.2 -r1.3
> >   --- FastTreeMap.java 2001/02/12 00:32:13 1.2
> >   +++ FastTreeMap.java 2001/05/20 01:15:18 1.3
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastTreeMap.java,v 1.2 
>2001/02/12 00:32:13 craigmcc Exp $
> >   - * $Revision: 1.2 $
> >   - * $Date: 2001/02/12 00:32:13 $
> >   + * $Header: 
>/home/cvs/jakarta-struts/src/share/org/apache/struts/util/FastTreeMap.java,v 1.3 
>2001/05/20 01:15:18 craigmcc Exp $
> >   + * $Revision: 1.3 $
> >   + * $Date: 2001/05/20 01:15:18 $
> >     *
> >     * ====================================================================
> >     *
> >   @@ -68,6 +68,7 @@
> >    import java.util.Comparator;
> >    import java.util.Iterator;
> >    import java.util.Map;
> >   +import java.util.Map.Entry;
> >    import java.util.Set;
> >    import java.util.SortedMap;
> >    import java.util.TreeMap;
> >   @@ -95,14 +96,14 @@
> >     * <code>java.util.TreeMap</code> directly (with no synchronization), for
> >     * maximum performance.</p>
> >     *
> >   - * <p><strong>NOTE</strong>: The following methods are <strong>NOT</strong>
> >   - * overridden:  clone(), equals(Object), hashCode().</p>
> >   + * @deprecated At some point after Struts 1.0 final, will be replaced by
> >   + *  an equivalent class in the Jakarta Commons Collections package.
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.2 $ $Date: 2001/02/12 00:32:13 $
> >   + * @version $Revision: 1.3 $ $Date: 2001/05/20 01:15:18 $
> >     */
> >
> >   -public class FastTreeMap implements Map, Cloneable, Serializable {
> >   +public class FastTreeMap extends TreeMap {
> >
> >
> >        // ----------------------------------------------------------- Constructors
> >   @@ -210,6 +211,26 @@
> >
> >
> >        /**
> >   +     * Return a shallow copy of this <code>FastTreeMap</code> instance.
> >   +     * The keys and values themselves are not copied.
> >   +     */
> >   +    public Object clone() {
> >   +
> >   +        FastTreeMap results = null;
> >   +        if (fast) {
> >   +            results = new FastTreeMap(map);
> >   +        } else {
> >   +            synchronized (map) {
> >   +                results = new FastTreeMap(map);
> >   +            }
> >   +        }
> >   +        results.setFast(getFast());
> >   +        return (results);
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >         * Return the comparator used to order this map, or <code>null</code>
> >         * if this map uses its keys' natural order.
> >         */
> >   @@ -282,6 +303,65 @@
> >
> >
> >        /**
> >   +     * Compare the specified object with this list for equality.  This
> >   +     * implementation uses exactly the code that is used to define the
> >   +     * list equals function in the documentation for the
> >   +     * <code>Map.equals</code> method.
> >   +     *
> >   +     * @param o Object to be compared to this list
> >   +     */
> >   +    public boolean equals(Object o) {
> >   +
> >   +        // Simple tests that require no synchronization
> >   +        if (o == this)
> >   +            return (true);
> >   +        else if (!(o instanceof Map))
> >   +            return (false);
> >   +        Map mo = (Map) o;
> >   +
> >   +        // Compare the two maps for equality
> >   +        if (fast) {
> >   +            if (mo.size() != map.size())
> >   +                return (false);
> >   +            Iterator i = map.entrySet().iterator();
> >   +            while (i.hasNext()) {
> >   +                Map.Entry e = (Map.Entry) i.next();
> >   +                Object key = e.getKey();
> >   +                Object value = e.getValue();
> >   +                if (value == null) {
> >   +                    if (!(mo.get(key) == null && mo.containsKey(key)))
> >   +                        return (false);
> >   +                } else {
> >   +                    if (!value.equals(mo.get(key)))
> >   +                        return (false);
> >   +                }
> >   +            }
> >   +            return (true);
> >   +        } else {
> >   +            synchronized (map) {
> >   +                if (mo.size() != map.size())
> >   +                    return (false);
> >   +                Iterator i = map.entrySet().iterator();
> >   +                while (i.hasNext()) {
> >   +                    Map.Entry e = (Map.Entry) i.next();
> >   +                    Object key = e.getKey();
> >   +                    Object value = e.getValue();
> >   +                    if (value == null) {
> >   +                        if (!(mo.get(key) == null && mo.containsKey(key)))
> >   +                            return (false);
> >   +                    } else {
> >   +                        if (!value.equals(mo.get(key)))
> >   +                            return (false);
> >   +                    }
> >   +                }
> >   +                return (true);
> >   +            }
> >   +        }
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >         * Return the first (lowest) key currently in this sorted map.
> >         */
> >        public Object firstKey() {
> >   @@ -312,6 +392,32 @@
> >            } else {
> >                synchronized (map) {
> >                    return (map.get(key));
> >   +            }
> >   +        }
> >   +
> >   +    }
> >   +
> >   +
> >   +    /**
> >   +     * Return the hash code value for this map.  This implementation uses
> >   +     * exactly the code that is used to define the list hash function in the
> >   +     * documentation for the <code>Map.hashCode</code> method.
> >   +     */
> >   +    public int hashCode() {
> >   +
> >   +        if (fast) {
> >   +            int h = 0;
> >   +            Iterator i = map.entrySet().iterator();
> >   +            while (i.hasNext())
> >   +                h += i.next().hashCode();
> >   +            return (h);
> >   +        } else {
> >   +            synchronized (map) {
> >   +                int h = 0;
> >   +                Iterator i = map.entrySet().iterator();
> >   +                while (i.hasNext())
> >   +                    h += i.next().hashCode();
> >   +                return (h);
> >                }
> >            }
> >
> >
> >
> >
> 
> 

Reply via email to