Another series of fixes from reverse JAPI...

ChangeLog:

2008-03-11  Andrew John Hughes  <[EMAIL PROTECTED]>

        * java/beans/beancontext/BeanContextServicesSupport.java:
        (BCSSProxyServiceProvider(BeanContextServiceProvider)):
        Add package-private constructor.
        * java/lang/StringBuffer.java:
        (ensureCapacity_unsynchronized(int)): Make package-private.
        * java/rmi/activation/Activatable.java:
        (export(ActivationID, Remote, int, RMIServerSocketFactory)):
        Make private.
        (makeId(ActivationID)): Likewise.
        * java/security/MessageDigest.java:
        (update(ByteBuffer)): Make final.
        * java/security/cert/PolicyQualifierInfo.java:
        (getPolicyQualifierId()): Likewise.
        (getEncoded()): Likewise.
        (getPolicyQualifier()): Likewise.
        * java/text/DateFormat.java:
        (ISO_YEAR_FIELD): Removed.
        (LOCALIZED_DAY_OF_WEEK_FIELD): Likewise.
        (EXTENDED_YEAR_FIELD): Likewise.
        (MODIFIED_JULIAN_DAY_FIELD): Likewise.
        (MILLISECOND_IN_DAY_FIELD): Likewise.
        (RFC822_TIMEZONE_FIELD): Likewise.
        (Field.ISO_YEAR_FIELD): Likewise.
        (Field.LOCALIZED_DAY_OF_WEEK_FIELD): Likewise.
        (Field.EXTENDED_YEAR_FIELD): Likewise.
        (Field.MODIFIED_JULIAN_DAY_FIELD): Likewise.
        (Field.MILLISECOND_IN_DAY_FIELD): Likewise.
        (Field.RFC822_TIMEZONE_FIELD): Likewise.        
        * java/text/DecimalFormat.java:
        (format(Object,StringBuffer,FieldPosition)): Make final.
        * java/text/Format.java:
        (Format()): Make protected.
        * java/text/NumberFormat.java:
        (NumberFormat()): Likewise.
        * java/text/SimpleDateFormat.java:
        Remove code using RFC822_TIMEZONE_FIELD.
        * java/util/Stack.java:
        Use array of Objects rather than instances of T.
        * java/util/Vector.java:
        Likewise.
        * java/util/concurrent/CopyOnWriteArrayList.java:
        Don't extend AbstractList.
        (containsAll(Collection)): Implemented.
        (listIterator()): Likewise.
        (subList(int,int)): Likewise.
        * java/util/zip/Deflater.java:
        (getTotalIn()): Remove deprecation.
        (getTotalOut()): Likewise.
        * java/util/zip/Inflater.java,
        (getTotalIn()): Likewise.
        (getTotalOut()): Likewise.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: java/beans/beancontext/BeanContextServicesSupport.java
===================================================================
RCS file: /sources/classpath/classpath/java/beans/beancontext/BeanContextServicesSupport.java,v
retrieving revision 1.16
diff -u -3 -p -u -r1.16 BeanContextServicesSupport.java
--- java/beans/beancontext/BeanContextServicesSupport.java	7 Jan 2008 21:11:24 -0000	1.16
+++ java/beans/beancontext/BeanContextServicesSupport.java	12 Mar 2008 23:24:35 -0000
@@ -86,6 +86,11 @@ public class BeanContextServicesSupport
 
     private BeanContextServiceProvider provider;
 
