sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1470197 [5/5] - in /sis/branches/JDK6: ./ sis-metadata/src/main/java/org/apache/sis/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/ sis-metadata/src/main...
Date Sat, 20 Apr 2013 17:16:13 GMT
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultVectorSpatialRepresentation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultVectorSpatialRepresentation.java?rev=1470197&r1=1470196&r2=1470197&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultVectorSpatialRepresentation.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultVectorSpatialRepresentation.java
[UTF-8] Sat Apr 20 17:16:11 2013
@@ -109,7 +109,7 @@ public class DefaultVectorSpatialReprese
      */
     @Override
     @XmlElement(name = "topologyLevel")
-    public synchronized TopologyLevel getTopologyLevel() {
+    public TopologyLevel getTopologyLevel() {
         return topologyLevel;
     }
 
@@ -118,7 +118,7 @@ public class DefaultVectorSpatialReprese
      *
      * @param newValue The new topology level.
      */
-    public synchronized void setTopologyLevel(final TopologyLevel newValue) {
+    public void setTopologyLevel(final TopologyLevel newValue) {
         checkWritePermission();
         topologyLevel = newValue;
     }
@@ -128,7 +128,7 @@ public class DefaultVectorSpatialReprese
      */
     @Override
     @XmlElement(name = "geometricObjects")
-    public synchronized Collection<GeometricObjects> getGeometricObjects() {
+    public Collection<GeometricObjects> getGeometricObjects() {
         return geometricObjects = nonNullCollection(geometricObjects, GeometricObjects.class);
     }
 
@@ -137,7 +137,7 @@ public class DefaultVectorSpatialReprese
      *
      * @param newValues The new geometric objects.
      */
-    public synchronized void setGeometricObjects(final Collection<? extends GeometricObjects>
newValues) {
+    public void setGeometricObjects(final Collection<? extends GeometricObjects> newValues)
{
         geometricObjects = writeCollection(newValues, geometricObjects, GeometricObjects.class);
     }
 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java?rev=1470197&r1=1470196&r2=1470197&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
[UTF-8] Sat Apr 20 17:16:11 2013
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.NoSuchElementException;
-import net.jcip.annotations.ThreadSafe;
 import org.apache.sis.util.Decorator;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.CheckedContainer;
@@ -32,29 +31,18 @@ import static org.apache.sis.util.Argume
 
 
 /**
- * A {@linkplain Collections#checkedList(List, Class) checked} and
- * {@linkplain Collections#synchronizedList(List) synchronized} {@link ArrayList}.
+ * A {@linkplain Collections#checkedList(List, Class) checked} {@link ArrayList}.
  * The type checks are performed at run-time in addition to the compile-time checks.
  *
  * <p>Using this class is similar to wrapping an {@link ArrayList} using the methods
provided
  * in the standard {@link Collections} class, except for the following advantages:</p>
  *
  * <ul>
- *   <li>Avoid the two levels of indirection (for type check and synchronization).</li>
+ *   <li>Avoid one level of indirection.</li>
  *   <li>Checks for write permission.</li>
- *   <li>Overrideable methods for controlling the synchronization lock,
- *       type checks and write permission checks.</li>
+ *   <li>Overrideable methods for controlling the type checks and write permission
checks.</li>
  * </ul>
  *
- * The synchronization is provided mostly in order to prevent damages
- * to the list in case of concurrent access. It does <strong>not</strong> prevent
- * {@link java.util.ConcurrentModificationException} to be thrown during iterations,
- * unless the whole iteration is synchronized on this list {@linkplain #getLock() lock}.
- * For real concurrency, see the {@link java.util.concurrent} package instead.
- *
- * {@note The above is the reason why the name of this class emphases the <cite>checked</cite>
- *        aspect rather than the <cite>synchronized</cite> aspect of the list.}
- *
  * @param <E> The type of elements in the list.
  *
  * @author  Martin Desruisseaux (Geomatys)
@@ -63,9 +51,7 @@ import static org.apache.sis.util.Argume
  * @module
  *
  * @see Collections#checkedList(List, Class)
- * @see Collections#synchronizedList(List)
  */
-@ThreadSafe
 public class CheckedArrayList<E> extends ArrayList<E> implements CheckedContainer<E>,
Cloneable {
     /**
      * Serial version UID for compatibility with different versions.
@@ -114,11 +100,6 @@ public class CheckedArrayList<E> extends
      * to the type specified at construction time. Subclasses can override this method
      * if they need to perform additional checks.
      *
-     * {@section Synchronization}
-     * This method is invoked <em>before</em> to get the synchronization {@linkplain
#getLock() lock}.
-     * This is different than the {@link #checkWritePermission()} method, which is invoked
inside the
-     * synchronized block.
-     *
      * @param  element the object to check, or {@code null}.
      * @throws IllegalArgumentException if the specified element can not be added to this
list.
      */
@@ -142,46 +123,25 @@ public class CheckedArrayList<E> extends
     }
 
     /**
-     * Checks if changes in this list are allowed. This method is automatically invoked
-     * after this list got the {@linkplain #getLock() lock} and before any operation that
-     * may change the content. If the write operation is allowed, then this method shall
-     * returns normally. Otherwise an {@link UnsupportedOperationException} is thrown.
-     *
-     * <p>The default implementation does nothing significant (see below), thus allowing
this list to
-     * be modified. Subclasses can override this method if they want to control write permissions.</p>
-     *
-     * {@note Actually the current implementation contains an <code>assert</code>
statement
-     * ensuring that the thread holds the lock. This is an implementation details that may
-     * change in any future version of the SIS library. Nevertheless methods that override
-     * this one are encouraged to invoke <code>super.checkWritePermission()</code>.}
+     * Checks if changes in this list are allowed. This method is automatically invoked before
any
+     * operation that may change the content. If the write operation is allowed, then this
method
+     * shall returns normally. Otherwise an {@link UnsupportedOperationException} is thrown.
+     *
+     * <p>The default implementation does nothing, thus allowing this list to be modified.
+     * Subclasses can override this method if they want to control write permissions.</p>
      *
      * @throws UnsupportedOperationException if this list is unmodifiable.
      */
     protected void checkWritePermission() throws UnsupportedOperationException {
-        assert Thread.holdsLock(getLock());
-    }
-
-    /**
-     * Returns the synchronization lock. The default implementation returns {@code this}.
-     *
-     * {@section Note for subclass implementors}
-     * Subclasses that override this method must be careful to update the lock reference
-     * (if needed) when this list is {@linkplain #clone() cloned}.
-     *
-     * @return The synchronization lock.
-     */
-    protected Object getLock() {
-        return this;
     }
 
     /**
-     * A synchronized iterator with a check for write permission prior element removal.
+     * An iterator with a check for write permission prior element removal.
      * This class wraps the iterator provided by {@link ArrayList#iterator()}, and is
      * also the base class for the wrapper around {@link ArrayList#listIterator()}.
      *
      * @see CheckedArrayList#iterator()
      */
-    @ThreadSafe
     @Decorator(Iterator.class)
     private class Iter<I extends Iterator<E>> implements Iterator<E> {
         /** The {@link ArrayList} iterator. */
@@ -195,31 +155,25 @@ public class CheckedArrayList<E> extends
         /** Returns {@code true} if there is more elements in the iteration. */
         @Override
         public final boolean hasNext() {
-            synchronized (getLock()) {
-                return iterator.hasNext();
-            }
+            return iterator.hasNext();
         }
 
         /** Returns the next element in the iteration. */
         @Override
         public final E next() throws NoSuchElementException {
-            synchronized (getLock()) {
-                return iterator.next();
-            }
+            return iterator.next();
         }
 
         /** Removes the previous element if the enclosing {@link CheckedArrayList} allows
write operations. */
         @Override
         public final void remove() throws UnsupportedOperationException {
-            synchronized (getLock()) {
-                checkWritePermission();
-                iterator.remove();
-            }
+            checkWritePermission();
+            iterator.remove();
         }
     }
 
     /**
-     * A synchronized list iterator with a check for write permission prior element removal.
+     * A list iterator with a check for write permission prior element removal.
      * This class wraps the iterator provided by {@link ArrayList#listIterator()}.
      *
      * @see CheckedArrayList#listIterator()
@@ -235,53 +189,41 @@ public class CheckedArrayList<E> extends
         /** Returns the index of the element to be returned by {@link #next()}. */
         @Override
         public int nextIndex() {
-            synchronized (getLock()) {
-                return iterator.nextIndex();
-            }
+            return iterator.nextIndex();
         }
 
         /** Returns the index of the element to be returned by {@link #previous()}. */
         @Override
         public int previousIndex() {
-            synchronized (getLock()) {
-                return iterator.previousIndex();
-            }
+            return iterator.previousIndex();
         }
 
         /** Returns {@code true} if there is elements before current position. */
         @Override
         public boolean hasPrevious() {
-            synchronized (getLock()) {
-                return iterator.hasPrevious();
-            }
+            return iterator.hasPrevious();
         }
 
         /** Returns the previous element in the iteration. */
         @Override
         public E previous() throws NoSuchElementException {
-            synchronized (getLock()) {
-                return iterator.previous();
-            }
+            return iterator.previous();
         }
 
         /** See the {@link CheckedArrayList#set(int, Object)} method contract. */
         @Override
         public void set(final E element) throws IllegalArgumentException, UnsupportedOperationException
{
             ensureValid(element);
-            synchronized (getLock()) {
-                checkWritePermission();
-                iterator.set(element);
-            }
+            checkWritePermission();
+            iterator.set(element);
         }
 
         /** See the {@link CheckedArrayList#add(Object)} method contract. */
         @Override
         public void add(final E element) throws IllegalArgumentException, UnsupportedOperationException
{
             ensureValid(element);
-            synchronized (getLock()) {
-                checkWritePermission();
-                iterator.add(element);
-            }
+            checkWritePermission();
+            iterator.add(element);
         }
     }
 
@@ -292,9 +234,7 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public Iterator<E> iterator() {
-        synchronized (getLock()) {
-            return new Iter<Iterator<E>>(super.iterator());
-        }
+        return new Iter<Iterator<E>>(super.iterator());
     }
 
     /**
@@ -305,9 +245,7 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public ListIterator<E> listIterator() {
-        synchronized (getLock()) {
-            return new ListIter(super.listIterator());
-        }
+        return new ListIter(super.listIterator());
     }
 
     /**
@@ -318,71 +256,7 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public ListIterator<E> listIterator(final int index) {
-        synchronized (getLock()) {
-            return new ListIter(super.listIterator(index));
-        }
-    }
-
-    /**
-     * Returns the number of elements in this list.
-     */
-    @Override
-    public int size() {
-        synchronized (getLock()) {
-            return super.size();
-        }
-    }
-
-    /**
-     * Returns {@code true} if this list contains no elements.
-     */
-    @Override
-    public boolean isEmpty() {
-        synchronized (getLock()) {
-            return super.isEmpty();
-        }
-    }
-
-    /**
-     * Returns {@code true} if this list contains the specified element.
-     */
-    @Override
-    public boolean contains(final Object o) {
-        synchronized (getLock()) {
-            return super.contains(o);
-        }
-    }
-
-    /**
-     * Returns the index of the first occurrence of the specified element in this list,
-     * or -1 if none.
-     */
-    @Override
-    public int indexOf(Object o) {
-        synchronized (getLock()) {
-            return super.indexOf(o);
-        }
-    }
-
-    /**
-     * Returns the index of the last occurrence of the specified element in this list,
-     * or -1 if none.
-     */
-    @Override
-    public int lastIndexOf(Object o) {
-        synchronized (getLock()) {
-            return super.lastIndexOf(o);
-        }
-    }
-
-    /**
-     * Returns the element at the specified position in this list.
-     */
-    @Override
-    public E get(int index) {
-        synchronized (getLock()) {
-            return super.get(index);
-        }
+        return new ListIter(super.listIterator(index));
     }
 
     /**
@@ -400,10 +274,8 @@ public class CheckedArrayList<E> extends
             throws IllegalArgumentException, UnsupportedOperationException
     {
         ensureValid(element);
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.set(index, element);
-        }
+        checkWritePermission();
+        return super.set(index, element);
     }
 
     /**
@@ -419,10 +291,8 @@ public class CheckedArrayList<E> extends
             throws IllegalArgumentException, UnsupportedOperationException
     {
         ensureValid(element);
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.add(element);
-        }
+        checkWritePermission();
+        return super.add(element);
     }
 
     /**
@@ -439,10 +309,8 @@ public class CheckedArrayList<E> extends
             throws IllegalArgumentException, UnsupportedOperationException
     {
         ensureValid(element);
-        synchronized (getLock()) {
-            checkWritePermission();
-            super.add(index, element);
-        }
+        checkWritePermission();
+        super.add(index, element);
     }
 
     /**
@@ -459,10 +327,8 @@ public class CheckedArrayList<E> extends
             throws IllegalArgumentException, UnsupportedOperationException
     {
         ensureValidCollection(collection);
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.addAll(collection);
-        }
+        checkWritePermission();
+        return super.addAll(collection);
     }
 
     /**
@@ -480,10 +346,8 @@ public class CheckedArrayList<E> extends
             throws IllegalArgumentException, UnsupportedOperationException
     {
         ensureValidCollection(collection);
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.addAll(index, collection);
-        }
+        checkWritePermission();
+        return super.addAll(index, collection);
     }
 
     /**
@@ -493,10 +357,8 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public E remove(int index) throws UnsupportedOperationException {
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.remove(index);
-        }
+        checkWritePermission();
+        return super.remove(index);
     }
 
     /**
@@ -506,10 +368,8 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public boolean remove(Object o) throws UnsupportedOperationException {
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.remove(o);
-        }
+        checkWritePermission();
+        return super.remove(o);
     }
 
     /**
@@ -519,10 +379,8 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public boolean removeAll(Collection<?> c) throws UnsupportedOperationException
{
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.removeAll(c);
-        }
+        checkWritePermission();
+        return super.removeAll(c);
     }
 
     /**
@@ -532,31 +390,8 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public boolean retainAll(Collection<?> c) throws UnsupportedOperationException
{
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.retainAll(c);
-        }
-    }
-
-    /**
-     * Trims the capacity to the list's current size.
-     */
-    @Override
-    public void trimToSize() {
-        synchronized (getLock()) {
-            super.trimToSize();
-        }
-    }
-
-    /**
-     * Increases the capacity, if necessary, to ensure that it can hold the given number
-     * of elements.
-     */
-    @Override
-    public void ensureCapacity(final int minCapacity) {
-        synchronized (getLock()) {
-            super.ensureCapacity(minCapacity);
-        }
+        checkWritePermission();
+        return super.retainAll(c);
     }
 
     /**
@@ -566,74 +401,7 @@ public class CheckedArrayList<E> extends
      */
     @Override
     public void clear() throws UnsupportedOperationException {
-        synchronized (getLock()) {
-            checkWritePermission();
-            super.clear();
-        }
-    }
-
-    /**
-     * Returns an array containing all of the elements in this list.
-     */
-    @Override
-    public Object[] toArray() {
-        synchronized (getLock()) {
-            return super.toArray();
-        }
-    }
-
-    /**
-     * Returns an array containing all of the elements in this list in proper sequence.
-     *
-     * @param <T> The type of array elements.
-     */
-    @Override
-    public <T> T[] toArray(T[] a) {
-        synchronized (getLock()) {
-            return super.toArray(a);
-        }
-    }
-
-    /**
-     * Returns a string representation of this list.
-     */
-    @Override
-    public String toString() {
-        synchronized (getLock()) {
-            return super.toString();
-        }
-    }
-
-    /**
-     * Compares the specified object with this list for equality.
-     */
-    @Override
-    public boolean equals(Object o) {
-        synchronized (getLock()) {
-            return super.equals(o);
-        }
-    }
-
-    /**
-     * Returns the hash code value for this list.
-     */
-    @Override
-    public int hashCode() {
-        synchronized (getLock()) {
-            return super.hashCode();
-        }
-    }
-
-    /**
-     * Returns a shallow copy of this list.
-     *
-     * @return A shallow copy of this list.
-     */
-    @Override
-    @SuppressWarnings("unchecked")
-    public CheckedArrayList<E> clone() {
-        synchronized (getLock()) {
-            return (CheckedArrayList<E>) super.clone();
-        }
+        checkWritePermission();
+        super.clear();
     }
 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedHashSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedHashSet.java?rev=1470197&r1=1470196&r2=1470197&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedHashSet.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedHashSet.java
[UTF-8] Sat Apr 20 17:16:11 2013
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.NoSuchElementException;
-import net.jcip.annotations.ThreadSafe;
 import org.apache.sis.util.Decorator;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.CheckedContainer;
@@ -31,29 +30,18 @@ import static org.apache.sis.util.Argume
 
 
 /**
- * A {@linkplain Collections#checkedSet(Set, Class) checked} and
- * {@linkplain Collections#synchronizedSet(Set) synchronized} {@link LinkedHashSet}.
+ * A {@linkplain Collections#checkedSet(Set, Class) checked} {@link LinkedHashSet}.
  * The type checks are performed at run-time in addition to the compile-time checks.
  *
  * <p>Using this class is similar to wrapping a {@link LinkedHashSet} using the methods
provided
  * in the standard {@link Collections} class, except for the following advantages:</p>
  *
  * <ul>
- *   <li>Avoid the two levels of indirection (for type check and synchronization).</li>
+ *   <li>Avoid one level of indirection.</li>
  *   <li>Checks for write permission.</li>
- *   <li>Overrideable methods for controlling the synchronization lock,
- *       type checks and write permission checks.</li>
+ *   <li>Overrideable methods for controlling the type checks and write permission
checks.</li>
  * </ul>
  *
- * The synchronization is provided mostly in order to prevent damages
- * to the set in case of concurrent access. It does <strong>not</strong> prevent
- * {@link java.util.ConcurrentModificationException} to be thrown during iterations,
- * unless the whole iteration is synchronized on this set {@linkplain #getLock() lock}.
- * For real concurrency, see the {@link java.util.concurrent} package instead.
- *
- * {@note The above is the reason why the name of this class emphases the <cite>checked</cite>
- *        aspect rather than the <cite>synchronized</cite> aspect of the set.}
- *
  * @param <E> The type of elements in the set.
  *
  * @author  Martin Desruisseaux (Geomatys)
@@ -62,9 +50,7 @@ import static org.apache.sis.util.Argume
  * @module
  *
  * @see Collections#checkedSet(Set, Class)
- * @see Collections#synchronizedSet(Set)
  */
-@ThreadSafe
 public class CheckedHashSet<E> extends LinkedHashSet<E> implements CheckedContainer<E>,
Cloneable {
     /**
      * Serial version UID for compatibility with different versions.
@@ -113,11 +99,6 @@ public class CheckedHashSet<E> extends L
      * to the type specified at construction time. Subclasses can override this method
      * if they need to perform additional checks.
      *
-     * {@section Synchronization}
-     * This method is invoked <em>before</em> to get the synchronization {@linkplain
#getLock() lock}.
-     * This is different than the {@link #checkWritePermission()} method, which is invoked
inside the
-     * synchronized block.
-     *
      * @param  element the object to check, or {@code null}.
      * @throws IllegalArgumentException if the specified element can not be added to this
set.
      */
@@ -141,45 +122,24 @@ public class CheckedHashSet<E> extends L
     }
 
     /**
-     * Checks if changes in this set are allowed. This method is automatically invoked
-     * after this set got the {@linkplain #getLock() lock} and before any operation that
-     * may change the content. If the write operation is allowed, then this method shall
-     * returns normally. Otherwise an {@link UnsupportedOperationException} is thrown.
-     *
-     * <p>The default implementation does nothing significant (see below), thus allowing
this set to
-     * be modified. Subclasses can override this method if they want to control write permissions.</p>
-     *
-     * {@note Actually the current implementation contains an <code>assert</code>
statement
-     *        ensuring that the thread holds the lock. This is an implementation details
that may
-     *        change in any future version of the SIS library. Nevertheless methods that
override
-     *        this one are encouraged to invoke <code>super.checkWritePermission()</code>.}
+     * Checks if changes in this set are allowed. This method is automatically invoked before
any
+     * operation that may change the content. If the write operation is allowed, then this
method
+     * shall returns normally. Otherwise an {@link UnsupportedOperationException} is thrown.
+     *
+     * <p>The default implementation does nothing, thus allowing this set to be modified.
+     * Subclasses can override this method if they want to control write permissions.</p>
      *
      * @throws UnsupportedOperationException if this set is unmodifiable.
      */
     protected void checkWritePermission() throws UnsupportedOperationException {
-        assert Thread.holdsLock(getLock());
-    }
-
-    /**
-     * Returns the synchronization lock. The default implementation returns {@code this}.
-     *
-     * {@section Note for subclass implementors}
-     * Subclasses that override this method must be careful to update the lock reference
-     * (if needed) when this set is {@linkplain #clone() cloned}.
-     *
-     * @return The synchronization lock.
-     */
-    protected Object getLock() {
-        return this;
     }
 
     /**
-     * A synchronized iterator with a check for write permission prior element removal.
+     * An iterator with a check for write permission prior element removal.
      * This class wraps the iterator provided by {@link LinkedHashSet#iterator()}.
      *
      * @see CheckedHashSet#iterator()
      */
-    @ThreadSafe
     @Decorator(Iterator.class)
     private final class Iter implements Iterator<E> {
         /** The {@link LinkedHashSet} iterator. */
@@ -193,26 +153,20 @@ public class CheckedHashSet<E> extends L
         /** Returns {@code true} if there is more elements in the iteration. */
         @Override
         public boolean hasNext() {
-            synchronized (getLock()) {
-                return iterator.hasNext();
-            }
+            return iterator.hasNext();
         }
 
         /** Returns the next element in the iteration. */
         @Override
         public E next() throws NoSuchElementException {
-            synchronized (getLock()) {
-                return iterator.next();
-            }
+            return iterator.next();
         }
 
         /** Removes the previous element if the enclosing {@link CheckedHashSet} allows write
operations. */
         @Override
         public void remove() throws UnsupportedOperationException {
-            synchronized (getLock()) {
-                checkWritePermission();
-                iterator.remove();
-            }
+            checkWritePermission();
+            iterator.remove();
         }
     }
 
@@ -223,39 +177,7 @@ public class CheckedHashSet<E> extends L
      */
     @Override
     public Iterator<E> iterator() {
-        synchronized (getLock()) {
-            return new Iter(super.iterator());
-        }
-    }
-
-    /**
-     * Returns the number of elements in this set.
-     */
-    @Override
-    public int size() {
-        synchronized (getLock()) {
-            return super.size();
-        }
-    }
-
-    /**
-     * Returns {@code true} if this set contains no elements.
-     */
-    @Override
-    public boolean isEmpty() {
-        synchronized (getLock()) {
-            return super.isEmpty();
-        }
-    }
-
-    /**
-     * Returns {@code true} if this set contains the specified element.
-     */
-    @Override
-    public boolean contains(final Object o) {
-        synchronized (getLock()) {
-            return super.contains(o);
-        }
+        return new Iter(super.iterator());
     }
 
     /**
@@ -271,10 +193,8 @@ public class CheckedHashSet<E> extends L
             throws IllegalArgumentException, UnsupportedOperationException
     {
         ensureValid(element);
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.add(element);
-        }
+        checkWritePermission();
+        return super.add(element);
     }
 
     /**
@@ -290,10 +210,8 @@ public class CheckedHashSet<E> extends L
             throws IllegalArgumentException, UnsupportedOperationException
     {
         ensureValidCollection(collection);
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.addAll(collection);
-        }
+        checkWritePermission();
+        return super.addAll(collection);
     }
 
     /**
@@ -303,10 +221,8 @@ public class CheckedHashSet<E> extends L
      */
     @Override
     public boolean remove(Object o) throws UnsupportedOperationException {
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.remove(o);
-        }
+        checkWritePermission();
+        return super.remove(o);
     }
 
     /**
@@ -316,10 +232,8 @@ public class CheckedHashSet<E> extends L
      */
     @Override
     public boolean removeAll(Collection<?> c) throws UnsupportedOperationException
{
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.removeAll(c);
-        }
+        checkWritePermission();
+        return super.removeAll(c);
     }
 
     /**
@@ -329,10 +243,8 @@ public class CheckedHashSet<E> extends L
      */
     @Override
     public boolean retainAll(Collection<?> c) throws UnsupportedOperationException
{
-        synchronized (getLock()) {
-            checkWritePermission();
-            return super.retainAll(c);
-        }
+        checkWritePermission();
+        return super.retainAll(c);
     }
 
     /**
@@ -342,74 +254,7 @@ public class CheckedHashSet<E> extends L
      */
     @Override
     public void clear() throws UnsupportedOperationException {
-        synchronized (getLock()) {
-            checkWritePermission();
-            super.clear();
-        }
-    }
-
-    /**
-     * Returns an array containing all of the elements in this set.
-     */
-    @Override
-    public Object[] toArray() {
-        synchronized (getLock()) {
-            return super.toArray();
-        }
-    }
-
-    /**
-     * Returns an array containing all of the elements in this set.
-     *
-     * @param <T> The type of array elements.
-     */
-    @Override
-    public <T> T[] toArray(T[] a) {
-        synchronized (getLock()) {
-            return super.toArray(a);
-        }
-    }
-
-    /**
-     * Returns a string representation of this set.
-     */
-    @Override
-    public String toString() {
-        synchronized (getLock()) {
-            return super.toString();
-        }
-    }
-
-    /**
-     * Compares the specified object with this set for equality.
-     */
-    @Override
-    public boolean equals(Object o) {
-        synchronized (getLock()) {
-            return super.equals(o);
-        }
-    }
-
-    /**
-     * Returns the hash code value for this set.
-     */
-    @Override
-    public int hashCode() {
-        synchronized (getLock()) {
-            return super.hashCode();
-        }
-    }
-
-    /**
-     * Returns a shallow copy of this set.
-     *
-     * @return A shallow copy of this set.
-     */
-    @Override
-    @SuppressWarnings("unchecked")
-    public CheckedHashSet<E> clone() {
-        synchronized (getLock()) {
-            return (CheckedHashSet<E>) super.clone();
-        }
+        checkWritePermission();
+        super.clear();
     }
 }



Mime
View raw message