+    BCSSProxyServiceProvider(BeanContextServiceProvider p)
+    {
+      provider = p;
+    }
+
     public Iterator getCurrentServiceSelectors (BeanContextServices bcs,
                                                 Class serviceClass)
     {
Index: java/lang/StringBuffer.java
===================================================================
RCS file: /sources/classpath/classpath/java/lang/StringBuffer.java,v
retrieving revision 1.36
diff -u -3 -p -u -r1.36 StringBuffer.java
--- java/lang/StringBuffer.java	26 Feb 2008 23:26:00 -0000	1.36
+++ java/lang/StringBuffer.java	12 Mar 2008 23:24:35 -0000
@@ -955,7 +955,7 @@ public final class StringBuffer
    * @param minimumCapacity the minimum capacity
    * @see #ensureCapacity(int)
    */
-  protected void ensureCapacity_unsynchronized(int minimumCapacity)
+  void ensureCapacity_unsynchronized(int minimumCapacity)
   {
     if (shared || minimumCapacity > value.length)
       {
Index: java/rmi/activation/Activatable.java
===================================================================
RCS file: /sources/classpath/classpath/java/rmi/activation/Activatable.java,v
retrieving revision 1.11
diff -u -3 -p -u -r1.11 Activatable.java
--- java/rmi/activation/Activatable.java	14 May 2007 02:20:01 -0000	1.11
+++ java/rmi/activation/Activatable.java	12 Mar 2008 23:24:36 -0000
@@ -462,8 +462,8 @@ public abstract class Activatable
    *          means anonymous port.
    * @param serverSocketFactory the server socket factory
    */
-  public static Remote export(ActivationID id, Remote obj, int port,
-                              RMIServerSocketFactory serverSocketFactory)
+  private static Remote export(ActivationID id, Remote obj, int port,
+			       RMIServerSocketFactory serverSocketFactory)
       throws RemoteException
   {
     ActivatableServerRef sref = null;
@@ -479,7 +479,7 @@ public abstract class Activatable
    * 
    * @return the object id
    */
-  public static ObjID makeId(ActivationID aid)
+  private static ObjID makeId(ActivationID aid)
   {
     ObjID id = new ObjID(0);
     
Index: java/security/MessageDigest.java
===================================================================
RCS file: /sources/classpath/classpath/java/security/MessageDigest.java,v
retrieving revision 1.17
diff -u -3 -p -u -r1.17 MessageDigest.java
--- java/security/MessageDigest.java	10 Dec 2006 20:25:45 -0000	1.17
+++ java/security/MessageDigest.java	12 Mar 2008 23:24:36 -0000
@@ -235,7 +235,7 @@ public abstract class MessageDigest exte
    * @param input The input byte buffer.
    * @since 1.5
    */
-  public void update (ByteBuffer input)
+  public final void update (ByteBuffer input)
   {
     engineUpdate (input);
   }
Index: java/security/cert/PolicyQualifierInfo.java
===================================================================
RCS file: /sources/classpath/classpath/java/security/cert/PolicyQualifierInfo.java,v
retrieving revision 1.6
diff -u -3 -p -u -r1.6 PolicyQualifierInfo.java
--- java/security/cert/PolicyQualifierInfo.java	10 Dec 2006 20:25:45 -0000	1.6
+++ java/security/cert/PolicyQualifierInfo.java	12 Mar 2008 23:24:37 -0000
@@ -124,7 +124,7 @@ PolicyQualifierId ::= OBJECT IDENTIFIER
    *
    * @return This structure's OID field.
    */
-  public String getPolicyQualifierId()
+  public final String getPolicyQualifierId()
   {
     return oid.toString();
   }
@@ -137,7 +137,7 @@ PolicyQualifierId ::= OBJECT IDENTIFIER
    *
    * @return The encoded form.
    */
-  public byte[] getEncoded()
+  public final byte[] getEncoded()
   {
     return (byte[]) encoded.clone();
   }
@@ -149,7 +149,7 @@ PolicyQualifierId ::= OBJECT IDENTIFIER
    *
    * @return The encoded qualifier.
    */
-  public byte[] getPolicyQualifier()
+  public final byte[] getPolicyQualifier()
   {
     if (qualifier == null)
       return new byte[0];
Index: java/text/DateFormat.java
===================================================================
RCS file: /sources/classpath/classpath/java/text/DateFormat.java,v
retrieving revision 1.24
diff -u -3 -p -u -r1.24 DateFormat.java
--- java/text/DateFormat.java	8 Jan 2007 00:41:24 -0000	1.24
+++ java/text/DateFormat.java	12 Mar 2008 23:24:38 -0000
@@ -219,80 +219,6 @@ public abstract class DateFormat extends
    * In the U.S. locale, this is 'z'.
    */
   public static final int TIMEZONE_FIELD = 17;
-  /**
-   * Represents the position of the ISO year
-   * pattern character in the array of
-   * localized pattern characters.
-   * In the U.S. locale, this is 'Y'.
-   * This is a GNU extension in accordance with
-   * the CLDR data used.  This value may
-   * differ from the normal year value.
-   */
-  public static final int ISO_YEAR_FIELD = 18;
-  /**
-   * Represents the position of the localized
-   * day of the week pattern character in the
-   * array of localized pattern characters.
-   * In the U.S. locale, this is 'e'.
-   * This is a GNU extension in accordance with
-   * the CLDR data used.  This value only
-   * differs from the day of the week with
-   * numeric formatting, in which case the
-   * locale's first day of the week is used.
-   */
-  public static final int LOCALIZED_DAY_OF_WEEK_FIELD = 19;
-  /**
-   * Represents the position of the extended year
-   * pattern character in the array of
-   * localized pattern characters.
-   * In the U.S. locale, this is 'u'.
-   * This is a GNU extension in accordance with
-   * the CLDR data used.  This value modifies
-   * the year value, so as to incorporate the era.
-   * For example, in the Gregorian calendar system,
-   * the extended year is negative instead of being
-   * marked as BC.
-   */
-  public static final int EXTENDED_YEAR_FIELD = 20;
-  /**
-   * Represents the position of the modified Julian
-   * day pattern character in the array of
-   * localized pattern characters.
-   * In the U.S. locale, this is 'g'.
-   * This is a GNU extension in accordance with
-   * the CLDR data used.  This value differs
-   * from the standard Julian day in that days
-   * are marked from midnight onwards rather than
-   * noon, and the local time zone affects the value.
-   * In simple terms, it can be thought of as all
-   * the date fields represented as a single number.
-   */
-  public static final int MODIFIED_JULIAN_DAY_FIELD = 21;
-  /**
-   * Represents the position of the millisecond
-   * in the day pattern character in the array of
-   * localized pattern characters.
-   * In the U.S. locale, this is 'A'.
-   * This is a GNU extension in accordance with
-   * the CLDR data used.  This value represents
-   * all the time fields (excluding the time zone)
-   * numerically, giving the number of milliseconds
-   * into the day (e.g. 10 in the morning would
-   * be 10 * 60 * 60 * 1000).  Any daylight savings
-   * offset also affects this value.
-   */
-  public static final int MILLISECOND_IN_DAY_FIELD = 22;
-  /**
-   * Represents the position of the RFC822
-   * timezone pattern character in the array of
-   * localized pattern characters.
-   * In the U.S. locale, this is 'Z'.
-   * This is a GNU extension in accordance with
-   * the CLDR data used.  The value is the offset
-   * of the current time from GMT e.g. -0500 would
-   * be five hours prior to GMT.
-   */
-  public static final int RFC822_TIMEZONE_FIELD = 23;
 
   public static class Field extends Format.Field
   {
@@ -336,18 +262,6 @@ public abstract class DateFormat extends
 	= new Field("hour0", Calendar.HOUR);
     public static final DateFormat.Field TIME_ZONE
 	= new Field("timezone", Calendar.ZONE_OFFSET);
-    public static final DateFormat.Field ISO_YEAR
-	= new Field("iso year", Calendar.YEAR);
-    public static final DateFormat.Field LOCALIZED_DAY_OF_WEEK
-	= new Field("localized day of week", Calendar.DAY_OF_WEEK);
-    public static final DateFormat.Field EXTENDED_YEAR
-      = new Field("extended year", Calendar.YEAR);
-    public static final DateFormat.Field MODIFIED_JULIAN_DAY
-	= new Field("julian day", -1);
-    public static final DateFormat.Field MILLISECOND_IN_DAY
-	= new Field("millisecond in day", -1);
-    public static final DateFormat.Field RFC822_TIME_ZONE
-	= new Field("rfc822 timezone", Calendar.ZONE_OFFSET);
 
     static final DateFormat.Field[] allFields =
     {
@@ -355,9 +269,7 @@ public abstract class DateFormat extends
       HOUR_OF_DAY0, MINUTE, SECOND, MILLISECOND,
       DAY_OF_WEEK, DAY_OF_YEAR, DAY_OF_WEEK_IN_MONTH,
       WEEK_OF_YEAR, WEEK_OF_MONTH, AM_PM, HOUR1, HOUR0,
-      TIME_ZONE, ISO_YEAR, LOCALIZED_DAY_OF_WEEK,
-      EXTENDED_YEAR, MODIFIED_JULIAN_DAY, MILLISECOND_IN_DAY,
-      RFC822_TIME_ZONE
+      TIME_ZONE
     };
 
     // For deserialization
Index: java/text/DecimalFormat.java
===================================================================
RCS file: /sources/classpath/classpath/java/text/DecimalFormat.java,v
retrieving revision 1.34
diff -u -3 -p -u -r1.34 DecimalFormat.java
--- java/text/DecimalFormat.java	27 Oct 2007 23:33:04 -0000	1.34
+++ java/text/DecimalFormat.java	12 Mar 2008 23:24:39 -0000
@@ -310,7 +310,7 @@ public class DecimalFormat extends Numbe
    * field. If used on output defines the offsets of the alignment field.
    * @return The String representation of this long.
    */
-  public StringBuffer format(Object obj, StringBuffer sbuf, FieldPosition pos)
+  public final StringBuffer format(Object obj, StringBuffer sbuf, FieldPosition pos)
   {
     if (obj instanceof BigInteger)
       {
Index: java/text/Format.java
===================================================================
RCS file: /sources/classpath/classpath/java/text/Format.java,v
retrieving revision 1.16
diff -u -3 -p -u -r1.16 Format.java
--- java/text/Format.java	2 Jul 2005 20:32:41 -0000	1.16
+++ java/text/Format.java	12 Mar 2008 23:24:39 -0000
@@ -81,7 +81,7 @@ public abstract class Format implements 
    * It performs no actions, but acts as a default constructor for
    * subclasses.
    */
-  public Format ()
+  protected Format ()
   {
   }
 
Index: java/text/NumberFormat.java
===================================================================
RCS file: /sources/classpath/classpath/java/text/NumberFormat.java,v
retrieving revision 1.23
diff -u -3 -p -u -r1.23 NumberFormat.java
--- java/text/NumberFormat.java	8 Jan 2007 00:41:24 -0000	1.23
+++ java/text/NumberFormat.java	12 Mar 2008 23:24:39 -0000
@@ -653,7 +653,7 @@ public abstract class NumberFormat exten
   /**
    * This is a default constructor for use by subclasses.
    */
-  public NumberFormat ()
+  protected NumberFormat ()
   {
   }
 
Index: java/text/SimpleDateFormat.java
===================================================================
RCS file: /sources/classpath/classpath/java/text/SimpleDateFormat.java,v
retrieving revision 1.56
diff -u -3 -p -u -r1.56 SimpleDateFormat.java
--- java/text/SimpleDateFormat.java	5 Feb 2008 14:59:05 -0000	1.56
+++ java/text/SimpleDateFormat.java	12 Mar 2008 23:24:40 -0000
@@ -801,18 +801,6 @@ public class SimpleDateFormat extends Da
 		  (isDST, cf.getSize() > 3 ? TimeZone.LONG : TimeZone.SHORT);
 		buffer.append (zoneID);
 		break;
-	      case RFC822_TIMEZONE_FIELD:
-		buffer.setDefaultAttribute(DateFormat.Field.RFC822_TIME_ZONE);
-		int pureMinutes = (calendar.get(Calendar.ZONE_OFFSET) +
-				   calendar.get(Calendar.DST_OFFSET)) / (1000 * 60);
-		String sign = (pureMinutes < 0) ? "-" : "+";
-                pureMinutes = Math.abs(pureMinutes);
-		int hours = pureMinutes / 60;
-		int minutes = pureMinutes % 60;
-		buffer.append(sign);
-		withLeadingZeros(hours, 2, buffer);
-		withLeadingZeros(minutes, 2, buffer);
-		break;
 	      default:
 		throw new IllegalArgumentException ("Illegal pattern character " +
 						    cf.getCharacter());
Index: java/util/Stack.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/Stack.java,v
retrieving revision 1.12
diff -u -3 -p -u -r1.12 Stack.java
--- java/util/Stack.java	10 Dec 2006 20:25:46 -0000	1.12
+++ java/util/Stack.java	12 Mar 2008 23:24:40 -0000
@@ -102,13 +102,14 @@ public class Stack<T> extends Vector<T>
    * @return the Object popped from the stack
    * @throws EmptyStackException if the stack is empty
    */
+  @SuppressWarnings("unchecked")
   public synchronized T pop()
   {
     if (elementCount == 0)
       throw new EmptyStackException();
 
     modCount++;
-    T obj = elementData[--elementCount];
+    T obj = (T) elementData[--elementCount];
 
     // Set topmost element to null to assist the gc in cleanup.
     elementData[elementCount] = null;
@@ -121,12 +122,13 @@ public class Stack<T> extends Vector<T>
    * @return the top Object on the stack
    * @throws EmptyStackException if the stack is empty
    */
+  @SuppressWarnings("unchecked")
   public synchronized T peek()
   {
     if (elementCount == 0)
       throw new EmptyStackException();
 
-    return elementData[elementCount - 1];
+    return (T) elementData[elementCount - 1];
   }
 
   /**
Index: java/util/Vector.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/Vector.java,v
retrieving revision 1.30
diff -u -3 -p -u -r1.30 Vector.java
--- java/util/Vector.java	10 Dec 2006 20:25:46 -0000	1.30
+++ java/util/Vector.java	12 Mar 2008 23:24:40 -0000
@@ -95,7 +95,7 @@ public class Vector<T> extends AbstractL
    * in positions 0 through elementCount - 1, and all remaining slots are null.
    * @serial the elements
    */
-  protected T[] elementData;
+  protected Object[] elementData;
 
   /**
    * The number of elements currently in the vector, also returned by
@@ -133,7 +133,7 @@ public class Vector<T> extends AbstractL
   public Vector(Collection<? extends T> c)
   {
     elementCount = c.size();
-    elementData = c.toArray((T[]) new Object[elementCount]);
+    elementData = c.toArray(new Object[elementCount]);
   }
 
   /**
@@ -149,7 +149,7 @@ public class Vector<T> extends AbstractL
   {
     if (initialCapacity < 0)
       throw new IllegalArgumentException();
-    elementData = (T[]) new Object[initialCapacity];
+    elementData = new Object[initialCapacity];
     this.capacityIncrement = capacityIncrement;
   }
 
@@ -295,11 +295,12 @@ public class Vector<T> extends AbstractL
         return i < elementCount;
       }
 
+      @SuppressWarnings("unchecked")
       public T nextElement()
       {
         if (i >= elementCount)
           throw new NoSuchElementException();
-        return elementData[i++];
+        return (T) elementData[i++];
       }
     };
   }
@@ -385,10 +386,11 @@ public class Vector<T> extends AbstractL
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
    * @see #get(int)
    */
+  @SuppressWarnings("unchecked")
   public synchronized T elementAt(int index)
   {
     checkBoundExclusive(index);
-    return elementData[index];
+    return (T) elementData[index];
   }
 
   /**
@@ -397,12 +399,13 @@ public class Vector<T> extends AbstractL
    * @return the first Object in the Vector
    * @throws NoSuchElementException the Vector is empty
    */
+  @SuppressWarnings("unchecked")
   public synchronized T firstElement()
   {
     if (elementCount == 0)
       throw new NoSuchElementException();
 
-    return elementData[0];
+    return (T) elementData[0];
   }
 
   /**
@@ -411,12 +414,13 @@ public class Vector<T> extends AbstractL
    * @return the last Object in the Vector
    * @throws NoSuchElementException the Vector is empty
    */
+  @SuppressWarnings("unchecked")
   public synchronized T lastElement()
   {
     if (elementCount == 0)
       throw new NoSuchElementException();
 
-    return elementData[elementCount - 1];
+    return (T) elementData[elementCount - 1];
   }
 
   /**
@@ -604,10 +608,11 @@ public class Vector<T> extends AbstractL
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
    * @since 1.2
    */
+  @SuppressWarnings("unchecked")
   public synchronized T set(int index, T element)
   {
     checkBoundExclusive(index);
-    T temp = elementData[index];
+    T temp = (T) elementData[index];
     elementData[index] = element;
     return temp;
   }
@@ -660,10 +665,11 @@ public class Vector<T> extends AbstractL
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
    * @since 1.2
    */
+  @SuppressWarnings("unchecked")
   public synchronized T remove(int index)
   {
     checkBoundExclusive(index);
-    T temp = elementData[index];
+    T temp = (T) elementData[index];
     modCount++;
     elementCount--;
     if (index < elementCount)
Index: java/util/concurrent/CopyOnWriteArrayList.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/concurrent/CopyOnWriteArrayList.java,v
retrieving revision 1.5
diff -u -3 -p -u -r1.5 CopyOnWriteArrayList.java
--- java/util/concurrent/CopyOnWriteArrayList.java	24 Nov 2007 22:31:07 -0000	1.5
+++ java/util/concurrent/CopyOnWriteArrayList.java	12 Mar 2008 23:24:40 -0000
@@ -46,9 +46,11 @@ import java.lang.reflect.Array;
 
 import java.util.AbstractList;
 import java.util.Collection;
+import java.util.ConcurrentModificationException;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.NoSuchElementException;
 import java.util.RandomAccess;
 
 /**
@@ -94,8 +96,8 @@ import java.util.RandomAccess;
  * 
  * @since 1.5
  */
-public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
-    List<E>, RandomAccess, Cloneable, Serializable
+public class CopyOnWriteArrayList<E> 
+  implements List<E>, RandomAccess, Cloneable, Serializable
 {
   /**
    * 
@@ -180,6 +182,28 @@ public class CopyOnWriteArrayList<E> ext
   }
 
   /**
+   * Tests whether this collection contains all the elements in a given
+   * collection. This implementation iterates over the given collection,
+   * testing whether each element is contained in this collection. If any one
+   * is not, false is returned. Otherwise true is returned.
+   *
+   * @param c the collection to test against
+   * @return true if this collection contains all the elements in the given
+   *         collection
+   * @throws NullPointerException if the given collection is null
+   * @see #contains(Object)
+   */
+  public boolean containsAll(Collection<?> c)
+  {
+    Iterator<?> itr = c.iterator();
+    int pos = c.size();
+    while (--pos >= 0)
+      if (!contains(itr.next()))
+        return false;
+    return true;
+  }
+
+  /**
    * Returns the lowest index at which element appears in this List, or -1 if it
    * does not appear.
    * 
@@ -711,6 +735,24 @@ public class CopyOnWriteArrayList<E> ext
    * 
    * @return a ListIterator containing the elements of this list in sequence.
    */
+  public ListIterator<E> listIterator()
+  {
+    return listIterator(0);
+  }
+
+  /**
+   * Return a ListIterator over the elements of this list starting at
+   * the specified index.  An initial call to [EMAIL PROTECTED] next()} will thus
+   * return the element at [EMAIL PROTECTED] index}, while an initial call to
+   * [EMAIL PROTECTED] previous()} will return the element at [EMAIL PROTECTED] index-1}.  The
+   * Iterator uses a snapshot of the state of the internal storage
+   * at the moment this method is called and does <strong>not</strong> support
+   * update operations, so no synchronization is needed to traverse the
+   * iterator.
+   * 
+   * @param index the index at which to start iterating.
+   * @return a ListIterator containing the elements of this list in sequence.
+   */
   public ListIterator<E> listIterator(final int index)
   {
     if (index < 0 || index > size())
@@ -783,6 +825,483 @@ public class CopyOnWriteArrayList<E> ext
   }
   
   /**
+   * Obtain a List view of a subsection of this list, from fromIndex
+   * (inclusive) to toIndex (exclusive). If the two indices are equal, the
+   * sublist is empty. The returned list should be modifiable if and only
+   * if this list is modifiable. Changes to the returned list should be
+   * reflected in this list. If this list is structurally modified in
+   * any way other than through the returned list, the result of any subsequent
+   * operations on the returned list is undefined.
+   * <p>
+   *
+   * This implementation returns a subclass of AbstractList. It stores, in
+   * private fields, the offset and size of the sublist, and the expected
+   * modCount of the backing list. If the backing list implements RandomAccess,
+   * the sublist will also.
+   * <p>
+   *
+   * The subclass's <code>set(int, Object)</code>, <code>get(int)</code>,
+   * <code>add(int, Object)</code>, <code>remove(int)</code>,
+   * <code>addAll(int, Collection)</code> and
+   * <code>removeRange(int, int)</code> methods all delegate to the
+   * corresponding methods on the backing abstract list, after
+   * bounds-checking the index and adjusting for the offset. The
+   * <code>addAll(Collection c)</code> method merely returns addAll(size, c).
+   * The <code>listIterator(int)</code> method returns a "wrapper object"
+   * over a list iterator on the backing list, which is created with the
+   * corresponding method on the backing list. The <code>iterator()</code>
+   * method merely returns listIterator(), and the <code>size()</code> method
+   * merely returns the subclass's size field.
+   * <p>
+   *
+   * All methods first check to see if the actual modCount of the backing
+   * list is equal to its expected value, and throw a
+   * ConcurrentModificationException if it is not. 
+   *
+   * @param fromIndex the index that the returned list should start from
+   *        (inclusive)
+   * @param toIndex the index that the returned list should go to (exclusive)
+   * @return a List backed by a subsection of this list
+   * @throws IndexOutOfBoundsException if fromIndex &lt; 0
+   *         || toIndex &gt; size()
+   * @throws IllegalArgumentException if fromIndex &gt; toIndex
+   * @see ConcurrentModificationException
+   * @see RandomAccess
+   */
+  public List<E> subList(int fromIndex, int toIndex)
+  {
+    // This follows the specification of AbstractList, but is inconsistent
+    // with the one in List. Don't you love Sun's inconsistencies?
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException(fromIndex + " > " + toIndex);
+    if (fromIndex < 0 || toIndex > size())
+      throw new IndexOutOfBoundsException();
+
+    if (this instanceof RandomAccess)
+      return new RandomAccessSubList<E>(this, fromIndex, toIndex);
+    return new SubList<E>(this, fromIndex, toIndex);
+  }
+
+  /**
+   * This class follows the implementation requirements set forth in
+   * [EMAIL PROTECTED] AbstractList#subList(int, int)}. It matches Sun's implementation
+   * by using a non-public top-level class in the same package.
+   *
+   * @author Original author unknown
+   * @author Eric Blake ([EMAIL PROTECTED])
+   */
+  private static class SubList<E> 
+    extends AbstractList<E>
+  {
+    // Package visible, for use by iterator.
+    /** The original list. */
+    final CopyOnWriteArrayList<E> backingList;
+    /** The index of the first element of the sublist. */
+    final int offset;
+    /** The size of the sublist. */
+    int size;
+    /** The backing data */
+    E[] data;
+
+    /**
+     * Construct the sublist.
+     *
+     * @param backing the list this comes from
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     */
+    SubList(CopyOnWriteArrayList<E> backing, int fromIndex, int toIndex)
+    {
+      backingList = backing;
+      data = backing.data;
+      offset = fromIndex;
+      size = toIndex - fromIndex;
+    }
+    
+    /**
+     * This method checks the two modCount fields to ensure that there has
+     * not been a concurrent modification, returning if all is okay.
+     *
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     */
+    // This can be inlined. Package visible, for use by iterator.
+    void checkMod()
+    {
+      if (data != backingList.data)
+	throw new ConcurrentModificationException();
+    }
+    
+    /**
+     * This method checks that a value is between 0 and size (inclusive). If
+     * it is not, an exception is thrown.
+     *
+     * @param index the value to check
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+     */
+    // This will get inlined, since it is private.
+    private void checkBoundsInclusive(int index)
+    {
+      if (index < 0 || index > size)
+	throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+					    + size);
+    }
+    
+    /**
+     * This method checks that a value is between 0 (inclusive) and size
+     * (exclusive). If it is not, an exception is thrown.
+     *
+     * @param index the value to check
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     */
+    // This will get inlined, since it is private.
+    private void checkBoundsExclusive(int index)
+    {
+      if (index < 0 || index >= size)
+	throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+					    + size);
+    }
+    
+    /**
+     * Specified by AbstractList.subList to return the private field size.
+     *
+     * @return the sublist size
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     */
+    public int size()
+    {
+      checkMod();
+      return size;
+    }
+    
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to modify
+     * @param o the new value
+     * @return the old value
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the set operation
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     * @throws ClassCastException if o cannot be added to the backing list due
+     *         to its type
+     * @throws IllegalArgumentException if o cannot be added to the backing list
+     *         for some other reason
+     */
+    public E set(int index, E o)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      return backingList.set(index + offset, o);
+    }
+    
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to get from
+     * @return the object at that location
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     */
+    public E get(int index)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      return backingList.get(index + offset);
+    }
+    
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the index to insert at
+     * @param o the object to add
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the add operation.
+     * @throws ClassCastException if o cannot be added to the backing list due
+     *         to its type.
+     * @throws IllegalArgumentException if o cannot be added to the backing
+     *         list for some other reason.
+     */
+    public void add(int index, E o)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+      backingList.add(index + offset, o);
+      size++;
+    }
+    
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the index to remove
+     * @return the removed object
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the remove operation
+     */
+    public E remove(int index)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      E o = backingList.remove(index + offset);
+      size--;
+      return o;
+    }
+        
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to insert at
+     * @param c the collection to insert
+     * @return true if this list was modified, in other words, c is non-empty
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+     * @throws UnsupportedOperationException if this list does not support the
+     *         addAll operation
+     * @throws ClassCastException if some element of c cannot be added to this
+     *         list due to its type
+     * @throws IllegalArgumentException if some element of c cannot be added
+     *         to this list for some other reason
+     * @throws NullPointerException if the specified collection is null
+     */
+    public boolean addAll(int index, Collection<? extends E> c)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+      int csize = c.size();
+      boolean result = backingList.addAll(offset + index, c);
+      size += csize;
+      return result;
+    }
+    
+    /**
+     * Specified by AbstractList.subList to return addAll(size, c).
+     *
+     * @param c the collection to insert
+     * @return true if this list was modified, in other words, c is non-empty
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if this list does not support the
+     *         addAll operation
+     * @throws ClassCastException if some element of c cannot be added to this
+     *         list due to its type
+     * @throws IllegalArgumentException if some element of c cannot be added
+     *         to this list for some other reason
+     * @throws NullPointerException if the specified collection is null
+     */
+    public boolean addAll(Collection<? extends E> c)
+    {
+      return addAll(size, c);
+    }
+    
+    /**
+     * Specified by AbstractList.subList to return listIterator().
+     *
+     * @return an iterator over the sublist
+     */
+    public Iterator<E> iterator()
+    {
+      return listIterator();
+    }
+    
+    /**
+     * Specified by AbstractList.subList to return a wrapper around the
+     * backing list's iterator.
+     *
+     * @param index the start location of the iterator
+     * @return a list iterator over the sublist
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if the value is out of range
+     */
+    public ListIterator<E> listIterator(final int index)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+      
+      return new ListIterator<E>()
+	{
+	  private final ListIterator<E> i
+	    = backingList.listIterator(index + offset);
+	  private int position = index;
+	  
+	  /**
+	   * Tests to see if there are any more objects to
+	   * return.
+	   *
+	   * @return True if the end of the list has not yet been
+	   *         reached.
+	   */
+	  public boolean hasNext()
+	  {
+	      return position < size;
+	  }
+	  
+	  /**
+	   * Tests to see if there are objects prior to the
+	   * current position in the list.
+	   *
+	   * @return True if objects exist prior to the current
+	   *         position of the iterator.
+	   */
+	  public boolean hasPrevious()
+	  {
+	      return position > 0;
+	  }
+	  
+	  /**
+	   * Retrieves the next object from the list.
+	   *
+	   * @return The next object.
+	   * @throws NoSuchElementException if there are no
+	   *         more objects to retrieve.
+	   * @throws ConcurrentModificationException if the
+	   *         list has been modified elsewhere.
+	   */
+	  public E next()
+	  {
+	      if (position == size)
+		throw new NoSuchElementException();
+	      position++;
+	      return i.next();
+	  }
+
+	  /**
+	   * Retrieves the previous object from the list.
+	   *
+	   * @return The next object.
+	   * @throws NoSuchElementException if there are no
+	   *         previous objects to retrieve.
+	   * @throws ConcurrentModificationException if the
+	   *         list has been modified elsewhere.
+	   */
+	  public E previous()
+	  {
+	      if (position == 0)
+		throw new NoSuchElementException();
+	      position--;
+	      return i.previous();
+	  }
+	  
+	  /**
+	   * Returns the index of the next element in the
+	   * list, which will be retrieved by <code>next()</code>
+	   *
+	   * @return The index of the next element.
+	   */
+	  public int nextIndex()
+	  {
+	      return i.nextIndex() - offset;
+	  }
+	  
+	  /**
+	   * Returns the index of the previous element in the
+	   * list, which will be retrieved by <code>previous()</code>
+	   *
+	   * @return The index of the previous element.
+	   */
+	  public int previousIndex()
+	  {
+	      return i.previousIndex() - offset;
+	  }
+	  
+	  /**
+	   * Removes the last object retrieved by <code>next()</code>
+	   * from the list, if the list supports object removal.
+	   *
+	   * @throws IllegalStateException if the iterator is positioned
+	   *         before the start of the list or the last object has already
+	   *         been removed.
+	   * @throws UnsupportedOperationException if the list does
+	   *         not support removing elements.
+	   */
+	  public void remove()
+	  {
+	    throw new UnsupportedOperationException("Modification not supported " +
+						    "on CopyOnWriteArrayList iterators");
+	  }
+	  
+	  
+	  /**
+	   * Replaces the last object retrieved by <code>next()</code>
+	   * or <code>previous</code> with o, if the list supports object
+	   * replacement and an add or remove operation has not already
+	   * been performed.
+	   *
+	   * @throws IllegalStateException if the iterator is positioned
+	   *         before the start of the list or the last object has already
+	   *         been removed.
+	   * @throws UnsupportedOperationException if the list doesn't support
+	   *         the addition or removal of elements.
+	   * @throws ClassCastException if the type of o is not a valid type
+	   *         for this list.
+	   * @throws IllegalArgumentException if something else related to o
+	   *         prevents its addition.
+	   * @throws ConcurrentModificationException if the list
+	   *         has been modified elsewhere.
+	   */
+	  public void set(E o)
+	  {
+	    throw new UnsupportedOperationException("Modification not supported " +
+						    "on CopyOnWriteArrayList iterators");
+	  }
+	  
+	  /**
+	   * Adds the supplied object before the element that would be returned
+	   * by a call to <code>next()</code>, if the list supports addition.
+	   * 
+	   * @param o The object to add to the list.
+	   * @throws UnsupportedOperationException if the list doesn't support
+	   *         the addition of new elements.
+	   * @throws ClassCastException if the type of o is not a valid type
+	   *         for this list.
+	   * @throws IllegalArgumentException if something else related to o
+	   *         prevents its addition.
+	   * @throws ConcurrentModificationException if the list
+	   *         has been modified elsewhere.
+	   */
+	  public void add(E o)
+	  {
+	    throw new UnsupportedOperationException("Modification not supported " +
+						    "on CopyOnWriteArrayList iterators");
+	  } 
+	};
+    }
+  } // class SubList
+
+  /**
+   * This class is a RandomAccess version of SubList, as required by
+   * [EMAIL PROTECTED] AbstractList#subList(int, int)}.
+   *
+   * @author Eric Blake ([EMAIL PROTECTED])
+   */
+  private static final class RandomAccessSubList<E> extends SubList<E>
+    implements RandomAccess
+  {
+    /**
+     * Construct the sublist.
+     *
+     * @param backing the list this comes from
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     */
+    RandomAccessSubList(CopyOnWriteArrayList<E> backing, int fromIndex, int toIndex)
+    {
+      super(backing, fromIndex, toIndex);
+    }
+  } // class RandomAccessSubList
+
+  /**
    * Serializes this object to the given stream.
    * 
    * @param s
Index: java/util/zip/Deflater.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/zip/Deflater.java,v
retrieving revision 1.8
diff -u -3 -p -u -r1.8 Deflater.java
--- java/util/zip/Deflater.java	10 Dec 2006 20:25:46 -0000	1.8
+++ java/util/zip/Deflater.java	12 Mar 2008 23:24:41 -0000
@@ -241,7 +241,6 @@ public class Deflater
   /** 
    * Gets the number of input bytes processed so far.
    */
-  @Deprecated
   public int getTotalIn()
   {
     return (int) engine.getTotalIn();
@@ -259,7 +258,6 @@ public class Deflater
   /** 
    * Gets the number of output bytes so far.
    */
-  @Deprecated
   public int getTotalOut()
   {
     return (int) totalOut;
Index: java/util/zip/Inflater.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/zip/Inflater.java,v
retrieving revision 1.10
diff -u -3 -p -u -r1.10 Inflater.java
--- java/util/zip/Inflater.java	10 Dec 2006 20:25:46 -0000	1.10
+++ java/util/zip/Inflater.java	12 Mar 2008 23:24:41 -0000
@@ -246,7 +246,6 @@ public class Inflater
    * Gets the total number of processed compressed input bytes.
    * @return the total number of bytes of processed input bytes.
    */
-  @Deprecated
   public int getTotalIn()
   {
     return (int) (totalIn - getRemaining());
@@ -266,7 +265,6 @@ public class Inflater
    * Gets the total number of output bytes returned by inflate().
    * @return the total number of output bytes.
    */
-  @Deprecated
   public int getTotalOut()
   {
     return (int) totalOut;

Attachment: signature.asc
Description: Digital signature

Reply via email to